MDL-31957 Course reset: Does not erase activity completion data

This commit is contained in:
sam marshall
2012-08-17 10:41:14 +01:00
parent 76c9fcc967
commit eaead2aea8
4 changed files with 32 additions and 5 deletions
+25
View File
@@ -709,6 +709,31 @@ class completion_info {
$DB->delete_records('course_completion_crit_compl', array('course' => $this->course_id));
}
/**
* Deletes all activity and course completion data for an entire course
* (the below delete_all_state function does this for a single activity).
*
* Used by course reset page.
*/
public function delete_all_completion_data() {
global $DB;
// Delete from database.
$DB->delete_records_select('course_modules_completion',
'coursemoduleid IN (SELECT id FROM {course_modules} WHERE course=?)',
array($this->course_id));
// Reset cache for current user.
if (isset($SESSION->completioncache) &&
array_key_exists($this->course_id, $SESSION->completioncache)) {
unset($SESSION->completioncache[$this->course_id]);
}
// Wipe course completion data too.
$this->delete_course_completion_data();
}
/**
* Deletes completion state related to an activity for all users.
*