Permalink
Browse files

MDL-17679: implement course reset for HotPot module (thanks to Albert…

… Gasset)
  • Loading branch information...
gbateson
gbateson committed Jan 27, 2009
1 parent d45bbc5 commit e260bf1c122737b07b7ca38a29483ec3505617da
Showing with 32 additions and 0 deletions.
  1. +2 −0 lang/en_utf8/hotpot.php
  2. +30 −0 mod/hotpot/lib.php
View
@@ -203,4 +203,6 @@
// error messages (attempt.php)
$string['error_invalidquiztype'] = 'Quiz type is missing or invalid';
+
+$string['deleteallattempts'] = 'Delete all attempts';
?>
View
@@ -2433,5 +2433,35 @@ function getDir(s) {
}
print '<span class="helplink">'.$html.'</span>';
}
+/**
+ * Called by course/reset.php
+ * @param $mform form passed by reference
+ */
+function hotpot_reset_course_form($course) {
+ print_checkbox('reset_hotpot_deleteallattempts', 1, true, get_string('deleteallattempts', 'hotpot'), '', ''); echo '<br />';
+}
+function hotpot_delete_userdata($data, $showfeedback=true) {
+ global $CFG;
+
+ if (!empty($data->reset_hotpot_deleteallattempts)) {
+ $hotpotids = "SELECT h.id FROM {$CFG->prefix}hotpot h WHERE h.course={$data->courseid}";
+ $attemptids = "SELECT a.id FROM {$CFG->prefix}hotpot_attempts a WHERE a.hotpot in ($hotpotids)";
+
+ delete_records_select('hotpot_responses', "attempt in ($attemptids)");
+ delete_records_select('hotpot_details', "attempt in ($attemptids)");
+ delete_records_select('hotpot_attempts', "hotpot IN ($hotpotids)");
+
+ if ($showfeedback) {
+ notify(get_string('reset').': '.get_string('modulenameplural', 'hotpot'), 'notifysuccess');
+ }
+ }
+}
+
+/**
+ * Course reset form defaults.
+ */
+function hotpot_reset_course_form_defaults($course) {
+ return array('reset_hotpot_deleteallattempts' => 1);
+}
?>

0 comments on commit e260bf1

Please sign in to comment.