MDL-56307 course: Return time updated and times updated

This commit is contained in:
Juan Leyva 2016-10-20 20:08:32 +01:00
parent cebce76f61
commit 65b2669d98
13 changed files with 146 additions and 63 deletions

View file

@ -1156,9 +1156,14 @@ function choice_check_updates_since(cm_info $cm, $from, $filter = array()) {
return $updates;
}
// Check if there are new responses in the choice.
$updates->answers = (object) array('updated' => false);
$select = 'choiceid = :id AND timemodified > :since';
$params = array('id' => $choice->id, 'since' => $from);
$updates->answers = $DB->count_records_select('choice_answers', $select, $params) > 0;
$answers = $DB->get_records_select('choice_answers', $select, $params, '', 'id');
if (!empty($answers)) {
$updates->answers->updated = true;
$updates->answers->itemids = array_keys($answers);
}
return $updates;
}