Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

… Gasset)
  • Loading branch information...
commit 035699d45939a45d9fa59f2d4bcece68ad605a40 1 parent fb59fff
gbateson authored
Showing with 33 additions and 0 deletions.
  1. +1 −0  lang/en_utf8/hotpot.php
  2. +32 −0 mod/hotpot/lib.php
View
1  lang/en_utf8/hotpot.php
@@ -22,6 +22,7 @@
$string['correct'] = 'Correct';
$string['deleteabandoned'] = 'Delete abandoned';
$string['deleteabandonedcheck'] = 'Do you really want to delete all $a abandoned attempts?';
+$string['deleteallattempts'] = 'Delete all attempts';
$string['displaycoursenext'] = 'Display Course page next';
$string['displayhotpotnext'] = 'Display Hot Potatoes quiz next';
$string['displayindexnext'] = 'Display HotPot index next';
View
32 mod/hotpot/lib.php
@@ -2434,4 +2434,36 @@ 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);
+}
+
?>
Please sign in to comment.
Something went wrong with that request. Please try again.