Skip to content

Commit

Permalink
Merge pull request #63 from bdecentgmbh/VID-734-3X
Browse files Browse the repository at this point in the history
Merge to master for 1.8 RC 2
  • Loading branch information
stefanscholz authored Dec 4, 2023
2 parents 37ba000 + 5a63de6 commit 69660bc
Show file tree
Hide file tree
Showing 81 changed files with 738 additions and 360 deletions.
12 changes: 6 additions & 6 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@

if ($id) {
$cm = get_coursemodule_from_id('videotime', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$moduleinstance = $DB->get_record('videotime', array('id' => $cm->instance), '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST);
$moduleinstance = $DB->get_record('videotime', ['id' => $cm->instance], '*', MUST_EXIST);
} else if ($v) {
$moduleinstance = $DB->get_record('videotime', array('id' => $n), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $moduleinstance->course), '*', MUST_EXIST);
$moduleinstance = $DB->get_record('videotime', ['id' => $n], '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $moduleinstance->course], '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('videotime', $moduleinstance->id, $course->id, false, MUST_EXIST);
} else {
throw new moodle_exception('invalidcoursemodule', 'mod_videotime');
Expand All @@ -65,7 +65,7 @@
'v' => $v,
'action' => $action,
'return' => $return,
'userid' => $userid
'userid' => $userid,
]);
$PAGE->set_title(format_string($moduleinstance->name));
$PAGE->set_heading(format_string($course->fullname));
Expand All @@ -77,7 +77,7 @@
$task = new \videotimeplugin_pro\task\delete_session_data();
$task->set_custom_data([
'user_id' => $userid,
'module_id' => $cm->id
'module_id' => $cm->id,
]);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions backup/moodle2/backup_videotime_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function define_structure() {
'resume_playback',
'preview_picture',
'show_description_in_player',
'enabletabs'
'enabletabs',
]);

// Build the tree.
Expand All @@ -99,7 +99,7 @@ protected function define_structure() {
$this->add_subplugin_structure('videotimeplugin', $module, true);

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

// Define file annotations.
$module->annotate_files('mod_videotime', 'intro', null); // This file area hasn't itemid.
Expand Down
12 changes: 6 additions & 6 deletions backup/moodle2/restore_videotime_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ protected function define_my_steps() {
* processed by the link decoder
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('videotime', array('intro'), 'videotime');
$contents[] = new restore_decode_content('videotime', array('video_description'), 'videotime');
$contents[] = new restore_decode_content('videotime', ['intro'], 'videotime');
$contents[] = new restore_decode_content('videotime', ['video_description'], 'videotime');

return $contents;
}
Expand All @@ -68,15 +68,15 @@ public static function define_decode_contents() {
* to the activity to be executed by the link decoder
*/
public static function define_decode_rules() {
return array();
return [];
}

/**
* Define the restore log rules that will be applied by the link restore_logs_processor when restoring
* videotime logs. It must return one array of restore_log_rule objects
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('videotime', 'add', 'view.php?id={course_module}', '{videotime}');
$rules[] = new restore_log_rule('videotime', 'update', 'view.php?id={course_module}', '{videotime}');
Expand All @@ -93,7 +93,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('videotime', 'view all', 'index.php?id={course}', null);

Expand Down
2 changes: 1 addition & 1 deletion classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ protected function init() {
* return array
*/
public static function get_objectid_mapping() {
return array('db' => 'videotime', 'restore' => 'videotime');
return ['db' => 'videotime', 'restore' => 'videotime'];
}
}
8 changes: 5 additions & 3 deletions classes/external/get_videotime.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
defined('MOODLE_INTERNAL') || die();

use external_api;
use external_function_parameters;
use external_value;
use mod_videotime\videotime_instance;

require_once($CFG->libdir.'/externallib.php');
Expand All @@ -43,8 +45,8 @@ trait get_videotime {
* @return external_function_parameters
*/
public static function get_videotime_parameters() {
return new \external_function_parameters([
'cmid' => new \external_value(PARAM_INT, 'Course module ID', VALUE_REQUIRED)
return new external_function_parameters([
'cmid' => new external_value(PARAM_INT, 'Course module ID', VALUE_REQUIRED),
]);
}

Expand All @@ -56,7 +58,7 @@ public static function get_videotime_parameters() {
*/
public static function get_videotime($cmid) {
$params = external_api::validate_parameters(self::get_videotime_parameters(), [
'cmid' => $cmid
'cmid' => $cmid,
]);

$context = \context_module::instance($params['cmid']);
Expand Down
8 changes: 5 additions & 3 deletions classes/external/view_videotime.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
defined('MOODLE_INTERNAL') || die();

use external_api;
use external_function_parameters;
use external_value;
use mod_videotime\videotime_instance;

require_once($CFG->libdir.'/externallib.php');
Expand All @@ -43,8 +45,8 @@ trait view_videotime {
* @return external_function_parameters
*/
public static function view_videotime_parameters() {
return new \external_function_parameters([
'cmid' => new \external_value(PARAM_INT, 'Course module ID.')
return new external_function_parameters([
'cmid' => new external_value(PARAM_INT, 'Course module ID.'),
]);
}

Expand All @@ -58,7 +60,7 @@ public static function view_videotime($cmid) {
global $DB;

$params = external_api::validate_parameters(self::view_videotime_parameters(), [
'cmid' => $cmid
'cmid' => $cmid,
]);

$cm = get_coursemodule_from_id('videotime', $params['cmid']);
Expand Down
20 changes: 10 additions & 10 deletions classes/local/dash_framework/structure/videotime_session_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ public function get_title(): string {
public function get_fields(): array {
$fields = [
new field('id', new lang_string('pluginname', 'videotime'), $this, null, [
new identifier_attribute()
new identifier_attribute(),
]),
new field('time', new lang_string('watch_time', 'videotime'), $this, 'SUM(time)', [
new time_attribute()
new time_attribute(),
]),
new field('state', new lang_string('state_finished', 'videotime'), $this, 'MAX(vtn.state)', [
new bool_attribute()
new bool_attribute(),
]),
new field('timestarted', new lang_string('timestarted', 'videotime'), $this, 'MIN(vtn.timecreated)', [
new date_attribute()
new date_attribute(),
]),
new field('percent_watch', new lang_string('watch_percent', 'videotime'), $this, 'MAX(percent_watch)', [
new percent_attribute()
new percent_attribute(),
]),
new field('current_watch_time', new lang_string('currentwatchtime', 'videotime'), $this, 'MAX(current_watch_time)', [
new time_attribute()
new time_attribute(),
]),
];

Expand All @@ -110,25 +110,25 @@ public function get_fields(): array {
new field('watched_time', new lang_string('watchedtime', 'videotime'), $this, 'MAX(
CASE WHEN vtn.current_watch_time - vtn.start_time > 1 THEN vtn.current_watch_time ELSE 0 END
)', [
new time_attribute()
new time_attribute(),
]),
new field('time_left', new lang_string('timeleft', 'videotime'), $this, 'MIN(
CASE WHEN vtn.current_watch_time - vtn.start_time > 1
THEN vvv.duration - vtn.current_watch_time
ELSE vvv.duration
END
)', [
new time_attribute()
new time_attribute(),
]),
new field('status', new lang_string('activitystatus', 'videotime'), $this, 'MAX(cmc.completionstate)', [
new completion_status_attribute()
new completion_status_attribute(),
]),
new field('timecompleted', new lang_string('timecompleted', 'videotime'), $this, 'CASE
WHEN MAX(cmc.completionstate) > 0
THEN MAX(cmc.timemodified)
ELSE NULL
END', [
new date_attribute()
new date_attribute(),
]),
];
$fields = array_merge($fields, $addfields);
Expand Down
37 changes: 19 additions & 18 deletions classes/local/dash_framework/structure/videotime_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,49 +85,50 @@ public function get_fields(): array {

$fields = [
new field('id', new lang_string('pluginname', 'videotime'), $this, null, [
new identifier_attribute()
new identifier_attribute(),
]),
new field('name', new lang_string('activity_name', 'videotime'), $this, 'vt.name'),
new field('idnumber', new lang_string('idnumber', 'core'), $this, 'cm.idnumber'),
new field('url', new lang_string('videotimeurl', 'videotime'), $this, 'vt.id', [
new moodle_url_attribute(['url' => new moodle_url('/mod/videotime/view.php', ['v' => 'vt_id'])])
new moodle_url_attribute(['url' => new moodle_url('/mod/videotime/view.php', ['v' => 'vt_id'])]),
]),
new field('link', new lang_string('videotimelink', 'videotime'), $this, 'vt.id', [
new moodle_url_attribute(['url' => new moodle_url('/mod/videotime/view.php', ['v' => 'vt_id'])]),
new link_attribute(['label' => get_string('view')])
new link_attribute(['label' => get_string('view')]),
]),
new field('video_description', new lang_string('video_description', 'videotime'), $this, 'vt.id', [
new notes_attribute()
new notes_attribute(),
]),
new field('intro', new lang_string('moduleintro'), $this, 'vt.id', [
new intro_attribute()
new intro_attribute(),
]),

];

if (videotime_has_pro()) {
$fields = array_merge($fields, [
new field('unique_visitors', new lang_string('totaluniquevisitors', 'videotime'), $this, 'vt.id', [
new unique_visitors_attribute()
new unique_visitors_attribute(),
]),
new field('views', new lang_string('totalviews', 'videotime'), $this, 'vt.id', [
new views_attribute()
new views_attribute(),
]),
new field('average_view_time', new lang_string('averageviewtime', 'videotime'), $this, 'vt.id', [
new average_view_time_attribute(),
new time_attribute()
new time_attribute(),
]),
new field('percentage_of_video_finished', new lang_string(
'percentageofvideofinished', 'videotime'), $this, 'vt.id', [
new percentage_of_video_finished_attribute()
new percentage_of_video_finished_attribute(),
]
),
new field('firstsession', new lang_string('firstsession', 'videotime'), $this, 'vt.id', [
new first_session_attribute(),
new date_attribute()
new date_attribute(),
]),
new field('lastsession', new lang_string('lastsession', 'videotime'), $this, 'vt.id', [
new last_session_attribute(),
new date_attribute()
new date_attribute(),
]),
]);
}
Expand All @@ -136,30 +137,30 @@ public function get_fields(): array {
$fields = array_merge($fields, [
new field('videocreated', new lang_string('videocreated', 'videotime'), $this, 'vt.id', [
new video_created_attribute(),
new date_attribute()
new date_attribute(),
]),
new field('preview_url', new lang_string('preview_picture_url', 'videotime'), $this, 'vt.id', [
new image_url_attribute(),
new video_preview_attribute()
new video_preview_attribute(),
]),
new field('preview_image', new lang_string('preview_picture', 'videotime'), $this, 'vt.id', [
new video_preview_attribute(),
new image_attribute()
new image_attribute(),
]),
new field('preview_image_linked', new lang_string('preview_picture_linked', 'videotime'), $this, 'vt.id', [
new video_preview_attribute(),
new image_attribute(),
new linked_data_attribute(['url' => new moodle_url('/mod/videotime/view.php', ['v' => 'vt_id'])])
new linked_data_attribute(['url' => new moodle_url('/mod/videotime/view.php', ['v' => 'vt_id'])]),
]),
new field('completion_on_view_time', new lang_string('completion_on_view', 'videotime'), $this, null, [
new bool_attribute()
new bool_attribute(),
]),
new field('completion_on_view_time_second', new lang_string('completion_on_view_seconds', 'videotime'), $this),
new field('completion_on_finish', new lang_string('completion_on_finish', 'videotime'), $this, null, [
new bool_attribute()
new bool_attribute(),
]),
new field('completion_on_percent', new lang_string('completion_on_percent', 'videotime'), $this, null, [
new bool_attribute()
new bool_attribute(),
]),
new field('completion_on_percent_value', new lang_string('completion_on_percent_value', 'videotime'), $this, null),
]);
Expand Down
6 changes: 3 additions & 3 deletions classes/local/tabs/tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function get_data(): array {
'label' => $this->get_label(),
'active' => $this->get_active(),
'persistent' => $this->get_persistent(),
'tabcontent' => $this->get_tab_content()
'tabcontent' => $this->get_tab_content(),
];
}

Expand Down Expand Up @@ -199,7 +199,7 @@ public static function data_preprocessing(array &$defaultvalues, int $instance)
* @return array
*/
public static function get_config_file_areas(): array {
return array();
return [];
}

/**
Expand Down Expand Up @@ -231,7 +231,7 @@ protected function get_record(): stdClass {

$name = preg_replace('/^videotimetab_(.*)\\\\tab/', '$1', get_called_class());
if (is_null($this->record)) {
$this->record = $DB->get_record("videotimetab_$name", array('videotime' => $this->get_instance()->id));
$this->record = $DB->get_record("videotimetab_$name", ['videotime' => $this->get_instance()->id]);
}
return $this->record;
}
Expand Down
10 changes: 5 additions & 5 deletions classes/output/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function mobile_course_view($args) {

require_capability('mod/videotime:view', $context);

$videotime = $DB->get_record('videotime', array('id' => $cm->instance));
$videotime = $DB->get_record('videotime', ['id' => $cm->instance]);

$videotime->name = format_string($videotime->name);
list($videotime->intro, $videotime->introformat) =
Expand All @@ -73,13 +73,13 @@ public static function mobile_course_view($args) {
'id' => $cm->id,
'token' => self::create_service_token($context),
]);
$data = array(
$data = [
'instance' => $videotime,
'cmid' => $cm->id,
'has_pro' => videotime_has_pro(),
'iframe' => !empty(get_config('videotime', 'mobileiframe')),
'url' => $url->out(false),
);
];

if (empty(get_config('videotime', 'mobileiframe'))) {
$js = file_get_contents($CFG->dirroot . '/mod/videotime/appjs/videotime.js');
Expand Down Expand Up @@ -109,7 +109,7 @@ public static function view_init(array $args) {

return [
'javascript' => file_get_contents($CFG->dirroot . '/mod/videotime/appjs/player.js') .
file_get_contents("$CFG->dirroot/mod/videotime/appjs/view_init.js")
file_get_contents("$CFG->dirroot/mod/videotime/appjs/view_init.js"),
];

}
Expand All @@ -124,7 +124,7 @@ public static function view_init(array $args) {
public static function create_service_token($context) {
global $DB;

$service = $DB->get_record('external_services', array('shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE), '*', MUST_EXIST);
$service = $DB->get_record('external_services', ['shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE], '*', MUST_EXIST);
return external_generate_token_for_current_user($service)->token;
}
}
2 changes: 1 addition & 1 deletion classes/output/next_activity_button.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function get_data() {
'availability_info' => $this->availabilityinfo,
'availability_title' => videotime_is_totara() ? strip_tags($this->availabilityinfo) : null,
'is_restricted' => $this->isrestricted,
'instance' => $this->moduleinstance->to_record()
'instance' => $this->moduleinstance->to_record(),
];
}

Expand Down
Loading

0 comments on commit 69660bc

Please sign in to comment.