Merge branch 'MDL-38315-master' of git://github.com/sammarshallou/moodle

This commit is contained in:
Damyon Wiese 2013-05-06 22:27:41 +08:00
commit 14cd6479de
8 changed files with 53 additions and 42 deletions

View File

@ -438,7 +438,7 @@ function update_moduleinfo($cm, $moduleinfo, $course, $mform = null) {
}
$completion = new completion_info($course);
if ($completion->is_enabled()) {
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
// Update completion settings.
$cm->completion = $moduleinfo->completion;
$cm->completiongradeitemnumber = $moduleinfo->completiongradeitemnumber;

View File

@ -312,8 +312,11 @@ abstract class moodleform_mod extends moodleform {
}
// Completion: Don't let them choose automatic completion without turning
// on some conditions
if (array_key_exists('completion', $data) && $data['completion']==COMPLETION_TRACKING_AUTOMATIC) {
// on some conditions. Ignore this check when completion settings are
// locked, as the options are then disabled.
if (array_key_exists('completion', $data) &&
$data['completion'] == COMPLETION_TRACKING_AUTOMATIC &&
!empty($data['completionunlocked'])) {
if (empty($data['completionview']) && empty($data['completionusegrade']) &&
!$this->completion_rule_enabled($data)) {
$errors['completion'] = get_string('badautocompletion', 'completion');

View File

@ -846,7 +846,9 @@ class assign {
$update->cutoffdate = $formdata->cutoffdate;
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
$update->grade = $formdata->grade;
$update->completionsubmit = !empty($formdata->completionsubmit);
if (!empty($formdata->completionunlocked)) {
$update->completionsubmit = !empty($formdata->completionsubmit);
}
$update->teamsubmission = $formdata->teamsubmission;
$update->requireallteammemberssubmit = $formdata->requireallteammemberssubmit;
$update->teamsubmissiongroupingid = $formdata->teamsubmissiongroupingid;

View File

@ -123,8 +123,10 @@ class mod_choice_mod_form extends moodleform_mod {
return false;
}
// Set up completion section even if checkbox is not ticked
if (empty($data->completionsection)) {
$data->completionsection=0;
if (!empty($data->completionunlocked)) {
if (empty($data->completionsubmit)) {
$data->completionsubmit = 0;
}
}
return $data;
}

View File

@ -197,14 +197,13 @@ class mod_feedback_mod_form extends moodleform_mod {
$data->page_after_submitformat = $data->page_after_submit_editor['format'];
$data->page_after_submit = $data->page_after_submit_editor['text'];
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = !empty($data->completion) AND
$data->completion==COMPLETION_TRACKING_AUTOMATIC;
if (empty($data->completion) || !$autocompletion) {
$data->completionsubmit=0;
}
if (empty($data->completionsubmit)) {
$data->completionsubmit=0;
if (!empty($data->completionunlocked)) {
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = !empty($data->completion) &&
$data->completion == COMPLETION_TRACKING_AUTOMATIC;
if (!$autocompletion || empty($data->completionsubmit)) {
$data->completionsubmit=0;
}
}
}

View File

@ -245,15 +245,17 @@ class mod_forum_mod_form extends moodleform_mod {
return false;
}
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
$data->completiondiscussions = 0;
}
if (empty($data->completionrepliesenabled) || !$autocompletion) {
$data->completionreplies = 0;
}
if (empty($data->completionpostsenabled) || !$autocompletion) {
$data->completionposts = 0;
if (!empty($data->completionunlocked)) {
$autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
$data->completiondiscussions = 0;
}
if (empty($data->completionrepliesenabled) || !$autocompletion) {
$data->completionreplies = 0;
}
if (empty($data->completionpostsenabled) || !$autocompletion) {
$data->completionposts = 0;
}
}
return $data;
}

View File

@ -205,10 +205,12 @@ class mod_glossary_mod_form extends moodleform_mod {
if (!$data) {
return false;
}
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
if (empty($data->completionentriesenabled) || !$autocompletion) {
$data->completionentries = 0;
if (!empty($data->completionunlocked)) {
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
if (empty($data->completionentriesenabled) || !$autocompletion) {
$data->completionentries = 0;
}
}
return $data;
}

View File

@ -520,24 +520,25 @@ class mod_scorm_mod_form extends moodleform_mod {
return false;
}
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
if (!empty($data->completionunlocked)) {
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
if (isset($data->completionstatusrequired) && is_array($data->completionstatusrequired)) {
$total = 0;
foreach (array_keys($data->completionstatusrequired) as $state) {
$total |= $state;
if (isset($data->completionstatusrequired) &&
is_array($data->completionstatusrequired) && $autocompletion) {
$total = 0;
foreach (array_keys($data->completionstatusrequired) as $state) {
$total |= $state;
}
$data->completionstatusrequired = $total;
} else {
$data->completionstatusrequired = null;
}
$data->completionstatusrequired = $total;
}
if (!$autocompletion) {
$data->completionstatusrequired = null;
}
if (!empty($data->completionscoredisabled) || !$autocompletion) {
$data->completionscorerequired = null;
if (!empty($data->completionscoredisabled) || !$autocompletion) {
$data->completionscorerequired = null;
}
}
return $data;