$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';
$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';
$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>.';
$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';
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');
+ }
+}
?>
\ No newline at end of file