course-completion MDL-24145 Course reset now has option for course completion data
authorSam Hemelryk <sam@moodle.com>
Thu, 16 Sep 2010 04:14:46 +0000 (04:14 +0000)
committerSam Hemelryk <sam@moodle.com>
Thu, 16 Sep 2010 04:14:46 +0000 (04:14 +0000)
course/reset_form.php
lang/en/completion.php
lib/moodlelib.php

index 3e61c88..4b4693d 100644 (file)
@@ -18,6 +18,7 @@ class course_reset_form extends moodleform {
         $mform->addElement('checkbox', 'reset_events', get_string('deleteevents', 'calendar'));
         $mform->addElement('checkbox', 'reset_logs', get_string('deletelogs'));
         $mform->addElement('checkbox', 'reset_notes', get_string('deletenotes', 'notes'));
+        $mform->addElement('checkbox', 'reset_course_completion', get_string('deletecoursecompletiondata', 'completion'));
         $mform->addElement('checkbox', 'delete_blog_associations', get_string('deleteblogassociations', 'blog'));
         $mform->addHelpButton('delete_blog_associations', 'deleteblogassociations', 'blog');
 
index ecc447e..2d87bcc 100644 (file)
@@ -65,6 +65,7 @@ $string['completionview_desc'] = 'Student must view this activity to complete it
 $string['configenablecompletion'] = 'When enabled, this lets you turn on completion tracking (progress) features at course level.';
 $string['configprogresstrackedroles'] = 'Roles that are displayed in the progress-tracking screen. (Usually includes just students and equivalent roles.)';
 $string['csvdownload'] = 'Download in spreadsheet format (UTF-8 .csv)';
+$string['deletecoursecompletiondata'] = 'Delete course 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.)';
index 7932523..86738e0 100644 (file)
@@ -4297,6 +4297,14 @@ 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
+        $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);
+    }
+
     $componentstr = get_string('roles');
 
     if (!empty($data->reset_roles_overrides)) {