diff --git a/course/mod.php b/course/mod.php index d30661fb21bc7..5f3be7994abce 100644 --- a/course/mod.php +++ b/course/mod.php @@ -76,7 +76,11 @@ error($return, "view.php?id=$course->id"); } - $SESSION->returnpage = "$CFG->wwwroot/mod/$mod->modulename/view.php?id=$mod->coursemodule"; + if (isset($mod->redirect)) { + $SESSION->returnpage = $mod->redirecturl; + } else { + $SESSION->returnpage = "$CFG->wwwroot/mod/$mod->modulename/view.php?id=$mod->coursemodule"; + } add_to_log($course->id, "course", "update mod", "../mod/$mod->modulename/view.php?id=$mod->coursemodule", @@ -128,7 +132,11 @@ error("Could not update the course module with the correct section"); } - $SESSION->returnpage = "$CFG->wwwroot/mod/$mod->modulename/view.php?id=$mod->coursemodule"; + if (isset($mod->redirect)) { + $SESSION->returnpage = $mod->redirecturl; + } else { + $SESSION->returnpage = "$CFG->wwwroot/mod/$mod->modulename/view.php?id=$mod->coursemodule"; + } add_to_log($course->id, "course", "add mod", "../mod/$mod->modulename/view.php?id=$mod->coursemodule", diff --git a/lang/en/help/hideoptions.html b/lang/en/help/hideoptions.html new file mode 100644 index 0000000000000..e25206ef76be7 --- /dev/null +++ b/lang/en/help/hideoptions.html @@ -0,0 +1,7 @@ +

Hide options

+ +

If you tick these boxes then the corresponding options will be +hidden from the teacher by default. However the teacher can access +these options by choosing "" on the quiz setup +page.

diff --git a/lang/en/help/quiz/review2.html b/lang/en/help/quiz/review2.html new file mode 100644 index 0000000000000..152f733bbc5ce --- /dev/null +++ b/lang/en/help/quiz/review2.html @@ -0,0 +1,5 @@ +

Allow review

+ +

This option controls whether and when students will be able to + review their past attempts at this quiz.

+ diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 593f16c80204a..5144778991171 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -62,6 +62,7 @@ $string['administratorsall'] = 'All administrators'; $string['administratorsandteachers'] = 'Administrators and teachers'; $string['advancedfilter'] = 'Advanced search'; +$string['advancedsettings'] = 'Advanced settings'; $string['again'] = 'again'; $string['all'] = 'All'; $string['allactivities'] = 'All activities'; @@ -474,7 +475,6 @@ $string['firstdayofweek'] = '0'; $string['firstname'] = 'First name'; $string['firsttime'] = 'Is this your first time here?'; -$string['fix'] = 'Fix'; $string['followingoptional'] = 'The following items are optional'; $string['followingrequired'] = 'The following items are required'; $string['force'] = 'Force'; @@ -570,6 +570,7 @@ $string['hiddensectionscollapsed'] = 'Hidden sections are shown in collapsed form'; $string['hiddensectionsinvisible'] = 'Hidden sections are completely invisible'; $string['hide'] = 'Hide'; +$string['hideadvancedsettings'] = 'Hide advanced settings'; $string['hidepicture'] = 'Hide picture'; $string['hidesettings'] = 'Hide settings'; $string['hits'] = 'Hits'; @@ -928,6 +929,7 @@ $string['shortnametaken'] = 'Short name is already used for another course ($a)'; $string['shortsitename'] = 'Short name for site (eg single word)'; $string['show'] = 'Show'; +$string['showadvancedsettings'] = 'Show advanced settings'; $string['showall'] = 'Show all $a'; $string['showallcourses'] = 'Show all courses'; $string['showalltopics'] = 'Show all topics'; diff --git a/lang/en/quiz.php b/lang/en/quiz.php index 1dfc09fdfc8fc..e683ba58b070a 100644 --- a/lang/en/quiz.php +++ b/lang/en/quiz.php @@ -211,11 +211,16 @@ $string['randomsamatchintro'] = 'For each of the following questions, select the matching answer from the menu.'; $string['randomsamatchnumber'] = 'Number of questions to select'; $string['readytosend'] = 'You are about to send your whole quiz to be graded. Are you sure you want to continue?'; +$string['reattemptquiz'] = 'Re-attempt quiz'; $string['recentlyaddedquestion'] = 'Recently added question!'; $string['regrade'] = 'Regrade all attempts'; $string['regradecomplete'] = 'All attempts have been regraded'; $string['regradecount'] = '$a->changed out of $a->attempt grades were changed'; $string['relative'] = 'Relative'; +$string['reviewnever'] = 'Never allow review'; +$string['reviewafter'] = 'Allow review after quiz is closed'; +$string['reviewbefore'] = 'Allow review while quiz is open'; +$string['reviewalways'] = 'Allow review at any time'; $string['remove'] = 'Remove'; $string['rename'] = 'Rename'; $string['report'] = 'Reports'; @@ -232,6 +237,7 @@ $string['reuseifpossible'] = 'reuse previously removed'; $string['review'] = 'Review'; $string['save'] = 'Save'; +$string['saveandedit'] = 'Save changes and edit questions'; $string['savegrades'] = 'Save grades'; $string['savemyanswers'] = 'Save my answers'; $string['savequiz'] = 'Save this whole quiz'; diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 6dddfec32a693..ccc1647aaf3b6 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -117,7 +117,7 @@ } -/// BEGIN EDIT Get time limit if any. +/// Get time limit if any. $timelimit = $quiz->timelimit * 60; @@ -135,7 +135,7 @@ if($timelimit and $timerstartvalue <= 0) { $timerstartvalue = 1; } -/// END EDIT + $timenow = time(); $available = ($quiz->timeopen < $timenow and $timenow < $quiz->timeclose) || isteacher($course->id); @@ -202,6 +202,11 @@ if (! quiz_save_best_grade($quiz, $USER->id)) { error("Sorry! Could not calculate your best grade!"); } + + if (empty($quiz->popup) and !$quiz->feedback) { + // No need to stop on this page, go directly to view.php + redirect('view.php?q='.$quiz->id); + } $strgrade = get_string("grade"); $strscore = get_string("score", "quiz"); diff --git a/mod/quiz/attempt_close_js.php b/mod/quiz/attempt_close_js.php index 013ebc32c8def..767e50e86a705 100644 --- a/mod/quiz/attempt_close_js.php +++ b/mod/quiz/attempt_close_js.php @@ -9,7 +9,7 @@ @@ -19,7 +19,7 @@ $cm->id ), get_string('continue')); + print_single_button("../../course/view.php", array( 'id' => $course->id ), get_string('continue')); } ?> diff --git a/mod/quiz/config.html b/mod/quiz/config.html index d26a22f7fb4ba..8345cb1f6d79e 100644 --- a/mod/quiz/config.html +++ b/mod/quiz/config.html @@ -9,7 +9,7 @@ - + @@ -150,11 +150,13 @@ : quiz_allowreview, "", "", ""); - helpbutton("review", get_string("allowreview","quiz"), "quiz"); + $reviewoptions = array(); + $reviewoptions[0] = get_string('reviewnever', 'quiz'); + $reviewoptions[1] = get_string('reviewafter', 'quiz'); + $reviewoptions[2] = get_string('reviewbefore', 'quiz'); + $reviewoptions[3] = get_string('reviewalways', 'quiz'); + choose_from_menu ($reviewoptions, "quiz_allowreview", $CFG->quiz_allowreview, "", "", ""); + helpbutton("review2", get_string("allowreview","quiz"), "quiz"); ?> diff --git a/mod/quiz/defaults.php b/mod/quiz/defaults.php index 8adf770e76218..1eda795ee4dc8 100644 --- a/mod/quiz/defaults.php +++ b/mod/quiz/defaults.php @@ -4,7 +4,7 @@ // It defines default values for any important configuration variables $defaults = array ( - 'quiz_allowreview' => 0, + 'quiz_allowreview' => 1, 'quiz_attemptonlast' => 0, 'quiz_attempts' => 0, 'quiz_grademethod' => '', diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 43ddb782cf93d..ab05c34efedca 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -6,6 +6,7 @@ require_login(); optional_variable($courseid); + optional_variable($quizid); if (empty($destination)) { $destination = ""; @@ -13,7 +14,7 @@ $modform = data_submitted($destination); - if ($modform and !empty($modform->course)) { // form submitted from mod.html + if ($modform and !empty($modform->course)) { // data submitted $modform->name = trim($modform->name); @@ -27,6 +28,15 @@ $SESSION->modform = $modform; // Save the form in the current session + } else if ($quizid) { + if (! $modform = get_record('quiz', 'id', $quizid)) { + error("The required quiz doesn't exist"); + } + + $modform->instance = $modform->id; + + $SESSION->modform = $modform; // Save the form in the current session + } else if ($courseid) { // Page retrieve through "Edit Questions" link - no quiz selected $modform->course = $courseid; unset($modform->instance); @@ -35,7 +45,9 @@ } else { if (!isset($SESSION->modform)) { - error("You have used this page incorrectly!"); + // We currently also get here after editing a question by + // following the edit link on the review page. Perhaps that should be fixed. + error(''); } $modform = $SESSION->modform; @@ -60,6 +72,10 @@ // Now, check for commands on this page and modify variables as necessary + + if (isset($cancel)) { + redirect('view.php?q='.$modform->instance); + } if (!empty($up)) { /// Move the given question up a slot $questions = explode(",", $modform->questions); @@ -147,6 +163,25 @@ } } } + + if (!empty($save)) { // Save the list of questions and grades in the database and return + + //If caller is correct, $SESSION->sesskey must exist and coincide + if (empty($SESSION->sesskey) or !confirm_sesskey($SESSION->sesskey)) { + error(get_string('confirmsesskeybad', 'error')); + } + //Unset this, check done + unset($SESSION->sesskey); + + quiz_update_instance($modform); + $coursemodule = get_coursemodule_from_instance('quiz', $modform->instance); + add_to_log($course->id, 'quiz', 'editquestions', + "view.php?id=$coursemodule", + "$modform->instance", $coursemodule); + redirect('view.php?q='.$modform->instance); + die; + } + if (!empty($cat)) { //----------------------------------------------------------- $modform->category = $cat; @@ -204,11 +239,12 @@ } notify("$strattemptsexist
id\">$strviewallanswers ($usercount $strusers)"); } - + + $SESSION->sesskey = !empty($USER->id) ? $USER->sesskey : ''; ?> -
destination ?>> - - " /> + + + " /> " />
diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index a9e3b334d4099..ea6233e313e66 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -43,6 +43,9 @@ define("QUIZ_MAX_EVENT_LENGTH", "432000"); // 5 days maximum +define('QUIZ_REVIEW_AFTER', 1); +define('QUIZ_REVIEW_BEFORE', 2); + $QUIZ_QTYPES= array(); /// QUIZ_QTYPES INITIATION ////////////////// @@ -337,9 +340,15 @@ function quiz_add_instance($quiz) { if (!$quiz->id = insert_record("quiz", $quiz)) { return false; // some error occurred } + + if (isset($quiz->optionsettingspref)) { + set_user_preference('quiz_optionsettingspref', $quiz->optionsettingspref); + } // The grades for every question in this quiz are stored in an array - if ($quiz->grades) { + // (because this is currently only called from mod.html there are not + // going to be any grades, but we will leave this code here just in case) + if (isset($quiz->grades)) { foreach ($quiz->grades as $question => $grade) { if ($question) { unset($questiongrade); @@ -390,7 +399,7 @@ function quiz_add_instance($quiz) { function quiz_update_instance($quiz) { /// Given an object containing all the necessary data, -/// (defined by the form in mod.html) this function +/// (defined by the form in mod.html or edit.php) this function /// will update an existing instance with new data. global $SESSION; @@ -398,23 +407,28 @@ function quiz_update_instance($quiz) { unset($SESSION->modform); $quiz->timemodified = time(); - $quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, - $quiz->openhour, $quiz->openminute, 0); - $quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, - $quiz->closehour, $quiz->closeminute, 0); + if (isset($quiz->openyear)) { // this would not be set if we come from edit.php + $quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, + $quiz->openhour, $quiz->openminute, 0); + $quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, + $quiz->closehour, $quiz->closeminute, 0); + } $quiz->id = $quiz->instance; if (!update_record("quiz", $quiz)) { return false; // some error occurred } + if (isset($quiz->optionsettingspref)) { + set_user_preference('quiz_optionsettingspref', $quiz->optionsettingspref); + } // The grades for every question in this quiz are stored in an array // Insert or update records as appropriate $existing = get_records("quiz_question_grades", "quiz", $quiz->id, "", "question,grade,id"); - if ($quiz->grades) { + if (isset($quiz->grades)) { // this will not be set if we come from mod.html foreach ($quiz->grades as $question => $grade) { if ($question) { unset($questiongrade); @@ -473,8 +487,6 @@ function quiz_update_instance($quiz) { add_event($event); } - - return true; } @@ -1234,6 +1246,7 @@ function quiz_gradesmenu_options($defaultgrade) { function quiz_print_question_list($questionlist, $grades) { // Prints a list of quiz questions in a small layout form with knobs +// returns sum of maximum grades // $questionlist is comma-separated list // $grades is an array of corresponding grades diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html index e194679113c82..4ff3814589f01 100644 --- a/mod/quiz/mod.html +++ b/mod/quiz/mod.html @@ -1,9 +1,38 @@ + + + dirroot/mod/quiz/lib.php"); - +// Ensure that all form variables are initialized if (!isset($form->name)) { $form->name = ""; } @@ -58,11 +87,40 @@ if (!isset($form->popup)) { $form->popup = $CFG->quiz_popup; } + + $fix = 0; // This will later be set to 1 if some of the variables have been fixed by the admin. + + // the following are used for drop-down menus + $reviewoptions = array(); + $reviewoptions[0] = get_string('reviewnever', 'quiz'); + $reviewoptions[1] = get_string('reviewafter', 'quiz'); + $reviewoptions[2] = get_string('reviewbefore', 'quiz'); + $reviewoptions[3] = get_string('reviewalways', 'quiz'); + + $yesnooptions = array(); + $yesnooptions[0] = get_string("no"); + $yesnooptions[1] = get_string("yes"); + + $attemptoptions = array(); + $attemptoptions[0] = get_string("attemptsunlimited", "quiz"); + $attemptoptions[1] = "1 ".strtolower(get_string("attempt", "quiz")); + for ($i=2;$i<=6;$i++) { + $attemptoptions[$i] = "$i ".strtolower(get_string("attempts", "quiz")); + } + + $grades = array(); + for ($i=100; $i>=1; $i--) { + $grades[$i] = $i; + } + $grades[0] = get_string("nograde"); ?> -
+ +
+ + @@ -124,9 +182,7 @@ -quiz_fix_timelimit) { ?> - - +quiz_fix_timelimit) { ?> -quiz_fix_shufflequestions) { ?> - - +quiz_fix_shufflequestions) { ?> -quiz_fix_shuffleanswers) { ?> - - +quiz_fix_shuffleanswers) { ?> -quiz_fix_attempts) { ?> - - +quiz_fix_attempts) { ?> -quiz_fix_attemptonlast) { ?> - - +quiz_fix_attemptonlast) { ?> -quiz_fix_grademethod) { ?> - - +quiz_fix_grademethod) { ?> -quiz_fix_showfeedback) { ?> - - +quiz_fix_showfeedback) { ?> -quiz_fix_showanswer) { ?> - - +quiz_fix_showanswer) { ?> -quiz_fix_allowreview) { ?> - - +quiz_fix_allowreview) { ?> + + + + + + +quiz_fix_maximumgrade) { ?> + + + + + + +quiz_fix_popup) { ?> + + + + + + +quiz_fix_password) { ?> + + + + + + +quiz_fix_subnet) { ?> + + + + + + +
: @@ -138,71 +194,48 @@
: shufflequestions", ""); + choose_from_menu($yesnooptions, "shufflequestions", "$form->shufflequestions", ""); helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); ?>
: shuffleanswers", ""); + choose_from_menu($yesnooptions, "shuffleanswers", "$form->shuffleanswers", ""); helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz"); ?>
: attempts", ""); + choose_from_menu($attemptoptions, "attempts", "$form->attempts", ""); helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); ?>
: attemptonlast", ""); helpbutton("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), @@ -212,18 +245,11 @@
: grademethod", ""); helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); ?> @@ -231,69 +257,217 @@
: feedback", ""); + choose_from_menu($yesnooptions, "feedback", "$form->feedback", ""); helpbutton("feedback", get_string("showfeedback","quiz"), "quiz"); ?>
: correctanswers", ""); + choose_from_menu($yesnooptions, "correctanswers", "$form->correctanswers", ""); helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz"); ?>
: + review", ""); + helpbutton("review2", get_string("allowreview","quiz"), "quiz"); + ?> +
: + grade", ""); + helpbutton("maxgrade", get_string("maximumgrade"), "quiz"); + ?> +
: + popup", ""); + helpbutton("popup", get_string("popup","quiz"), "quiz"); + ?> +
: + + +
: + + +
+ + + + + +
+ + + + + +quiz_fix_timelimit) { $fix = 1; ?> + + + + + + +quiz_fix_shufflequestions) { $fix = 1; ?> + + + + + + +quiz_fix_shuffleanswers) { $fix = 1; ?> + + + + + + +quiz_fix_attempts) { $fix = 1; ?> + + + + + + +quiz_fix_attemptonlast) { $fix = 1; ?> + + + + + + +quiz_fix_grademethod) { $fix = 1; ?> + + + + + + +quiz_fix_showfeedback) { $fix = 1; ?> + + + + + + +quiz_fix_showanswer) { $fix = 1; ?> + + + + + + +quiz_fix_allowreview) { $fix = 1; ?> -quiz_fix_maximumgrade) { ?> - - +quiz_fix_maximumgrade) { $fix = 1; ?> -quiz_fix_popup) { ?> - - +quiz_fix_popup) { $fix = 1; ?> -quiz_fix_password) { ?> - - +quiz_fix_password) { $fix = 1; ?> -quiz_fix_subnet) { ?> - - +quiz_fix_subnet) { $fix = 1; ?> - +
: + timelimit, get_string("minutes","quiz")); + helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz"); + ?> +
: + shufflequestions", ""); + helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); + ?> +
: + shuffleanswers", ""); + helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz"); + ?> +
: + attempts", ""); + helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); + ?> +
: + attemptonlast", ""); + helpbutton("repeatattempts", + get_string("eachattemptbuildsonthelast", "quiz"), + "quiz"); + ?> +
: + grademethod", ""); + helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); + ?> +
: + feedback", ""); + helpbutton("feedback", get_string("showfeedback","quiz"), "quiz"); + ?> +
: + correctanswers", ""); + helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz"); + ?> +
: review", ""); + choose_from_menu($reviewoptions, "review", "$form->review", ""); helpbutton("review", get_string("allowreview","quiz"), "quiz"); ?>
: =1; $i--) { - $grades[$i] = $i; - } - $grades[0] = get_string("nograde"); - choose_from_menu($grades, "grade", "$form->grade", ""); helpbutton("maxgrade", get_string("maximumgrade"), "quiz"); ?> @@ -301,26 +475,19 @@
: popup", ""); + choose_from_menu($yesnooptions, "popup", "$form->popup", ""); helpbutton("popup", get_string("popup","quiz"), "quiz"); ?>
: @@ -330,9 +497,7 @@
: @@ -341,9 +506,25 @@
- + +
+ + + + + +
+ + + + +
+ @@ -352,7 +533,14 @@ -wwwroot/course/mod.php" ?>" /> -" /> +" /> + +wwwroot/mod/quiz/edit.php?quizid=$form->instance") ?>" /> + +" />
+ + \ No newline at end of file diff --git a/mod/quiz/questiontypes/random/random.html b/mod/quiz/questiontypes/random/random.html index 3e0f6fdcbb5af..61e13b7eb33f1 100644 --- a/mod/quiz/questiontypes/random/random.html +++ b/mod/quiz/questiontypes/random/random.html @@ -43,7 +43,7 @@ - + diff --git a/mod/quiz/review.php b/mod/quiz/review.php index a9ca26afce9f3..a1c4604da1772 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -46,9 +46,12 @@ if (!$quiz->review) { error(get_string("noreview", "quiz")); } - if (time() < $quiz->timeclose) { + if (time() < $quiz->timeclose and $quiz->review == QUIZ_REVIEW_AFTER) { error(get_string("noreviewuntil", "quiz", userdate($quiz->timeclose))); } + if (time() > $quiz->timeclose and $quiz->review == QUIZ_REVIEW_BEFORE) { + error(get_string("noreview", "quiz")); + } if ($attempt->userid != $USER->id) { error("This is not your attempt!"); } diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 382395dc48e55..acfe6ed996714 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -34,6 +34,11 @@ } require_login($course->id); + + // if no questions have been set up yet redirect to edit.php + if (!$quiz->questions and isteacheredit($course->id)) { + redirect('edit.php?quizid='.$quiz->id); + } add_to_log($course->id, "quiz", "view", "view.php?id=$cm->id", $quiz->id, $cm->id); @@ -44,10 +49,20 @@ $strquizzes = get_string("modulenameplural", "quiz"); $strquiz = get_string("modulename", "quiz"); + $stredit = get_string('editquestions', 'quiz'); + if (isteacheredit($course->id)) { + $buttons = "
framename\" method=\"get\" action=\"edit.php\">". + "id\" />". + "
". + update_module_button($cm->id, $course->id, $strquiz). + '
'; + } else { + $buttons = ''; + } print_header_simple("$quiz->name", "", "id\">$strquizzes -> $quiz->name", - "", "", true, update_module_button($cm->id, $course->id, $strquiz), navmenu($course, $cm)); + "", "", true, $buttons, navmenu($course, $cm)); if (isteacher($course->id)) { $attemptcount = count_records_select("quiz_attempts", "quiz = '$quiz->id' AND timefinish > 0"); @@ -118,17 +133,17 @@ if ($attemptgrade == $mygrade) { $attemptgrade = "$attemptgrade"; } - if (!$available and $quiz->review) { + if (quiz_review_allowed($quiz)) { $attemptgrade = "id&attempt=$attempt->id\">$attemptgrade"; - $attempt->attempt = "id&attempt=$attempt->id\">$attempt->attempt"; + $attempt->attempt = "id&attempt=$attempt->id\">#$attempt->attempt"; } $table->data[] = array( $attempt->attempt, format_time($attempt->timefinish - $attempt->timestart), userdate($attempt->timefinish), $attemptgrade); } else { // No grades are being used - if (!$available and $quiz->review) { - $attempt->attempt = "id&attempt=$attempt->id\">$attempt->attempt"; + if (quiz_review_allowed($quiz)) { + $attempt->attempt = "id&attempt=$attempt->id\">#$attempt->attempt"; } $table->data[] = array( $attempt->attempt, format_time($attempt->timefinish - $attempt->timestart), @@ -176,8 +191,20 @@ } } - // Finish the page print_footer($course); + + function quiz_review_allowed($quiz) { + if (!$quiz->review) { + return false; + } + if ((time() < $quiz->timeclose) and ($quiz->review == QUIZ_REVIEW_AFTER)) { + return false; + } + if ((time() > $quiz->timeclose) and ($quiz->review == QUIZ_REVIEW_BEFORE)) { + return false; + } + return true; + } ?> diff --git a/mod/quiz/view_js.php b/mod/quiz/view_js.php index 46c7ae02e72a9..513d773f7d1f4 100644 --- a/mod/quiz/view_js.php +++ b/mod/quiz/view_js.php @@ -3,12 +3,13 @@ $window = (!empty($quiz->popup)) ? 'quizpopup' : '_self'; $windowoptions = ($window == '_self') ? '' : "left=0, top=0, height='+window.screen.height+', width='+window.screen.width+', channelmode=yes, fullscreen=yes, scrollbars=yes, resizeable=no, directories=no, toolbar=no, titlebar=no, location=no, status=no, menubar=no"; +$buttontext = ($numattempts) ? get_string('reattemptquiz', 'quiz') : get_string('attemptquiznow', 'quiz'); ?>