mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-31957-master' of git://github.com/sammarshallou/moodle
This commit is contained in:
commit
57733008c9
@ -19,7 +19,7 @@ class course_reset_form extends moodleform {
|
||||
$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');
|
||||
|
||||
|
@ -70,7 +70,7 @@ $string['completionview'] = 'Require view';
|
||||
$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['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.)';
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -4850,12 +4850,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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user