From 9ddbd4459839481d53654412fcecc5f823295618 Mon Sep 17 00:00:00 2001 From: sam_marshall Date: Tue, 29 Jul 2008 09:13:25 +0000 Subject: [PATCH] MDL-15869: Fixed bug in saving module settings when completion is not enabled --- course/modedit.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/course/modedit.php b/course/modedit.php index 7aafb57837..65fe91495d 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -279,17 +279,21 @@ 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 -- 2.39.5