mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-68451 mod_h5pactivity: Add info attempts in check_updates_since
Add updates information related to attempts in check_updates_since because they may affect the user or the information displayed in the app.
This commit is contained in:
parent
1afe68f382
commit
887644a1d5
@ -334,7 +334,41 @@ function h5pactivity_page_type_list(string $pagetype, stdClass $parentcontext, s
|
||||
* @return stdClass an object with the different type of areas indicating if they were updated or not
|
||||
*/
|
||||
function h5pactivity_check_updates_since(cm_info $cm, int $from, array $filter = []): stdClass {
|
||||
global $DB, $USER;
|
||||
|
||||
$updates = course_check_module_updates_since($cm, $from, ['package'], $filter);
|
||||
|
||||
$updates->tracks = (object) ['updated' => false];
|
||||
$select = 'h5pactivityid = ? AND userid = ? AND timemodified > ?';
|
||||
$params = [$cm->instance, $USER->id, $from];
|
||||
$tracks = $DB->get_records_select('h5pactivity_attempts', $select, $params, '', 'id');
|
||||
if (!empty($tracks)) {
|
||||
$updates->tracks->updated = true;
|
||||
$updates->tracks->itemids = array_keys($tracks);
|
||||
}
|
||||
|
||||
// Now, teachers should see other students updates.
|
||||
if (has_capability('mod/h5pactivity:reviewattempts', $cm->context)) {
|
||||
$select = 'h5pactivityid = ? AND timemodified > ?';
|
||||
$params = [$cm->instance, $from];
|
||||
|
||||
if (groups_get_activity_groupmode($cm) == SEPARATEGROUPS) {
|
||||
$groupusers = array_keys(groups_get_activity_shared_group_members($cm));
|
||||
if (empty($groupusers)) {
|
||||
return $updates;
|
||||
}
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($groupusers);
|
||||
$select .= ' AND userid ' . $insql;
|
||||
$params = array_merge($params, $inparams);
|
||||
}
|
||||
|
||||
$updates->usertracks = (object) ['updated' => false];
|
||||
$tracks = $DB->get_records_select('h5pactivity_attempts', $select, $params, '', 'id');
|
||||
if (!empty($tracks)) {
|
||||
$updates->usertracks->updated = true;
|
||||
$updates->usertracks->itemids = array_keys($tracks);
|
||||
}
|
||||
}
|
||||
return $updates;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user