mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Teachers can choose to allow review of quizzes, which means that students
are allowed to see past quizzes. This only works once the quiz is completely closed (to perhaps prevent easy cheating).
This commit is contained in:
parent
d78ab28640
commit
8e6c87ccf3
6 changed files with 90 additions and 22 deletions
6
lang/en/help/quiz/review.html
Normal file
6
lang/en/help/quiz/review.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<P ALIGN=CENTER><B>Allow review once quiz is closed</B></P>
|
||||||
|
|
||||||
|
<P>If you enable this option, then students will be able to
|
||||||
|
review their past attempts at this quiz.</P>
|
||||||
|
|
||||||
|
<P>This is only enabled once the quiz is closed.</P>
|
|
@ -6,6 +6,7 @@ $string['modulenameplural'] = "Quizzes";
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
||||||
$string['addselectedtoquiz'] = "Add selected to quiz";
|
$string['addselectedtoquiz'] = "Add selected to quiz";
|
||||||
|
$string['allowreview'] = "Allow review";
|
||||||
$string['alwaysavailable'] = "Always available";
|
$string['alwaysavailable'] = "Always available";
|
||||||
$string['alreadysubmitted'] = "It is likely that you have already submitted this attempt";
|
$string['alreadysubmitted'] = "It is likely that you have already submitted this attempt";
|
||||||
$string['answer'] = "Answer";
|
$string['answer'] = "Answer";
|
||||||
|
@ -68,6 +69,8 @@ $string['noanswers'] = "No answers were selected!";
|
||||||
$string['noattempts'] = "No attempts have been made on this quiz";
|
$string['noattempts'] = "No attempts have been made on this quiz";
|
||||||
$string['nomoreattempts'] = "No more attempts are allowed";
|
$string['nomoreattempts'] = "No more attempts are allowed";
|
||||||
$string['noquestions'] = "No questions have been added yet";
|
$string['noquestions'] = "No questions have been added yet";
|
||||||
|
$string['noreview'] = "You are not allowed to review this quiz";
|
||||||
|
$string['noreviewuntil'] = "You are not allowed to review this quiz until \$a";
|
||||||
$string['publish'] = "Publish";
|
$string['publish'] = "Publish";
|
||||||
$string['question'] = "Question";
|
$string['question'] = "Question";
|
||||||
$string['questioninuse'] = "The question '\$a' is currently being used:";
|
$string['questioninuse'] = "The question '\$a' is currently being used:";
|
||||||
|
|
|
@ -453,10 +453,10 @@ function quiz_print_question($number, $questionid, $grade, $courseid,
|
||||||
$answer = $answers[$answerid];
|
$answer = $answers[$answerid];
|
||||||
$qnum = $key + 1;
|
$qnum = $key + 1;
|
||||||
|
|
||||||
if ($feedback and $response[$answerid]) {
|
if (empty($feedback) or empty($response[$answerid])) {
|
||||||
$checked = "CHECKED";
|
|
||||||
} else {
|
|
||||||
$checked = "";
|
$checked = "";
|
||||||
|
} else {
|
||||||
|
$checked = "CHECKED";
|
||||||
}
|
}
|
||||||
echo "<TR><TD valign=top>";
|
echo "<TR><TD valign=top>";
|
||||||
if ($options->single) {
|
if ($options->single) {
|
||||||
|
@ -465,14 +465,14 @@ function quiz_print_question($number, $questionid, $grade, $courseid,
|
||||||
echo "<INPUT $checked TYPE=CHECKBOX NAME=q$question->id"."a$answer->id VALUE=\"$answer->id\">";
|
echo "<INPUT $checked TYPE=CHECKBOX NAME=q$question->id"."a$answer->id VALUE=\"$answer->id\">";
|
||||||
}
|
}
|
||||||
echo "</TD>";
|
echo "</TD>";
|
||||||
if ($feedback and $correct[$answer->id]) {
|
if (empty($feedback) or empty($correct[$answer->id])) {
|
||||||
echo "<TD valign=top CLASS=highlight>$qnum. $answer->answer</TD>";
|
|
||||||
} else {
|
|
||||||
echo "<TD valign=top>$qnum. $answer->answer</TD>";
|
echo "<TD valign=top>$qnum. $answer->answer</TD>";
|
||||||
|
} else {
|
||||||
|
echo "<TD valign=top CLASS=highlight>$qnum. $answer->answer</TD>";
|
||||||
}
|
}
|
||||||
if ($feedback) {
|
if (!empty($feedback)) {
|
||||||
echo "<TD valign=top> ";
|
echo "<TD valign=top> ";
|
||||||
if ($response[$answerid]) {
|
if (!empty($response[$answerid])) {
|
||||||
quiz_print_comment($feedback[$answerid]);
|
quiz_print_comment($feedback[$answerid]);
|
||||||
}
|
}
|
||||||
echo "</TD>";
|
echo "</TD>";
|
||||||
|
@ -498,7 +498,7 @@ function quiz_print_question($number, $questionid, $grade, $courseid,
|
||||||
function quiz_print_quiz_questions($quiz, $results=NULL) {
|
function quiz_print_quiz_questions($quiz, $results=NULL) {
|
||||||
// Prints a whole quiz on one page.
|
// Prints a whole quiz on one page.
|
||||||
|
|
||||||
if (!$quiz->questions) {
|
if (empty($quiz->questions)) {
|
||||||
notify("No questions have been defined!", "view.php?id=$cm->id");
|
notify("No questions have been defined!", "view.php?id=$cm->id");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -520,12 +520,20 @@ function quiz_print_quiz_questions($quiz, $results=NULL) {
|
||||||
$response = NULL;
|
$response = NULL;
|
||||||
$actualgrades = NULL;
|
$actualgrades = NULL;
|
||||||
$correct = NULL;
|
$correct = NULL;
|
||||||
if ($results) {
|
if (!empty($results)) {
|
||||||
$feedback = $results->feedback[$questionid];
|
if (!empty($results->feedback[$questionid])) {
|
||||||
$response = $results->response[$questionid];
|
$feedback = $results->feedback[$questionid];
|
||||||
$actualgrades = $results->grades[$questionid];
|
}
|
||||||
|
if (!empty($results->response[$questionid])) {
|
||||||
|
$response = $results->response[$questionid];
|
||||||
|
}
|
||||||
|
if (!empty($results->grades[$questionid])) {
|
||||||
|
$actualgrades = $results->grades[$questionid];
|
||||||
|
}
|
||||||
if ($quiz->correctanswers) {
|
if ($quiz->correctanswers) {
|
||||||
$correct = $results->correct[$questionid];
|
if (!empty($results->correct[$questionid])) {
|
||||||
|
$correct = $results->correct[$questionid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +544,7 @@ function quiz_print_quiz_questions($quiz, $results=NULL) {
|
||||||
echo "<BR>";
|
echo "<BR>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$results) {
|
if (empty($results)) {
|
||||||
echo "<CENTER><INPUT TYPE=submit VALUE=\"".get_string("savemyanswers", "quiz")."\"></CENTER>";
|
echo "<CENTER><INPUT TYPE=submit VALUE=\"".get_string("savemyanswers", "quiz")."\"></CENTER>";
|
||||||
}
|
}
|
||||||
echo "</FORM>";
|
echo "</FORM>";
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
if (empty($form->correctanswers)) {
|
if (empty($form->correctanswers)) {
|
||||||
$form->correctanswers = "";
|
$form->correctanswers = "";
|
||||||
}
|
}
|
||||||
|
if (empty($form->review)) {
|
||||||
|
$form->review = "";
|
||||||
|
}
|
||||||
if (empty($form->grade)) {
|
if (empty($form->grade)) {
|
||||||
$form->grade = "";
|
$form->grade = "";
|
||||||
}
|
}
|
||||||
|
@ -132,6 +135,18 @@
|
||||||
?>
|
?>
|
||||||
</TD>
|
</TD>
|
||||||
</TR>
|
</TR>
|
||||||
|
<TR valign=top>
|
||||||
|
<TD align=right><P><B><? print_string("allowreview", "quiz") ?>:</B></P></TD>
|
||||||
|
<TD>
|
||||||
|
<?
|
||||||
|
$options = array();
|
||||||
|
$options[0] = get_string("no");
|
||||||
|
$options[1] = get_string("yes");
|
||||||
|
choose_from_menu($options, "review", "$form->review", "");
|
||||||
|
helpbutton("review", get_string("allowreview","quiz"), "quiz");
|
||||||
|
?>
|
||||||
|
</TD>
|
||||||
|
</TR>
|
||||||
<TR valign=top>
|
<TR valign=top>
|
||||||
<TD align=right><P><B><? print_string("maximumgrade") ?>:</B></P></TD>
|
<TD align=right><P><B><? print_string("maximumgrade") ?>:</B></P></TD>
|
||||||
<TD>
|
<TD>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
optional_variable($q); // quiz ID
|
optional_variable($q); // quiz ID
|
||||||
|
|
||||||
optional_variable($attempt); // A particular attempt ID
|
optional_variable($attempt); // A particular attempt ID
|
||||||
|
optional_variable($review); // A particular attempt ID for review by student
|
||||||
optional_variable($regrade); // Regrade all attempts
|
optional_variable($regrade); // Regrade all attempts
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
|
@ -38,8 +39,21 @@
|
||||||
|
|
||||||
require_login($course->id);
|
require_login($course->id);
|
||||||
|
|
||||||
|
|
||||||
if (!isteacher($course->id)) {
|
if (!isteacher($course->id)) {
|
||||||
error("Only teachers can see this page");
|
if (!$quiz->review) {
|
||||||
|
error(get_string("noreview", "quiz"));
|
||||||
|
}
|
||||||
|
if (time() < $quiz->timeclose) {
|
||||||
|
error(get_string("noreviewuntil", "quiz", userdate($quiz->timeclose)));
|
||||||
|
}
|
||||||
|
if (empty($review)) {
|
||||||
|
error("You are using this script wrongly.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($review)) {
|
||||||
|
$attempt = $review;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_to_log($course->id, "quiz", "report", "report.php?id=$cm->id", "$quiz->id");
|
add_to_log($course->id, "quiz", "report", "report.php?id=$cm->id", "$quiz->id");
|
||||||
|
@ -68,12 +82,18 @@
|
||||||
|
|
||||||
print_heading($quiz->name);
|
print_heading($quiz->name);
|
||||||
|
|
||||||
if ($attempt) { // Show a particular attempt
|
if (!empty($attempt)) { // Show a particular attempt
|
||||||
|
|
||||||
if (! $attempt = get_record("quiz_attempts", "id", $attempt)) {
|
if (! $attempt = get_record("quiz_attempts", "id", $attempt)) {
|
||||||
error("No such attempt ID exists");
|
error("No such attempt ID exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isteacher($course->id)) {
|
||||||
|
if ($attempt->userid != $USER->id) {
|
||||||
|
error("This is not your attempt!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $questions = quiz_get_attempt_responses($attempt)) {
|
if (! $questions = quiz_get_attempt_responses($attempt)) {
|
||||||
error("Could not reconstruct quiz results for attempt $attempt->id!");
|
error("Could not reconstruct quiz results for attempt $attempt->id!");
|
||||||
}
|
}
|
||||||
|
@ -95,18 +115,26 @@
|
||||||
$table->data[] = array("$strgrade:", "$result->grade/$quiz->grade");
|
$table->data[] = array("$strgrade:", "$result->grade/$quiz->grade");
|
||||||
print_table($table);
|
print_table($table);
|
||||||
|
|
||||||
print_continue("report.php?q=$quiz->id");
|
if (empty($review)) {
|
||||||
|
print_continue("report.php?q=$quiz->id");
|
||||||
|
} else {
|
||||||
|
print_continue("view.php?q=$quiz->id");
|
||||||
|
}
|
||||||
|
|
||||||
$quiz->feedback = true;
|
$quiz->feedback = true;
|
||||||
$quiz->correctanswers = true;
|
$quiz->correctanswers = true;
|
||||||
quiz_print_quiz_questions($quiz, $result);
|
quiz_print_quiz_questions($quiz, $result);
|
||||||
|
|
||||||
print_continue("report.php?q=$quiz->id");
|
if (empty($review)) {
|
||||||
|
print_continue("report.php?q=$quiz->id");
|
||||||
|
} else {
|
||||||
|
print_continue("view.php?q=$quiz->id");
|
||||||
|
}
|
||||||
print_footer($course);
|
print_footer($course);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($regrade) {
|
if (!empty($regrade)) {
|
||||||
if (!$attempts = get_records("quiz_attempts", "quiz", $quiz->id)) {
|
if (!$attempts = get_records("quiz_attempts", "quiz", $quiz->id)) {
|
||||||
print_header(get_string("noattempts", "quiz"));
|
print_header(get_string("noattempts", "quiz"));
|
||||||
print_continue("report.php?id=$cm->id");
|
print_continue("report.php?id=$cm->id");
|
||||||
|
|
|
@ -96,6 +96,8 @@
|
||||||
$strgrade = get_string("grade");
|
$strgrade = get_string("grade");
|
||||||
$strbestgrade = get_string("bestgrade", "quiz");
|
$strbestgrade = get_string("bestgrade", "quiz");
|
||||||
|
|
||||||
|
$mygrade = quiz_get_best_grade($quiz->id, $USER->id);
|
||||||
|
|
||||||
if ($numattempts) {
|
if ($numattempts) {
|
||||||
$table->head = array($strattempt, $strtimetaken, $strtimecompleted, "$strgrade / $quiz->grade");
|
$table->head = array($strattempt, $strtimetaken, $strtimecompleted, "$strgrade / $quiz->grade");
|
||||||
$table->align = array("CENTER", "CENTER", "LEFT", "RIGHT");
|
$table->align = array("CENTER", "CENTER", "LEFT", "RIGHT");
|
||||||
|
@ -106,10 +108,17 @@
|
||||||
} else {
|
} else {
|
||||||
$timetaken = "-";
|
$timetaken = "-";
|
||||||
}
|
}
|
||||||
|
$attemptgrade = format_float(($attempt->sumgrades/$quiz->sumgrades)*$quiz->grade);
|
||||||
|
if ($attemptgrade == $mygrade) {
|
||||||
|
$attemptgrade = "<SPAN class=highlight>$attemptgrade</SPAN>";
|
||||||
|
}
|
||||||
|
if (!$available and $quiz->review) {
|
||||||
|
$attemptgrade = "<A HREF=\"report.php?q=$quiz->id&review=$attempt->id\">$attemptgrade</A>";
|
||||||
|
}
|
||||||
$table->data[] = array( $attempt->attempt,
|
$table->data[] = array( $attempt->attempt,
|
||||||
format_time($attempt->timefinish - $attempt->timestart),
|
format_time($attempt->timefinish - $attempt->timestart),
|
||||||
userdate($attempt->timefinish),
|
userdate($attempt->timefinish),
|
||||||
format_float(($attempt->sumgrades/$quiz->sumgrades)*$quiz->grade) );
|
$attemptgrade);
|
||||||
}
|
}
|
||||||
print_table($table);
|
print_table($table);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +131,6 @@
|
||||||
echo "<P ALIGN=CENTER>".get_string("quizclosed", "quiz", userdate($quiz->timeclose));
|
echo "<P ALIGN=CENTER>".get_string("quizclosed", "quiz", userdate($quiz->timeclose));
|
||||||
}
|
}
|
||||||
|
|
||||||
$mygrade = quiz_get_best_grade($quiz->id, $USER->id);
|
|
||||||
|
|
||||||
if (!$quiz->questions) {
|
if (!$quiz->questions) {
|
||||||
print_heading(get_string("noquestions", "quiz"));
|
print_heading(get_string("noquestions", "quiz"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue