Skip to content

Commit

Permalink
Activity completion MDL-24746 If you turn on autocompletion for an ac…
Browse files Browse the repository at this point in the history
…tivity after users have already done things that should complete it, it didn't mark them complete
  • Loading branch information
sammarshallou committed Nov 8, 2010
1 parent fc2b631 commit 91d0bb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions course/modedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,7 @@

$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;
Expand Down Expand Up @@ -340,6 +334,12 @@
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;
Expand Down
4 changes: 4 additions & 0 deletions course/moodleform_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ function definition_after_data() {
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')) {
Expand Down

0 comments on commit 91d0bb0

Please sign in to comment.