MDL-6043 - Implement course reset function for quizzes.

This commit is contained in:
tjhunt
2007-06-19 22:17:47 +00:00
parent b069fbd9b3
commit 7a6f4066ce
2 changed files with 57 additions and 0 deletions
+4
View File
@@ -45,6 +45,7 @@ $string['attemptlast'] = 'Last attempt';
$string['attemptquiznow'] = 'Attempt quiz now';
$string['attempts'] = 'Attempts';
$string['attemptsallowed'] = 'Attempts allowed';
$string['attemptsdeleted'] = 'Quiz attempts deleted';
$string['attemptselection'] = 'Select which attempts to analyze per user:';
$string['attemptsexist'] = 'You can no longer add or remove questions.';
$string['attemptsonly'] = 'Show only students with attempts';
@@ -132,6 +133,7 @@ $string['deleteattemptcheck'] = 'Are you absolutely sure you want to completely
$string['deletequestioncheck'] = 'Are you absolutely sure you want to delete \'$a\'?';
$string['deletequestionscheck'] = 'Are you absolutely sure you want to delete the following questions?<br /><br />$a';
$string['deleteselected'] = 'Delete selected';
$string['deletingquestionattempts'] = 'Deleting question attempts';
$string['description'] = 'Description';
$string['discrimination'] = 'Discrim. Index';
$string['displayoptions'] = 'Display options';
@@ -227,6 +229,7 @@ $string['gradeboundary'] = 'Grade boundary';
$string['gradeessays'] = 'Grade Essays';
$string['gradehighest'] = 'Highest grade';
$string['grademethod'] = 'Grading method';
$string['gradesdeleted'] = 'Quiz grades deleted';
$string['gradesofar'] = '$a->method: $a->mygrade / $a->quizgrade.';
$string['gradingdetails'] = 'Marks for this submission: $a->raw/$a->max.';
$string['gradingdetailsadjustment'] = 'With previous penalties this gives <strong>$a->cur/$a->max</strong>.';
@@ -411,6 +414,7 @@ $string['regradingquestion'] = 'Regrading \"$a\".';
$string['regradingquiz'] = 'Regrading Quiz \"$a\"';
$string['relative'] = 'Relative';
$string['remove'] = 'Remove';
$string['removeallquizattempts'] = 'Remove all quiz attempts';
$string['rename'] = 'Rename';
$string['renderingserverconnectfailed'] = 'The server $a failed to process an RQP request. Check that the URL is correct.';
$string['reordertool'] = 'Show the reordering tool';
+53
View File
@@ -813,4 +813,57 @@ function quiz_question_list_instances($questionid) {
return array();
}
/**
* Implementation of the function for printing the form elements that control
* whether the course reset functionality affects the quiz.
* @param $course The course id of the course the user is thinking of resetting.
*/
function quiz_reset_course_form($course) {
echo '<p>';
print_checkbox('reset_quiz_attempts', 1, true, get_string('removeallquizattempts','quiz'));
echo '</p>';
}
/**
* Actual implementation of the rest coures functionality, delete all the
* quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is
* set and true.
* @param $data the data submitted from the reset course forum.
* @param $showfeedback whether to output progress information as the reset
* progresses.
*/
function quiz_delete_userdata($data, $showfeedback=true) {
global $CFG;
if (empty($data->reset_quiz_attempts)) {
return;
}
$conditiononquizids = 'quiz IN (SELECT id FROM ' .
$CFG->prefix . 'quiz q WHERE q.course = ' . $data->courseid . ')';
$attemptids = get_records_select('quiz_attempts', $conditiononquizids, '', 'id, uniqueid');
if ($attemptids) {
if ($showfeedback) {
echo '<div class="notifysuccess">', get_string('deletingquestionattempts', 'quiz');
$divider = ': ';
}
foreach ($attemptids as $attemptid) {
delete_attempt($attemptid->uniqueid);
if ($showfeedback) {
echo $divider, $attemptid->uniqueid;
$divider = ', ';
}
}
if ($showfeedback) {
echo "</div><br />\n";
}
}
if (delete_records_select('quiz_grades', $conditiononquizids) && $showfeedback) {
notify(get_string('gradesdeleted','quiz'), 'notifysuccess');
}
if (delete_records_select('quiz_attempts', $conditiononquizids) && $showfeedback) {
notify(get_string('attemptsdeleted','quiz'), 'notifysuccess');
}
}
?>