Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-29662_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
commit befce5863d508fbc75684ec19ce850803c0a99a8 2 parents 9488354 + fe470a2
@stronk7 stronk7 authored
Showing with 18 additions and 2 deletions.
  1. +1 −1  lib/moodlelib.php
  2. +17 −1 mod/quiz/lib.php
View
2  lib/moodlelib.php
@@ -4708,7 +4708,7 @@ function shift_course_mod_dates($modname, $fields, $timeshift, $courseid) {
foreach ($fields as $field) {
$updatesql = "UPDATE {".$modname."}
SET $field = $field + ?
- WHERE course=? AND $field<>0 AND $field<>0";
+ WHERE course=? AND $field<>0";
$return = $DB->execute($updatesql, array($timeshift, $courseid)) && $return;
}
View
18 mod/quiz/lib.php
@@ -1135,8 +1135,14 @@ function quiz_update_events($quiz, $override = null) {
$addopen = empty($current->id) || !empty($current->timeopen);
$addclose = empty($current->id) || !empty($current->timeclose);
+ if (!empty($quiz->coursemodule)) {
+ $cmid = $quiz->coursemodule;
+ } else {
+ $cmid = get_coursemodule_from_instance('quiz', $quiz->id, $courseid)->id;
+ }
+
$event = new stdClass();
- $event->description = format_module_intro('quiz', $quiz, $quiz->coursemodule);
+ $event->description = format_module_intro('quiz', $quiz, $cmid);
// Events module won't show user events when the courseid is nonzero.
$event->courseid = ($userid) ? 0 : $quiz->course;
$event->groupid = $groupid;
@@ -1328,8 +1334,18 @@ function quiz_reset_userdata($data) {
// Updating dates - shift may be negative too
if ($data->timeshift) {
+ $DB->execute("UPDATE {quiz_overrides}
+ SET timeopen = timeopen + ?
+ WHERE quiz IN (SELECT id FROM {quiz} WHERE course = ?)
+ AND timeopen <> 0", array($data->timeshift, $data->courseid));
+ $DB->execute("UPDATE {quiz_overrides}
+ SET timeclose = timeclose + ?
+ WHERE quiz IN (SELECT id FROM {quiz} WHERE course = ?)
+ AND timeclose <> 0", array($data->timeshift, $data->courseid));
+
shift_course_mod_dates('quiz', array('timeopen', 'timeclose'),
$data->timeshift, $data->courseid);
+
$status[] = array(
'component' => $componentstr,
'item' => get_string('openclosedatesupdated', 'quiz'),
Please sign in to comment.
Something went wrong with that request. Please try again.