Beispiel #1
0
     }
     error("Could not add a new instance of {$mod->modulename}", "view.php?id={$course->id}");
 }
 if (is_string($return)) {
     error($return, "view.php?id={$course->id}");
 }
 if (!isset($mod->groupmode)) {
     // to deal with pre-1.5 modules
     $mod->groupmode = $course->groupmode;
     /// Default groupmode the same as course
 }
 if (isset($mod->groupingid)) {
     set_coursemodule_groupingid($mod->coursemodule, $mod->groupingid);
 }
 if (isset($mod->groupmembersonly)) {
     set_coursemodule_groupmembersonly($mod->coursemodule, $mod->groupmembersonly);
 }
 $mod->instance = $return;
 // course_modules and course_sections each contain a reference
 // to each other, so we have to update one of them twice.
 if (!($mod->coursemodule = add_course_module($mod))) {
     error("Could not add a new course module");
 }
 if (!($sectionid = add_mod_to_section($mod))) {
     error("Could not add the new course module to that section");
 }
 if (!set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
     error("Could not update the course module with the correct section");
 }
 if (!isset($mod->visible)) {
     // We get the section's visible field status
Beispiel #2
0
 if (!empty($fromform->update)) {
     if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
         $fromform->groupmode = $cm->groupmode;
         // keep original
     }
     $returnfromfunc = $updateinstancefunction($fromform);
     if (!$returnfromfunc) {
         error("Could not update the {$fromform->modulename}", "view.php?id={$course->id}");
     }
     if (is_string($returnfromfunc)) {
         error($returnfromfunc, "view.php?id={$course->id}");
     }
     set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
     set_coursemodule_groupmode($fromform->coursemodule, $fromform->groupmode);
     set_coursemodule_groupingid($fromform->coursemodule, $fromform->groupingid);
     set_coursemodule_groupmembersonly($fromform->coursemodule, $fromform->groupmembersonly);
     if (isset($fromform->cmidnumber)) {
         //label
         // set cm idnumber
         set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
     }
     add_to_log($course->id, "course", "update mod", "../mod/{$fromform->modulename}/view.php?id={$fromform->coursemodule}", "{$fromform->modulename} {$fromform->instance}");
     add_to_log($course->id, $fromform->modulename, "update", "view.php?id={$fromform->coursemodule}", "{$fromform->instance}", $fromform->coursemodule);
 } else {
     if (!empty($fromform->add)) {
         if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
             $fromform->groupmode = 0;
             // do not set groupmode
         }
         if (!course_allowed_module($course, $fromform->modulename)) {
             error("This module ({$fromform->modulename}) has been disabled for this particular course");