]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15869: Fixed bug in saving module settings when completion is not enabled
authorsam_marshall <sam_marshall>
Tue, 29 Jul 2008 09:13:25 +0000 (09:13 +0000)
committersam_marshall <sam_marshall>
Tue, 29 Jul 2008 09:13:25 +0000 (09:13 +0000)
course/modedit.php

index 7aafb578378444bdab82e6116dc54d838274f7fc..65fe91495d753375172e17d4862a0ff93d769821 100644 (file)
             set_coursemodule_groupingid($fromform->coursemodule, $fromform->groupingid);
             set_coursemodule_groupmembersonly($fromform->coursemodule, $fromform->groupmembersonly);
 
-            // Handle completion settings. If necessary, wipe existing completion
-            // data first.
-            if(!empty($fromform->completionunlocked)) {
-                $completion=new completion_info($course);
-                $completion->reset_all_state($cm);
+            require_once($CFG->libdir.'/completionlib.php');
+            $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);
+                }
+                set_coursemodule_completion($fromform->coursemodule, $fromform->completion);
+                set_coursemodule_completionview($fromform->coursemodule, $fromform->completionview);
+                set_coursemodule_completionexpected($fromform->coursemodule, $fromform->completionexpected);
+                set_coursemodule_completiongradeitemnumber(
+                        $fromform->coursemodule,$fromform->completiongradeitemnumber);
             }
-            set_coursemodule_completion($fromform->coursemodule, $fromform->completion);
-            set_coursemodule_completionview($fromform->coursemodule, $fromform->completionview);
-            set_coursemodule_completionexpected($fromform->coursemodule, $fromform->completionexpected);
-            set_coursemodule_completiongradeitemnumber(
-                    $fromform->coursemodule,$fromform->completiongradeitemnumber);
 
             if (isset($fromform->cmidnumber)) { //label
                 // set cm idnumber