Skip to content

Commit

Permalink
Bug fixes and minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sokunthearithmakara committed Dec 12, 2024
1 parent 0e3bd84 commit 4321bfe
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ function interactivevideo_displayinline(cm_info $cm) {
$OUTPUT->get_generated_image_for_id($cm->id) : $interactivevideo->posterimage; // Fallback to default image.
$duration = $interactivevideo->endtime - $interactivevideo->starttime;
// Convert to hh:mm:ss format.
$duration = gmdate($duration > 3600 * 60 ? 'H:i:s' : 'i:s', (int) $duration);
$duration = gmdate($duration > 3600 ? 'H:i:s' : 'i:s', (int) $duration);

// Format the intro: keep text only and truncate it.
$datafortemplate = [
Expand Down
20 changes: 9 additions & 11 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,15 @@ public static function get_report_data_by_group($interactivevideo, $group, $cont
// Get fields for userpicture.
$fields = \core_user\fields::get_picture_fields();
$fields = 'u.' . implode(', u.', $fields);
// Graded roles.
$roles = get_config('core', 'gradebookroles');
if ($group == 0) {
// Get all enrolled users (student only).
$sql = "SELECT " . $fields . ", ac.timecompleted, ac.timecreated,
ac.completionpercentage, ac.completeditems, ac.xp, ac.completiondetails, ac.id as completionid
FROM {user} u
LEFT JOIN {interactivevideo_completion} ac ON ac.userid = u.id AND ac.cmid = :cmid
WHERE u.id IN (
SELECT ra.userid
FROM {role_assignments} ra
JOIN {role} r ON ra.roleid = r.id
WHERE ra.contextid = :contextid AND r.archetype = 'student'
)
WHERE u.id IN (SELECT userid FROM {role_assignments} WHERE contextid = :contextid AND roleid IN (" . $roles . "))
ORDER BY u.lastname, u.firstname";
$records = $DB->get_records_sql($sql, ['cmid' => $interactivevideo, 'contextid' => $contextid]);
} else {
Expand All @@ -325,8 +322,9 @@ public static function get_report_data_by_group($interactivevideo, $group, $cont
FROM {user} u
LEFT JOIN {interactivevideo_completion} ac ON ac.userid = u.id AND ac.cmid = :cmid
WHERE u.id IN (SELECT userid FROM {groups_members} WHERE groupid = :groupid)
AND u.id IN (SELECT userid FROM {role_assignments} WHERE contextid = :contextid AND roleid IN (" . $roles . "))
ORDER BY u.lastname, u.firstname";
$records = $DB->get_records_sql($sql, ['cmid' => $interactivevideo, 'groupid' => $group]);
$records = $DB->get_records_sql($sql, ['cmid' => $interactivevideo, 'groupid' => $group, 'contextid' => $contextid]);
}

// Render the photo of the user.
Expand Down Expand Up @@ -558,7 +556,7 @@ public static function encode_text($text) {
* @param string $field The field associated with the text.
* @param int $id The ID related to the text processing.
*
* @return void
* @return string The processed text.
*/
public static function process_text($text, $contextid, $field, $id) {
if (!$text) {
Expand Down Expand Up @@ -650,7 +648,7 @@ public static function get_taught_courses($userid) {
if (!$userid) {
$userid = $USER->id;
}
$PAGE->set_context(context_system::instance());
$PAGE->set_context(\context_system::instance());
// Get all courses where the user is a teacher.
$sql = "SELECT c.id, c.fullname, c.shortname FROM {course} c
JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = 50
Expand All @@ -677,7 +675,7 @@ public static function get_taught_courses($userid) {
* Retrieves the course module by course ID.
*
* @param int $courseid The ID of the course.
* @return object|null The course module object if found, null otherwise.
* @return array The course modules.
*/
public static function get_cm_by_courseid($courseid) {
global $DB, $PAGE;
Expand Down Expand Up @@ -751,7 +749,7 @@ public static function import_annotations($fromcourse, $tocourse, $module, $from
* @param int $userid The user ID.
* @param int $courseid The course ID.
* @param int $contextid The context ID.
* @return string The completion information.
* @return array The completion information.
*/
public static function get_cm_completion($cmid, $userid, $courseid, $contextid) {
global $OUTPUT, $CFG, $PAGE, $USER;
Expand Down
2 changes: 1 addition & 1 deletion plugins/chapter/amd/build/main.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/chapter/amd/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class Chapter extends Base {
<ul class="annolistinchapter w-100 p-0"></ul></li>`);
});

$(document).on('timeupdate', async (e) => {
$(document).on('timeupdate', async(e) => {
const currenttime = e.originalEvent.detail.time;
const currentchapter = chapters.find((chapter) => currenttime >= chapter.start && currenttime < chapter.end);
if (currentchapter) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/contentbank/amd/build/main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/contentbank/amd/build/main.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/contentbank/amd/build/util.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4321bfe

Please sign in to comment.