Skip to content

Commit

Permalink
MDL-17679: implement course reset for HotPot module (thanks to Albert…
Browse files Browse the repository at this point in the history
… Gasset)
  • Loading branch information
gbateson committed Jan 27, 2009
1 parent d45bbc5 commit e260bf1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lang/en_utf8/hotpot.php
Expand Up @@ -203,4 +203,6 @@


// error messages (attempt.php) // error messages (attempt.php)
$string['error_invalidquiztype'] = 'Quiz type is missing or invalid'; $string['error_invalidquiztype'] = 'Quiz type is missing or invalid';

$string['deleteallattempts'] = 'Delete all attempts';
?> ?>
30 changes: 30 additions & 0 deletions mod/hotpot/lib.php
Expand Up @@ -2433,5 +2433,35 @@ function getDir(s) {
} }
print '<span class="helplink">'.$html.'</span>'; 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.