Merge branch 'MDL-31957-m23' of git://github.com/sammarshallou/moodle into MOODLE_23_STABLE

This commit is contained in:
Eloy Lafuente (stronk7) 2012-08-21 01:23:05 +02:00
commit 0c6800e771
4 changed files with 32 additions and 5 deletions

View file

@ -711,6 +711,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.
*

View file

@ -4829,12 +4829,13 @@ function reset_course_userdata($data) {
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteblogassociations', 'blog'), 'error'=>false);
}
if (!empty($data->reset_course_completion)) {
// Delete course completion information
if (!empty($data->reset_completion)) {
// Delete course and activity completion information.
$course = $DB->get_record('course', array('id'=>$data->courseid));
$cc = new completion_info($course);
$cc->delete_course_completion_data();
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletecoursecompletiondata', 'completion'), 'error'=>false);
$cc->delete_all_completion_data();
$status[] = array('component' => $componentstr,
'item' => get_string('deletecompletiondata', 'completion'), 'error' => false);
}
$componentstr = get_string('roles');