Skip to content
Open

Dev #100

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions amd/build/player.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/player.min.js.map

Large diffs are not rendered by default.

296 changes: 211 additions & 85 deletions amd/src/player.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions backup/moodle2/backup_videotime_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ protected function define_structure() {
'enabletabs',
]);

$texttracks = new backup_nested_element('texttracks');
$texttrack = new backup_nested_element('texttrack', ['id'], [
'videotime',
'isdefault',
'kind',
'label',
'srclang',
'visible',
]);

// Build the tree.
$module->add_child($texttracks);
$texttracks->add_child($texttrack);

// Define elements for tab subplugin settings.
$this->add_subplugin_structure('videotimetab', $module, true);
Expand All @@ -99,10 +111,12 @@ protected function define_structure() {

// Define sources.
$module->set_source_table('videotime', ['id' => backup::VAR_ACTIVITYID]);
$texttrack->set_source_table('videotime_track', ['videotime' => backup::VAR_PARENTID], 'id ASC');

// Define file annotations.
$module->annotate_files('mod_videotime', 'intro', null); // This file area hasn't itemid.
$module->annotate_files('mod_videotime', 'video_description', null); // This file area hasn't itemid.
$texttrack->annotate_files('mod_videotime', 'texttrack', 'id');

$this->annotate_plugin_config_files($module, 'videotimetab');
$this->annotate_plugin_config_files($module, 'videotimeplugin');
Expand Down
18 changes: 11 additions & 7 deletions backup/moodle2/restore_videotime_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,21 @@ public function after_restore() {

if ($options->next_activity_id > 0) {
$updaterequired = true;
if ($newitem = restore_dbops::get_backup_ids_record(
$this->get_restoreid(),
'course_module',
$options->next_activity_id
)) {
if (
$newitem = restore_dbops::get_backup_ids_record(
$this->get_restoreid(),
'course_module',
$options->next_activity_id
)
) {
$options->next_activity_id = $newitem->newitemid;
}
if (!$DB->record_exists('course_modules', [
if (
!$DB->record_exists('course_modules', [
'id' => $options->next_activity_id,
'course' => $options->course,
])) {
])
) {
$options->next_activity_id = 0;
}
}
Expand Down
23 changes: 22 additions & 1 deletion backup/moodle2/restore_videotime_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ protected function define_structure() {
$videotime = new restore_path_element('videotime', '/activity/videotime');
$paths[] = $videotime;

$texttrack = new restore_path_element('texttrack', '/activity/videotime/texttracks/texttrack');
$paths[] = $texttrack;

if ($userinfo) {
$paths[] = new restore_path_element('videotime_session', '/activity/videotime/sessions/session');
}
Expand Down Expand Up @@ -82,7 +85,7 @@ protected function add_subplugin_files($subtype) {
}

/**
* Processes the videotim restore data.
* Processes the videotime restore data.
*
* @param array $data Parsed element data.
*/
Expand All @@ -102,6 +105,23 @@ protected function process_videotime($data) {
$this->apply_activity_instance($newitemid);
}

/**
* Processes the texttrack restore data.
*
* @param array $data Parsed element data.
*/
protected function process_texttrack($data) {
global $DB;

$data = (object)$data;
$oldid = $data->id;
$data->videotime = $this->get_new_parentid('videotime');

// Insert the videotime record.
$newitemid = $DB->insert_record('videotime_track', $data);
$this->set_mapping('videotime_track', $oldid, $newitemid, true);
}

/**
* Process session data
*
Expand Down Expand Up @@ -138,6 +158,7 @@ protected function after_execute() {
// Add videotime related files, no need to match by itemname (just internally handled context).
$this->add_related_files('mod_videotime', 'intro', null);
$this->add_related_files('mod_videotime', 'video_description', null);
$this->add_related_files('mod_videotime', 'texttrack', 'videotime_track');

$this->add_subplugin_files('videotimeplugin');
}
Expand Down
101 changes: 101 additions & 0 deletions classes/courseformat/overview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_videotime\courseformat;

use cm_info;
use core\url;
use core\output\local\properties\button;
use core\output\local\properties\text_align;
use core_courseformat\local\overview\overviewitem;
use core_courseformat\output\local\overview\overviewaction;
use core\output\action_link;

/**
* Video Time overview integration class.
*
* @package mod_videotime
* @copyright 2025 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class overview extends \core_courseformat\activityoverviewbase {
#[\Override]
public function get_extra_overview_items(): array {
return [
'totalviews' => $this->get_extra_totalviews_overview(),
];
}

#[\Override]
public function get_actions_overview(): ?overviewitem {
if (!videotime_has_pro() || !has_capability('mod/videotime:view_report', $this->context)) {
return null;
}

$viewscount = 1;
$url = new url('/mod/videotime/report.php', ['id' => $this->cm->id, 'mode' => 'approval']);
$text = get_string('view_report', 'mod_videotime');

if (class_exists('overviewaction')) {
$content = new overviewaction(
url: $url,
text: $text,
badgevalue: null,
badgetitle: null,
);
} else {
$content = new action_link(
url: $url,
text: $text,
attributes: ['class' => button::SECONDARY_OUTLINE->classes()],
);
}

return new overviewitem(
name: get_string('actions'),
value: $viewscount,
content: $content,
textalign: text_align::CENTER,
);
}

/**
* Get the "Total views" overview item.
*
* @return overviewitem The overview item.
*/
private function get_extra_totalviews_overview(): overviewitem {
global $DB, $USER;

$columnheader = get_string('views', 'mod_videotime');

$params = ['module_id' => $this->cm->id];
if (!has_capability('moodle/course:viewparticipants', $this->context)) {
$params['user_id'] = $USER->id;
}
$viewscount = $DB->get_field(
\videotimeplugin_pro\session::TABLE,
'COUNT(DISTINCT uuid)',
$params
);

return new overviewitem(
name: $columnheader,
value: $viewscount,
textalign: text_align::END,
);
}
}
Loading