MDL-20636 fix many code-checker issues in mod/quiz.
This commit is contained in:
+47
-36
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -78,10 +77,12 @@ class quiz_access_manager {
|
||||
}
|
||||
if (!empty($quiz->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 @@ class quiz_access_manager {
|
||||
*
|
||||
* @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 @@ class quiz_access_manager {
|
||||
}
|
||||
}
|
||||
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 @@ class quiz_access_manager {
|
||||
|
||||
/**
|
||||
* @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 @@ class quiz_access_manager {
|
||||
echo '<p>' . get_string('pleaseclose', 'quiz') . '</p>';
|
||||
$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 @@ class quiz_access_manager {
|
||||
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 @@ class quiz_access_manager {
|
||||
*
|
||||
* @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 @@ class quiz_access_manager {
|
||||
|
||||
$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 @@ class quiz_access_manager {
|
||||
$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 @@ abstract class quiz_access_rule_base {
|
||||
* 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 @@ class open_close_date_access_rule extends quiz_access_rule_base {
|
||||
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 @@ class inter_attempt_delay_access_rule extends quiz_access_rule_base {
|
||||
}
|
||||
|
||||
$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 @@ class password_access_rule extends quiz_access_rule_base {
|
||||
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 @@ class password_access_rule extends quiz_access_rule_base {
|
||||
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 @@ class password_access_rule extends quiz_access_rule_base {
|
||||
}
|
||||
|
||||
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 .= '<p class="notifyproblem">' . get_string('passworderror', 'quiz') . '</p>';
|
||||
}
|
||||
|
||||
/// Print the password entry form.
|
||||
// Print the password entry form.
|
||||
$output .= '<p>' . get_string('requirepasswordmessage', 'quiz') . "</p>\n";
|
||||
$output .= '<form id="passwordform" method="post" action="' . $CFG->wwwroot .
|
||||
'/mod/quiz/startattempt.php" onclick="this.autocomplete=\'off\'">' . "\n";
|
||||
@@ -744,10 +755,10 @@ class password_access_rule extends quiz_access_rule_base {
|
||||
$output .= "</div>\n";
|
||||
$output .= "</form>\n";
|
||||
|
||||
/// Finish page.
|
||||
// Finish page.
|
||||
$output .= $OUTPUT->box_end();
|
||||
|
||||
/// return or display form.
|
||||
// return or display form.
|
||||
echo $output;
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
+47
-31
@@ -39,7 +39,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @since Moodle 2.0
|
||||
*/
|
||||
class moodle_quiz_exception extends moodle_exception {
|
||||
public function __construct($quizobj, $errorcode, $a = NULL, $link = '', $debuginfo = null) {
|
||||
public function __construct($quizobj, $errorcode, $a = null, $link = '', $debuginfo = null) {
|
||||
if (!$link) {
|
||||
$link = $quizobj->view_url();
|
||||
}
|
||||
@@ -128,8 +128,9 @@ class quiz {
|
||||
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 @@ class quiz {
|
||||
|
||||
/**
|
||||
* @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 @@ class quiz {
|
||||
/**
|
||||
* 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 @@ class quiz {
|
||||
|
||||
// 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 @@ class quiz_attempt {
|
||||
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 @@ class quiz_attempt {
|
||||
|
||||
/**
|
||||
* @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 @@ class quiz_attempt {
|
||||
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 @@ class quiz_attempt {
|
||||
|
||||
// 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 @@ class quiz_attempt {
|
||||
/**
|
||||
* 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 @@ class quiz_attempt {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ class quiz_attempt {
|
||||
$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 @@ class quiz_attempt {
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -25,7 +24,8 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->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 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
$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 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
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 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
+123
-87
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -37,22 +36,25 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->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);
|
||||
}
|
||||
|
||||
+33
-26
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -61,8 +60,8 @@ function module_specific_buttons($cmid, $cmoptions) {
|
||||
} else {
|
||||
$disabled = '';
|
||||
}
|
||||
$out = '<input type="submit" name="add" value="' . $OUTPUT->larrow() . ' ' . get_string('addtoquiz', 'quiz') .
|
||||
'" ' . $disabled . "/>\n";
|
||||
$out = '<input type="submit" name="add" value="' . $OUTPUT->larrow() . ' ' .
|
||||
get_string('addtoquiz', 'quiz') . '" ' . $disabled . "/>\n";
|
||||
return $out;
|
||||
}
|
||||
|
||||
@@ -212,7 +211,7 @@ if (optional_param('repaginate', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
}
|
||||
|
||||
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 @@ if (($addquestion = optional_param('addquestion', 0, PARAM_INT)) && confirm_sess
|
||||
}
|
||||
|
||||
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 @@ if ((optional_param('addrandom', false, PARAM_BOOL)) && confirm_sesskey()) {
|
||||
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 @@ if (($remove = optional_param('remove', false, PARAM_INT)) && confirm_sesskey())
|
||||
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 @@ if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
|
||||
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 @@ if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$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 @@ $questionbank->process_actions($thispageurl, $cm);
|
||||
|
||||
$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 @@ if ($quiz_reordertool) {
|
||||
$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 @@ if ($quiz->shufflequestions) {
|
||||
$repaginatingdisabled = false;
|
||||
}
|
||||
if ($quiz_reordertool) {
|
||||
echo '<div class="repaginatecommand"><button id="repaginatecommand" '.$repaginatingdisabledhtml.'>'.
|
||||
echo '<div class="repaginatecommand"><button id="repaginatecommand" ' .
|
||||
$repaginatingdisabledhtml.'>'.
|
||||
get_string('repaginatecommand', 'quiz').'...</button>';
|
||||
echo '</div>';
|
||||
}
|
||||
@@ -523,10 +529,12 @@ if ($quiz_reordertool) {
|
||||
echo '<input type="hidden" name="repaginate" value="'.$gostring.'" />';
|
||||
$attributes = array();
|
||||
$attributes['disabled'] = $repaginatingdisabledhtml ? 'disabled' : null;
|
||||
$select = html_writer::select($perpage, 'questionsperpage', $quiz->questionsperpage, null, $attributes);
|
||||
$select = html_writer::select(
|
||||
$perpage, 'questionsperpage', $quiz->questionsperpage, null, $attributes);
|
||||
print_string('repaginate', 'quiz', $select);
|
||||
echo '<div class="quizquestionlistcontrols">';
|
||||
echo ' <input type="submit" name="repaginate" value="'. $gostring .'" '.$repaginatingdisabledhtml.' />';
|
||||
echo ' <input type="submit" name="repaginate" value="'. $gostring . '" ' .
|
||||
$repaginatingdisabledhtml.' />';
|
||||
echo '</div></fieldset></form></div></div>';
|
||||
}
|
||||
|
||||
@@ -551,16 +559,15 @@ if (!$quiz_reordertool) {
|
||||
'cmid' => $cm->id,
|
||||
));
|
||||
?>
|
||||
<div id="randomquestiondialog">
|
||||
<div class="hd"><?php print_string('addrandomquestiontoquiz', 'quiz', $quiz->name); ?>
|
||||
<span id="pagenumber"><!-- JavaScript will insert the page number here. -->
|
||||
</span>
|
||||
</div>
|
||||
<div class="bd"><?php
|
||||
$randomform->display();
|
||||
?></div>
|
||||
</div>
|
||||
<div id="randomquestiondialog">
|
||||
<div class="hd"><?php print_string('addrandomquestiontoquiz', 'quiz', $quiz->name); ?>
|
||||
<span id="pagenumber"><!-- JavaScript will insert the page number here. -->
|
||||
</span>
|
||||
</div>
|
||||
<div class="bd"><?php
|
||||
$randomform->display();
|
||||
?></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -165,7 +164,7 @@ function quiz_add_random_questions($quiz, $addonpage, $categoryid, $number, $inc
|
||||
// Find existing random questions in this category that are
|
||||
// not used by any quiz.
|
||||
if ($existingquestions = $DB->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 '<ul>';
|
||||
@@ -1183,7 +1182,6 @@ function quiz_print_status_bar($quiz) {
|
||||
echo get_string('numquestionsx', 'quiz', $numberofquestions);
|
||||
?></span>
|
||||
<?php
|
||||
|
||||
// Current status of the quiz, with open an close dates as a tool tip.
|
||||
$currentstatus = get_string('quizisopen', 'quiz');
|
||||
$dates = array();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
+110
-77
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -49,8 +48,6 @@ define('QUIZ_MAX_Q_DECIMAL_OPTION', 7);
|
||||
*/
|
||||
define('QUIZ_MAX_EVENT_LENGTH', 5*24*60*60); // 5 days
|
||||
|
||||
/// FUNCTIONS ///////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Given an object containing all the necessary data,
|
||||
* (defined by the form in mod_form.php) this function
|
||||
@@ -149,7 +146,7 @@ function quiz_delete_instance($id) {
|
||||
$DB->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).'<br />';
|
||||
}
|
||||
} 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 '<p>'. $message .'</p>';
|
||||
@@ -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 = '<div class="quiz overview">' .
|
||||
'<div class="name">' . $strquiz . ': <a ' . ($quiz->visible ? '' : ' class="dimmed"') .
|
||||
' href="' . $CFG->wwwroot . '/mod/quiz/view.php?id=' . $quiz->coursemodule . '">' .
|
||||
'<div class="name">' . $strquiz . ': <a ' .
|
||||
($quiz->visible ? '' : ' class="dimmed"') .
|
||||
' href="' . $CFG->wwwroot . '/mod/quiz/view.php?id=' .
|
||||
$quiz->coursemodule . '">' .
|
||||
$quiz->name . '</a></div>';
|
||||
$str .= '<div class="info">' . get_string('quizcloseson', 'quiz', userdate($quiz->timeclose)) . '</div>';
|
||||
$str .= '<div class="info">' . get_string('quizcloseson', 'quiz',
|
||||
userdate($quiz->timeclose)) . '</div>';
|
||||
|
||||
/// 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 .= '<div class="info">' . quiz_num_attempt_summary($quiz, $quiz, true) . '</div>';
|
||||
} 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 .= '<div class="info">' .
|
||||
quiz_num_attempt_summary($quiz, $quiz, true) . '</div>';
|
||||
} 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))) {
|
||||
$numattempts = count($attempts);
|
||||
$str .= '<div class="info">' . get_string('numattemptsmade', 'quiz', $numattempts) . '</div>';
|
||||
$str .= '<div class="info">' .
|
||||
get_string('numattemptsmade', 'quiz', $numattempts) . '</div>';
|
||||
} else {
|
||||
$str .= '<div class="info">' . $strnoattempts . '</div>';
|
||||
}
|
||||
} 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 .= '</div>';
|
||||
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', ''));
|
||||
}
|
||||
|
||||
+55
-36
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -79,18 +78,19 @@ function quiz_create_attempt($quiz, $attemptnumber, $lastattempt, $timenow, $isp
|
||||
global $USER;
|
||||
|
||||
if ($attemptnumber == 1 || !$quiz->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 = '<a href="' . $a->quizreporturl . '">' . format_string($quiz->name) . ' report</a>';
|
||||
$a->quizreportlink = '<a href="' . $a->quizreporturl . '">' .
|
||||
format_string($quiz->name) . ' report</a>';
|
||||
$a->quizreviewurl = $CFG->wwwroot . '/mod/quiz/review.php?attempt=' . $attempt->id;
|
||||
$a->quizreviewlink = '<a href="' . $a->quizreviewurl . '">' . format_string($quiz->name) . ' review</a>';
|
||||
$a->quizreviewlink = '<a href="' . $a->quizreviewurl . '">' .
|
||||
format_string($quiz->name) . ' review</a>';
|
||||
$a->quizurl = $CFG->wwwroot . '/mod/quiz/view.php?id=' . $cm->id;
|
||||
$a->quizlink = '<a href="' . $a->quizurl . '">' . format_string($quiz->name) . '</a>';
|
||||
// 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 @@ class mod_quiz_display_options extends question_display_options {
|
||||
|
||||
$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 @@ class mod_quiz_display_options extends question_display_options {
|
||||
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 {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -212,7 +211,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$mform->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);
|
||||
|
||||
|
||||
+1
-1
@@ -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, '*');
|
||||
|
||||
+37
-25
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -27,7 +26,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once $CFG->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 @@ class quiz_override_form extends moodleform {
|
||||
$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 @@ class quiz_override_form extends moodleform {
|
||||
// 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 @@ class quiz_override_form extends moodleform {
|
||||
$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 @@ class quiz_override_form extends moodleform {
|
||||
$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 @@ class quiz_override_form extends moodleform {
|
||||
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 @@ class quiz_override_form extends moodleform {
|
||||
}
|
||||
|
||||
$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 @@ class quiz_override_form extends moodleform {
|
||||
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 @@ class quiz_override_form extends moodleform {
|
||||
$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 @@ class quiz_override_form extends moodleform {
|
||||
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 @@ class quiz_override_form extends moodleform {
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -86,10 +85,11 @@ $PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->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));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
+40
-28
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -96,8 +95,7 @@ if ($groupmode) {
|
||||
ON o.groupid = g.id
|
||||
WHERE o.quiz = ?
|
||||
ORDER BY g.name';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$colname = get_string('user');
|
||||
$sql = 'SELECT o.*, u.firstname, u.lastname
|
||||
FROM {quiz_overrides} o JOIN {user} u
|
||||
@@ -111,8 +109,8 @@ $overrides = $DB->get_records_sql($sql, $params);
|
||||
|
||||
// Initialise table
|
||||
$table = new html_table();
|
||||
$table->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 @@ foreach ($overrides as $override) {
|
||||
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 @@ foreach ($overrides as $override) {
|
||||
// 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 @@ foreach ($overrides as $override) {
|
||||
// edit
|
||||
$editurlstr = $overrideediturl->out(true, array('id' => $override->id));
|
||||
$iconstr = '<a title="' . get_string('edit') . '" href="'. $editurlstr . '">' .
|
||||
'<img src="' . $OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="' . get_string('edit') . '" /></a> ';
|
||||
'<img src="' . $OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="' .
|
||||
get_string('edit') . '" /></a> ';
|
||||
// duplicate
|
||||
$copyurlstr = $overrideediturl->out(true, array('id' => $override->id, 'action' => 'duplicate'));
|
||||
$copyurlstr = $overrideediturl->out(true,
|
||||
array('id' => $override->id, 'action' => 'duplicate'));
|
||||
$iconstr .= '<a title="' . get_string('copy') . '" href="' . $copyurlstr . '">' .
|
||||
'<img src="' . $OUTPUT->pix_url('t/copy') . '" class="iconsmall" alt="' . get_string('copy') . '" /></a> ';
|
||||
'<img src="' . $OUTPUT->pix_url('t/copy') . '" class="iconsmall" alt="' .
|
||||
get_string('copy') . '" /></a> ';
|
||||
}
|
||||
// delete
|
||||
$deleteurlstr = $overridedeleteurl->out(true, array('id' => $override->id, 'sesskey' => sesskey()));
|
||||
$deleteurlstr = $overridedeleteurl->out(true,
|
||||
array('id' => $override->id, 'sesskey' => sesskey()));
|
||||
$iconstr .= '<a title="' . get_string('delete') . '" href="' . $deleteurlstr . '">' .
|
||||
'<img src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall" alt="' . get_string('delete') . '" /></a> ';
|
||||
'<img src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall" alt="' .
|
||||
get_string('delete') . '" /></a> ';
|
||||
|
||||
if ($groupmode) {
|
||||
$usergroupstr = '<a href="' . $groupurl->out(true, array('group' => $override->groupid)) . '" >' . $override->name . '</a>';
|
||||
}
|
||||
else {
|
||||
$usergroupstr = '<a href="' . $userurl->out(true, array('id' => $override->userid)) . '" >' . fullname($override) . '</a>';
|
||||
$usergroupstr = '<a href="' . $groupurl->out(true,
|
||||
array('group' => $override->groupid)) . '" >' . $override->name . '</a>';
|
||||
} else {
|
||||
$usergroupstr = '<a href="' . $userurl->out(true,
|
||||
array('id' => $override->userid)) . '" >' . fullname($override) . '</a>';
|
||||
}
|
||||
|
||||
$class = '';
|
||||
@@ -251,8 +261,9 @@ if ($groupmode) {
|
||||
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 @@ if ($groupmode) {
|
||||
// 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 @@ if ($groupmode) {
|
||||
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');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -85,7 +84,7 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
|
||||
if (!$students = get_users_by_capability($this->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 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
// 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 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
* @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 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
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 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
|
||||
// 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 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
$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 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
* @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 @@ abstract class quiz_attempt_report_table extends table_sql {
|
||||
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 @@ abstract class quiz_attempt_report_table extends table_sql {
|
||||
}
|
||||
|
||||
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 @@ abstract class quiz_attempt_report_table extends table_sql {
|
||||
$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;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -37,7 +36,7 @@ function xmldb_quiz_overview_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->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.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -70,11 +69,13 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
}
|
||||
if ($this->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 @@ class quiz_report_overview_table extends quiz_attempt_report_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 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
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 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
} 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 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
}
|
||||
|
||||
// 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 '<div id="tablecontainer" class="overview-tablecontainer">';
|
||||
echo '<form id="attemptsform" method="post" action="' . $this->reporturl->out_omit_querystring() . '">';
|
||||
echo '<form id="attemptsform" method="post" action="' .
|
||||
$this->reporturl->out_omit_querystring() . '">';
|
||||
echo '<div style="display: none;">';
|
||||
echo html_writer::input_hidden_params($url);
|
||||
echo '</div>';
|
||||
@@ -164,15 +171,17 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
|
||||
// TODO add back are you sure, and convert to html_writer.
|
||||
echo '<div id="commands">';
|
||||
echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.
|
||||
get_string('selectall', 'quiz').'</a> / ';
|
||||
echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.
|
||||
get_string('selectnone', 'quiz').'</a> ';
|
||||
echo '<a href="javascript:select_all_in(\'DIV\', null, \'tablecontainer\');">' .
|
||||
get_string('selectall', 'quiz') . '</a> / ';
|
||||
echo '<a href="javascript:deselect_all_in(\'DIV\', null, \'tablecontainer\');">' .
|
||||
get_string('selectnone', 'quiz') . '</a> ';
|
||||
echo ' ';
|
||||
if (has_capability('mod/quiz:regrade', $this->context)) {
|
||||
echo '<input type="submit" name="regrade" value="'.get_string('regradeselected', 'quiz_overview').'"/>';
|
||||
echo '<input type="submit" name="regrade" value="' .
|
||||
get_string('regradeselected', 'quiz_overview') . '"/>';
|
||||
}
|
||||
echo '<input type="submit" name="delete" value="'.get_string('deleteselected', 'quiz_overview').'"/>';
|
||||
echo '<input type="submit" name="delete" value="' .
|
||||
get_string('deleteselected', 'quiz_overview') . '"/>';
|
||||
echo '</div>';
|
||||
// Close form
|
||||
echo '</div>';
|
||||
@@ -194,11 +203,15 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
$oldsumgrade = 0;
|
||||
foreach ($this->questions as $question) {
|
||||
if (isset($this->regradedqs[$attempt->usageid][$question->slot])) {
|
||||
$newsumgrade += $this->regradedqs[$attempt->usageid][$question->slot]->newfraction * $question->maxmark;
|
||||
$oldsumgrade += $this->regradedqs[$attempt->usageid][$question->slot]->oldfraction * $question->maxmark;
|
||||
$newsumgrade += $this->regradedqs[$attempt->usageid]
|
||||
[$question->slot]->newfraction * $question->maxmark;
|
||||
$oldsumgrade += $this->regradedqs[$attempt->usageid]
|
||||
[$question->slot]->oldfraction * $question->maxmark;
|
||||
} else {
|
||||
$newsumgrade += $this->lateststeps[$attempt->usageid][$question->slot]->fraction * $question->maxmark;
|
||||
$oldsumgrade += $this->lateststeps[$attempt->usageid][$question->slot]->fraction * $question->maxmark;
|
||||
$newsumgrade += $this->lateststeps[$attempt->usageid]
|
||||
[$question->slot]->fraction * $question->maxmark;
|
||||
$oldsumgrade += $this->lateststeps[$attempt->usageid]
|
||||
[$question->slot]->fraction * $question->maxmark;
|
||||
}
|
||||
}
|
||||
$newsumgrade = quiz_rescale_grade($newsumgrade, $this->quiz);
|
||||
@@ -220,7 +233,7 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
*/
|
||||
public function other_cols($colname, $attempt) {
|
||||
if (!preg_match('/^qsgrade(\d+)$/', $colname, $matches)) {
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
$slot = $matches[1];
|
||||
$question = $this->questions[$slot];
|
||||
@@ -240,7 +253,8 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
|
||||
$grade = '-';
|
||||
}
|
||||
} else {
|
||||
$grade = quiz_rescale_grade($stepdata->fraction * $question->maxmark, $this->quiz, 'question');
|
||||
$grade = quiz_rescale_grade(
|
||||
$stepdata->fraction * $question->maxmark, $this->quiz, 'question');
|
||||
}
|
||||
|
||||
if ($this->is_downloading()) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -41,7 +40,8 @@ class mod_quiz_report_overview_settings extends moodleform {
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
|
||||
$mform->addElement('header', 'preferencespage',
|
||||
get_string('preferencespage', 'quiz_overview'));
|
||||
|
||||
if (!$this->_customdata['currentgroup']) {
|
||||
$studentsstring = get_string('participants');
|
||||
@@ -50,42 +50,55 @@ class mod_quiz_report_overview_settings extends moodleform {
|
||||
$a->coursestudent = get_string('participants');
|
||||
$a->groupname = groups_get_group_name($this->_customdata['currentgroup']);
|
||||
if (20 < strlen($a->groupname)) {
|
||||
$studentsstring = get_string('studentingrouplong', 'quiz_overview', $a);
|
||||
$studentsstring = get_string('studentingrouplong', 'quiz_overview', $a);
|
||||
} else {
|
||||
$studentsstring = get_string('studentingroup', 'quiz_overview', $a);
|
||||
$studentsstring = get_string('studentingroup', 'quiz_overview', $a);
|
||||
}
|
||||
}
|
||||
$options = array();
|
||||
if (!$this->_customdata['currentgroup']) {
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts','quiz_overview');
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts', 'quiz_overview');
|
||||
}
|
||||
if ($this->_customdata['currentgroup'] || !is_inside_frontpage($this->_customdata['context'])) {
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents','quiz_overview', $studentsstring);
|
||||
if ($this->_customdata['currentgroup'] ||
|
||||
!is_inside_frontpage($this->_customdata['context'])) {
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] =
|
||||
get_string('optallstudents', 'quiz_overview', $studentsstring);
|
||||
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH] =
|
||||
get_string('optattemptsonly','quiz_overview', $studentsstring);
|
||||
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'quiz_overview', $studentsstring);
|
||||
get_string('optattemptsonly', 'quiz_overview', $studentsstring);
|
||||
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] =
|
||||
get_string('optnoattemptsonly', 'quiz_overview', $studentsstring);
|
||||
}
|
||||
$mform->addElement('select', 'attemptsmode', get_string('show', 'quiz_overview'), $options);
|
||||
|
||||
$showattemptsgrp = array();
|
||||
if ($this->_customdata['qmsubselect']) {
|
||||
$gm = '<span class="highlight">'.quiz_get_grading_option_name($this->_customdata['quiz']->grademethod).'</span>';
|
||||
$showattemptsgrp[] =& $mform->createElement('advcheckbox', 'qmfilter', get_string('showattempts', 'quiz_overview'), get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0,1));
|
||||
$gm = '<span class="highlight">' .
|
||||
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
|
||||
'</span>';
|
||||
$showattemptsgrp[] = $mform->createElement('advcheckbox', 'qmfilter',
|
||||
get_string('showattempts', 'quiz_overview'),
|
||||
get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1));
|
||||
}
|
||||
if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) {
|
||||
$showattemptsgrp[] =& $mform->createElement('advcheckbox', 'regradefilter', get_string('showattempts', 'quiz_overview'), get_string('optonlyregradedattempts', 'quiz_overview'), null, array(0,1));
|
||||
$showattemptsgrp[] = $mform->createElement('advcheckbox', 'regradefilter',
|
||||
get_string('showattempts', 'quiz_overview'),
|
||||
get_string('optonlyregradedattempts', 'quiz_overview'), null, array(0, 1));
|
||||
}
|
||||
if ($showattemptsgrp) {
|
||||
$mform->addGroup($showattemptsgrp, null, get_string('showattempts', 'quiz_overview'), '<br />', false);
|
||||
$mform->addGroup($showattemptsgrp, null,
|
||||
get_string('showattempts', 'quiz_overview'), '<br />', false);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview'));
|
||||
$mform->addElement('header', 'preferencesuser',
|
||||
get_string('preferencesuser', 'quiz_overview'));
|
||||
|
||||
$mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz_overview'));
|
||||
$mform->setType('pagesize', PARAM_INT);
|
||||
|
||||
$mform->addElement('selectyesno', 'detailedmarks', get_string('showdetailedmarks', 'quiz_overview'));
|
||||
$mform->addElement('selectyesno', 'detailedmarks',
|
||||
get_string('showdetailedmarks', 'quiz_overview'));
|
||||
|
||||
$mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview'));
|
||||
$mform->addElement('submit', 'submitbutton',
|
||||
get_string('preferencessave', 'quiz_overview'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -98,7 +97,8 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
$displayoptions['qmfilter'] = $qmfilter;
|
||||
$displayoptions['regradefilter'] = $regradefilter;
|
||||
|
||||
$mform->set_data($displayoptions + array('detailedmarks' => $detailedmarks, 'pagesize' => $pagesize));
|
||||
$mform->set_data($displayoptions +
|
||||
array('detailedmarks' => $detailedmarks, 'pagesize' => $pagesize));
|
||||
|
||||
if (!$this->should_show_grades($quiz)) {
|
||||
$detailedmarks = 0;
|
||||
@@ -204,7 +204,8 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
$hasstudents = $students && (!$currentgroup || $groupstudents);
|
||||
if ($hasquestions && ($hasstudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL))) {
|
||||
// Construct the SQL
|
||||
$fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') . ' AS uniqueid, ';
|
||||
$fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') .
|
||||
' AS uniqueid, ';
|
||||
if ($qmsubselect) {
|
||||
$fields .=
|
||||
"(CASE " .
|
||||
@@ -219,9 +220,17 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
$table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params);
|
||||
|
||||
// Test to see if there are any regraded attempts to be listed.
|
||||
$fields .= ", COALESCE((SELECT MAX(qqr.regraded) FROM {quiz_overview_regrades} qqr WHERE qqr.questionusageid = quiza.uniqueid), -1) AS regraded";
|
||||
$fields .= ", COALESCE((
|
||||
SELECT MAX(qqr.regraded)
|
||||
FROM {quiz_overview_regrades} qqr
|
||||
WHERE qqr.questionusageid = quiza.uniqueid
|
||||
), -1) AS regraded";
|
||||
if ($regradefilter) {
|
||||
$where .= " AND COALESCE((SELECT MAX(qqr.regraded) FROM {quiz_overview_regrades} qqr WHERE qqr.questionusageid = quiza.uniqueid), -1) <> -1";
|
||||
$where .= " AND COALESCE((
|
||||
SELECT MAX(qqr.regraded)
|
||||
FROM {quiz_overview_regrades} qqr
|
||||
WHERE qqr.questionusageid = quiza.uniqueid
|
||||
), -1) <> -1";
|
||||
}
|
||||
$table->set_sql($fields, $from, $where, $params);
|
||||
|
||||
@@ -235,30 +244,40 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
$a->groupname = groups_get_group_name($currentgroup);
|
||||
$a->coursestudents = get_string('participants');
|
||||
$a->countregradeneeded = $regradesneeded;
|
||||
$regradealldrydolabel = get_string('regradealldrydogroup', 'quiz_overview', $a);
|
||||
$regradealldrylabel = get_string('regradealldrygroup', 'quiz_overview', $a);
|
||||
$regradealllabel = get_string('regradeallgroup', 'quiz_overview', $a);
|
||||
$regradealldrydolabel =
|
||||
get_string('regradealldrydogroup', 'quiz_overview', $a);
|
||||
$regradealldrylabel =
|
||||
get_string('regradealldrygroup', 'quiz_overview', $a);
|
||||
$regradealllabel =
|
||||
get_string('regradeallgroup', 'quiz_overview', $a);
|
||||
} else {
|
||||
$regradealldrydolabel = get_string('regradealldrydo', 'quiz_overview', $regradesneeded);
|
||||
$regradealldrylabel = get_string('regradealldry', 'quiz_overview');
|
||||
$regradealllabel = get_string('regradeall', 'quiz_overview');
|
||||
$regradealldrydolabel =
|
||||
get_string('regradealldrydo', 'quiz_overview', $regradesneeded);
|
||||
$regradealldrylabel =
|
||||
get_string('regradealldry', 'quiz_overview');
|
||||
$regradealllabel =
|
||||
get_string('regradeall', 'quiz_overview');
|
||||
}
|
||||
$displayurl = new moodle_url($reporturl, $displayoptions + array('sesskey' => sesskey()));
|
||||
$displayurl = new moodle_url($reporturl,
|
||||
$displayoptions + array('sesskey' => sesskey()));
|
||||
echo '<div class="mdl-align">';
|
||||
echo '<form action="'.$displayurl->out_omit_querystring().'">';
|
||||
echo '<div>';
|
||||
echo html_writer::input_hidden_params($displayurl);
|
||||
echo '<input type="submit" name="regradeall" value="'.$regradealllabel.'"/>';
|
||||
echo '<input type="submit" name="regradealldry" value="'.$regradealldrylabel.'"/>';
|
||||
echo '<input type="submit" name="regradealldry" value="' .
|
||||
$regradealldrylabel . '"/>';
|
||||
if ($regradesneeded) {
|
||||
echo '<input type="submit" name="regradealldrydo" value="'.$regradealldrydolabel.'"/>';
|
||||
echo '<input type="submit" name="regradealldrydo" value="' .
|
||||
$regradealldrydolabel . '"/>';
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
// Print information on the grading method
|
||||
if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) {
|
||||
if ($strattempthighlight = quiz_report_highlighting_grading_method(
|
||||
$quiz, $qmsubselect, $qmfilter)) {
|
||||
echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>';
|
||||
}
|
||||
}
|
||||
@@ -269,7 +288,7 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
|
||||
if (!$table->is_downloading() && $candelete) {
|
||||
$columns[] = 'checkbox';
|
||||
$headers[] = NULL;
|
||||
$headers[] = null;
|
||||
}
|
||||
|
||||
$this->add_user_columns($table, $columns, $headers);
|
||||
@@ -299,7 +318,8 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
|
||||
$this->add_grade_columns($quiz, $columns, $headers);
|
||||
|
||||
$this->set_up_table_columns($table, $columns, $headers, $reporturl, $displayoptions, false);
|
||||
$this->set_up_table_columns(
|
||||
$table, $columns, $headers, $reporturl, $displayoptions, false);
|
||||
$table->set_attribute('class', 'generaltable generalbox grades');
|
||||
|
||||
$table->out($pagesize, true);
|
||||
@@ -309,19 +329,27 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
if ($currentgroup && $groupstudents) {
|
||||
list($usql, $params) = $DB->get_in_or_equal($groupstudents);
|
||||
$params[] = $quiz->id;
|
||||
if ($DB->record_exists_select('quiz_grades', "userid $usql AND quiz = ?", $params)) {
|
||||
$imageurl = "{$CFG->wwwroot}/mod/quiz/report/overview/overviewgraph.php?id={$quiz->id}&groupid=$currentgroup";
|
||||
$graphname = get_string('overviewreportgraphgroup', 'quiz_overview', groups_get_group_name($currentgroup));
|
||||
if ($DB->record_exists_select('quiz_grades', "userid $usql AND quiz = ?",
|
||||
$params)) {
|
||||
$imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php',
|
||||
array('id' => $quiz->id, 'groupid' => $currentgroup));
|
||||
$graphname = get_string('overviewreportgraphgroup', 'quiz_overview',
|
||||
groups_get_group_name($currentgroup));
|
||||
echo $OUTPUT->heading($graphname);
|
||||
echo '<div class="graph"><img src="'.$imageurl.'" alt="'.$graphname.'" /></div>';
|
||||
echo html_writer::tag('div', html_writer::empty_tag('img',
|
||||
array('src' => $imageurl, 'alt' => $graphname)),
|
||||
array('class' => 'graph'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($DB->record_exists('quiz_grades', array('quiz'=> $quiz->id))) {
|
||||
$graphname = get_string('overviewreportgraph', 'quiz_overview');
|
||||
$imageurl = $CFG->wwwroot.'/mod/quiz/report/overview/overviewgraph.php?id='.$quiz->id;
|
||||
$imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php',
|
||||
array('id' => $quiz->id));
|
||||
echo $OUTPUT->heading($graphname);
|
||||
echo '<div class="graph"><img src="'.$imageurl.'" alt="'.$graphname.'" /></div>';
|
||||
echo html_writer::tag('div', html_writer::empty_tag('img',
|
||||
array('src' => $imageurl, 'alt' => $graphname)),
|
||||
array('class' => 'graph'));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -456,7 +484,8 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
foreach ($toregrade as $row) {
|
||||
$attemptquestions[$row->uniqueid][] = $row->slot;
|
||||
}
|
||||
$attempts = $DB->get_records_list('quiz_attempts', 'uniqueid', array_keys($attemptquestions));
|
||||
$attempts = $DB->get_records_list('quiz_attempts', 'uniqueid',
|
||||
array_keys($attemptquestions));
|
||||
|
||||
$this->clear_regrade_table($quiz, $groupstudents);
|
||||
|
||||
@@ -507,7 +536,8 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
global $DB;
|
||||
$qubaids = new qubaid_join($from, 'uniqueid', $where, $params);
|
||||
return $DB->record_exists_select('quiz_overview_regrades',
|
||||
'questionusageid ' . $qubaids->usage_id_in(), $qubaids->usage_id_in_params());
|
||||
'questionusageid ' . $qubaids->usage_id_in(),
|
||||
$qubaids->usage_id_in_params());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -90,7 +89,8 @@ function quiz_report_unindex($datum) {
|
||||
/**
|
||||
* Get the slots of real questions (not descriptions) in this quiz, in order.
|
||||
* @param object $quiz the quiz.
|
||||
* @return array of slot => $question object with fields ->slot, ->id, ->maxmark, ->number, ->length.
|
||||
* @return array of slot => $question object with fields
|
||||
* ->slot, ->id, ->maxmark, ->number, ->length.
|
||||
*/
|
||||
function quiz_report_get_significant_questions($quiz) {
|
||||
global $DB;
|
||||
@@ -147,36 +147,36 @@ function quiz_report_qm_filter_select($quiz, $quizattemptsalias = 'quiza') {
|
||||
}
|
||||
|
||||
switch ($quiz->grademethod) {
|
||||
case QUIZ_GRADEHIGHEST :
|
||||
return "$quizattemptsalias.id = (
|
||||
SELECT MIN(qa2.id)
|
||||
FROM {quiz_attempts} qa2
|
||||
WHERE qa2.quiz = $quizattemptsalias.quiz AND
|
||||
qa2.userid = $quizattemptsalias.userid AND
|
||||
COALESCE(qa2.sumgrades, 0) = (
|
||||
SELECT MAX(COALESCE(qa3.sumgrades, 0))
|
||||
FROM {quiz_attempts} qa3
|
||||
WHERE qa3.quiz = $quizattemptsalias.quiz AND
|
||||
qa3.userid = $quizattemptsalias.userid
|
||||
)
|
||||
)";
|
||||
case QUIZ_GRADEHIGHEST :
|
||||
return "$quizattemptsalias.id = (
|
||||
SELECT MIN(qa2.id)
|
||||
FROM {quiz_attempts} qa2
|
||||
WHERE qa2.quiz = $quizattemptsalias.quiz AND
|
||||
qa2.userid = $quizattemptsalias.userid AND
|
||||
COALESCE(qa2.sumgrades, 0) = (
|
||||
SELECT MAX(COALESCE(qa3.sumgrades, 0))
|
||||
FROM {quiz_attempts} qa3
|
||||
WHERE qa3.quiz = $quizattemptsalias.quiz AND
|
||||
qa3.userid = $quizattemptsalias.userid
|
||||
)
|
||||
)";
|
||||
|
||||
case QUIZ_GRADEAVERAGE :
|
||||
return '';
|
||||
case QUIZ_GRADEAVERAGE :
|
||||
return '';
|
||||
|
||||
case QUIZ_ATTEMPTFIRST :
|
||||
return "$quizattemptsalias.id = (
|
||||
SELECT MIN(qa2.id)
|
||||
FROM {quiz_attempts} qa2
|
||||
WHERE qa2.quiz = $quizattemptsalias.quiz AND
|
||||
qa2.userid = $quizattemptsalias.userid)";
|
||||
case QUIZ_ATTEMPTFIRST :
|
||||
return "$quizattemptsalias.id = (
|
||||
SELECT MIN(qa2.id)
|
||||
FROM {quiz_attempts} qa2
|
||||
WHERE qa2.quiz = $quizattemptsalias.quiz AND
|
||||
qa2.userid = $quizattemptsalias.userid)";
|
||||
|
||||
case QUIZ_ATTEMPTLAST :
|
||||
return "$quizattemptsalias.id = (
|
||||
SELECT MAX(qa2.id)
|
||||
FROM {quiz_attempts} qa2
|
||||
WHERE qa2.quiz = $quizattemptsalias.quiz AND
|
||||
qa2.userid = $quizattemptsalias.userid)";
|
||||
case QUIZ_ATTEMPTLAST :
|
||||
return "$quizattemptsalias.id = (
|
||||
SELECT MAX(qa2.id)
|
||||
FROM {quiz_attempts} qa2
|
||||
WHERE qa2.quiz = $quizattemptsalias.quiz AND
|
||||
qa2.userid = $quizattemptsalias.userid)";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ function quiz_report_feedback_for_grade($grade, $quizid, $context) {
|
||||
$feedbacktext = '';
|
||||
$feedbacktextformat = FORMAT_MOODLE;
|
||||
foreach ($feedbacks as $feedback) {
|
||||
if ($feedback->mingrade <= $grade && $grade < $feedback->maxgrade){
|
||||
if ($feedback->mingrade <= $grade && $grade < $feedback->maxgrade) {
|
||||
$feedbackid = $feedback->id;
|
||||
$feedbacktext = $feedback->feedbacktext;
|
||||
$feedbacktextformat = $feedback->feedbacktextformat;
|
||||
@@ -281,7 +281,8 @@ function quiz_report_feedback_for_grade($grade, $quizid, $context) {
|
||||
// Clean the text, ready for display.
|
||||
$formatoptions = new stdClass();
|
||||
$formatoptions->noclean = true;
|
||||
$feedbacktext = file_rewrite_pluginfile_urls($feedbacktext, 'pluginfile.php', $context->id, 'mod_quiz', 'feedback', $feedbackid);
|
||||
$feedbacktext = file_rewrite_pluginfile_urls($feedbacktext, 'pluginfile.php',
|
||||
$context->id, 'mod_quiz', 'feedback', $feedbackid);
|
||||
$feedbacktext = format_text($feedbacktext, $feedbacktextformat, $formatoptions);
|
||||
|
||||
return $feedbacktext;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -75,9 +74,9 @@ class quiz_report_responses_table extends quiz_attempt_report_table {
|
||||
|
||||
// TODO add back are you sure, and convert to html_writer.
|
||||
echo '<div id="commands">';
|
||||
echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.
|
||||
echo '<a href="javascript:select_all_in(\'DIV\', null, \'tablecontainer\');">'.
|
||||
get_string('selectall', 'quiz').'</a> / ';
|
||||
echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.
|
||||
echo '<a href="javascript:deselect_all_in(\'DIV\', null, \'tablecontainer\');">'.
|
||||
get_string('selectnone', 'quiz').'</a> ';
|
||||
echo ' ';
|
||||
echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -41,7 +40,8 @@ class mod_quiz_report_responses_settings extends moodleform {
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview'));
|
||||
$mform->addElement('header', 'preferencespage',
|
||||
get_string('preferencespage', 'quiz_overview'));
|
||||
|
||||
if (!$this->_customdata['currentgroup']) {
|
||||
$studentsstring = get_string('participants');
|
||||
@@ -57,32 +57,46 @@ class mod_quiz_report_responses_settings extends moodleform {
|
||||
}
|
||||
$options = array();
|
||||
if (!$this->_customdata['currentgroup']) {
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts','quiz_overview');
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts', 'quiz_overview');
|
||||
}
|
||||
if ($this->_customdata['currentgroup'] || !is_inside_frontpage($this->_customdata['context'])) {
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents','quiz_overview', $studentsstring);
|
||||
if ($this->_customdata['currentgroup'] ||
|
||||
!is_inside_frontpage($this->_customdata['context'])) {
|
||||
$options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] =
|
||||
get_string('optallstudents', 'quiz_overview', $studentsstring);
|
||||
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH] =
|
||||
get_string('optattemptsonly','quiz_overview', $studentsstring);
|
||||
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'quiz_overview', $studentsstring);
|
||||
get_string('optattemptsonly', 'quiz_overview', $studentsstring);
|
||||
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] =
|
||||
get_string('optnoattemptsonly', 'quiz_overview', $studentsstring);
|
||||
}
|
||||
$mform->addElement('select', 'attemptsmode', get_string('show', 'quiz_overview'), $options);
|
||||
$mform->addElement('select', 'attemptsmode',
|
||||
get_string('show', 'quiz_overview'), $options);
|
||||
|
||||
if ($this->_customdata['qmsubselect']) {
|
||||
$gm = '<span class="gradedattempt">'.quiz_get_grading_option_name($this->_customdata['quiz']->grademethod).'</span>';
|
||||
$mform->addElement('advcheckbox', 'qmfilter', get_string('showattempts', 'quiz_overview'), get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0,1));
|
||||
$gm = '<span class="gradedattempt">' .
|
||||
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
|
||||
'</span>';
|
||||
$mform->addElement('advcheckbox', 'qmfilter',
|
||||
get_string('showattempts', 'quiz_overview'),
|
||||
get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1));
|
||||
}
|
||||
|
||||
$colsgroup = array();
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'qtext', '', get_string('summaryofquestiontext', 'quiz_responses'));
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'resp', '', get_string('summaryofresponse', 'quiz_responses'));
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'right', '', get_string('summaryofrightanswer', 'quiz_responses'));
|
||||
$mform->addGroup($colsgroup, null, get_string('include', 'quiz_responses'), '<br />', false);
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'qtext', '',
|
||||
get_string('summaryofquestiontext', 'quiz_responses'));
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'resp', '',
|
||||
get_string('summaryofresponse', 'quiz_responses'));
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'right', '',
|
||||
get_string('summaryofrightanswer', 'quiz_responses'));
|
||||
$mform->addGroup($colsgroup, null,
|
||||
get_string('include', 'quiz_responses'), '<br />', false);
|
||||
|
||||
$mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview'));
|
||||
$mform->addElement('header', 'preferencesuser',
|
||||
get_string('preferencesuser', 'quiz_overview'));
|
||||
|
||||
$mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz_overview'));
|
||||
$mform->setType('pagesize', PARAM_INT);
|
||||
|
||||
$mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview'));
|
||||
$mform->addElement('submit', 'submitbutton',
|
||||
get_string('preferencessave', 'quiz_overview'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -37,96 +36,107 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
//===== 1.9.0 upgrade line ======//
|
||||
//===== 1.9.0 upgrade line ======//
|
||||
|
||||
if ($oldversion < 2008072401) {
|
||||
//register cron to run every 5 hours.
|
||||
$DB->set_field('quiz_report', 'cron', HOURSECS*5, array('name'=>'statistics'));
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008072401, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008072500) {
|
||||
|
||||
/// Define field s to be added to quiz_question_statistics
|
||||
// Define field s to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('s', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'subquestion');
|
||||
$field = new xmldb_field('s', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'subquestion');
|
||||
|
||||
/// Conditionally launch add field s
|
||||
// Conditionally launch add field s
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008072500, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008072800) {
|
||||
|
||||
/// Define field maxgrade to be added to quiz_question_statistics
|
||||
// Define field maxgrade to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
null, null, null, 'subquestions');
|
||||
|
||||
/// Conditionally launch add field maxgrade
|
||||
// Conditionally launch add field maxgrade
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008072800, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008072801) {
|
||||
|
||||
/// Define field positions to be added to quiz_question_statistics
|
||||
// Define field positions to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('positions', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'maxgrade');
|
||||
$field = new xmldb_field('positions', XMLDB_TYPE_TEXT, 'medium', null,
|
||||
null, null, null, 'maxgrade');
|
||||
|
||||
/// Conditionally launch add field positions
|
||||
// Conditionally launch add field positions
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008072801, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008081500) {
|
||||
/// Changing type of field maxgrade on table quiz_question_statistics to number
|
||||
// Changing type of field maxgrade on table quiz_question_statistics to number
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', null,
|
||||
null, null, null, 'subquestions');
|
||||
|
||||
/// Launch change of type for field maxgrade
|
||||
// Launch change of type for field maxgrade
|
||||
$dbman->change_field_type($table, $field);
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008081500, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008082600) {
|
||||
|
||||
/// Define table quiz_question_response_stats to be created
|
||||
// Define table quiz_question_response_stats to be created
|
||||
$table = new xmldb_table('quiz_question_response_stats');
|
||||
|
||||
/// Adding fields to table quiz_question_response_stats
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('quizstatisticsid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('anssubqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('response', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
|
||||
$table->add_field('rcount', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('credit', XMLDB_TYPE_NUMBER, '15, 5', null, XMLDB_NOTNULL, null, null);
|
||||
// Adding fields to table quiz_question_response_stats
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('quizstatisticsid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('anssubqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
null, null, null);
|
||||
$table->add_field('response', XMLDB_TYPE_TEXT, 'big', null,
|
||||
null, null, null);
|
||||
$table->add_field('rcount', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
null, null, null);
|
||||
$table->add_field('credit', XMLDB_TYPE_NUMBER, '15, 5', null,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table quiz_question_response_stats
|
||||
// Adding keys to table quiz_question_response_stats
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
/// Conditionally launch create table for quiz_question_response_stats
|
||||
// Conditionally launch create table for quiz_question_response_stats
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008082600, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
@@ -135,59 +145,63 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
$DB->delete_records('quiz_statistics');
|
||||
$DB->delete_records('quiz_question_statistics');
|
||||
$DB->delete_records('quiz_question_response_stats');
|
||||
/// Define field anssubqid to be dropped from quiz_question_response_stats
|
||||
// Define field anssubqid to be dropped from quiz_question_response_stats
|
||||
$table = new xmldb_table('quiz_question_response_stats');
|
||||
$field = new xmldb_field('anssubqid');
|
||||
|
||||
/// Conditionally launch drop field subqid
|
||||
// Conditionally launch drop field subqid
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
/// Define field subqid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('subqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'questionid');
|
||||
// Define field subqid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('subqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null, 'questionid');
|
||||
|
||||
/// Conditionally launch add field subqid
|
||||
// Conditionally launch add field subqid
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
/// Define field aid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('aid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'subqid');
|
||||
// Define field aid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('aid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null, 'subqid');
|
||||
|
||||
/// Conditionally launch add field aid
|
||||
// Conditionally launch add field aid
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008090500, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008111000) {
|
||||
//delete all cached results first
|
||||
// Delete all cached results first
|
||||
$DB->delete_records('quiz_statistics');
|
||||
$DB->delete_records('quiz_question_statistics');
|
||||
$DB->delete_records('quiz_question_response_stats');
|
||||
|
||||
/// Define field anssubqid to be dropped from quiz_question_response_stats
|
||||
// Define field anssubqid to be dropped from quiz_question_response_stats
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
/// Define field subqid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('negcovar', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'effectiveweight');
|
||||
// Define field subqid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('negcovar', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'effectiveweight');
|
||||
|
||||
/// Conditionally launch add field subqid
|
||||
// Conditionally launch add field subqid
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008111000, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008112100) {
|
||||
$DB->set_field('quiz_report', 'capability', 'quizreport/statistics:view', array('name'=>'statistics'));
|
||||
$DB->set_field('quiz_report', 'capability', 'quizreport/statistics:view',
|
||||
array('name'=>'statistics'));
|
||||
|
||||
/// statistics savepoint reached
|
||||
// statistics savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008112100, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
@@ -196,27 +210,33 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
$table = new xmldb_table('quiz_statistics');
|
||||
|
||||
// Change of sign for field firstattemptsavg
|
||||
$field = new xmldb_field('firstattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null, 'allattemptscount');
|
||||
$field = new xmldb_field('firstattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null,
|
||||
null, null, null, 'allattemptscount');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field allattemptsavg
|
||||
$field = new xmldb_field('allattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null, 'firstattemptsavg');
|
||||
$field = new xmldb_field('allattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null,
|
||||
null, null, null, 'firstattemptsavg');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field median
|
||||
$field = new xmldb_field('median', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null, 'allattemptsavg');
|
||||
$field = new xmldb_field('median', XMLDB_TYPE_NUMBER, '15, 5', null,
|
||||
null, null, null, 'allattemptsavg');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field standarddeviation
|
||||
$field = new xmldb_field('standarddeviation', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null, 'median');
|
||||
$field = new xmldb_field('standarddeviation', XMLDB_TYPE_NUMBER, '15, 5', null,
|
||||
null, null, null, 'median');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field errorratio
|
||||
$field = new xmldb_field('errorratio', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null, 'cic');
|
||||
$field = new xmldb_field('errorratio', XMLDB_TYPE_NUMBER, '15, 10', null,
|
||||
null, null, null, 'cic');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field standarderror
|
||||
$field = new xmldb_field('standarderror', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null, 'errorratio');
|
||||
$field = new xmldb_field('standarderror', XMLDB_TYPE_NUMBER, '15, 10', null,
|
||||
null, null, null, 'errorratio');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// statistics savepoint reached
|
||||
@@ -228,19 +248,23 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
|
||||
// Change of sign for field effectiveweight
|
||||
$field = new xmldb_field('effectiveweight', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null, 's');
|
||||
$field = new xmldb_field('effectiveweight', XMLDB_TYPE_NUMBER, '15, 5', null,
|
||||
null, null, null, 's');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field sd
|
||||
$field = new xmldb_field('sd', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null, 'discriminativeefficiency');
|
||||
$field = new xmldb_field('sd', XMLDB_TYPE_NUMBER, '15, 10', null,
|
||||
null, null, null, 'discriminativeefficiency');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field facility
|
||||
$field = new xmldb_field('facility', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null, 'sd');
|
||||
$field = new xmldb_field('facility', XMLDB_TYPE_NUMBER, '15, 10', null,
|
||||
null, null, null, 'sd');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// Change of sign for field maxgrade
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', null,
|
||||
null, null, null, 'subquestions');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// statistics savepoint reached
|
||||
@@ -252,7 +276,8 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
$table = new xmldb_table('quiz_question_response_stats');
|
||||
|
||||
// Change of sign for field credit
|
||||
$field = new xmldb_field('credit', XMLDB_TYPE_NUMBER, '15, 5', null, XMLDB_NOTNULL, null, null, 'rcount');
|
||||
$field = new xmldb_field('credit', XMLDB_TYPE_NUMBER, '15, 5', null,
|
||||
XMLDB_NOTNULL, null, null, 'rcount');
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
// statistics savepoint reached
|
||||
@@ -263,7 +288,8 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
// Define field randomguessscore to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('randomguessscore', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'positions');
|
||||
$field = new xmldb_field('randomguessscore', XMLDB_TYPE_NUMBER, '12, 7', null,
|
||||
null, null, null, 'positions');
|
||||
|
||||
// Conditionally launch add field randomguessscore
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@@ -278,7 +304,8 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
// Define field slot to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('slot', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'questionid');
|
||||
$field = new xmldb_field('slot', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null,
|
||||
null, null, 'questionid');
|
||||
|
||||
// Conditionally launch add field slot
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@@ -291,14 +318,15 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2010032401) {
|
||||
|
||||
/// Delete all cached data
|
||||
// Delete all cached data
|
||||
$DB->delete_records('quiz_question_response_stats');
|
||||
$DB->delete_records('quiz_question_statistics');
|
||||
$DB->delete_records('quiz_statistics');
|
||||
|
||||
// Rename field maxgrade on table quiz_question_statistics to maxmark
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', XMLDB_UNSIGNED, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', XMLDB_UNSIGNED,
|
||||
null, null, null, 'subquestions');
|
||||
|
||||
// Launch rename field maxmark
|
||||
$dbman->rename_field($table, $field, 'maxmark');
|
||||
@@ -311,7 +339,8 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
// Changing nullability of field aid on table quiz_question_response_stats to null
|
||||
$table = new xmldb_table('quiz_question_response_stats');
|
||||
$field = new xmldb_field('aid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'subqid');
|
||||
$field = new xmldb_field('aid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
null, null, null, 'subqid');
|
||||
|
||||
// Launch change of nullability for field aid
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
@@ -324,7 +353,8 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
// Changing type of field maxmark on table quiz_question_statistics to number
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('maxmark', XMLDB_TYPE_NUMBER, '12, 7', XMLDB_UNSIGNED, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxmark', XMLDB_TYPE_NUMBER, '12, 7', XMLDB_UNSIGNED,
|
||||
null, null, null, 'subquestions');
|
||||
|
||||
// Launch change of type for field maxmark
|
||||
$dbman->change_field_type($table, $field);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -119,7 +118,9 @@ class quiz_statistics_question_stats {
|
||||
FROM $fromqa
|
||||
JOIN {question_attempts} qa ON qa.questionusageid = quiza.uniqueid
|
||||
JOIN (
|
||||
SELECT questionattemptid, MAX(id) AS latestid FROM {question_attempt_steps} GROUP BY questionattemptid
|
||||
SELECT questionattemptid, MAX(id) AS latestid
|
||||
FROM {question_attempt_steps}
|
||||
GROUP BY questionattemptid
|
||||
) lateststepid ON lateststepid.questionattemptid = qa.id
|
||||
JOIN {question_attempt_steps} qas ON qas.id = lateststepid.latestid
|
||||
|
||||
@@ -184,7 +185,8 @@ class quiz_statistics_question_stats {
|
||||
if ($subquestionstats[$qid]->differentweights) {
|
||||
// TODO output here really sucks, but throwing is too severe.
|
||||
global $OUTPUT;
|
||||
echo $OUTPUT->notification(get_string('erroritemappearsmorethanoncewithdifferentweight',
|
||||
echo $OUTPUT->notification(
|
||||
get_string('erroritemappearsmorethanoncewithdifferentweight',
|
||||
'quiz_statistics', $this->subquestions[$qid]->name));
|
||||
}
|
||||
|
||||
@@ -215,13 +217,15 @@ class quiz_statistics_question_stats {
|
||||
if ($question->qtype == 'random') {
|
||||
$randomselectorstring = $question->category.'/'.$question->questiontext;
|
||||
if ($nextquestion && $nextquestion->qtype == 'random') {
|
||||
$nextrandomselectorstring = $nextquestion->category.'/'.$nextquestion->questiontext;
|
||||
$nextrandomselectorstring = $nextquestion->category . '/' .
|
||||
$nextquestion->questiontext;
|
||||
if ($randomselectorstring == $nextrandomselectorstring) {
|
||||
continue; // Next loop iteration
|
||||
}
|
||||
}
|
||||
if (isset($this->randomselectors[$randomselectorstring])) {
|
||||
$question->_stats->subquestions = implode(',', $this->randomselectors[$randomselectorstring]);
|
||||
$question->_stats->subquestions = implode(',',
|
||||
$this->randomselectors[$randomselectorstring]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,12 +332,14 @@ class quiz_statistics_question_stats {
|
||||
if ($stats->subquestion) {
|
||||
$othermarkdifference = $step->sumgrades - $stats->othermarkaverage;
|
||||
} else {
|
||||
$othermarkdifference = $step->sumgrades - $step->mark - $stats->othermarkaverage;
|
||||
$othermarkdifference = $step->sumgrades - $step->mark -
|
||||
$stats->othermarkaverage;
|
||||
}
|
||||
$overallmarkdifference = $step->sumgrades - $this->summarksavg;
|
||||
|
||||
$sortedmarkdifference = array_shift($stats->markarray) - $stats->markaverage;
|
||||
$sortedothermarkdifference = array_shift($stats->othermarksarray) - $stats->othermarkaverage;
|
||||
$sortedothermarkdifference = array_shift($stats->othermarksarray) -
|
||||
$stats->othermarkaverage;
|
||||
|
||||
$stats->markvariancesum += pow($markdifference, 2);
|
||||
$stats->othermarkvariancesum += pow($othermarkdifference, 2);
|
||||
@@ -353,7 +359,8 @@ class quiz_statistics_question_stats {
|
||||
$stats->othermarkvariance = $stats->othermarkvariancesum / ($stats->s - 1);
|
||||
$stats->covariance = $stats->covariancesum / ($stats->s - 1);
|
||||
$stats->covariancemax = $stats->covariancemaxsum / ($stats->s - 1);
|
||||
$stats->covariancewithoverallmark = $stats->covariancewithoverallmarksum / ($stats->s - 1);
|
||||
$stats->covariancewithoverallmark = $stats->covariancewithoverallmarksum /
|
||||
($stats->s - 1);
|
||||
$stats->sd = sqrt($stats->markvariancesum / ($stats->s - 1));
|
||||
|
||||
} else {
|
||||
@@ -385,7 +392,8 @@ class quiz_statistics_question_stats {
|
||||
* @return number the random guess score for this question.
|
||||
*/
|
||||
protected function get_random_guess_score($questiondata) {
|
||||
return question_bank::get_qtype($questiondata->qtype, false)->get_random_guess_score($questiondata);
|
||||
return question_bank::get_qtype(
|
||||
$questiondata->qtype, false)->get_random_guess_score($questiondata);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -75,7 +74,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
if ($fromform = $mform->get_data()) {
|
||||
$useallattempts = $fromform->useallattempts;
|
||||
if ($fromform->useallattempts) {
|
||||
set_user_preference('quiz_report_statistics_useallattempts', $fromform->useallattempts);
|
||||
set_user_preference('quiz_report_statistics_useallattempts',
|
||||
$fromform->useallattempts);
|
||||
} else {
|
||||
unset_user_preference('quiz_report_statistics_useallattempts');
|
||||
}
|
||||
@@ -116,7 +116,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$report = get_string('questionstatsfilename', 'quiz_statistics');
|
||||
}
|
||||
$filename = quiz_report_download_filename($report, $course->shortname, $quiz->name);
|
||||
$this->table->is_downloading($download, $filename, get_string('quizstructureanalysis', 'quiz_statistics'));
|
||||
$this->table->is_downloading($download, $filename,
|
||||
get_string('quizstructureanalysis', 'quiz_statistics'));
|
||||
|
||||
// Load the questions.
|
||||
$questions = quiz_report_get_significant_questions($quiz);
|
||||
@@ -178,7 +179,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
}
|
||||
|
||||
foreach ($questions as $question) {
|
||||
if (question_bank::get_qtype($question->qtype, false)->can_analyse_responses()) {
|
||||
if (question_bank::get_qtype(
|
||||
$question->qtype, false)->can_analyse_responses()) {
|
||||
$this->output_individual_question_response_analysis(
|
||||
$question, $reporturl, $quizstats);
|
||||
|
||||
@@ -233,7 +235,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
} else {
|
||||
// On-screen display of overview report.
|
||||
echo $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'));
|
||||
echo $this->output_caching_info($quizstats, $quiz->id, $currentgroup, $groupstudents, $useallattempts, $reporturl);
|
||||
echo $this->output_caching_info($quizstats, $quiz->id, $currentgroup,
|
||||
$groupstudents, $useallattempts, $reporturl);
|
||||
echo $this->everything_download_options();
|
||||
echo $this->output_quiz_info_table($quizinfo);
|
||||
if ($s) {
|
||||
@@ -289,14 +292,17 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$actions = $datumfromtable['actions'];
|
||||
unset($datumfromtable['actions']);
|
||||
unset($datumfromtable['name']);
|
||||
$labels = array('s' => get_string('attempts', 'quiz_statistics'),
|
||||
'facility' => get_string('facility', 'quiz_statistics'),
|
||||
'sd' => get_string('standarddeviationq', 'quiz_statistics'),
|
||||
'random_guess_score' => get_string('random_guess_score', 'quiz_statistics'),
|
||||
'intended_weight' => get_string('intended_weight', 'quiz_statistics'),
|
||||
'effective_weight' => get_string('effective_weight', 'quiz_statistics'),
|
||||
'discrimination_index' => get_string('discrimination_index', 'quiz_statistics'),
|
||||
'discriminative_efficiency' => get_string('discriminative_efficiency', 'quiz_statistics'));
|
||||
$labels = array(
|
||||
's' => get_string('attempts', 'quiz_statistics'),
|
||||
'facility' => get_string('facility', 'quiz_statistics'),
|
||||
'sd' => get_string('standarddeviationq', 'quiz_statistics'),
|
||||
'random_guess_score' => get_string('random_guess_score', 'quiz_statistics'),
|
||||
'intended_weight' => get_string('intended_weight', 'quiz_statistics'),
|
||||
'effective_weight' => get_string('effective_weight', 'quiz_statistics'),
|
||||
'discrimination_index' => get_string('discrimination_index', 'quiz_statistics'),
|
||||
'discriminative_efficiency' =>
|
||||
get_string('discriminative_efficiency', 'quiz_statistics')
|
||||
);
|
||||
foreach ($datumfromtable as $item => $value) {
|
||||
$questionstatstable->data[] = array($labels[$item], $value);
|
||||
}
|
||||
@@ -305,7 +311,9 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
echo $OUTPUT->heading(get_string('questioninformation', 'quiz_statistics'));
|
||||
echo html_writer::table($questioninfotable);
|
||||
|
||||
echo $OUTPUT->box(format_text($question->questiontext, $question->questiontextformat, array('overflowdiv'=>true)).$actions, 'boxaligncenter generalbox boxwidthnormal mdl-align');
|
||||
echo $OUTPUT->box(format_text($question->questiontext, $question->questiontextformat,
|
||||
array('overflowdiv' => true)) . $actions,
|
||||
'boxaligncenter generalbox boxwidthnormal mdl-align');
|
||||
|
||||
echo $OUTPUT->heading(get_string('questionstatistics', 'quiz_statistics'));
|
||||
echo html_writer::table($questionstatstable);
|
||||
@@ -317,7 +325,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
* @param moodle_url $reporturl the URL to resisplay this report.
|
||||
* @param object $quizstats Holds the quiz statistics.
|
||||
*/
|
||||
protected function output_individual_question_response_analysis($question, $reporturl, $quizstats) {
|
||||
protected function output_individual_question_response_analysis($question,
|
||||
$reporturl, $quizstats) {
|
||||
global $OUTPUT;
|
||||
|
||||
if (!question_bank::get_qtype($question->qtype, false)->can_analyse_responses()) {
|
||||
@@ -338,7 +347,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$questiontabletitle = '(' . $question->number . ') ' . $questiontabletitle;
|
||||
}
|
||||
if ($this->table->is_downloading() == 'xhtml') {
|
||||
$questiontabletitle = get_string('analysisofresponsesfor', 'quiz_statistics', $questiontabletitle);
|
||||
$questiontabletitle = get_string('analysisofresponsesfor',
|
||||
'quiz_statistics', $questiontabletitle);
|
||||
}
|
||||
|
||||
// Set up the table.
|
||||
@@ -443,7 +453,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$quizinfo[get_string('quizclose', 'quiz')] = userdate($quiz->timeclose);
|
||||
}
|
||||
if ($quiz->timeopen && $quiz->timeclose) {
|
||||
$quizinfo[get_string('duration', 'quiz_statistics')] = format_time($quiz->timeclose - $quiz->timeopen);
|
||||
$quizinfo[get_string('duration', 'quiz_statistics')] =
|
||||
format_time($quiz->timeclose - $quiz->timeopen);
|
||||
}
|
||||
|
||||
// The statistics.
|
||||
@@ -461,7 +472,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$formattedvalue = quiz_format_grade($quiz, $value) . '%';
|
||||
break;
|
||||
case 'number_format':
|
||||
// + 2 decimal places, since not a percentage, and we want the same number of sig figs.
|
||||
// + 2 decimal places, since not a percentage,
|
||||
// and we want the same number of sig figs.
|
||||
$formattedvalue = format_float($value, $quiz->decimalpoints + 2);
|
||||
break;
|
||||
case 'number':
|
||||
@@ -543,8 +555,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$imageurl = new moodle_url('/mod/quiz/report/statistics/statistics_graph.php',
|
||||
array('id' => $quizstatsid));
|
||||
$OUTPUT->heading(get_string('statisticsreportgraph', 'quiz_statistics'));
|
||||
echo html_writer::tag('div', html_writer::empty_tag('img',
|
||||
array('src' => $imageurl, 'alt' => get_string('statisticsreportgraph', 'quiz_statistics'))),
|
||||
echo html_writer::tag('div', html_writer::empty_tag('img', array('src' => $imageurl,
|
||||
'alt' => get_string('statisticsreportgraph', 'quiz_statistics'))),
|
||||
array('class' => 'graph'));
|
||||
}
|
||||
|
||||
@@ -592,7 +604,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
global $DB;
|
||||
|
||||
// Calculating MEAN of marks for all attempts by students
|
||||
// http://docs.moodle.org/en/Development:Quiz_item_analysis_calculations_in_practise#Calculating_MEAN_of_grades_for_all_attempts_by_students
|
||||
// http://docs.moodle.org/en/Development:Quiz_item_analysis_calculations_in_practise
|
||||
// #Calculating_MEAN_of_grades_for_all_attempts_by_students
|
||||
if ($nostudentsingroup) {
|
||||
return $this->get_emtpy_stats($questions);
|
||||
}
|
||||
@@ -680,9 +693,9 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
//differences between marks and mean mark
|
||||
$mean = $usingattempts->total / $s;
|
||||
$sql = "SELECT
|
||||
SUM(POWER((quiza.sumgrades - $mean),2)) AS power2,
|
||||
SUM(POWER((quiza.sumgrades - $mean),3)) AS power3,
|
||||
SUM(POWER((quiza.sumgrades - $mean),4)) AS power4
|
||||
SUM(POWER((quiza.sumgrades - $mean), 2)) AS power2,
|
||||
SUM(POWER((quiza.sumgrades - $mean), 3)) AS power3,
|
||||
SUM(POWER((quiza.sumgrades - $mean), 4)) AS power4
|
||||
FROM $fromqa
|
||||
WHERE $whereqa";
|
||||
$params = array('mean1' => $mean, 'mean2' => $mean, 'mean3' => $mean)+$qaparams;
|
||||
@@ -690,13 +703,15 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$powers = $DB->get_record_sql($sql, $params, MUST_EXIST);
|
||||
|
||||
// Standard_Deviation
|
||||
//see http://docs.moodle.org/en/Development:Quiz_item_analysis_calculations_in_practise#Standard_Deviation
|
||||
// see http://docs.moodle.org/en/Development:Quiz_item_analysis_calculations_in_practise
|
||||
// #Standard_Deviation
|
||||
|
||||
$quizstats->standarddeviation = sqrt($powers->power2 / ($s - 1));
|
||||
|
||||
// Skewness
|
||||
if ($s > 2) {
|
||||
//see http://docs.moodle.org/en/Development:Quiz_item_analysis_calculations_in_practise#Skewness_and_Kurtosis
|
||||
// see http://docs.moodle.org/en/Development:
|
||||
// Quiz_item_analysis_calculations_in_practise#Skewness_and_Kurtosis
|
||||
$m2= $powers->power2 / $s;
|
||||
$m3= $powers->power3 / $s;
|
||||
$m4= $powers->power4 / $s;
|
||||
@@ -724,9 +739,11 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
if ($s > 1) {
|
||||
$p = count($qstats->questions); // No of positions
|
||||
if ($p > 1 && isset($k2)) {
|
||||
$quizstats->cic = (100 * $p / ($p -1)) * (1 - ($qstats->get_sum_of_mark_variance())/$k2);
|
||||
$quizstats->errorratio = 100 * sqrt(1-($quizstats->cic/100));
|
||||
$quizstats->standarderror = ($quizstats->errorratio * $quizstats->standarddeviation / 100);
|
||||
$quizstats->cic = (100 * $p / ($p -1)) *
|
||||
(1 - ($qstats->get_sum_of_mark_variance()) / $k2);
|
||||
$quizstats->errorratio = 100 * sqrt(1 - ($quizstats->cic / 100));
|
||||
$quizstats->standarderror = $quizstats->errorratio *
|
||||
$quizstats->standarddeviation / 100;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,7 +900,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
protected function analyse_responses($quizstatisticsid, $quizid, $currentgroup,
|
||||
$nostudentsingroup, $useallattempts, $groupstudents, $questions, $subquestions) {
|
||||
|
||||
$qubaids = quiz_statistics_qubaids_condition($quizid, $currentgroup, $groupstudents, $useallattempts);
|
||||
$qubaids = quiz_statistics_qubaids_condition(
|
||||
$quizid, $currentgroup, $groupstudents, $useallattempts);
|
||||
|
||||
$done = array();
|
||||
foreach ($questions as $question) {
|
||||
@@ -919,8 +937,10 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$output = '<form action="'. $this->table->baseurl .'" method="post">';
|
||||
$output .= '<div class="mdl-align">';
|
||||
$output .= '<input type="hidden" name="everything" value="1"/>';
|
||||
$output .= '<input type="submit" value="'.get_string('downloadeverything', 'quiz_statistics').'"/>';
|
||||
$output .= html_writer::select($downloadoptions, 'download', $this->table->defaultdownloadformat, false);
|
||||
$output .= '<input type="submit" value="' .
|
||||
get_string('downloadeverything', 'quiz_statistics') . '"/>';
|
||||
$output .= html_writer::select($downloadoptions, 'download',
|
||||
$this->table->defaultdownloadformat, false);
|
||||
$output .= '</div></form>';
|
||||
|
||||
return $output;
|
||||
@@ -933,8 +953,10 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
* @param int $quizid the quiz id.
|
||||
* @param int $currentgroup the id of the currently selected group, or 0.
|
||||
* @param array $groupstudents ids of students in the group.
|
||||
* @param bool $useallattempts whether to use all attempts, instead of just first attempts.
|
||||
* @return string a HTML snipped saying when the stats were last computed, or blank if that is not appropriate.
|
||||
* @param bool $useallattempts whether to use all attempts, instead of just
|
||||
* first attempts.
|
||||
* @return string a HTML snipped saying when the stats were last computed,
|
||||
* or blank if that is not appropriate.
|
||||
*/
|
||||
protected function output_caching_info($quizstats, $quizid, $currentgroup,
|
||||
$groupstudents, $useallattempts, $reporturl) {
|
||||
@@ -962,11 +984,14 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$a->lastcalculated = format_time(time() - $quizstats->timemodified);
|
||||
$a->count = $count;
|
||||
|
||||
$recalcualteurl = new moodle_url($reporturl, array('recalculate' => 1, 'sesskey' => sesskey()));
|
||||
$recalcualteurl = new moodle_url($reporturl,
|
||||
array('recalculate' => 1, 'sesskey' => sesskey()));
|
||||
$output = '';
|
||||
$output .= $OUTPUT->box_start('boxaligncenter generalbox boxwidthnormal mdl-align', 'cachingnotice');
|
||||
$output .= $OUTPUT->box_start(
|
||||
'boxaligncenter generalbox boxwidthnormal mdl-align', 'cachingnotice');
|
||||
$output .= get_string('lastcalculated', 'quiz_statistics', $a);
|
||||
$output .= $OUTPUT->single_button($recalcualteurl, get_string('recalculatenow', 'quiz_statistics'));
|
||||
$output .= $OUTPUT->single_button($recalcualteurl,
|
||||
get_string('recalculatenow', 'quiz_statistics'));
|
||||
$output .= $OUTPUT->box_end(true);
|
||||
|
||||
return $output;
|
||||
@@ -983,7 +1008,7 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
global $DB;
|
||||
|
||||
$todelete = $DB->get_records_menu('quiz_statistics', array('quizid' => $quizid,
|
||||
'groupid' => $currentgroup, 'allattempts' => $useallattempts), '', 'id,1');
|
||||
'groupid' => $currentgroup, 'allattempts' => $useallattempts), '', 'id, 1');
|
||||
|
||||
if (!$todelete) {
|
||||
return;
|
||||
@@ -991,9 +1016,12 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
|
||||
list($todeletesql, $todeleteparams) = $DB->get_in_or_equal(array_keys($todelete));
|
||||
|
||||
$DB->delete_records_select('quiz_question_statistics', 'quizstatisticsid ' . $todeletesql, $todeleteparams);
|
||||
$DB->delete_records_select('quiz_question_response_stats', 'quizstatisticsid ' . $todeletesql, $todeleteparams);
|
||||
$DB->delete_records_select('quiz_statistics', 'id ' . $todeletesql, $todeleteparams);
|
||||
$DB->delete_records_select('quiz_question_statistics',
|
||||
'quizstatisticsid ' . $todeletesql, $todeleteparams);
|
||||
$DB->delete_records_select('quiz_question_response_stats',
|
||||
'quizstatisticsid ' . $todeletesql, $todeleteparams);
|
||||
$DB->delete_records_select('quiz_statistics',
|
||||
'id ' . $todeletesql, $todeleteparams);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -64,24 +63,40 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
|
||||
public function test_qstats() {
|
||||
global $CFG;
|
||||
//data is taken from randomly generated attempts data generated by contrib/tools/generators/qagenerator/
|
||||
$steps = $this->get_records_from_csv($CFG->dirroot.'/mod/quiz/report/statistics/simpletest/mdl_question_states.csv');
|
||||
//data is taken from questions mostly generated by contrib/tools/generators/generator.php
|
||||
$questions = $this->get_records_from_csv($CFG->dirroot.'/mod/quiz/report/statistics/simpletest/mdl_question.csv');
|
||||
// Data is taken from randomly generated attempts data generated by
|
||||
// contrib/tools/generators/qagenerator/
|
||||
$steps = $this->get_records_from_csv($CFG->dirroot .
|
||||
'/mod/quiz/report/statistics/simpletest/mdl_question_states.csv');
|
||||
// Data is taken from questions mostly generated by
|
||||
// contrib/tools/generators/generator.php
|
||||
$questions = $this->get_records_from_csv($CFG->dirroot .
|
||||
'/mod/quiz/report/statistics/simpletest/mdl_question.csv');
|
||||
$this->qstats = new testable_quiz_statistics_question_stats($questions, 22, 10045.45455);
|
||||
$this->qstats->set_step_data($steps);
|
||||
$this->qstats->compute_statistics();
|
||||
|
||||
//values expected are taken from contrib/tools/quiz_tools/stats.xls
|
||||
$facility = array(0,0,0,0,null,null,null,41.19318182,81.36363636,71.36363636,65.45454545,65.90909091,36.36363636,59.09090909,50,59.09090909,63.63636364,45.45454545,27.27272727,50);
|
||||
// Values expected are taken from contrib/tools/quiz_tools/stats.xls
|
||||
$facility = array(0, 0, 0, 0, null, null, null, 41.19318182, 81.36363636,
|
||||
71.36363636, 65.45454545, 65.90909091, 36.36363636, 59.09090909, 50,
|
||||
59.09090909, 63.63636364, 45.45454545, 27.27272727, 50);
|
||||
$this->qstats_q_fields('facility', $facility, 100);
|
||||
$sd = array(0,0,0,0,null,null,null,1912.733589,251.2738111,322.6312277,333.4199022,337.5811591,492.3659639,503.2362797,511.7663157,503.2362797,492.3659639,509.6471914,455.8423058,511.7663157);
|
||||
$sd = array(0, 0, 0, 0, null, null, null, 1912.733589, 251.2738111,
|
||||
322.6312277, 333.4199022, 337.5811591, 492.3659639, 503.2362797,
|
||||
511.7663157, 503.2362797, 492.3659639, 509.6471914, 455.8423058, 511.7663157);
|
||||
$this->qstats_q_fields('sd', $sd, 1000);
|
||||
$effectiveweight = array(0,0,0,0,0,0,0,26.58464457,3.368456046,3.253955259,7.584083694,3.79658376,3.183278505,4.532356904,7.78856243,10.08351572,8.381139345,8.727645713,7.946277111,4.769500946);
|
||||
$effectiveweight = array(0, 0, 0, 0, 0, 0, 0, 26.58464457, 3.368456046,
|
||||
3.253955259, 7.584083694, 3.79658376, 3.183278505, 4.532356904,
|
||||
7.78856243, 10.08351572, 8.381139345, 8.727645713, 7.946277111, 4.769500946);
|
||||
$this->qstats_q_fields('effectiveweight', $effectiveweight);
|
||||
$discriminationindex = array(null,null,null,null,null,null,null,25.88327077,1.170256965,-4.207816809,28.16930644,-2.513606859,-12.99017581,-8.900638238,8.670004606,29.63337745,15.18945843,16.21079629,15.52451404,-8.396734802);
|
||||
$discriminationindex = array(null, null, null, null, null, null, null,
|
||||
25.88327077, 1.170256965, -4.207816809, 28.16930644, -2.513606859,
|
||||
-12.99017581, -8.900638238, 8.670004606, 29.63337745, 15.18945843,
|
||||
16.21079629, 15.52451404, -8.396734802);
|
||||
$this->qstats_q_fields('discriminationindex', $discriminationindex);
|
||||
$discriminativeefficiency = array(null,null,null,null,null,null,null,27.23492723,1.382386552,-4.691171307,31.12404354,-2.877487579,-17.5074184,-10.27568922,10.86956522,34.58997279,17.4790556,20.14359793,22.06477733,-10);
|
||||
$discriminativeefficiency = array(null, null, null, null, null, null, null,
|
||||
27.23492723, 1.382386552, -4.691171307, 31.12404354, -2.877487579,
|
||||
-17.5074184, -10.27568922, 10.86956522, 34.58997279, 17.4790556,
|
||||
20.14359793, 22.06477733, -10);
|
||||
$this->qstats_q_fields('discriminativeefficiency', $discriminativeefficiency);
|
||||
}
|
||||
|
||||
@@ -89,9 +104,10 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
foreach ($this->qstats->questions as $question) {
|
||||
$value = array_shift($values);
|
||||
if ($value !== null) {
|
||||
$this->assertWithinMargin($question->_stats->{$fieldname}*$multiplier, $value, 1E-6);
|
||||
$this->assertWithinMargin($question->_stats->{$fieldname} * $multiplier,
|
||||
$value, 1E-6);
|
||||
} else {
|
||||
$this->assertEqual($question->_stats->{$fieldname}*$multiplier, $value);
|
||||
$this->assertEqual($question->_stats->{$fieldname} * $multiplier, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +123,7 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
$item = $items[$key];
|
||||
unset($items[$key]);
|
||||
list($key) = each($items);
|
||||
$items[$key] = $item.','.$items[$key];
|
||||
$items[$key] = $item . ',' . $items[$key];
|
||||
}
|
||||
$items[$key] = substr($items[$key], 0, strlen($items[$key])-1);
|
||||
}
|
||||
@@ -121,13 +137,13 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
|
||||
$filecontents = file($filename, FILE_IGNORE_NEW_LINES);
|
||||
$records = array();
|
||||
$keys = $this->get_fields_from_csv(array_shift($filecontents));//first line is field names
|
||||
while (NULL !== ($line = array_shift($filecontents))) {
|
||||
while (null !== ($line = array_shift($filecontents))) {
|
||||
$data = $this->get_fields_from_csv($line);
|
||||
$arraykey = reset($data);
|
||||
$object = new stdClass();
|
||||
foreach ($keys as $key) {
|
||||
$value = array_shift($data);
|
||||
if ($value !== NULL) {
|
||||
if ($value !== null) {
|
||||
$object->{$key} = $value;
|
||||
} else {
|
||||
$object->{$key} = '';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -52,8 +51,10 @@ class simple_rules_test extends UnitTestCase {
|
||||
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt), get_string('nomoreattempts', 'quiz'));
|
||||
$this->assertEqual($rule->prevent_new_attempt(666, $attempt), get_string('nomoreattempts', 'quiz'));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt),
|
||||
get_string('nomoreattempts', 'quiz'));
|
||||
$this->assertEqual($rule->prevent_new_attempt(666, $attempt),
|
||||
get_string('nomoreattempts', 'quiz'));
|
||||
|
||||
$this->assertFalse($rule->is_finished(0, $attempt));
|
||||
$this->assertFalse($rule->is_finished(2, $attempt));
|
||||
@@ -105,7 +106,8 @@ class simple_rules_test extends UnitTestCase {
|
||||
$rule = new time_limit_access_rule($quizobj, 10000);
|
||||
$attempt = new stdClass();
|
||||
|
||||
$this->assertEqual($rule->description(), get_string('quiztimelimit', 'quiz', format_time(3600)));
|
||||
$this->assertEqual($rule->description(),
|
||||
get_string('quiztimelimit', 'quiz', format_time(3600)));
|
||||
|
||||
$attempt->timestart = 10000;
|
||||
$this->assertEqual($rule->time_left($attempt, 10000), 3600);
|
||||
@@ -163,14 +165,17 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
$attempt->preview = 0;
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 9999);
|
||||
$this->assertEqual($rule->description(), array(get_string('quiznotavailable', 'quiz', userdate(10000))));
|
||||
$this->assertEqual($rule->prevent_access(), get_string('notavailable', 'quiz'));
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quiznotavailable', 'quiz', userdate(10000))));
|
||||
$this->assertEqual($rule->prevent_access(),
|
||||
get_string('notavailable', 'quiz'));
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->is_finished(0, $attempt));
|
||||
$this->assertFalse($rule->time_left($attempt, 0));
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 10000);
|
||||
$this->assertEqual($rule->description(), array(get_string('quizopenedon', 'quiz', userdate(10000))));
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quizopenedon', 'quiz', userdate(10000))));
|
||||
$this->assertFalse($rule->prevent_access());
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->is_finished(0, $attempt));
|
||||
@@ -189,7 +194,8 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
$attempt->preview = 0;
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 20000);
|
||||
$this->assertEqual($rule->description(), array(get_string('quizcloseson', 'quiz', userdate(20000))));
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quizcloseson', 'quiz', userdate(20000))));
|
||||
$this->assertFalse($rule->prevent_access());
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->is_finished(0, $attempt));
|
||||
@@ -199,8 +205,10 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
$this->assertEqual($rule->time_left($attempt, 20100), -100);
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 20001);
|
||||
$this->assertEqual($rule->description(), array(get_string('quizclosed', 'quiz', userdate(20000))));
|
||||
$this->assertEqual($rule->prevent_access(), get_string('notavailable', 'quiz'));
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quizclosed', 'quiz', userdate(20000))));
|
||||
$this->assertEqual($rule->prevent_access(),
|
||||
get_string('notavailable', 'quiz'));
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertTrue($rule->is_finished(0, $attempt));
|
||||
$this->assertFalse($rule->time_left($attempt, 20000 - QUIZ_SHOW_TIME_BEFORE_DEADLINE));
|
||||
@@ -221,28 +229,34 @@ class open_close_date_access_rule_test extends UnitTestCase {
|
||||
$attempt->preview = 0;
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 9999);
|
||||
$this->assertEqual($rule->description(), array(get_string('quiznotavailable', 'quiz', userdate(10000))));
|
||||
$this->assertEqual($rule->prevent_access(), get_string('notavailable', 'quiz'));
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quiznotavailable', 'quiz', userdate(10000))));
|
||||
$this->assertEqual($rule->prevent_access(),
|
||||
get_string('notavailable', 'quiz'));
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->is_finished(0, $attempt));
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 10000);
|
||||
$this->assertEqual($rule->description(), array(get_string('quizopenedon', 'quiz', userdate(10000)),
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quizopenedon', 'quiz', userdate(10000)),
|
||||
get_string('quizcloseson', 'quiz', userdate(20000))));
|
||||
$this->assertFalse($rule->prevent_access());
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->is_finished(0, $attempt));
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 20000);
|
||||
$this->assertEqual($rule->description(), array(get_string('quizopenedon', 'quiz', userdate(10000)),
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quizopenedon', 'quiz', userdate(10000)),
|
||||
get_string('quizcloseson', 'quiz', userdate(20000))));
|
||||
$this->assertFalse($rule->prevent_access());
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->is_finished(0, $attempt));
|
||||
|
||||
$rule = new open_close_date_access_rule($quizobj, 20001);
|
||||
$this->assertEqual($rule->description(), array(get_string('quizclosed', 'quiz', userdate(20000))));
|
||||
$this->assertEqual($rule->prevent_access(), get_string('notavailable', 'quiz'));
|
||||
$this->assertEqual($rule->description(),
|
||||
array(get_string('quizclosed', 'quiz', userdate(20000))));
|
||||
$this->assertEqual($rule->prevent_access(),
|
||||
get_string('notavailable', 'quiz'));
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertTrue($rule->is_finished(0, $attempt));
|
||||
|
||||
@@ -281,13 +295,15 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$attempt->timefinish = 9000;
|
||||
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$attempt->timefinish = 9001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
}
|
||||
|
||||
@@ -314,16 +330,20 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(5, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$attempt->timefinish = 9000;
|
||||
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
|
||||
$attempt->timefinish = 9001;
|
||||
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
}
|
||||
|
||||
public function test_just_both_delays() {
|
||||
@@ -348,25 +368,33 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(5, $attempt));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(12000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(12000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$attempt->timefinish = 8000;
|
||||
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
|
||||
$attempt->timefinish = 8001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(4, $attempt));
|
||||
$attempt->timefinish = 9000;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
|
||||
$attempt->timefinish = 9001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(11001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
}
|
||||
|
||||
public function test_with_close_date() {
|
||||
@@ -390,23 +418,29 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->time_left($attempt, 0));
|
||||
|
||||
$attempt->timefinish = 13000;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(15000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(15000)));
|
||||
$attempt->timefinish = 13001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youcannotwait', 'quiz'));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youcannotwait', 'quiz'));
|
||||
$attempt->timefinish = 14000;
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(15000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(15000)));
|
||||
$attempt->timefinish = 14001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youcannotwait', 'quiz'));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youcannotwait', 'quiz'));
|
||||
|
||||
$rule = new inter_attempt_delay_access_rule($quizobj, 15000);
|
||||
$attempt->timefinish = 13000;
|
||||
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
|
||||
$attempt->timefinish = 13001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youcannotwait', 'quiz'));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youcannotwait', 'quiz'));
|
||||
$attempt->timefinish = 14000;
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$attempt->timefinish = 14001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youcannotwait', 'quiz'));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youcannotwait', 'quiz'));
|
||||
|
||||
$rule = new inter_attempt_delay_access_rule($quizobj, 15001);
|
||||
$attempt->timefinish = 13000;
|
||||
@@ -442,9 +476,12 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
|
||||
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(5, $attempt));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(12000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(12000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(3, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$attempt->timestart = 7950;
|
||||
$attempt->timefinish = 8000;
|
||||
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
|
||||
@@ -452,29 +489,38 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
|
||||
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
|
||||
$attempt->timestart = 7950;
|
||||
$attempt->timefinish = 8001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(4, $attempt));
|
||||
$attempt->timestart = 8950;
|
||||
$attempt->timefinish = 9000;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
|
||||
$attempt->timestart = 8950;
|
||||
$attempt->timefinish = 9001;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(11001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$attempt->timestart = 8900;
|
||||
$attempt->timefinish = 9100;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11000)));
|
||||
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
|
||||
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
|
||||
$attempt->timestart = 8901;
|
||||
$attempt->timefinish = 9100;
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt), get_string('youmustwait', 'quiz', userdate(11001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt), get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(1, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(11001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(2, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
$this->assertEqual($rule->prevent_new_attempt(4, $attempt),
|
||||
get_string('youmustwait', 'quiz', userdate(10001)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,10 +594,14 @@ class quiz_access_manager_test extends UnitTestCase {
|
||||
|
||||
$am = new quiz_access_manager($quizobj, time(), false);
|
||||
|
||||
$this->assertEqual('', $am->cannot_review_message(mod_quiz_display_options::DURING));
|
||||
$this->assertEqual('', $am->cannot_review_message(mod_quiz_display_options::IMMEDIATELY_AFTER));
|
||||
$this->assertEqual(get_string('noreview', 'quiz'), $am->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN));
|
||||
$this->assertEqual(get_string('noreview', 'quiz'), $am->cannot_review_message(mod_quiz_display_options::AFTER_CLOSE));
|
||||
$this->assertEqual('',
|
||||
$am->cannot_review_message(mod_quiz_display_options::DURING));
|
||||
$this->assertEqual('',
|
||||
$am->cannot_review_message(mod_quiz_display_options::IMMEDIATELY_AFTER));
|
||||
$this->assertEqual(get_string('noreview', 'quiz'),
|
||||
$am->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN));
|
||||
$this->assertEqual(get_string('noreview', 'quiz'),
|
||||
$am->cannot_review_message(mod_quiz_display_options::AFTER_CLOSE));
|
||||
|
||||
$closetime = time() + 10000;
|
||||
$quiz->timeclose = $closetime;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
||||
Reference in New Issue
Block a user