diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php
index 13806a00493b7..fc79ddbe539af 100644
--- a/mod/quiz/accessrules.php
+++ b/mod/quiz/accessrules.php
@@ -1,5 +1,4 @@
popup)) {
if ($quiz->popup == 1) {
- $this->_securewindowrule = new securewindow_access_rule($this->_quizobj, $this->_timenow);
+ $this->_securewindowrule = new securewindow_access_rule(
+ $this->_quizobj, $this->_timenow);
$this->_rules[] = $this->_securewindowrule;
- } elseif ($quiz->popup == 2) {
- $this->_safebrowserrule = new safebrowser_access_rule($this->_quizobj, $this->_timenow);
+ } else if ($quiz->popup == 2) {
+ $this->_safebrowserrule = new safebrowser_access_rule(
+ $this->_quizobj, $this->_timenow);
$this->_rules[] = $this->_safebrowserrule;
}
}
@@ -154,7 +155,8 @@ public function prevent_access() {
*
* @param int $numattempts the number of previous attempts this user has made.
* @param object $lastattempt information about the user's last completed attempt.
- * @return bool true if there is no way the user will ever be allowed to attempt this quiz again.
+ * @return bool true if there is no way the user will ever be allowed to attempt
+ * this quiz again.
*/
public function is_finished($numprevattempts, $lastattempt) {
foreach ($this->_rules as $rule) {
@@ -185,8 +187,8 @@ public function show_attempt_timer_if_needed($attempt, $timenow) {
}
}
if ($timeleft !== false) {
- /// Make sure the timer starts just above zero. If $timeleft was <= 0, then
- /// this will just have the effect of causing the quiz to be submitted immediately.
+ // Make sure the timer starts just above zero. If $timeleft was <= 0, then
+ // this will just have the effect of causing the quiz to be submitted immediately.
$timerstartvalue = max($timeleft, 1);
$PAGE->requires->js_init_call('M.mod_quiz.timer.init',
array($timerstartvalue), false, quiz_get_js_module());
@@ -202,7 +204,7 @@ public function securewindow_required($canpreview) {
/**
* @return bolean if this quiz should only be shown to students with safe browser.
- */
+ */
public function safebrowser_required($canpreview) {
return !$canpreview && !is_null($this->_safebrowserrule);
}
@@ -268,7 +270,8 @@ public function back_to_view_page($canpreview, $message = '') {
echo '
' . get_string('pleaseclose', 'quiz') . '
';
$delay = 0;
}
- $PAGE->requires->js_function_call('M.mod_quiz.secure_window.close', array($url, $delay));
+ $PAGE->requires->js_function_call('M.mod_quiz.secure_window.close',
+ array($url, $delay));
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
die();
@@ -338,11 +341,11 @@ public function do_password_check($canpreview) {
public function confirm_start_attempt_message() {
$quiz = $this->_quizobj->get_quiz();
if ($quiz->timelimit && $quiz->attempts) {
- return get_string('confirmstartattempttimelimit','quiz', $quiz->attempts);
+ return get_string('confirmstartattempttimelimit', 'quiz', $quiz->attempts);
} else if ($quiz->timelimit) {
- return get_string('confirmstarttimelimit','quiz');
+ return get_string('confirmstarttimelimit', 'quiz');
} else if ($quiz->attempts) {
- return get_string('confirmstartattemptlimit','quiz', $quiz->attempts);
+ return get_string('confirmstartattemptlimit', 'quiz', $quiz->attempts);
}
return '';
}
@@ -352,18 +355,20 @@ public function confirm_start_attempt_message() {
*
* @param string $linktext some text.
* @param object $attempt the attempt object
- * @return string some HTML, the $linktext either unmodified or wrapped in a link to the review page.
+ * @return string some HTML, the $linktext either unmodified or wrapped in a
+ * link to the review page.
*/
public function make_review_link($attempt, $canpreview, $reviewoptions) {
global $CFG;
- /// If review of responses is not allowed, or the attempt is still open, don't link.
+ // If review of responses is not allowed, or the attempt is still open, don't link.
if (!$attempt->timefinish) {
return '';
}
$when = quiz_attempt_state($this->_quizobj->get_quiz(), $attempt);
- $reviewoptions = mod_quiz_display_options::make_from_quiz($this->_quizobj->get_quiz(), $when);
+ $reviewoptions = mod_quiz_display_options::make_from_quiz(
+ $this->_quizobj->get_quiz(), $when);
if (!$reviewoptions->attempt) {
$message = $this->cannot_review_message($when, true);
@@ -376,7 +381,7 @@ public function make_review_link($attempt, $canpreview, $reviewoptions) {
$linktext = get_string('review', 'quiz');
- /// It is OK to link, does it need to be in a secure window?
+ // It is OK to link, does it need to be in a secure window?
if ($this->securewindow_required($canpreview)) {
return $this->_securewindowrule->make_review_link($linktext, $attempt->id);
} else {
@@ -403,11 +408,13 @@ public function cannot_review_message($when, $short = false) {
$langstrsuffix = '';
$dateformat = '';
}
- if ($when == mod_quiz_display_options::DURING || $when == mod_quiz_display_options::IMMEDIATELY_AFTER) {
+ if ($when == mod_quiz_display_options::DURING ||
+ $when == mod_quiz_display_options::IMMEDIATELY_AFTER) {
return '';
- } else if ($when == mod_quiz_display_options::LATER_WHILE_OPEN &&
- $quiz->timeclose && $quiz->reviewattempt & mod_quiz_display_options::AFTER_CLOSE) {
- return get_string('noreviewuntil' . $langstrsuffix, 'quiz', userdate($quiz->timeclose, $dateformat));
+ } else if ($when == mod_quiz_display_options::LATER_WHILE_OPEN && $quiz->timeclose &&
+ $quiz->reviewattempt & mod_quiz_display_options::AFTER_CLOSE) {
+ return get_string('noreviewuntil' . $langstrsuffix, 'quiz',
+ userdate($quiz->timeclose, $dateformat));
} else {
return get_string('noreview' . $langstrsuffix, 'quiz');
}
@@ -444,14 +451,16 @@ public function __construct($quizobj, $timenow) {
* Whether or not a user should be allowed to start a new attempt at this quiz now.
* @param int $numattempts the number of previous attempts this user has made.
* @param object $lastattempt information about the user's last completed attempt.
- * @return string false if access should be allowed, a message explaining the reason if access should be prevented.
+ * @return string false if access should be allowed, a message explaining the
+ * reason if access should be prevented.
*/
public function prevent_new_attempt($numprevattempts, $lastattempt) {
return false;
}
/**
* Whether or not a user should be allowed to start a new attempt at this quiz now.
- * @return string false if access should be allowed, a message explaining the reason if access should be prevented.
+ * @return string false if access should be allowed, a message explaining the
+ * reason if access should be prevented.
*/
public function prevent_access() {
return false;
@@ -575,11 +584,11 @@ public function time_left($attempt, $timenow) {
class inter_attempt_delay_access_rule extends quiz_access_rule_base {
public function prevent_new_attempt($numprevattempts, $lastattempt) {
if ($this->_quiz->attempts > 0 && $numprevattempts >= $this->_quiz->attempts) {
- /// No more attempts allowed anyway.
+ // No more attempts allowed anyway.
return false;
}
if ($this->_quiz->timeclose != 0 && $this->_timenow > $this->_quiz->timeclose) {
- /// No more attempts allowed anyway.
+ // No more attempts allowed anyway.
return false;
}
$nextstarttime = $this->compute_next_start_time($numprevattempts, $lastattempt);
@@ -606,7 +615,7 @@ protected function compute_next_start_time($numprevattempts, $lastattempt) {
}
$lastattemptfinish = $lastattempt->timefinish;
- if ($this->_quiz->timelimit > 0){
+ if ($this->_quiz->timelimit > 0) {
$lastattemptfinish = min($lastattemptfinish,
$lastattempt->timestart + $this->_quiz->timelimit);
}
@@ -673,17 +682,17 @@ public function clear_access_allowed() {
public function do_password_check($canpreview, $accessmanager) {
global $CFG, $SESSION, $OUTPUT, $PAGE;
- /// We have already checked the password for this quiz this session, so don't ask again.
+ // We have already checked the password for this quiz this session, so don't ask again.
if (!empty($SESSION->passwordcheckedquizzes[$this->_quiz->id])) {
return;
}
- /// If the user cancelled the password form, send them back to the view page.
+ // If the user cancelled the password form, send them back to the view page.
if (optional_param('cancelpassword', false, PARAM_BOOL)) {
$accessmanager->back_to_view_page($canpreview);
}
- /// If they entered the right password, let them in.
+ // If they entered the right password, let them in.
$enteredpassword = optional_param('quizpassword', '', PARAM_RAW);
$validpassword = false;
if (strcmp($this->_quiz->password, $enteredpassword) === 0) {
@@ -702,15 +711,16 @@ public function do_password_check($canpreview, $accessmanager) {
return;
}
- /// User entered the wrong password, or has not entered one yet, so display the form.
+ // User entered the wrong password, or has not entered one yet, so display the form.
$output = '';
- /// Start the page and print the quiz intro, if any.
+ // Start the page and print the quiz intro, if any.
if ($accessmanager->securewindow_required($canpreview)) {
$accessmanager->setup_secure_page($this->_quizobj->get_course()->shortname . ': ' .
format_string($this->_quizobj->get_quiz_name()));
} else if ($accessmanager->safebrowser_required($canpreview)) {
- $PAGE->set_title($this->_quizobj->get_course()->shortname . ': '.format_string($this->_quizobj->get_quiz_name()));
+ $PAGE->set_title($this->_quizobj->get_course()->shortname . ': ' .
+ format_string($this->_quizobj->get_quiz_name()));
$PAGE->set_cacheable(false);
echo $OUTPUT->header();
} else {
@@ -719,16 +729,17 @@ public function do_password_check($canpreview, $accessmanager) {
}
if (trim(strip_tags($this->_quiz->intro))) {
- $output .= $OUTPUT->box(format_module_intro('quiz', $this->_quiz, $this->_quizobj->get_cmid()), 'generalbox', 'intro');
+ $output .= $OUTPUT->box(format_module_intro('quiz', $this->_quiz,
+ $this->_quizobj->get_cmid()), 'generalbox', 'intro');
}
$output .= $OUTPUT->box_start('generalbox', 'passwordbox');
- /// If they have previously tried and failed to enter a password, tell them it was wrong.
+ // If they have previously tried and failed to enter a password, tell them it was wrong.
if (!empty($enteredpassword)) {
$output .= '
' . get_string('passworderror', 'quiz') . '
';
}
- /// Print the password entry form.
+ // Print the password entry form.
$output .= '
\n";
$output .= '\n";
- /// Finish page.
+ // Finish page.
$output .= $OUTPUT->box_end();
- /// return or display form.
+ // return or display form.
echo $output;
echo $OUTPUT->footer();
exit;
diff --git a/mod/quiz/addrandom.php b/mod/quiz/addrandom.php
index 9ff0afe86f929..9950735746d5e 100644
--- a/mod/quiz/addrandom.php
+++ b/mod/quiz/addrandom.php
@@ -1,5 +1,4 @@
view_url();
}
@@ -128,8 +128,9 @@ public function preload_questions() {
array('quizid' => $this->quiz->id));
}
- /**
- * Fully load some or all of the questions for this quiz. You must call {@link preload_questions()} first.
+ /**
+ * Fully load some or all of the questions for this quiz. You must call
+ * {@link preload_questions()} first.
*
* @param array $questionids question ids of the questions to load. null for all.
*/
@@ -238,12 +239,13 @@ public function get_questions($questionids = null) {
/**
* @param int $timenow the current time as a unix timestamp.
- * @return quiz_access_manager and instance of the quiz_access_manager class for this quiz at this time.
+ * @return quiz_access_manager and instance of the quiz_access_manager class
+ * for this quiz at this time.
*/
public function get_access_manager($timenow) {
if (is_null($this->accessmanager)) {
$this->accessmanager = new quiz_access_manager($this, $timenow,
- has_capability('mod/quiz:ignoretimelimits', $this->context, NULL, false));
+ has_capability('mod/quiz:ignoretimelimits', $this->context, null, false));
}
return $this->accessmanager;
}
@@ -251,14 +253,14 @@ public function get_access_manager($timenow) {
/**
* Wrapper round the has_capability funciton that automatically passes in the quiz context.
*/
- public function has_capability($capability, $userid = NULL, $doanything = true) {
+ public function has_capability($capability, $userid = null, $doanything = true) {
return has_capability($capability, $this->context, $userid, $doanything);
}
/**
* Wrapper round the require_capability funciton that automatically passes in the quiz context.
*/
- public function require_capability($capability, $userid = NULL, $doanything = true) {
+ public function require_capability($capability, $userid = null, $doanything = true) {
return require_capability($capability, $this->context, $userid, $doanything);
}
@@ -319,8 +321,8 @@ public function navigation($title) {
// Private methods =====================================================================
/**
- * Check that the definition of a particular question is loaded, and if not throw an exception.
- * @param $id a questionid.
+ * Check that the definition of a particular question is loaded, and if not throw an exception.
+ * @param $id a questionid.
*/
protected function ensure_question_loaded($id) {
if (isset($this->questions[$id]->_partiallyloaded)) {
@@ -372,11 +374,11 @@ public function __construct($attempt, $quiz, $cm, $course) {
protected static function create_helper($conditions) {
global $DB;
-// TODO deal with the issue that makes this necessary.
-// if (!$DB->record_exists('question_sessions', array('attemptid' => $attempt->uniqueid))) {
-// // this attempt has not yet been upgraded to the new model
-// quiz_upgrade_states($attempt);
-// }
+ // TODO deal with the issue that makes this necessary.
+ // if (!$DB->record_exists('question_sessions', array('attemptid' => $attempt->uniqueid))) {
+ // // this attempt has not yet been upgraded to the new model
+ // quiz_upgrade_states($attempt);
+ // }
$attempt = $DB->get_record('quiz_attempts', $conditions, '*', MUST_EXIST);
$quiz = $DB->get_record('quiz', array('id' => $attempt->quiz), '*', MUST_EXIST);
@@ -507,7 +509,8 @@ public function get_num_pages() {
/**
* @param int $timenow the current time as a unix timestamp.
- * @return quiz_access_manager and instance of the quiz_access_manager class for this quiz at this time.
+ * @return quiz_access_manager and instance of the quiz_access_manager class
+ * for this quiz at this time.
*/
public function get_access_manager($timenow) {
return $this->quizobj->get_access_manager($timenow);
@@ -538,7 +541,10 @@ public function get_userid() {
return $this->attempt->userid;
}
- /** @return bool whether this attempt has been finished (true) or is still in progress (false). */
+ /**
+ * @return bool whether this attempt has been finished (true) or is still
+ * in progress (false).
+ */
public function is_finished() {
return $this->attempt->timefinish != 0;
}
@@ -588,7 +594,8 @@ public function is_review_allowed() {
// Check the users have at least one group in common.
$teachersgroups = groups_get_activity_allowed_groups($cm);
- $studentsgroups = groups_get_all_groups($cm->course, $this->attempt->userid, $cm->groupingid);
+ $studentsgroups = groups_get_all_groups(
+ $cm->course, $this->attempt->userid, $cm->groupingid);
return $teachersgroups && $studentsgroups &&
array_intersect(array_keys($teachersgroups), array_keys($studentsgroups));
}
@@ -605,14 +612,14 @@ public function get_overall_feedback($grade) {
/**
* Wrapper round the has_capability funciton that automatically passes in the quiz context.
*/
- public function has_capability($capability, $userid = NULL, $doanything = true) {
+ public function has_capability($capability, $userid = null, $doanything = true) {
return $this->quizobj->has_capability($capability, $userid, $doanything);
}
/**
* Wrapper round the require_capability funciton that automatically passes in the quiz context.
*/
- public function require_capability($capability, $userid = NULL, $doanything = true) {
+ public function require_capability($capability, $userid = null, $doanything = true) {
return $this->quizobj->require_capability($capability, $userid, $doanything);
}
@@ -715,35 +722,41 @@ public function is_question_flagged($slot) {
}
/**
- * Return the grade obtained on a particular question, if the user is permitted to see it.
- * You must previously have called load_question_states to load the state data about this question.
+ * Return the grade obtained on a particular question, if the user is permitted
+ * to see it. You must previously have called load_question_states to load the
+ * state data about this question.
*
* @param int $slot the number used to identify this question within this attempt.
- * @return string the formatted grade, to the number of decimal places specified by the quiz.
+ * @return string the formatted grade, to the number of decimal places specified
+ * by the quiz.
*/
public function get_question_number($slot) {
return $this->quba->get_question($slot)->_number;
}
/**
- * Return the grade obtained on a particular question, if the user is permitted to see it.
- * You must previously have called load_question_states to load the state data about this question.
+ * Return the grade obtained on a particular question, if the user is permitted
+ * to see it. You must previously have called load_question_states to load the
+ * state data about this question.
*
* @param int $slot the number used to identify this question within this attempt.
- * @return string the formatted grade, to the number of decimal places specified by the quiz.
+ * @return string the formatted grade, to the number of decimal places specified
+ * by the quiz.
*/
public function get_question_name($slot) {
return $this->quba->get_question($slot)->name;
}
/**
- * Return the grade obtained on a particular question, if the user is permitted to see it.
- * You must previously have called load_question_states to load the state data about this question.
+ * Return the grade obtained on a particular question, if the user is permitted
+ * to see it. You must previously have called load_question_states to load the
+ * state data about this question.
*
* @param int $slot the number used to identify this question within this attempt.
* @param bool $showcorrectness Whether right/partial/wrong states should
* be distinguised.
- * @return string the formatted grade, to the number of decimal places specified by the quiz.
+ * @return string the formatted grade, to the number of decimal places specified
+ * by the quiz.
*/
public function get_question_status($slot, $showcorrectness) {
return $this->quba->get_question_state_string($slot, $showcorrectness);
@@ -911,7 +924,8 @@ public function render_question_for_commenting($slot) {
$options = $this->get_display_options(true);
$options->hide_all_feedback();
$options->manualcomment = question_display_options::EDITABLE;
- return $this->quba->render_question($slot, $options, $this->quba->get_question($slot)->_number);
+ return $this->quba->render_question($slot, $options,
+ $this->quba->get_question($slot)->_number);
}
/**
@@ -1054,8 +1068,10 @@ public function question_print_comment_fields($slot, $prefix) {
* Used by {@link attempt_url()} and {@link review_url()}.
*
* @param string $script. Used in the URL like /mod/quiz/$script.php
- * @param int $slot identifies the specific question on the page to jump to. 0 to just use the $page parameter.
- * @param int $page -1 to look up the page number from the slot, otherwise the page number to go to.
+ * @param int $slot identifies the specific question on the page to jump to.
+ * 0 to just use the $page parameter.
+ * @param int $page -1 to look up the page number from the slot, otherwise
+ * the page number to go to.
* @param bool $showall if true, return a URL with showall=1, and not page number
* @param int $thispage the page we are currently on. Links to questions on this
* page will just be a fragment #q123. -1 to disable this.
diff --git a/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php b/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php
index dedde469d02f9..e5092f4b42fdf 100644
--- a/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php
+++ b/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php
@@ -1,5 +1,4 @@
dirroot . '/mod/quiz/backup/moodle2/restore_quiz_stepslib.php'); // Because it exists (must)
+require_once($CFG->dirroot . '/mod/quiz/backup/moodle2/restore_quiz_stepslib.php');
+// Because it exists (must)
/**
@@ -60,7 +60,8 @@ public static function define_decode_contents() {
$contents = array();
$contents[] = new restore_decode_content('quiz', array('intro'), 'quiz');
- $contents[] = new restore_decode_content('quiz_feedback', array('feedbacktext'), 'quiz_feedback');
+ $contents[] = new restore_decode_content('quiz_feedback',
+ array('feedbacktext'), 'quiz_feedback');
return $contents;
}
@@ -72,9 +73,12 @@ public static function define_decode_contents() {
public static function define_decode_rules() {
$rules = array();
- $rules[] = new restore_decode_rule('QUIZVIEWBYID', '/mod/quiz/view.php?id=$1', 'course_module');
- $rules[] = new restore_decode_rule('QUIZVIEWBYQ', '/mod/quiz/view.php?q=$1', 'quiz');
- $rules[] = new restore_decode_rule('QUIZINDEX', '/mod/quiz/index.php?id=$1', 'course');
+ $rules[] = new restore_decode_rule('QUIZVIEWBYID',
+ '/mod/quiz/view.php?id=$1', 'course_module');
+ $rules[] = new restore_decode_rule('QUIZVIEWBYQ',
+ '/mod/quiz/view.php?q=$1', 'quiz');
+ $rules[] = new restore_decode_rule('QUIZINDEX',
+ '/mod/quiz/index.php?id=$1', 'course');
return $rules;
@@ -89,51 +93,77 @@ public static function define_decode_rules() {
public static function define_restore_log_rules() {
$rules = array();
- $rules[] = new restore_log_rule('quiz', 'add', 'view.php?id={course_module}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'update', 'view.php?id={course_module}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'view', 'view.php?id={course_module}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'preview', 'view.php?id={course_module}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'report', 'report.php?id={course_module}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'editquestions', 'view.php?id={course_module}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'delete attempt', 'report.php?id={course_module}', '[oldattempt]');
- $rules[] = new restore_log_rule('quiz', 'edit override', 'overrideedit.php?id={quiz_override}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'delete override', 'overrides.php.php?cmid={course_module}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'addcategory', 'view.php?id={course_module}', '{question_category}');
- $rules[] = new restore_log_rule('quiz', 'view summary', 'summary.php?attempt={quiz_attempt_id}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'manualgrade', 'comment.php?attempt={quiz_attempt_id}&question={question}', '{quiz}');
- $rules[] = new restore_log_rule('quiz', 'manualgrading', 'report.php?mode=grading&q={quiz}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'add',
+ 'view.php?id={course_module}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'update',
+ 'view.php?id={course_module}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'view',
+ 'view.php?id={course_module}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'preview',
+ 'view.php?id={course_module}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'report',
+ 'report.php?id={course_module}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'editquestions',
+ 'view.php?id={course_module}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'delete attempt',
+ 'report.php?id={course_module}', '[oldattempt]');
+ $rules[] = new restore_log_rule('quiz', 'edit override',
+ 'overrideedit.php?id={quiz_override}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'delete override',
+ 'overrides.php.php?cmid={course_module}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'addcategory',
+ 'view.php?id={course_module}', '{question_category}');
+ $rules[] = new restore_log_rule('quiz', 'view summary',
+ 'summary.php?attempt={quiz_attempt_id}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'manualgrade',
+ 'comment.php?attempt={quiz_attempt_id}&question={question}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'manualgrading',
+ 'report.php?mode=grading&q={quiz}', '{quiz}');
// All the ones calling to review.php have two rules to handle both old and new urls
// in any case they are always converted to new urls on restore
// TODO: In Moodle 2.x (x >= 5) kill the old rules
- // Note we are using the 'quiz_attempt_id' mapping becuase that is the one containing the quiz_attempt->ids
- // old an new for quiz-attempt
- $rules[] = new restore_log_rule('quiz', 'attempt', 'review.php?id={course_module}&attempt={quiz_attempt}', '{quiz}',
- null, null, 'review.php?attempt={quiz_attempt}');
+ // Note we are using the 'quiz_attempt_id' mapping becuase that is the
+ // one containing the quiz_attempt->ids old an new for quiz-attempt
+ $rules[] = new restore_log_rule('quiz', 'attempt',
+ 'review.php?id={course_module}&attempt={quiz_attempt}', '{quiz}',
+ null, null, 'review.php?attempt={quiz_attempt}');
// old an new for quiz-submit
- $rules[] = new restore_log_rule('quiz', 'submit', 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
- null, null, 'review.php?attempt={quiz_attempt_id}');
- $rules[] = new restore_log_rule('quiz', 'submit', 'review.php?attempt={quiz_attempt_id}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'submit',
+ 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
+ null, null, 'review.php?attempt={quiz_attempt_id}');
+ $rules[] = new restore_log_rule('quiz', 'submit',
+ 'review.php?attempt={quiz_attempt_id}', '{quiz}');
// old an new for quiz-review
- $rules[] = new restore_log_rule('quiz', 'review', 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
- null, null, 'review.php?attempt={quiz_attempt_id}');
- $rules[] = new restore_log_rule('quiz', 'review', 'review.php?attempt={quiz_attempt_id}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'review',
+ 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
+ null, null, 'review.php?attempt={quiz_attempt_id}');
+ $rules[] = new restore_log_rule('quiz', 'review',
+ 'review.php?attempt={quiz_attempt_id}', '{quiz}');
// old an new for quiz-start attemp
- $rules[] = new restore_log_rule('quiz', 'start attempt', 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
- null, null, 'review.php?attempt={quiz_attempt_id}');
- $rules[] = new restore_log_rule('quiz', 'start attempt', 'review.php?attempt={quiz_attempt_id}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'start attempt',
+ 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
+ null, null, 'review.php?attempt={quiz_attempt_id}');
+ $rules[] = new restore_log_rule('quiz', 'start attempt',
+ 'review.php?attempt={quiz_attempt_id}', '{quiz}');
// old an new for quiz-close attemp
- $rules[] = new restore_log_rule('quiz', 'close attempt', 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
- null, null, 'review.php?attempt={quiz_attempt_id}');
- $rules[] = new restore_log_rule('quiz', 'close attempt', 'review.php?attempt={quiz_attempt_id}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'close attempt',
+ 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
+ null, null, 'review.php?attempt={quiz_attempt_id}');
+ $rules[] = new restore_log_rule('quiz', 'close attempt',
+ 'review.php?attempt={quiz_attempt_id}', '{quiz}');
// old an new for quiz-continue attempt
- $rules[] = new restore_log_rule('quiz', 'continue attempt', 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
- null, null, 'review.php?attempt={quiz_attempt_id}');
- $rules[] = new restore_log_rule('quiz', 'continue attempt', 'review.php?attempt={quiz_attempt_id}', '{quiz}');
+ $rules[] = new restore_log_rule('quiz', 'continue attempt',
+ 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
+ null, null, 'review.php?attempt={quiz_attempt_id}');
+ $rules[] = new restore_log_rule('quiz', 'continue attempt',
+ 'review.php?attempt={quiz_attempt_id}', '{quiz}');
// old an new for quiz-continue attemp
- $rules[] = new restore_log_rule('quiz', 'continue attemp', 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
- null, 'continue attempt', 'review.php?attempt={quiz_attempt_id}');
- $rules[] = new restore_log_rule('quiz', 'continue attemp', 'review.php?attempt={quiz_attempt_id}', '{quiz}',
- null, 'continue attempt');
+ $rules[] = new restore_log_rule('quiz', 'continue attemp',
+ 'review.php?id={course_module}&attempt={quiz_attempt_id}', '{quiz}',
+ null, 'continue attempt', 'review.php?attempt={quiz_attempt_id}');
+ $rules[] = new restore_log_rule('quiz', 'continue attemp',
+ 'review.php?attempt={quiz_attempt_id}', '{quiz}',
+ null, 'continue attempt');
return $rules;
}
diff --git a/mod/quiz/backup/moodle2/restore_quiz_stepslib.php b/mod/quiz/backup/moodle2/restore_quiz_stepslib.php
index fd8a19151d3bf..68da356999f58 100644
--- a/mod/quiz/backup/moodle2/restore_quiz_stepslib.php
+++ b/mod/quiz/backup/moodle2/restore_quiz_stepslib.php
@@ -1,5 +1,4 @@
get_manager();
-//===== 1.9.0 upgrade line ======//
+ //===== 1.9.0 upgrade line ======//
if ($oldversion < 2008062000) {
- /// Define table quiz_report to be created
+ // Define table quiz_report to be created
$table = new xmldb_table('quiz_report');
- /// Adding fields to table quiz_report
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('displayorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
+ // Adding fields to table quiz_report
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('name', XMLDB_TYPE_CHAR, '255', null,
+ null, null, null);
+ $table->add_field('displayorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, null);
- /// Adding keys to table quiz_report
+ // Adding keys to table quiz_report
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
- /// Conditionally launch create table for quiz_report
+ // Conditionally launch create table for quiz_report
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
@@ -86,60 +88,64 @@ function xmldb_quiz_upgrade($oldversion) {
if ($oldversion < 2008072402) {
- /// Define field lastcron to be added to quiz_report
+ // Define field lastcron to be added to quiz_report
$table = new xmldb_table('quiz_report');
- $field = new xmldb_field('lastcron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'displayorder');
+ $field = new xmldb_field('lastcron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, '0', 'displayorder');
- /// Conditionally launch add field lastcron
+ // Conditionally launch add field lastcron
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
- /// Define field cron to be added to quiz_report
- $field = new xmldb_field('cron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'lastcron');
+ // Define field cron to be added to quiz_report
+ $field = new xmldb_field('cron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, '0', 'lastcron');
- /// Conditionally launch add field cron
+ // Conditionally launch add field cron
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2008072402, 'quiz');
}
if ($oldversion < 2008072900) {
- /// Delete the regrade report - it is now part of the overview report.
+ // Delete the regrade report - it is now part of the overview report.
$DB->delete_records('quiz_report', array('name' => 'regrade'));
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2008072900, 'quiz');
}
if ($oldversion < 2008081500) {
- /// Define table quiz_question_versions to be dropped
+ // Define table quiz_question_versions to be dropped
$table = new xmldb_table('quiz_question_versions');
- /// Launch drop table for quiz_question_versions
+ // Launch drop table for quiz_question_versions
$dbman->drop_table($table);
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2008081500, 'quiz');
}
- /// Changing the type of all the columns that store grades to be NUMBER(10, 5) or similar.
+ // Changing the type of all the columns that store grades to be NUMBER(10, 5) or similar.
if ($oldversion < 2008081501) {
// First set all quiz.sumgrades to 0 if they are null. This should never
// happen however some users have encountered a null value there.
$DB->execute('UPDATE {quiz} SET sumgrades=0 WHERE sumgrades IS NULL');
$table = new xmldb_table('quiz');
- $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'questions');
+ $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'questions');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2008081501, 'quiz');
}
if ($oldversion < 2008081502) {
$table = new xmldb_table('quiz');
- $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'sumgrades');
+ $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'sumgrades');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2008081502, 'quiz');
}
@@ -149,40 +155,45 @@ function xmldb_quiz_upgrade($oldversion) {
// happen however some users have encountered a null value there.
$DB->execute('UPDATE {quiz_attempts} SET sumgrades=0 WHERE sumgrades IS NULL');
$table = new xmldb_table('quiz_attempts');
- $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'attempt');
+ $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'attempt');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2008081503, 'quiz');
}
if ($oldversion < 2008081504) {
$table = new xmldb_table('quiz_feedback');
- $field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'feedbacktext');
+ $field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'feedbacktext');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2008081504, 'quiz');
}
if ($oldversion < 2008081505) {
$table = new xmldb_table('quiz_feedback');
- $field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'mingrade');
+ $field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'mingrade');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2008081505, 'quiz');
}
if ($oldversion < 2008081506) {
$table = new xmldb_table('quiz_grades');
- $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'userid');
+ $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'userid');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2008081506, 'quiz');
}
if ($oldversion < 2008081507) {
$table = new xmldb_table('quiz_question_instances');
- $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, '0', 'question');
+ $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null,
+ XMLDB_NOTNULL, null, '0', 'question');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2008081507, 'quiz');
}
- /// Move all of the quiz config settings from $CFG to the config_plugins table.
+ // Move all of the quiz config settings from $CFG to the config_plugins table.
if ($oldversion < 2008082200) {
foreach (get_object_vars($CFG) as $name => $value) {
if (strpos($name, 'quiz_') === 0) {
@@ -198,11 +209,11 @@ function xmldb_quiz_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2008082200, 'quiz');
}
- /// Now that the quiz is no longer responsible for creating all the question
- /// bank tables, and some of the tables are now the responsibility of the
- /// datasetdependent question type, which did not have a version.php file before,
- /// we need to say that these tables are already installed, otherwise XMLDB
- /// will try to create them again and give an error.
+ // Now that the quiz is no longer responsible for creating all the question
+ // bank tables, and some of the tables are now the responsibility of the
+ // datasetdependent question type, which did not have a version.php file before,
+ // we need to say that these tables are already installed, otherwise XMLDB
+ // will try to create them again and give an error.
if ($oldversion < 2008082600) {
// Since MDL-16505 was fixed, and we eliminated the datasetdependent
// question type, this is now a no-op.
@@ -211,37 +222,39 @@ function xmldb_quiz_upgrade($oldversion) {
if ($oldversion < 2008112101) {
- /// Define field lastcron to be added to quiz_report
+ // Define field lastcron to be added to quiz_report
$table = new xmldb_table('quiz_report');
- $field = new xmldb_field('capability', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'cron');
+ $field = new xmldb_field('capability', XMLDB_TYPE_CHAR, '255', null,
+ null, null, null, 'cron');
- /// Conditionally launch add field lastcron
+ // Conditionally launch add field lastcron
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2008112101, 'quiz');
}
if ($oldversion < 2009010700) {
- /// Define field showuserpicture to be added to quiz
+ // Define field showuserpicture to be added to quiz
$table = new xmldb_table('quiz');
- $field = new xmldb_field('showuserpicture', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'delay2');
+ $field = new xmldb_field('showuserpicture', XMLDB_TYPE_INTEGER, '4', null,
+ XMLDB_NOTNULL, null, '0', 'delay2');
- /// Conditionally launch add field showuserpicture
+ // Conditionally launch add field showuserpicture
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2009010700, 'quiz');
}
if ($oldversion < 2009030900) {
- /// If there are no quiz settings set to advanced yet, the set up the default
- /// advanced fields from Moodle 2.0.
+ // If there are no quiz settings set to advanced yet, the set up the default
+ // advanced fields from Moodle 2.0.
$quizconfig = get_config('quiz');
$arealreadyadvanced = false;
foreach (array($quizconfig) as $name => $value) {
@@ -262,37 +275,39 @@ function xmldb_quiz_upgrade($oldversion) {
set_config('fix_popup', 1, 'quiz');
}
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2009030900, 'quiz');
}
if ($oldversion < 2009031000) {
- /// Add new questiondecimaldigits setting, separate form the overall decimaldigits one.
+ // Add new questiondecimaldigits setting, separate form the overall decimaldigits one.
$table = new xmldb_table('quiz');
- $field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '-2', 'decimalpoints');
+ $field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null,
+ XMLDB_NOTNULL, null, '-2', 'decimalpoints');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2009031000, 'quiz');
}
if ($oldversion < 2009031001) {
- /// Convert quiz.timelimit from minutes to seconds.
+ // Convert quiz.timelimit from minutes to seconds.
$DB->execute('UPDATE {quiz} SET timelimit = timelimit * 60');
$default = get_config('quiz', 'timelimit');
set_config('timelimit', 60 * $default, 'quiz');
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2009031001, 'quiz');
}
if ($oldversion < 2009042000) {
- /// Define field introformat to be added to quiz
+ // Define field introformat to be added to quiz
$table = new xmldb_table('quiz');
- $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
+ $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, '0', 'intro');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
@@ -300,7 +315,8 @@ function xmldb_quiz_upgrade($oldversion) {
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
- $rs = $DB->get_recordset('quiz', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat');
+ $rs = $DB->get_recordset('quiz', array('introformat' => FORMAT_MOODLE),
+ '', 'id, intro, introformat');
foreach ($rs as $q) {
$q->intro = text_to_html($q->intro, false, false, true);
$q->introformat = FORMAT_HTML;
@@ -310,37 +326,45 @@ function xmldb_quiz_upgrade($oldversion) {
$rs->close();
}
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2009042000, 'quiz');
}
if ($oldversion < 2010030501) {
- /// Define table quiz_overrides to be created
+ // Define table quiz_overrides to be created
$table = new xmldb_table('quiz_overrides');
- /// Adding fields to table quiz_overrides
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('quiz', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
- $table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
- $table->add_field('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
- $table->add_field('timeclose', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
- $table->add_field('timelimit', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
- $table->add_field('attempts', XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, null, null, null);
+ // Adding fields to table quiz_overrides
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('quiz', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, '0');
+ $table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ null, null, null);
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ null, null, null);
+ $table->add_field('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ null, null, null);
+ $table->add_field('timeclose', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ null, null, null);
+ $table->add_field('timelimit', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ null, null, null);
+ $table->add_field('attempts', XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
+ null, null, null);
$table->add_field('password', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- /// Adding keys to table quiz_overrides
+ // Adding keys to table quiz_overrides
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('quiz', XMLDB_KEY_FOREIGN, array('quiz'), 'quiz', array('id'));
$table->add_key('groupid', XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
- /// Conditionally launch create table for quiz_overrides
+ // Conditionally launch create table for quiz_overrides
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
- /// quiz savepoint reached
+ // quiz savepoint reached
upgrade_mod_savepoint(true, 2010030501, 'quiz');
}
@@ -348,7 +372,8 @@ function xmldb_quiz_upgrade($oldversion) {
// Define field showblocks to be added to quiz
$table = new xmldb_table('quiz');
- $field = new xmldb_field('showblocks', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'showuserpicture');
+ $field = new xmldb_field('showblocks', XMLDB_TYPE_INTEGER, '4', null,
+ XMLDB_NOTNULL, null, '0', 'showuserpicture');
// Conditionally launch add field showblocks
if (!$dbman->field_exists($table, $field)) {
@@ -363,7 +388,8 @@ function xmldb_quiz_upgrade($oldversion) {
// Define field feedbacktextformat to be added to quiz_feedback
$table = new xmldb_table('quiz_feedback');
- $field = new xmldb_field('feedbacktextformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'feedbacktext');
+ $field = new xmldb_field('feedbacktextformat', XMLDB_TYPE_INTEGER, '2', null,
+ XMLDB_NOTNULL, null, '0', 'feedbacktext');
// Conditionally launch add field feedbacktextformat
if (!$dbman->field_exists($table, $field)) {
@@ -381,7 +407,8 @@ function xmldb_quiz_upgrade($oldversion) {
// Define field showblocks to be added to quiz
// Repeat this step, because the column was missing from install.xml for a time.
$table = new xmldb_table('quiz');
- $field = new xmldb_field('showblocks', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'showuserpicture');
+ $field = new xmldb_field('showblocks', XMLDB_TYPE_INTEGER, '4', null,
+ XMLDB_NOTNULL, null, '0', 'showuserpicture');
// Conditionally launch add field showblocks
if (!$dbman->field_exists($table, $field)) {
@@ -398,28 +425,32 @@ function xmldb_quiz_upgrade($oldversion) {
$columns = $DB->get_columns('quiz');
// quiz.questiondecimalpoints should be int (4) not null default -2
- if (array_key_exists('questiondecimalpoints', $columns) && $columns['questiondecimalpoints']->default_value != '-2') {
- $field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, -2, 'decimalpoints');
+ if (array_key_exists('questiondecimalpoints', $columns) &&
+ $columns['questiondecimalpoints']->default_value != '-2') {
+ $field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null,
+ XMLDB_NOTNULL, null, -2, 'decimalpoints');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
}
- // quiz.sumgrades should be decimal(10,5) not null default 0
+ // quiz.sumgrades should be decimal(10, 5) not null default 0
if (array_key_exists('sumgrades', $columns) && empty($columns['sumgrades']->not_null)) {
// First set all quiz.sumgrades to 0 if they are null. This should never
// happen however some users have encountered a null value there.
$DB->execute('UPDATE {quiz} SET sumgrades=0 WHERE sumgrades IS NULL');
- $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'questions');
+ $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'questions');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
}
- // quiz.grade should be decimal(10,5) not null default 0
+ // quiz.grade should be decimal(10, 5) not null default 0
if (array_key_exists('grade', $columns) && empty($columns['grade']->not_null)) {
- $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'sumgrades');
+ $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'sumgrades');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
@@ -433,13 +464,14 @@ function xmldb_quiz_upgrade($oldversion) {
$table = new xmldb_table('quiz_attempts');
$columns = $DB->get_columns('quiz_attempts');
- // quiz_attempts.sumgrades should be decimal(10,5) not null default 0
+ // quiz_attempts.sumgrades should be decimal(10, 5) not null default 0
if (array_key_exists('sumgrades', $columns) && empty($columns['sumgrades']->not_null)) {
// First set all quiz.sumgrades to 0 if they are null. This should never
// happen however some users have encountered a null value there.
$DB->execute('UPDATE {quiz_attempts} SET sumgrades=0 WHERE sumgrades IS NULL');
- $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'attempt');
+ $field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'attempt');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
@@ -453,18 +485,20 @@ function xmldb_quiz_upgrade($oldversion) {
$table = new xmldb_table('quiz_feedback');
$columns = $DB->get_columns('quiz_feedback');
- // quiz_feedback.mingrade should be decimal(10,5) not null default 0
+ // quiz_feedback.mingrade should be decimal(10, 5) not null default 0
if (array_key_exists('mingrade', $columns) && empty($columns['mingrade']->not_null)) {
- $field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'feedbacktextformat');
+ $field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'feedbacktextformat');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
}
- // quiz_feedback.maxgrade should be decimal(10,5) not null default 0
+ // quiz_feedback.maxgrade should be decimal(10, 5) not null default 0
if (array_key_exists('maxgrade', $columns) && empty($columns['maxgrade']->not_null)) {
// Fixed in earlier upgrade code
- $field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'mingrade');
+ $field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'mingrade');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
@@ -478,9 +512,10 @@ function xmldb_quiz_upgrade($oldversion) {
$table = new xmldb_table('quiz_grades');
$columns = $DB->get_columns('quiz_grades');
- // quiz_grades.grade should be decimal(10,5) not null default 0
+ // quiz_grades.grade should be decimal(10, 5) not null default 0
if (array_key_exists('grade', $columns) && empty($columns['grade']->not_null)) {
- $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'userid');
+ $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null,
+ XMLDB_NOTNULL, null, '0', 'userid');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
@@ -494,9 +529,10 @@ function xmldb_quiz_upgrade($oldversion) {
$table = new xmldb_table('quiz_question_instances');
$columns = $DB->get_columns('quiz_question_instances');
- // quiz_question_instances.grade should be decimal(12,7) not null default 0
+ // quiz_question_instances.grade should be decimal(12, 7) not null default 0
if (array_key_exists('grade', $columns) && empty($columns['grade']->not_null)) {
- $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, '0', 'question');
+ $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null,
+ XMLDB_NOTNULL, null, '0', 'question');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_default($table, $field);
}
diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php
index e65105354681d..1241f8a8cdd0b 100644
--- a/mod/quiz/edit.php
+++ b/mod/quiz/edit.php
@@ -1,5 +1,4 @@
larrow() . ' ' . get_string('addtoquiz', 'quiz') .
- '" ' . $disabled . "/>\n";
+ $out = '\n";
return $out;
}
@@ -212,7 +211,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
}
if (($addquestion = optional_param('addquestion', 0, PARAM_INT)) && confirm_sesskey()) {
-/// Add a single question to the current quiz
+ // Add a single question to the current quiz
$addonpage = optional_param('addonpage', 0, PARAM_INT);
quiz_add_quiz_question($addquestion, $quiz, $addonpage);
quiz_delete_previews($quiz);
@@ -222,7 +221,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
}
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
-/// Add selected questions to the current quiz
+ // Add selected questions to the current quiz
$rawdata = (array) data_submitted();
foreach ($rawdata as $key => $value) { // Parse input for question ids
if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
@@ -248,7 +247,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
redirect($afteractionurl);
}
-if (optional_param('addnewpagesafterselected', null, PARAM_CLEAN) && !empty($selectedquestionids) && confirm_sesskey()) {
+if (optional_param('addnewpagesafterselected', null, PARAM_CLEAN) &&
+ !empty($selectedquestionids) && confirm_sesskey()) {
foreach ($selectedquestionids as $questionid) {
$quiz->questions = quiz_add_page_break_after($quiz->questions, $questionid);
}
@@ -281,7 +281,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
redirect($afteractionurl);
}
-if (optional_param('quizdeleteselected', false, PARAM_BOOL) && !empty($selectedquestionids) && confirm_sesskey()) {
+if (optional_param('quizdeleteselected', false, PARAM_BOOL) &&
+ !empty($selectedquestionids) && confirm_sesskey()) {
foreach ($selectedquestionids as $questionid) {
quiz_remove_question($quiz, $questionid);
}
@@ -305,7 +306,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
foreach ($rawdata as $key => $value) {
if (preg_match('!^g([0-9]+)$!', $key, $matches)) {
- /// Parse input for question -> grades
+ // Parse input for question -> grades
$questionid = $matches[1];
$quiz->grades[$questionid] = clean_param($value, PARAM_FLOAT);
quiz_update_question_instance($quiz->grades[$questionid], $questionid, $quiz);
@@ -313,7 +314,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
$recomputesummarks = true;
} else if (preg_match('!^o(pg)?([0-9]+)$!', $key, $matches)) {
- /// Parse input for ordering info
+ // Parse input for ordering info
$questionid = $matches[2];
// Make sure two questions don't overwrite each other. If we get a second
// question with the same position, shift the second one along to the next gap.
@@ -389,8 +390,10 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
$PAGE->requires->yui2_lib('container');
$PAGE->requires->yui2_lib('dragdrop');
-$PAGE->requires->skip_link_to('questionbank', get_string('skipto', 'access', get_string('questionbank', 'question')));
-$PAGE->requires->skip_link_to('quizcontentsblock', get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz')));
+$PAGE->requires->skip_link_to('questionbank',
+ get_string('skipto', 'access', get_string('questionbank', 'question')));
+$PAGE->requires->skip_link_to('quizcontentsblock',
+ get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz')));
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
$node = $PAGE->settingsnav->find('mod_quiz_edit', navigation_node::TYPE_SETTING);
@@ -419,8 +422,10 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
$currenttab = 'edit';
}
$tabs = array(array(
- new tabobject('edit', new moodle_url($thispageurl, array('reordertool' => 0)), get_string('editingquiz', 'quiz')),
- new tabobject('reorder', new moodle_url($thispageurl, array('reordertool' => 1)), get_string('orderingquiz', 'quiz')),
+ new tabobject('edit', new moodle_url($thispageurl,
+ array('reordertool' => 0)), get_string('editingquiz', 'quiz')),
+ new tabobject('reorder', new moodle_url($thispageurl,
+ array('reordertool' => 1)), get_string('orderingquiz', 'quiz')),
));
print_tabs($tabs, $currenttab);
@@ -469,7 +474,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
$repaginatingdisabled = false;
}
if ($quiz_reordertool) {
- echo '';
}
@@ -551,16 +559,15 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
'cmid' => $cm->id,
));
?>
-
-
name); ?>
-
-
-
-
display();
-?>
-
+
+
name); ?>
+
+
+
+
display();
+ ?>
+
footer();
-?>
diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php
index abe20982609e6..78c01fc8c6157 100644
--- a/mod/quiz/editlib.php
+++ b/mod/quiz/editlib.php
@@ -1,5 +1,4 @@
get_records_sql(
- "SELECT q.id,q.qtype FROM {question} q
+ "SELECT q.id, q.qtype FROM {question} q
WHERE qtype = 'random'
AND category = ?
AND " . $DB->sql_compare_text('questiontext') . " = ?
@@ -815,7 +814,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
// Get a sample from the database,
$questionidstoshow = array_slice($questionids, 0, NUM_QS_TO_SHOW_IN_RANDOM);
$questionstoshow = $DB->get_records_list('question', 'id', $questionidstoshow,
- '', 'id,qtype,name,questiontext,questiontextformat');
+ '', 'id, qtype, name, questiontext, questiontextformat');
// list them,
echo '
';
@@ -1183,7 +1182,6 @@ function quiz_print_status_bar($quiz) {
echo get_string('numquestionsx', 'quiz', $numberofquestions);
?>
delete_records('quiz_feedback', array('quizid' => $quiz->id));
$events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
- foreach($events as $event) {
+ foreach ($events as $event) {
$event = calendar_event::load($event);
$event->delete();
}
@@ -315,12 +312,13 @@ function quiz_delete_all_attempts($quiz) {
*
* @param object $quiz the quiz settings.
* @param int $userid the id of the user.
- * @return float the user's current grade for this quiz, or NULL if this user does
+ * @return float the user's current grade for this quiz, or null if this user does
* not have a grade on this quiz.
*/
function quiz_get_best_grade($quiz, $userid) {
global $DB;
- $grade = $DB->get_field('quiz_grades', 'grade', array('quiz' => $quiz->id, 'userid' => $userid));
+ $grade = $DB->get_field('quiz_grades', 'grade',
+ array('quiz' => $quiz->id, 'userid' => $userid));
// Need to detect errors/no result, without catching 0 grades.
if ($grade === false) {
@@ -396,18 +394,20 @@ function quiz_user_complete($course, $user, $mod, $quiz) {
}
}
- if ($attempts = $DB->get_records('quiz_attempts', array('userid' => $user->id, 'quiz' => $quiz->id), 'attempt')) {
+ if ($attempts = $DB->get_records('quiz_attempts',
+ array('userid' => $user->id, 'quiz' => $quiz->id), 'attempt')) {
foreach ($attempts as $attempt) {
echo get_string('attempt', 'quiz').' '.$attempt->attempt.': ';
if ($attempt->timefinish == 0) {
print_string('unfinished');
} else {
- echo quiz_format_grade($quiz, $attempt->sumgrades) . '/' . quiz_format_grade($quiz, $quiz->sumgrades);
+ echo quiz_format_grade($quiz, $attempt->sumgrades) . '/' .
+ quiz_format_grade($quiz, $quiz->sumgrades);
}
echo ' - '.userdate($attempt->timemodified).' ';
}
} else {
- print_string('noattempts', 'quiz');
+ print_string('noattempts', 'quiz');
}
return true;
@@ -429,7 +429,8 @@ function quiz_cron() {
* @param int $userid the userid.
* @param string $status 'all', 'finished' or 'unfinished' to control
* @param bool $includepreviews
- * @return an array of all the user's attempts at this quiz. Returns an empty array if there are none.
+ * @return an array of all the user's attempts at this quiz. Returns an empty
+ * array if there are none.
*/
function quiz_get_user_attempts($quizid, $userid, $status = 'finished', $includepreviews = false) {
global $DB;
@@ -575,7 +576,7 @@ function quiz_upgrade_grades() {
* @param mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int 0 if ok, error code otherwise
*/
-function quiz_grade_item_update($quiz, $grades = NULL) {
+function quiz_grade_item_update($quiz, $grades = null) {
global $CFG, $OUTPUT;
require_once($CFG->libdir.'/gradelib.php');
@@ -594,12 +595,13 @@ function quiz_grade_item_update($quiz, $grades = NULL) {
$params['gradetype'] = GRADE_TYPE_NONE;
}
-/* description by TJ:
-1/ If the quiz is set to not show grades while the quiz is still open, and is set to show grades after
- the quiz is closed, then create the grade_item with a show-after date that is the quiz close date.
-2/ If the quiz is set to not show grades at either of those times, create the grade_item as hidden.
-3/ If the quiz is set to show grades, create the grade_item visible.
-*/
+ // description by TJ:
+ // 1. If the quiz is set to not show grades while the quiz is still open,
+ // and is set to show grades after the quiz is closed, then create the
+ // grade_item with a show-after date that is the quiz close date.
+ // 2. If the quiz is set to not show grades at either of those times,
+ // create the grade_item as hidden.
+ // 3. If the quiz is set to show grades, create the grade_item visible.
$openreviewoptions = mod_quiz_display_options::make_from_quiz($quiz,
mod_quiz_display_options::LATER_WHILE_OPEN);
$closedreviewoptions = mod_quiz_display_options::make_from_quiz($quiz,
@@ -618,13 +620,14 @@ function quiz_grade_item_update($quiz, $grades = NULL) {
} else {
// a) both open and closed enabled
- // b) open enabled, closed disabled - we can not "hide after", grades are kept visible even after closing
+ // b) open enabled, closed disabled - we can not "hide after",
+ // grades are kept visible even after closing
$params['hidden'] = 0;
}
if ($grades === 'reset') {
$params['reset'] = true;
- $grades = NULL;
+ $grades = null;
}
$gradebook_grades = grade_get_grades($quiz->course, 'mod', 'quiz', $quiz->id);
@@ -634,7 +637,8 @@ function quiz_grade_item_update($quiz, $grades = NULL) {
$confirm_regrade = optional_param('confirm_regrade', 0, PARAM_INT);
if (!$confirm_regrade) {
$message = get_string('gradeitemislocked', 'grades');
- $back_link = $CFG->wwwroot . '/mod/quiz/report.php?q=' . $quiz->id . '&mode=overview';
+ $back_link = $CFG->wwwroot . '/mod/quiz/report.php?q=' . $quiz->id .
+ '&mode=overview';
$regrade_link = qualified_me() . '&confirm_regrade=1';
echo $OUTPUT->box_start('generalbox', 'notice');
echo '
'. $message .'
';
@@ -662,7 +666,8 @@ function quiz_grade_item_delete($quiz) {
global $CFG;
require_once($CFG->libdir . '/gradelib.php');
- return grade_update('mod/quiz', $quiz->course, 'mod', 'quiz', $quiz->id, 0, NULL, array('deleted' => 1));
+ return grade_update('mod/quiz', $quiz->course, 'mod', 'quiz', $quiz->id, 0,
+ null, array('deleted' => 1));
}
/**
@@ -770,11 +775,12 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
$groupmode = groups_get_activity_groupmode($cm, $course);
if (is_null($modinfo->groups)) {
- $modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo
+ // load all my groups and cache it in modinfo
+ $modinfo->groups = groups_get_user_groups($course->id);
}
$usersgroups = null;
- $aname = format_string($cm->name,true);
+ $aname = format_string($cm->name, true);
foreach ($attempts as $attempt) {
if ($attempt->userid != $USER->id) {
if (!$grader) {
@@ -931,17 +937,20 @@ function quiz_process_options($quiz) {
// Check there is nothing in the remaining unused fields.
if (!empty($quiz->feedbackboundaries)) {
for ($i = $numboundaries; $i < count($quiz->feedbackboundaries); $i += 1) {
- if (!empty($quiz->feedbackboundaries[$i]) && trim($quiz->feedbackboundaries[$i]) != '') {
+ if (!empty($quiz->feedbackboundaries[$i]) &&
+ trim($quiz->feedbackboundaries[$i]) != '') {
return get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
}
}
}
for ($i = $numboundaries + 1; $i < count($quiz->feedbacktext); $i += 1) {
- if (!empty($quiz->feedbacktext[$i]['text']) && trim($quiz->feedbacktext[$i]['text']) != '') {
+ if (!empty($quiz->feedbacktext[$i]['text']) &&
+ trim($quiz->feedbacktext[$i]['text']) != '') {
return get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
}
}
- $quiz->feedbackboundaries[-1] = $quiz->grade + 1; // Needs to be bigger than $quiz->grade because of '<' test in quiz_feedback_for_grade().
+ // Needs to be bigger than $quiz->grade because of '<' test in quiz_feedback_for_grade().
+ $quiz->feedbackboundaries[-1] = $quiz->grade + 1;
$quiz->feedbackboundaries[$numboundaries] = 0;
$quiz->feedbackboundarycount = $numboundaries;
}
@@ -1008,8 +1017,12 @@ function quiz_after_add_or_update($quiz) {
$feedback->mingrade = $quiz->feedbackboundaries[$i];
$feedback->maxgrade = $quiz->feedbackboundaries[$i - 1];
$feedback->id = $DB->insert_record('quiz_feedback', $feedback);
- $feedbacktext = file_save_draft_area_files((int)$quiz->feedbacktext[$i]['itemid'], $context->id, 'mod_quiz', 'feedback', $feedback->id, array('subdirs'=>false, 'maxfiles'=>-1, 'maxbytes'=>0), $quiz->feedbacktext[$i]['text']);
- $DB->set_field('quiz_feedback', 'feedbacktext', $feedbacktext, array('id'=>$feedback->id));
+ $feedbacktext = file_save_draft_area_files((int)$quiz->feedbacktext[$i]['itemid'],
+ $context->id, 'mod_quiz', 'feedback', $feedback->id,
+ array('subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0),
+ $quiz->feedbacktext[$i]['text']);
+ $DB->set_field('quiz_feedback', 'feedbacktext', $feedbacktext,
+ array('id' => $feedback->id));
}
// Update the events relating to this quiz.
@@ -1048,8 +1061,7 @@ function quiz_update_events($quiz, $override = null) {
$overrides = $DB->get_records('quiz_overrides', array('quiz' => $quiz->id));
// as well as the original quiz (empty override)
$overrides[] = new stdClass();
- }
- else {
+ } else {
// Just do the one override
$overrides = array($override);
}
@@ -1066,7 +1078,8 @@ function quiz_update_events($quiz, $override = null) {
$event = new stdClass();
$event->description = $quiz->intro;
- $event->courseid = ($userid) ? 0 : $quiz->course; // Events module won't show user events when the courseid is nonzero
+ // Events module won't show user events when the courseid is nonzero
+ $event->courseid = ($userid) ? 0 : $quiz->course;
$event->groupid = $groupid;
$event->userid = $userid;
$event->modulename = 'quiz';
@@ -1086,8 +1099,7 @@ function quiz_update_events($quiz, $override = null) {
continue;
}
$eventname = get_string('overridegroupeventname', 'quiz', $params);
- }
- else if ($userid) {
+ } else if ($userid) {
$params = new stdClass();
$params->quiz = $quiz->name;
$eventname = get_string('overrideusereventname', 'quiz', $params);
@@ -1099,8 +1111,7 @@ function quiz_update_events($quiz, $override = null) {
// Single event for the whole quiz.
if ($oldevent = array_shift($oldevents)) {
$event->id = $oldevent->id;
- }
- else {
+ } else {
unset($event->id);
}
$event->name = $eventname;
@@ -1112,8 +1123,7 @@ function quiz_update_events($quiz, $override = null) {
if ($timeopen && $addopen) {
if ($oldevent = array_shift($oldevents)) {
$event->id = $oldevent->id;
- }
- else {
+ } else {
unset($event->id);
}
$event->name = $eventname.' ('.get_string('quizopens', 'quiz').')';
@@ -1123,8 +1133,7 @@ function quiz_update_events($quiz, $override = null) {
if ($timeclose && $addclose) {
if ($oldevent = array_shift($oldevents)) {
$event->id = $oldevent->id;
- }
- else {
+ } else {
unset($event->id);
}
$event->name = $eventname.' ('.get_string('quizcloses', 'quiz').')';
@@ -1154,7 +1163,8 @@ function quiz_get_view_actions() {
* @return array
*/
function quiz_get_post_actions() {
- return array('attempt', 'close attempt', 'preview', 'editquestions', 'delete attempt', 'manualgrade');
+ return array('attempt', 'close attempt', 'preview', 'editquestions',
+ 'delete attempt', 'manualgrade');
}
/**
@@ -1179,7 +1189,8 @@ function quiz_questions_in_use($questionids) {
*/
function quiz_reset_course_form_definition($mform) {
$mform->addElement('header', 'quizheader', get_string('modulenameplural', 'quiz'));
- $mform->addElement('advcheckbox', 'reset_quiz_attempts', get_string('removeallquizattempts','quiz'));
+ $mform->addElement('advcheckbox', 'reset_quiz_attempts',
+ get_string('removeallquizattempts', 'quiz'));
}
/**
@@ -1228,7 +1239,7 @@ function quiz_reset_userdata($data) {
$componentstr = get_string('modulenameplural', 'quiz');
$status = array();
- /// Delete attempts.
+ // Delete attempts.
if (!empty($data->reset_quiz_attempts)) {
require_once($CFG->libdir . '/questionlib.php');
@@ -1241,7 +1252,7 @@ function quiz_reset_userdata($data) {
'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', array($data->courseid));
$status[] = array(
'component' => $componentstr,
- 'item' => get_string('attemptsdeleted','quiz'),
+ 'item' => get_string('attemptsdeleted', 'quiz'),
'error' => false);
// Remove all grades from gradebook
@@ -1254,9 +1265,10 @@ function quiz_reset_userdata($data) {
'error' => false);
}
- /// Updating dates - shift may be negative too
+ // Updating dates - shift may be negative too
if ($data->timeshift) {
- shift_course_mod_dates('quiz', array('timeopen', 'timeclose'), $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'),
@@ -1305,9 +1317,10 @@ function quiz_check_file_access($attemptuniqueid, $questionid, $context = null)
// access granted if the current user submitted this file
if ($attempt->userid != $USER->id) {
return false;
- // access granted if the current user has permission to grade quizzes in this course
}
- if (!(has_capability('mod/quiz:viewreports', $context) || has_capability('mod/quiz:grade', $context))) {
+ // access granted if the current user has permission to grade quizzes in this course
+ if (!(has_capability('mod/quiz:viewreports', $context) ||
+ has_capability('mod/quiz:grade', $context))) {
return false;
}
@@ -1321,7 +1334,7 @@ function quiz_check_file_access($attemptuniqueid, $questionid, $context = null)
*/
function quiz_print_overview($courses, &$htmlarray) {
global $USER, $CFG;
-/// These next 6 Lines are constant in all modules (just change module name)
+ // These next 6 Lines are constant in all modules (just change module name)
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return array();
}
@@ -1330,43 +1343,50 @@ function quiz_print_overview($courses, &$htmlarray) {
return;
}
-/// Fetch some language strings outside the main loop.
+ // Fetch some language strings outside the main loop.
$strquiz = get_string('modulename', 'quiz');
$strnoattempts = get_string('noattempts', 'quiz');
-/// We want to list quizzes that are currently available, and which have a close date.
-/// This is the same as what the lesson does, and the dabate is in MDL-10568.
+ // We want to list quizzes that are currently available, and which have a close date.
+ // This is the same as what the lesson does, and the dabate is in MDL-10568.
$now = time();
foreach ($quizzes as $quiz) {
if ($quiz->timeclose >= $now && $quiz->timeopen < $now) {
- /// Give a link to the quiz, and the deadline.
+ // Give a link to the quiz, and the deadline.
$str = '
';
- /// Now provide more information depending on the uers's role.
+ // Now provide more information depending on the uers's role.
$context = get_context_instance(CONTEXT_MODULE, $quiz->coursemodule);
if (has_capability('mod/quiz:viewreports', $context)) {
- /// For teacher-like people, show a summary of the number of student attempts.
+ // For teacher-like people, show a summary of the number of student attempts.
// The $quiz objects returned by get_all_instances_in_course have the necessary $cm
// fields set to make the following call work.
- $str .= '
';
- } else if (has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $context)) { // Student
- /// For student-like people, tell them how many attempts they have made.
- if (isset($USER->id) && ($attempts = quiz_get_user_attempts($quiz->id, $USER->id))) {
+ $str .= '
';
}
} else {
- /// For ayone else, there is no point listing this quiz, so stop processing.
+ // For ayone else, there is no point listing this quiz, so stop processing.
continue;
}
- /// Add the output for this quiz to the rest.
+ // Add the output for this quiz to the rest.
$str .= '
';
if (empty($htmlarray[$quiz->course]['quiz'])) {
$htmlarray[$quiz->course]['quiz'] = $str;
@@ -1382,8 +1402,10 @@ function quiz_print_overview($courses, &$htmlarray) {
* returns '' if no attempts have been made yet, unless $returnzero is passed as true.
*
* @param object $quiz the quiz object. Only $quiz->id is used at the moment.
- * @param object $cm the cm object. Only $cm->course, $cm->groupmode and $cm->groupingid fields are used at the moment.
- * @param bool $returnzero if false (default), when no attempts have been made '' is returned instead of 'Attempts: 0'.
+ * @param object $cm the cm object. Only $cm->course, $cm->groupmode and
+ * $cm->groupingid fields are used at the moment.
+ * @param bool $returnzero if false (default), when no attempts have been
+ * made '' is returned instead of 'Attempts: 0'.
* @param int $currentgroup if there is a concept of current group where this method is being called
* (e.g. a report) pass it in here. Default 0 which means no current group.
* @return string a string like "Attempts: 123", "Attemtps 123 (45 from your groups)" or
@@ -1399,7 +1421,8 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup
$a->group = $DB->count_records_sql('SELECT count(1) FROM ' .
'{quiz_attempts} qa JOIN ' .
'{groups_members} gm ON qa.userid = gm.userid ' .
- 'WHERE quiz = ? AND preview = 0 AND groupid = ?', array($quiz->id, $currentgroup));
+ 'WHERE quiz = ? AND preview = 0 AND groupid = ?',
+ array($quiz->id, $currentgroup));
return get_string('attemptsnumthisgroup', 'quiz', $a);
} else if ($groups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid)) {
list($usql, $params) = $DB->get_in_or_equal(array_keys($groups));
@@ -1421,14 +1444,17 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup
* to the quiz reports.
*
* @param object $quiz the quiz object. Only $quiz->id is used at the moment.
- * @param object $cm the cm object. Only $cm->course, $cm->groupmode and $cm->groupingid fields are used at the moment.
+ * @param object $cm the cm object. Only $cm->course, $cm->groupmode and
+ * $cm->groupingid fields are used at the moment.
* @param object $context the quiz context.
- * @param bool $returnzero if false (default), when no attempts have been made '' is returned instead of 'Attempts: 0'.
+ * @param bool $returnzero if false (default), when no attempts have been made
+ * '' is returned instead of 'Attempts: 0'.
* @param int $currentgroup if there is a concept of current group where this method is being called
* (e.g. a report) pass it in here. Default 0 which means no current group.
* @return string HTML fragment for the link.
*/
-function quiz_attempt_summary_link_to_reports($quiz, $cm, $context, $returnzero = false, $currentgroup = 0) {
+function quiz_attempt_summary_link_to_reports($quiz, $cm, $context, $returnzero = false,
+ $currentgroup = 0) {
global $CFG;
$summary = quiz_num_attempt_summary($quiz, $cm, $returnzero, $currentgroup);
if (!$summary) {
@@ -1497,13 +1523,17 @@ function quiz_extend_navigation($quiznode, $course, $module, $cm) {
require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
$reportlist = quiz_report_list($context);
- $url = new moodle_url('/mod/quiz/report.php', array('id' => $cm->id, 'mode' => reset($reportlist)));
- $reportnode = $quiznode->add(get_string('results', 'quiz'), $url, navigation_node::TYPE_SETTING,
+ $url = new moodle_url('/mod/quiz/report.php',
+ array('id' => $cm->id, 'mode' => reset($reportlist)));
+ $reportnode = $quiznode->add(get_string('results', 'quiz'), $url,
+ navigation_node::TYPE_SETTING,
null, null, new pix_icon('i/report', ''));
foreach ($reportlist as $report) {
- $url = new moodle_url('/mod/quiz/report.php', array('id' => $cm->id, 'mode' => $report));
- $reportnode->add(get_string($report, 'quiz_'.$report), $url, navigation_node::TYPE_SETTING,
+ $url = new moodle_url('/mod/quiz/report.php',
+ array('id' => $cm->id, 'mode' => $report));
+ $reportnode->add(get_string($report, 'quiz_'.$report), $url,
+ navigation_node::TYPE_SETTING,
null, 'quiz_report_' . $report, new pix_icon('i/item', ''));
}
}
@@ -1529,9 +1559,11 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
if (has_capability('mod/quiz:manageoverrides', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$PAGE->cm->id));
- $quiznode->add(get_string('groupoverrides', 'quiz'), new moodle_url($url, array('mode'=>'group')),
+ $quiznode->add(get_string('groupoverrides', 'quiz'),
+ new moodle_url($url, array('mode'=>'group')),
navigation_node::TYPE_SETTING, null, 'groupoverrides');
- $quiznode->add(get_string('useroverrides', 'quiz'), new moodle_url($url, array('mode'=>'user')),
+ $quiznode->add(get_string('useroverrides', 'quiz'),
+ new moodle_url($url, array('mode'=>'user')),
navigation_node::TYPE_SETTING, null, 'useroverrides');
}
@@ -1543,7 +1575,8 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
}
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
- $url = new moodle_url('/mod/quiz/startattempt.php', array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
+ $url = new moodle_url('/mod/quiz/startattempt.php',
+ array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
$quiznode->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING,
null, 'mod_quiz_preview', new pix_icon('t/preview', ''));
}
diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php
index 5a484e704dcf0..620abc52ca924 100644
--- a/mod/quiz/locallib.php
+++ b/mod/quiz/locallib.php
@@ -1,5 +1,4 @@
attemptonlast) {
- /// We are not building on last attempt so create a new attempt.
+ // We are not building on last attempt so create a new attempt.
$attempt = new stdClass();
$attempt->quiz = $quiz->id;
$attempt->userid = $USER->id;
$attempt->preview = 0;
if ($quiz->shufflequestions) {
- $attempt->layout = quiz_clean_layout(quiz_repaginate($quiz->questions, $quiz->questionsperpage, true),true);
+ $attempt->layout = quiz_clean_layout(quiz_repaginate(
+ $quiz->questions, $quiz->questionsperpage, true), true);
} else {
- $attempt->layout = quiz_clean_layout($quiz->questions,true);
+ $attempt->layout = quiz_clean_layout($quiz->questions, true);
}
} else {
- /// Build on last attempt.
+ // Build on last attempt.
if (empty($lastattempt)) {
print_error('cannotfindprevattempt', 'quiz');
}
@@ -102,7 +102,7 @@ function quiz_create_attempt($quiz, $attemptnumber, $lastattempt, $timenow, $isp
$attempt->timefinish = 0;
$attempt->timemodified = $timenow;
-/// If this is a preview, mark it as such.
+ // If this is a preview, mark it as such.
if ($ispreview) {
$attempt->preview = 1;
}
@@ -154,7 +154,8 @@ function quiz_get_latest_attempt_by_user($quizid, $userid) {
/**
* Delete a quiz attempt.
- * @param mixed $attempt an integer attempt id or an attempt object (row of the quiz_attempts table).
+ * @param mixed $attempt an integer attempt id or an attempt object
+ * (row of the quiz_attempts table).
* @param object $quiz the quiz object.
*/
function quiz_delete_attempt($attempt, $quiz) {
@@ -179,7 +180,7 @@ function quiz_delete_attempt($attempt, $quiz) {
// else recalculate best grade
$userid = $attempt->userid;
if (!$DB->record_exists('quiz_attempts', array('userid' => $userid, 'quiz' => $quiz->id))) {
- $DB->delete_records('quiz_grades', array('userid' => $userid,'quiz' => $quiz->id));
+ $DB->delete_records('quiz_grades', array('userid' => $userid, 'quiz' => $quiz->id));
} else {
quiz_save_best_grade($quiz, $userid);
}
@@ -312,7 +313,7 @@ function quiz_get_all_question_grades($quiz) {
$params = array_merge($params, $question_params);
}
- $instances = $DB->get_records_sql("SELECT question,grade,id
+ $instances = $DB->get_records_sql("SELECT question, grade, id
FROM {quiz_question_instances}
WHERE quiz = ? $wheresql", $params);
@@ -337,7 +338,8 @@ function quiz_get_all_question_grades($quiz) {
* @param object $quiz the quiz object. Only the fields grade, sumgrades and decimalpoints are used.
* @param bool|string $format whether to format the results for display
* or 'question' to format a question grade (different number of decimal places.
- * @return float|string the rescaled grade, or null/the lang string 'notyetgraded' if the $grade is null.
+ * @return float|string the rescaled grade, or null/the lang string 'notyetgraded'
+ * if the $grade is null.
*/
function quiz_rescale_grade($rawgrade, $quiz, $format = true) {
if (is_null($rawgrade)) {
@@ -381,7 +383,8 @@ function quiz_feedback_for_grade($grade, $quiz, $context) {
// Clean the text, ready for display.
$formatoptions = new stdClass();
$formatoptions->noclean = true;
- $feedbacktext = file_rewrite_pluginfile_urls($feedback->feedbacktext, 'pluginfile.php', $context->id, 'mod_quiz', 'feedback', $feedback->id);
+ $feedbacktext = file_rewrite_pluginfile_urls($feedback->feedbacktext, 'pluginfile.php',
+ $context->id, 'mod_quiz', 'feedback', $feedback->id);
$feedbacktext = format_text($feedbacktext, $feedback->feedbacktextformat, $formatoptions);
return $feedbacktext;
@@ -462,7 +465,8 @@ function quiz_update_all_attempt_sumgrades($quiz) {
* quiz_update_grades.
*
* @param float $newgrade the new maximum grade for the quiz.
- * @param object $quiz the quiz we are updating. Passed by reference so its grade field can be updated too.
+ * @param object $quiz the quiz we are updating. Passed by reference so its
+ * grade field can be updated too.
* @return bool indicating success or failure.
*/
function quiz_set_grade($newgrade, $quiz) {
@@ -533,7 +537,7 @@ function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
$userid = $USER->id;
}
- if (!$attempts){
+ if (!$attempts) {
// Get all the attempts made by the user
$attempts = quiz_get_user_attempts($quiz->id, $userid);
}
@@ -546,7 +550,8 @@ function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
if (is_null($bestgrade)) {
$DB->delete_records('quiz_grades', array('quiz' => $quiz->id, 'userid' => $userid));
- } else if ($grade = $DB->get_record('quiz_grades', array('quiz' => $quiz->id, 'userid' => $userid))) {
+ } else if ($grade = $DB->get_record('quiz_grades',
+ array('quiz' => $quiz->id, 'userid' => $userid))) {
$grade->grade = $bestgrade;
$grade->timemodified = time();
$DB->update_record('quiz_grades', $grade);
@@ -804,7 +809,8 @@ function quiz_get_grading_options() {
}
/**
- * @param int $option one of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST.
+ * @param int $option one of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE,
+ * QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST.
* @return the lang string for that option.
*/
function quiz_get_grading_option_name($option) {
@@ -817,10 +823,10 @@ function quiz_get_grading_option_name($option) {
/**
* Upgrade states for an attempt to Moodle 1.5 model
*
- * Any state that does not yet have its timestamp set to nonzero has not yet been upgraded from Moodle 1.4
- * The reason these are still around is that for large sites it would have taken too long to
- * upgrade all states at once. This function sets the timestamp field and creates an entry in the
- * question_sessions table.
+ * Any state that does not yet have its timestamp set to nonzero has not yet been
+ * upgraded from Moodle 1.4. The reason these are still around is that for large
+ * sites it would have taken too long to upgrade all states at once. This function
+ * sets the timestamp field and creates an entry in the question_sessions table.
* @param object $attempt The attempt whose states need upgrading
*/
function quiz_upgrade_states($attempt) {
@@ -829,7 +835,8 @@ function quiz_upgrade_states($attempt) {
// only one state record per question for this attempt.
// We set the timestamp of all states to the timemodified field of the attempt.
- $DB->execute("UPDATE {question_states} SET timestamp = ? WHERE attempt = ?", array($attempt->timemodified, $attempt->uniqueid));
+ $DB->execute("UPDATE {question_states} SET timestamp = ? WHERE attempt = ?",
+ array($attempt->timemodified, $attempt->uniqueid));
// For each state we create an entry in the question_sessions table, with both newest and
// newgraded pointing to this state.
@@ -840,10 +847,11 @@ function quiz_upgrade_states($attempt) {
$session->attemptid = $attempt->uniqueid;
$questionlist = quiz_questions_in_quiz($attempt->layout);
$params = array($attempt->uniqueid);
- list($usql, $question_params) = $DB->get_in_or_equal(explode(',',$questionlist));
+ list($usql, $question_params) = $DB->get_in_or_equal(explode(',', $questionlist));
$params = array_merge($params, $question_params);
- if ($questionlist and $states = $DB->get_records_select('question_states', "attempt = ? AND question $usql", $params)) {
+ if ($questionlist and $states = $DB->get_records_select('question_states',
+ "attempt = ? AND question $usql", $params)) {
foreach ($states as $state) {
$session->newgraded = $state->id;
$session->newest = $state->id;
@@ -872,7 +880,8 @@ function quiz_question_action_icons($quiz, $cmid, $question, $returnurl) {
* @param object $question the question.
* @param string $returnurl url to return to after action is done.
* @param string $contentbeforeicon some HTML content to be added inside the link, before the icon.
- * @return the HTML for an edit icon, view icon, or nothing for a question (depending on permissions).
+ * @return the HTML for an edit icon, view icon, or nothing for a question
+ * (depending on permissions).
*/
function quiz_question_edit_button($cmid, $question, $returnurl, $contentaftericon = '') {
global $CFG, $OUTPUT;
@@ -880,18 +889,20 @@ function quiz_question_edit_button($cmid, $question, $returnurl, $contentafteric
// Minor efficiency saving. Only get strings once, even if there are a lot of icons on one page.
static $stredit = null;
static $strview = null;
- if ($stredit === null){
+ if ($stredit === null) {
$stredit = get_string('edit');
$strview = get_string('view');
}
// What sort of icon should we show?
$action = '';
- if (!empty($question->id) && (question_has_capability_on($question, 'edit', $question->category) ||
- question_has_capability_on($question, 'move', $question->category))) {
+ if (!empty($question->id) &&
+ (question_has_capability_on($question, 'edit', $question->category) ||
+ question_has_capability_on($question, 'move', $question->category))) {
$action = $stredit;
$icon = '/t/edit';
- } else if (!empty($question->id) && question_has_capability_on($question, 'view', $question->category)) {
+ } else if (!empty($question->id) &&
+ question_has_capability_on($question, 'view', $question->category)) {
$action = $strview;
$icon = '/i/info';
}
@@ -1007,7 +1018,8 @@ function quiz_get_review_options($quiz, $attempt, $context) {
array('attempt' => $attempt->id));
}
- if (!is_null($context) && !$attempt->preview && has_capability('mod/quiz:viewreports', $context) &&
+ if (!is_null($context) && !$attempt->preview &&
+ has_capability('mod/quiz:viewreports', $context) &&
has_capability('moodle/grade:viewhidden', $context)) {
// People who can see reports and hidden grades should be shown everything,
// except during preview when teachers want to see what students see.
@@ -1241,7 +1253,7 @@ function quiz_send_notification_emails($course, $quiz, $attempt, $context, $cm)
// check for confirmation required
$sendconfirm = false;
$notifyexcludeusers = '';
- if (has_capability('mod/quiz:emailconfirmsubmission', $context, NULL, false)) {
+ if (has_capability('mod/quiz:emailconfirmsubmission', $context, null, false)) {
// exclude from notify emails later
$notifyexcludeusers = $USER->id;
// send the email
@@ -1249,7 +1261,8 @@ function quiz_send_notification_emails($course, $quiz, $attempt, $context, $cm)
}
// check for notifications required
- $notifyfields = 'u.id, u.username, u.firstname, u.lastname, u.email, u.lang, u.timezone, u.mailformat, u.maildisplay';
+ $notifyfields = 'u.id, u.username, u.firstname, u.lastname, u.email, u.lang, ' .
+ 'u.timezone, u.mailformat, u.maildisplay';
$groups = groups_get_all_groups($course->id, $USER->id);
if (is_array($groups) && count($groups) > 0) {
$groups = array_keys($groups);
@@ -1273,9 +1286,11 @@ function quiz_send_notification_emails($course, $quiz, $attempt, $context, $cm)
// quiz info
$a->quizname = $quiz->name;
$a->quizreporturl = $CFG->wwwroot . '/mod/quiz/report.php?id=' . $cm->id;
- $a->quizreportlink = '' . format_string($quiz->name) . ' report';
+ $a->quizreportlink = '' .
+ format_string($quiz->name) . ' report';
$a->quizreviewurl = $CFG->wwwroot . '/mod/quiz/review.php?attempt=' . $attempt->id;
- $a->quizreviewlink = '' . format_string($quiz->name) . ' review';
+ $a->quizreviewlink = '' .
+ format_string($quiz->name) . ' review';
$a->quizurl = $CFG->wwwroot . '/mod/quiz/view.php?id=' . $cm->id;
$a->quizlink = '' . format_string($quiz->name) . '';
// attempt info
@@ -1317,7 +1332,8 @@ function quiz_send_notification_emails($course, $quiz, $attempt, $context, $cm)
// log errors sending emails if any
if (! empty($emailresult['fail'])) {
- debugging('quiz_send_notification_emails:: '.$emailresult['fail'].' email(s) failed to be sent.', DEBUG_DEVELOPER);
+ debugging('quiz_send_notification_emails:: ' . $emailresult['fail'] .
+ ' email(s) failed to be sent.', DEBUG_DEVELOPER);
}
// return the number of successfully sent emails
@@ -1338,7 +1354,8 @@ function quiz_get_js_module() {
return array(
'name' => 'mod_quiz',
'fullpath' => '/mod/quiz/module.js',
- 'requires' => array('base', 'dom', 'event-delegate', 'event-key', 'core_question_engine'),
+ 'requires' => array('base', 'dom', 'event-delegate', 'event-key',
+ 'core_question_engine'),
'strings' => array(
array('timesup', 'quiz'),
array('functiondisabledbysecuremode', 'quiz'),
@@ -1390,7 +1407,8 @@ public static function make_from_quiz($quiz, $when) {
$options->attempt = self::extract($quiz->reviewattempt, $when, true, false);
$options->correctness = self::extract($quiz->reviewcorrectness, $when);
- $options->marks = self::extract($quiz->reviewmarks, $when, self::MARK_AND_MAX, self::MAX_ONLY);
+ $options->marks = self::extract($quiz->reviewmarks, $when,
+ self::MARK_AND_MAX, self::MAX_ONLY);
$options->feedback = self::extract($quiz->reviewspecificfeedback, $when);
$options->generalfeedback = self::extract($quiz->reviewgeneralfeedback, $when);
$options->rightanswer = self::extract($quiz->reviewrightanswer, $when);
@@ -1407,7 +1425,8 @@ public static function make_from_quiz($quiz, $when) {
return $options;
}
- protected static function extract($bitmask, $bit, $whenset = self::VISIBLE, $whennotset = self::HIDDEN) {
+ protected static function extract($bitmask, $bit,
+ $whenset = self::VISIBLE, $whennotset = self::HIDDEN) {
if ($bitmask & $bit) {
return $whenset;
} else {
diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php
index 0932c7caff661..95e2bc894ac9c 100644
--- a/mod/quiz/mod_form.php
+++ b/mod/quiz/mod_form.php
@@ -1,5 +1,4 @@
addElement('select', 'questiondecimalpoints', get_string('decimalplacesquestion', 'quiz'), $options);
- $mform->addHelpButton('questiondecimalpoints', 'decimalplacesquestion','quiz');
+ $mform->addHelpButton('questiondecimalpoints', 'decimalplacesquestion', 'quiz');
$mform->setAdvanced('questiondecimalpoints', $quizconfig->questiondecimalpoints_adv);
$mform->setDefault('questiondecimalpoints', $quizconfig->questiondecimalpoints);
diff --git a/mod/quiz/module.js b/mod/quiz/module.js
index 1f64df023075a..7c11547ef853b 100644
--- a/mod/quiz/module.js
+++ b/mod/quiz/module.js
@@ -175,7 +175,7 @@ M.mod_quiz.nav.init = function(Y) {
M.mod_quiz.secure_window = {
init: function(Y) {
- if (window.location.href.substring(0,4) == 'file') {
+ if (window.location.href.substring(0, 4) == 'file') {
window.location = 'about:blank';
}
Y.delegate('contextmenu', M.mod_quiz.secure_window.prevent, document.body, '*');
diff --git a/mod/quiz/override_form.php b/mod/quiz/override_form.php
index 60303e270c624..c5e12f4dca274 100644
--- a/mod/quiz/override_form.php
+++ b/mod/quiz/override_form.php
@@ -1,5 +1,4 @@
libdir.'/formslib.php';
+require_once($CFG->libdir . '/formslib.php');
/**
@@ -45,7 +44,7 @@ class quiz_override_form extends moodleform {
protected $groupid; // groupid, if provided
protected $userid; // userid, if provided
- public function quiz_override_form($submiturl, $cm, $quiz, $context, $groupmode, $override) {
+ public function __construct($submiturl, $cm, $quiz, $context, $groupmode, $override) {
$this->cm = $cm;
$this->quiz = $quiz;
@@ -54,7 +53,7 @@ public function quiz_override_form($submiturl, $cm, $quiz, $context, $groupmode,
$this->groupid = empty($override->groupid) ? 0 : $override->groupid;
$this->userid = empty($override->userid) ? 0 : $override->userid;
- parent::moodleform($submiturl, null, 'post');
+ parent::__construct($submiturl, null, 'post');
}
@@ -72,7 +71,8 @@ protected function definition() {
// There is already a groupid, so freeze the selector
$groupchoices = array();
$groupchoices[$this->groupid] = groups_get_group_name($this->groupid);
- $mform->addElement('select', 'groupid', get_string('overridegroup', 'quiz'), $groupchoices);
+ $mform->addElement('select', 'groupid',
+ get_string('overridegroup', 'quiz'), $groupchoices);
$mform->freeze('groupid');
} else {
// Prepare the list of groups
@@ -93,7 +93,8 @@ protected function definition() {
$groupchoices[0] = get_string('none');
}
- $mform->addElement('select', 'groupid', get_string('overridegroup', 'quiz'), $groupchoices);
+ $mform->addElement('select', 'groupid',
+ get_string('overridegroup', 'quiz'), $groupchoices);
$mform->addRule('groupid', get_string('required'), 'required', null, 'client');
}
} else {
@@ -103,7 +104,8 @@ protected function definition() {
$user = $DB->get_record('user', array('id'=>$this->userid));
$userchoices = array();
$userchoices[$this->userid] = fullname($user);
- $mform->addElement('select', 'userid', get_string('overrideuser', 'quiz'), $userchoices);
+ $mform->addElement('select', 'userid',
+ get_string('overrideuser', 'quiz'), $userchoices);
$mform->freeze('userid');
} else {
// Prepare the list of users
@@ -111,15 +113,16 @@ protected function definition() {
if (!empty($CFG->enablegroupmembersonly) && $cm->groupmembersonly) {
// only users from the grouping
$groups = groups_get_all_groups($cm->course, 0, $cm->groupingid);
- if (empty($groups)) {
- // empty grouping
- } else {
- $users = get_users_by_capability($this->context, 'mod/quiz:attempt', 'u.id,u.firstname,u.lastname,u.email' ,
- 'firstname ASC, lastname ASC', '', '', array_keys($groups), '', false, true);
+ if (!empty($groups)) {
+ $users = get_users_by_capability($this->context, 'mod/quiz:attempt',
+ 'u.id, u.firstname, u.lastname, u.email',
+ 'firstname ASC, lastname ASC', '', '', array_keys($groups),
+ '', false, true);
}
} else {
- $users = get_users_by_capability($this->context, 'mod/quiz:attempt', 'u.id,u.firstname,u.lastname,u.email' ,
- 'firstname ASC, lastname ASC', '', '', '', '', false, true);
+ $users = get_users_by_capability($this->context, 'mod/quiz:attempt',
+ 'u.id, u.firstname, u.lastname, u.email' ,
+ 'firstname ASC, lastname ASC', '', '', '', '', false, true);
}
if (empty($users)) {
// generate an error
@@ -128,8 +131,9 @@ protected function definition() {
}
$userchoices = array();
- foreach ($users as $id=>$user) {
- if (empty($invalidusers[$id]) || (!empty($override) && $id == $override->userid)) {
+ foreach ($users as $id => $user) {
+ if (empty($invalidusers[$id]) || (!empty($override) &&
+ $id == $override->userid)) {
$userchoices[$id] = fullname($user) . ', ' . $user->email;
}
}
@@ -138,7 +142,8 @@ protected function definition() {
if (count($userchoices) == 0) {
$userchoices[0] = get_string('none');
}
- $mform->addElement('searchableselector', 'userid', get_string('overrideuser', 'quiz'), $userchoices);
+ $mform->addElement('searchableselector', 'userid',
+ get_string('overrideuser', 'quiz'), $userchoices);
$mform->addRule('userid', get_string('required'), 'required', null, 'client');
}
}
@@ -152,14 +157,17 @@ protected function definition() {
$mform->setDefault('password', $this->quiz->password);
// Open and close dates.
- $mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'), array('optional' => true));
+ $mform->addElement('date_time_selector', 'timeopen',
+ get_string('quizopen', 'quiz'), array('optional' => true));
$mform->setDefault('timeopen', $this->quiz->timeopen);
- $mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'), array('optional' => true));
+ $mform->addElement('date_time_selector', 'timeclose',
+ get_string('quizclose', 'quiz'), array('optional' => true));
$mform->setDefault('timeclose', $this->quiz->timeclose);
// Time limit.
- $mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'), array('optional' => true));
+ $mform->addElement('duration', 'timelimit',
+ get_string('timelimit', 'quiz'), array('optional' => true));
$mform->addHelpButton('timelimit', 'timelimit', 'quiz');
$mform->setDefault('timelimit', $this->quiz->timelimit);
@@ -168,15 +176,19 @@ protected function definition() {
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
$attemptoptions[$i] = $i;
}
- $mform->addElement('select', 'attempts', get_string('attemptsallowed', 'quiz'), $attemptoptions);
+ $mform->addElement('select', 'attempts',
+ get_string('attemptsallowed', 'quiz'), $attemptoptions);
$mform->setDefault('attempts', $this->quiz->attempts);
// Submit buttons
- $mform->addElement('submit', 'resetbutton', get_string('reverttodefaults','quiz'));
+ $mform->addElement('submit', 'resetbutton',
+ get_string('reverttodefaults', 'quiz'));
$buttonarray = array();
- $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('save', 'quiz'));
- $buttonarray[] = $mform->createElement('submit', 'againbutton', get_string('saveoverrideandstay', 'quiz'));
+ $buttonarray[] = $mform->createElement('submit', 'submitbutton',
+ get_string('save', 'quiz'));
+ $buttonarray[] = $mform->createElement('submit', 'againbutton',
+ get_string('saveoverrideandstay', 'quiz'));
$buttonarray[] = $mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonbar', '', array(' '), false);
@@ -213,7 +225,7 @@ public function validation($data, $files) {
// Ensure that at least one quiz setting was changed
$changed = false;
- $keys = array('timeopen','timeclose', 'timelimit', 'attempts', 'password');
+ $keys = array('timeopen', 'timeclose', 'timelimit', 'attempts', 'password');
foreach ($keys as $key) {
if ($data[$key] != $quiz->{$key}) {
$changed = true;
diff --git a/mod/quiz/overridedelete.php b/mod/quiz/overridedelete.php
index af1d68d4b0fbc..188704832cdea 100644
--- a/mod/quiz/overridedelete.php
+++ b/mod/quiz/overridedelete.php
@@ -1,5 +1,4 @@
header();
if ($override->groupid) {
- $group = $DB->get_record('groups', array('id' => $override->groupid), 'id,name');
+ $group = $DB->get_record('groups', array('id' => $override->groupid), 'id, name');
$confirmstr = get_string("overridedeletegroupsure", "quiz", $group->name);
} else {
- $user = $DB->get_record('user', array('id' => $override->userid), 'id,firstname,lastname');
+ $user = $DB->get_record('user', array('id' => $override->userid),
+ 'id, firstname, lastname');
$confirmstr = get_string("overridedeleteusersure", "quiz", fullname($user));
}
diff --git a/mod/quiz/overrideedit.php b/mod/quiz/overrideedit.php
index 804916c66fbe4..8461f4d499d1e 100644
--- a/mod/quiz/overrideedit.php
+++ b/mod/quiz/overrideedit.php
@@ -1,5 +1,4 @@
headspan = array(1,2,1);
-$table->colclasses = array('colname','colsetting','colvalue','colaction');
+$table->headspan = array(1, 2, 1);
+$table->colclasses = array('colname', 'colsetting', 'colvalue', 'colaction');
$table->head = array(
$colname,
get_string('overrides', 'quiz'),
@@ -138,7 +136,8 @@
if (!has_capability('mod/quiz:attempt', $context, $override->userid)) {
// user not allowed to take the quiz
$active = false;
- } else if (!empty($CFG->enablegroupmembersonly) && $cm->groupmembersonly && !groups_has_membership($cm, $override->userid)) {
+ } else if (!empty($CFG->enablegroupmembersonly) && $cm->groupmembersonly &&
+ !groups_has_membership($cm, $override->userid)) {
// user does not belong to the current grouping
$active = false;
}
@@ -147,31 +146,36 @@
// Format timeopen
if (isset($override->timeopen)) {
$fields[] = get_string('quizopens', 'quiz');
- $values[] = ($override->timeopen > 0)? userdate($override->timeopen) : get_string('noopen', 'quiz');
+ $values[] = $override->timeopen > 0 ?
+ userdate($override->timeopen) : get_string('noopen', 'quiz');
}
// Format timeclose
if (isset($override->timeclose)) {
$fields[] = get_string('quizcloses', 'quiz');
- $values[] = ($override->timeclose > 0)? userdate($override->timeclose) : get_string('noclose', 'quiz');
+ $values[] = $override->timeclose > 0 ?
+ userdate($override->timeclose) : get_string('noclose', 'quiz');
}
// Format timelimit
if (isset($override->timelimit)) {
$fields[] = get_string('timelimit', 'quiz');
- $values[] = ($override->timelimit > 0)? format_time($override->timelimit) : get_string('none', 'quiz');
+ $values[] = $override->timelimit > 0 ?
+ format_time($override->timelimit) : get_string('none', 'quiz');
}
// Format number of attempts
if (isset($override->attempts)) {
$fields[] = get_string('attempts', 'quiz');
- $values[] = ($override->attempts > 0)? $override->attempts : get_string('unlimited');
+ $values[] = $override->attempts > 0 ?
+ $override->attempts : get_string('unlimited');
}
// Format password
if (isset($override->password)) {
$fields[] = get_string('requirepassword', 'quiz');
- $values[] = ($override->password !== '')? get_string('enabled', 'quiz') : get_string('none', 'quiz');
+ $values[] = $override->password !== '' ?
+ get_string('enabled', 'quiz') : get_string('none', 'quiz');
}
// Icons:
@@ -182,22 +186,28 @@
// edit
$editurlstr = $overrideediturl->out(true, array('id' => $override->id));
$iconstr = '' .
- ' ';
+ ' ';
// duplicate
- $copyurlstr = $overrideediturl->out(true, array('id' => $override->id, 'action' => 'duplicate'));
+ $copyurlstr = $overrideediturl->out(true,
+ array('id' => $override->id, 'action' => 'duplicate'));
$iconstr .= '' .
- ' ';
+ ' ';
}
// delete
- $deleteurlstr = $overridedeleteurl->out(true, array('id' => $override->id, 'sesskey' => sesskey()));
+ $deleteurlstr = $overridedeleteurl->out(true,
+ array('id' => $override->id, 'sesskey' => sesskey()));
$iconstr .= '' .
- ' ';
+ ' ';
if ($groupmode) {
- $usergroupstr = '' . $override->name . '';
- }
- else {
- $usergroupstr = '' . fullname($override) . '';
+ $usergroupstr = '' . $override->name . '';
+ } else {
+ $usergroupstr = '' . fullname($override) . '';
}
$class = '';
@@ -251,8 +261,9 @@
echo $OUTPUT->notification(get_string('groupsnone', 'quiz'), 'error');
$options['disabled'] = true;
}
- echo $OUTPUT->single_button($overrideediturl->out(true, array('action' => 'addgroup', 'cmid' => $cm->id)),
- get_string('addnewgroupoverride', 'quiz'), 'post', $options);
+ echo $OUTPUT->single_button($overrideediturl->out(true,
+ array('action' => 'addgroup', 'cmid' => $cm->id)),
+ get_string('addnewgroupoverride', 'quiz'), 'post', $options);
} else {
$users = array();
// See if there are any students in the quiz
@@ -260,12 +271,12 @@
// restrict to grouping
$limitgroups = groups_get_all_groups($cm->course, 0, $cm->groupingid);
if (!empty($limitgroups)) {
- $users = get_users_by_capability($context, 'mod/quiz:attempt', 'u.id', '', '', 1, array_keys($limitgroups)); // Limit to one user for speed
- } else {
- // empty grouping
+ $users = get_users_by_capability($context, 'mod/quiz:attempt', 'u.id',
+ '', '', 1, array_keys($limitgroups)); // Limit to one user for speed
}
} else {
- $users = get_users_by_capability($context, 'mod/quiz:attempt', 'u.id'); // Limit to one user for speed
+ // Limit to one user for speed.
+ $users = get_users_by_capability($context, 'mod/quiz:attempt', 'u.id');
}
if (empty($users)) {
@@ -273,8 +284,9 @@
echo $OUTPUT->notification(get_string('usersnone', 'quiz'), 'error');
$options['disabled'] = true;
}
- echo $OUTPUT->single_button($overrideediturl->out(true, array('action' => 'adduser', 'cmid' => $cm->id)),
- get_string('addnewuseroverride', 'quiz'), 'post', $options);
+ echo $OUTPUT->single_button($overrideediturl->out(true,
+ array('action' => 'adduser', 'cmid' => $cm->id)),
+ get_string('addnewuseroverride', 'quiz'), 'post', $options);
}
echo html_writer::end_tag('div');
echo html_writer::end_tag('div');
diff --git a/mod/quiz/processattempt.php b/mod/quiz/processattempt.php
index d28eae8a3c99a..7d74e19432ca8 100644
--- a/mod/quiz/processattempt.php
+++ b/mod/quiz/processattempt.php
@@ -1,5 +1,4 @@
context,
array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),
- 'u.id,1', '', '', '', '', '', false)) {
+ 'u.id, 1', '', '', '', '', '', false)) {
$students = array();
} else {
$students = array_keys($students);
@@ -98,7 +97,7 @@ protected function load_relevant_students($cm) {
// We have a currently selected group.
if (!$groupstudents = get_users_by_capability($this->context,
array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),
- 'u.id,1', '', '', '', $currentgroup, '', false)) {
+ 'u.id, 1', '', '', '', $currentgroup, '', false)) {
$groupstudents = array();
} else {
$groupstudents = array_keys($groupstudents);
@@ -138,7 +137,8 @@ protected function validate_common_options(&$attemptsmode, &$pagesize, $course,
* @param object $quiz the quiz settings.
* @param string $qmsubselect SQL fragment from {@link quiz_report_qm_filter_select()}.
* @param bool $qmfilter whether to show all, or only the final grade attempt.
- * @param int $attemptsmode which attempts to show. One of the QUIZ_REPORT_ATTEMPTS_... constants.
+ * @param int $attemptsmode which attempts to show.
+ * One of the QUIZ_REPORT_ATTEMPTS_... constants.
* @param array $reportstudents list if userids of users to include in the report.
* @return array with 4 elements ($fields, $from, $where, $params) that can be used to
* build the actual database query.
@@ -168,8 +168,8 @@ protected function base_sql($quiz, $qmsubselect, $qmfilter, $attemptsmode, $repo
quiza.timefinish,
quiza.timestart,
CASE WHEN quiza.timefinish = 0 THEN null
- WHEN quiza.timefinish > quiza.timestart THEN quiza.timefinish - quiza.timestart
- ELSE 0 END AS duration';
+ WHEN quiza.timefinish > quiza.timestart THEN quiza.timefinish - quiza.timestart
+ ELSE 0 END AS duration';
// To explain that last bit, in MySQL, qa.timestart and qa.timefinish
// are unsigned. Since MySQL 5.5.5, when they introduced strict mode,
// subtracting a larger unsigned int from a smaller one gave an error.
@@ -179,7 +179,8 @@ protected function base_sql($quiz, $qmsubselect, $qmfilter, $attemptsmode, $repo
// This part is the same for all cases - join users and quiz_attempts tables
$from = "\n{user} u";
- $from .= "\nLEFT JOIN {quiz_attempts} quiza ON quiza.userid = u.id AND quiza.quiz = :quizid";
+ $from .= "\nLEFT JOIN {quiz_attempts} quiza ON
+ quiza.userid = u.id AND quiza.quiz = :quizid";
$params = array('quizid' => $quiz->id);
if ($qmsubselect && $qmfilter) {
@@ -280,7 +281,7 @@ protected function add_time_columns(&$columns, &$headers) {
$headers[] = get_string('startedon', 'quiz');
$columns[] = 'timefinish';
- $headers[] = get_string('timecompleted','quiz');
+ $headers[] = get_string('timecompleted', 'quiz');
$columns[] = 'duration';
$headers[] = get_string('attemptduration', 'quiz');
@@ -315,7 +316,8 @@ protected function add_grade_columns($quiz, &$columns, &$headers) {
* @param array $displayoptions the display options.
* @param bool $collapsible whether to allow columns in the report to be collapsed.
*/
- protected function set_up_table_columns($table, $columns, $headers, $reporturl, $displayoptions, $collapsible) {
+ protected function set_up_table_columns($table, $columns, $headers, $reporturl,
+ $displayoptions, $collapsible) {
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'uniqueid');
@@ -455,7 +457,7 @@ public function col_timefinish($attempt) {
public function col_duration($attempt) {
if ($attempt->timefinish) {
return format_time($attempt->timefinish - $attempt->timestart);
- } elseif ($attempt->timestart) {
+ } else if ($attempt->timestart) {
return get_string('unfinished', 'quiz');
} else {
return '-';
@@ -468,10 +470,13 @@ public function col_feedbacktext($attempt) {
}
if (!$this->is_downloading()) {
- return quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $this->quiz, false),
+ return quiz_report_feedback_for_grade(
+ quiz_rescale_grade($attempt->sumgrades, $this->quiz, false),
$this->quiz->id, $this->context);
} else {
- return strip_tags(quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $this->quiz, false), $this->quiz->id));
+ return strip_tags(quiz_report_feedback_for_grade(
+ quiz_rescale_grade($attempt->sumgrades, $this->quiz, false),
+ $this->quiz->id));
}
}
@@ -514,7 +519,8 @@ public function make_review_link($data, $attempt, $slot) {
$url = new moodle_url('/mod/quiz/reviewquestion.php',
array('attempt' => $attempt->attempt, 'slot' => $slot));
$output = $OUTPUT->action_link($url, $output,
- new popup_action('click', $url, 'reviewquestion', array('height' => 450, 'width' => 650)),
+ new popup_action('click', $url, 'reviewquestion',
+ array('height' => 450, 'width' => 650)),
array('title' => get_string('reviewresponse', 'quiz')));
return $output;
diff --git a/mod/quiz/report/default.php b/mod/quiz/report/default.php
index c845e4c0210fd..ad80e2ea5f9fd 100644
--- a/mod/quiz/report/default.php
+++ b/mod/quiz/report/default.php
@@ -1,5 +1,4 @@
get_manager();
-//===== 1.9.0 upgrade line ======//
+ //===== 1.9.0 upgrade line ======//
if ($oldversion < 2009091400) {
@@ -45,13 +44,20 @@ function xmldb_quiz_overview_upgrade($oldversion) {
$table = new xmldb_table('quiz_question_regrade');
// Adding fields to table quiz_question_regrade
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
- $table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
- $table->add_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
- $table->add_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
- $table->add_field('regraded', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, null);
+ $table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, null);
+ $table->add_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null,
+ XMLDB_NOTNULL, null, null);
+ $table->add_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null,
+ XMLDB_NOTNULL, null, null);
+ $table->add_field('regraded', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, null);
+ $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, null);
// Adding keys to table quiz_question_regrade
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
@@ -79,7 +85,8 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Rename field attemptid on table quiz_question_regrade to questionusageid
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'id');
+ $field = new xmldb_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, null, 'id');
// Launch rename field questionusageid
$dbman->rename_field($table, $field, 'questionusageid');
@@ -92,7 +99,8 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Define field slot to be added to quiz_question_regrade
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('slot', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'questionusageid');
+ $field = new xmldb_field('slot', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ XMLDB_NOTNULL, null, null, 'questionusageid');
// Conditionally launch add field slot
if (!$dbman->field_exists($table, $field)) {
@@ -122,7 +130,8 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Rename field newgrade on table quiz_question_regrade to newfraction
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');
+ $field = new xmldb_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null,
+ null, null, null, 'slot');
// Launch rename field newfraction
$dbman->rename_field($table, $field, 'newfraction');
@@ -135,7 +144,8 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Rename field oldgrade on table quiz_question_regrade to oldfraction
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');
+ $field = new xmldb_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null,
+ null, null, null, 'slot');
// Launch rename field newfraction
$dbman->rename_field($table, $field, 'oldfraction');
@@ -148,20 +158,22 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Changing precision of field newfraction on table quiz_question_regrade to (12, 7)
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('newfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');
+ $field = new xmldb_field('newfraction', XMLDB_TYPE_NUMBER, '12, 7', null,
+ null, null, null, 'slot');
// Launch change of precision for field newfraction
$dbman->change_field_precision($table, $field);
// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040606, 'quiz', 'overview');
- }
+ }
if ($oldversion < 2010040607) {
// Changing precision of field oldfraction on table quiz_question_regrade to (12, 7)
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('oldfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');
+ $field = new xmldb_field('oldfraction', XMLDB_TYPE_NUMBER, '12, 7', null,
+ null, null, null, 'slot');
// Launch change of precision for field newfraction
$dbman->change_field_precision($table, $field);
@@ -174,7 +186,8 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Changing nullability of field newfraction on table quiz_question_regrade to null
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('newfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');
+ $field = new xmldb_field('newfraction', XMLDB_TYPE_NUMBER, '12, 7', null,
+ null, null, null, 'slot');
// Launch change of nullability for field newfraction
$dbman->change_field_notnull($table, $field);
@@ -187,7 +200,8 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Changing nullability of field oldfraction on table quiz_question_regrade to null
$table = new xmldb_table('quiz_question_regrade');
- $field = new xmldb_field('oldfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');
+ $field = new xmldb_field('oldfraction', XMLDB_TYPE_NUMBER, '12, 7', null,
+ null, null, null, 'slot');
// Launch change of nullability for field newfraction
$dbman->change_field_notnull($table, $field);
@@ -196,7 +210,7 @@ function xmldb_quiz_overview_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2010082701, 'quiz', 'overview');
}
- if ($oldversion < 2011021600) {
+ if ($oldversion < 2011021600) {
// Define table quiz_question_regrade to be renamed to quiz_overview_regrades
// so that it follows the Moodle coding guidelines.
diff --git a/mod/quiz/report/overview/lang/en/quiz_overview.php b/mod/quiz/report/overview/lang/en/quiz_overview.php
index c98ac931e66e6..21a90ebf4e820 100644
--- a/mod/quiz/report/overview/lang/en/quiz_overview.php
+++ b/mod/quiz/report/overview/lang/en/quiz_overview.php
@@ -1,5 +1,4 @@
groupstudents) {
list($usql, $uparams) = $DB->get_in_or_equal($this->groupstudents);
- $record = $DB->get_record_sql($averagesql . ' AND qg.userid ' . $usql, array_merge($params, $uparams));
+ $record = $DB->get_record_sql($averagesql . ' AND qg.userid ' . $usql,
+ array_merge($params, $uparams));
$groupaveragerow = array(
$namekey => get_string('groupavg', 'grades'),
'sumgrades' => $this->format_average($record),
- 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade($record->grade, $this->quiz->id)));
+ 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade(
+ $record->grade, $this->quiz->id)));
if ($this->detailedmarks && ($this->quiz->attempts == 1 || $this->qmsubselect)) {
$avggradebyq = $this->load_average_question_grades($this->groupstudents);
$groupaveragerow += $this->format_average_grade_for_questions($avggradebyq);
@@ -84,11 +85,13 @@ public function build_table() {
if ($this->students) {
list($usql, $uparams) = $DB->get_in_or_equal($this->students);
- $record = $DB->get_record_sql($averagesql . ' AND qg.userid ' . $usql, array_merge($params, $uparams));
+ $record = $DB->get_record_sql($averagesql . ' AND qg.userid ' . $usql,
+ array_merge($params, $uparams));
$overallaveragerow = array(
$namekey => get_string('overallaverage', 'grades'),
'sumgrades' => $this->format_average($record),
- 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade($record->grade, $this->quiz->id, $this->context)));
+ 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade(
+ $record->grade, $this->quiz->id, $this->context)));
if ($this->detailedmarks && ($this->quiz->attempts == 1 || $this->qmsubselect)) {
$avggradebyq = $this->load_average_question_grades($this->students);
$overallaveragerow += $this->format_average_grade_for_questions($avggradebyq);
@@ -106,7 +109,8 @@ protected function format_average_grade_for_questions($gradeaverages) {
foreach ($this->questions as $question) {
if (isset($gradeaverages[$question->slot]) && $question->maxmark > 0) {
$record = $gradeaverages[$question->slot];
- $record->grade = quiz_rescale_grade($record->averagefraction * $question->maxmark, $this->quiz, false);
+ $record->grade = quiz_rescale_grade(
+ $record->averagefraction * $question->maxmark, $this->quiz, false);
} else {
$record = new stdClass();
$record->grade = null;
@@ -138,7 +142,8 @@ protected function format_average($record, $question = false) {
} else {
return html_writer::tag('span', html_writer::tag('span',
$average, array('class' => 'average')) . ' ' . html_writer::tag('span',
- '(' . $record->numaveraged . ')', array('class' => 'count')), array('class' => 'avgcell'));
+ '(' . $record->numaveraged . ')', array('class' => 'count')),
+ array('class' => 'avgcell'));
}
}
@@ -148,9 +153,11 @@ public function wrap_html_start() {
}
// Start form
- $url = new moodle_url($this->reporturl, $this->displayoptions + array('sesskey' => sesskey()));
+ $url = new moodle_url($this->reporturl, $this->displayoptions +
+ array('sesskey' => sesskey()));
echo '