Permalink
Browse files

Merge branch 'MDL-31957-m22' of git://github.com/sammarshallou/moodle…

… into MOODLE_22_STABLE
  • Loading branch information...
2 parents de4c3e6 + eaead2a commit d60f8ef2db09f606f8a24245724a41a12dcc51c7 @stronk7 stronk7 committed Aug 20, 2012
Showing with 32 additions and 5 deletions.
  1. +1 −1 course/reset_form.php
  2. +1 −0 lang/en/completion.php
  3. +25 −0 lib/completionlib.php
  4. +5 −4 lib/moodlelib.php
@@ -19,7 +19,7 @@ function definition (){
$mform->addElement('checkbox', 'reset_logs', get_string('deletelogs'));
$mform->addElement('checkbox', 'reset_notes', get_string('deletenotes', 'notes'));
$mform->addElement('checkbox', 'reset_comments', get_string('deleteallcomments', 'moodle'));
- $mform->addElement('checkbox', 'reset_course_completion', get_string('deletecoursecompletiondata', 'completion'));
+ $mform->addElement('checkbox', 'reset_completion', get_string('deletecompletiondata', 'completion'));
$mform->addElement('checkbox', 'delete_blog_associations', get_string('deleteblogassociations', 'blog'));
$mform->addHelpButton('delete_blog_associations', 'deleteblogassociations', 'blog');
@@ -71,6 +71,7 @@
$string['configenablecompletion'] = 'When enabled, this lets you turn on completion tracking (progress) features at course level.';
$string['csvdownload'] = 'Download in spreadsheet format (UTF-8 .csv)';
$string['deletecoursecompletiondata'] = 'Delete course completion data';
+$string['deletecompletiondata'] = 'Delete completion data';
$string['enablecompletion'] = 'Enable completion tracking';
$string['err_noactivities'] = 'Completion information is not enabled for any activity, so none can be displayed. You can enable completion information by editing the settings for an activity.';
$string['err_nousers'] = 'There are no students on this course or group for whom completion information is displayed. (By default, completion information is displayed only for students, so if there are no students, you will see this error. Administrators can alter this option via the admin screens.)';
View
@@ -710,6 +710,31 @@ public function delete_course_completion_data() {
}
/**
+ * 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.
*
* Intended for use only when the activity itself is deleted.
View
@@ -4746,12 +4746,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');

0 comments on commit d60f8ef

Please sign in to comment.