Activity completion MDL-24746 If you turn on autocompletion for an activity after users have already done things that should complete it, it didn't mark them complete

This commit is contained in:
Sam Marshall
2010-11-08 11:51:19 +00:00
parent fc2b6316f1
commit 91d0bb0a1f
2 changed files with 11 additions and 7 deletions
+7 -7
View File
@@ -290,13 +290,7 @@ if ($mform->is_cancelled()) {
$completion = new completion_info($course);
if ($completion->is_enabled()) {
// Handle completion settings. If necessary, wipe existing completion
// data first.
if (!empty($fromform->completionunlocked)) {
$completion = new completion_info($course);
$completion->reset_all_state($cm);
}
// Update completion settings
$cm->completion = $fromform->completion;
$cm->completiongradeitemnumber = $fromform->completiongradeitemnumber;
$cm->completionview = $fromform->completionview;
@@ -340,6 +334,12 @@ if ($mform->is_cancelled()) {
set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
}
// Now that module is fully updated, also update completion data if
// required (this will wipe all user completion data and recalculate it)
if ($completion->is_enabled() && !empty($fromform->completionunlocked)) {
$completion->reset_all_state($cm);
}
// Trigger mod_updated event with information about this module.
$eventdata = new stdClass();
$eventdata->modulename = $fromform->modulename;
+4
View File
@@ -199,6 +199,10 @@ abstract class moodleform_mod extends moodleform {
if ($mform->elementExists('unlockcompletion')) {
$mform->removeElement('unlockcompletion');
}
// Automatically set to unlocked (note: this is necessary
// in order to make it recalculate completion once the option
// is changed, maybe someone has completed it now)
$mform->getElement('completionunlocked')->setValue(1);
} else {
// Has the element been unlocked?
if ($mform->exportValue('unlockcompletion')) {