3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Adds or updates modules in a course using new formslib
22 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require_once("../config.php");
27 require_once("lib.php");
28 require_once($CFG->libdir
.'/filelib.php');
29 require_once($CFG->libdir
.'/gradelib.php');
30 require_once($CFG->libdir
.'/completionlib.php');
31 require_once($CFG->libdir
.'/conditionlib.php');
32 require_once($CFG->libdir
.'/plagiarismlib.php');
34 $add = optional_param('add', '', PARAM_ALPHA
); // module name
35 $update = optional_param('update', 0, PARAM_INT
);
36 $return = optional_param('return', 0, PARAM_BOOL
); //return to course/view.php if false or mod/modname/view.php if true
37 $type = optional_param('type', '', PARAM_ALPHANUM
); //TODO: hopefully will be removed in 2.0
38 $sectionreturn = optional_param('sr', null, PARAM_INT
);
40 $url = new moodle_url('/course/modedit.php');
41 $url->param('sr', $sectionreturn);
42 if (!empty($return)) {
43 $url->param('return', $return);
47 $section = required_param('section', PARAM_INT
);
48 $course = required_param('course', PARAM_INT
);
50 $url->param('add', $add);
51 $url->param('section', $section);
52 $url->param('course', $course);
55 $course = $DB->get_record('course', array('id'=>$course), '*', MUST_EXIST
);
56 $module = $DB->get_record('modules', array('name'=>$add), '*', MUST_EXIST
);
58 require_login($course);
59 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
60 require_capability('moodle/course:manageactivities', $context);
62 $cw = get_course_section($section, $course->id
);
64 if (!course_allowed_module($course, $module->name
)) {
65 print_error('moduledisable');
70 $data = new stdClass();
71 $data->section
= $section; // The section number itself - relative!!! (section column in course_sections)
72 $data->visible
= $cw->visible
;
73 $data->course
= $course->id
;
74 $data->module
= $module->id
;
75 $data->modulename
= $module->name
;
76 $data->groupmode
= $course->groupmode
;
77 $data->groupingid
= $course->defaultgroupingid
;
78 $data->groupmembersonly
= 0;
81 $data->coursemodule
= '';
83 $data->return = 0; //must be false if this is an add, go back to course view on cancel
84 $data->sr
= $sectionreturn;
86 if (plugin_supports('mod', $data->modulename
, FEATURE_MOD_INTRO
, true)) {
87 $draftid_editor = file_get_submitted_draft_itemid('introeditor');
88 file_prepare_draft_area($draftid_editor, null, null, null, null);
89 $data->introeditor
= array('text'=>'', 'format'=>FORMAT_HTML
, 'itemid'=>$draftid_editor); // TODO: add better default
92 if (plugin_supports('mod', $data->modulename
, FEATURE_ADVANCED_GRADING
, false)
93 and has_capability('moodle/grade:managegradingforms', $context)) {
94 require_once($CFG->dirroot
.'/grade/grading/lib.php');
96 $data->_advancedgradingdata
['methods'] = grading_manager
::available_methods();
97 $areas = grading_manager
::available_areas('mod_'.$module->name
);
99 foreach ($areas as $areaname => $areatitle) {
100 $data->_advancedgradingdata
['areas'][$areaname] = array(
101 'title' => $areatitle,
104 $formfield = 'advancedgradingmethod_'.$areaname;
105 $data->{$formfield} = '';
109 if (!empty($type)) { //TODO: hopefully will be removed in 2.0
113 $sectionname = get_section_name($course, $cw);
114 $fullmodulename = get_string('modulename', $module->name
);
116 if ($data->section
&& $course->format
!= 'site') {
117 $heading = new stdClass();
118 $heading->what
= $fullmodulename;
119 $heading->to
= $sectionname;
120 $pageheading = get_string('addinganewto', 'moodle', $heading);
122 $pageheading = get_string('addinganew', 'moodle', $fullmodulename);
125 } else if (!empty($update)) {
127 $url->param('update', $update);
128 $PAGE->set_url($url);
130 $cm = get_coursemodule_from_id('', $update, 0, false, MUST_EXIST
);
131 $course = $DB->get_record('course', array('id'=>$cm->course
), '*', MUST_EXIST
);
133 require_login($course, false, $cm); // needed to setup proper $COURSE
134 $context = get_context_instance(CONTEXT_MODULE
, $cm->id
);
135 require_capability('moodle/course:manageactivities', $context);
137 $module = $DB->get_record('modules', array('id'=>$cm->module
), '*', MUST_EXIST
);
138 $data = $data = $DB->get_record($module->name
, array('id'=>$cm->instance
), '*', MUST_EXIST
);
139 $cw = $DB->get_record('course_sections', array('id'=>$cm->section
), '*', MUST_EXIST
);
141 $data->coursemodule
= $cm->id
;
142 $data->section
= $cw->section
; // The section number itself - relative!!! (section column in course_sections)
143 $data->visible
= $cm->visible
; //?? $cw->visible ? $cm->visible : 0; // section hiding overrides
144 $data->cmidnumber
= $cm->idnumber
; // The cm IDnumber
145 $data->groupmode
= groups_get_activity_groupmode($cm); // locked later if forced
146 $data->groupingid
= $cm->groupingid
;
147 $data->groupmembersonly
= $cm->groupmembersonly
;
148 $data->course
= $course->id
;
149 $data->module
= $module->id
;
150 $data->modulename
= $module->name
;
151 $data->instance
= $cm->instance
;
152 $data->return = $return;
153 $data->sr
= $sectionreturn;
154 $data->update
= $update;
155 $data->completion
= $cm->completion
;
156 $data->completionview
= $cm->completionview
;
157 $data->completionexpected
= $cm->completionexpected
;
158 $data->completionusegrade
= is_null($cm->completiongradeitemnumber
) ?
0 : 1;
159 $data->showdescription
= $cm->showdescription
;
160 if (!empty($CFG->enableavailability
)) {
161 $data->availablefrom
= $cm->availablefrom
;
162 $data->availableuntil
= $cm->availableuntil
;
163 $data->showavailability
= $cm->showavailability
;
166 if (plugin_supports('mod', $data->modulename
, FEATURE_MOD_INTRO
, true)) {
167 $draftid_editor = file_get_submitted_draft_itemid('introeditor');
168 $currentintro = file_prepare_draft_area($draftid_editor, $context->id
, 'mod_'.$data->modulename
, 'intro', 0, array('subdirs'=>true), $data->intro
);
169 $data->introeditor
= array('text'=>$currentintro, 'format'=>$data->introformat
, 'itemid'=>$draftid_editor);
172 if (plugin_supports('mod', $data->modulename
, FEATURE_ADVANCED_GRADING
, false)
173 and has_capability('moodle/grade:managegradingforms', $context)) {
174 require_once($CFG->dirroot
.'/grade/grading/lib.php');
175 $gradingman = get_grading_manager($context, 'mod_'.$data->modulename
);
176 $data->_advancedgradingdata
['methods'] = $gradingman->get_available_methods();
177 $areas = $gradingman->get_available_areas();
179 foreach ($areas as $areaname => $areatitle) {
180 $gradingman->set_area($areaname);
181 $method = $gradingman->get_active_method();
182 $data->_advancedgradingdata
['areas'][$areaname] = array(
183 'title' => $areatitle,
186 $formfield = 'advancedgradingmethod_'.$areaname;
187 $data->{$formfield} = $method;
191 if ($items = grade_item
::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$data->modulename
,
192 'iteminstance'=>$data->instance
, 'courseid'=>$course->id
))) {
193 // add existing outcomes
194 foreach ($items as $item) {
195 if (!empty($item->outcomeid
)) {
196 $data->{'outcome_'.$item->outcomeid
} = 1;
200 // set category if present
202 foreach ($items as $item) {
203 if ($gradecat === false) {
204 $gradecat = $item->categoryid
;
207 if ($gradecat != $item->categoryid
) {
213 if ($gradecat !== false) {
214 // do not set if mixed categories present
215 $data->gradecat
= $gradecat;
219 $sectionname = get_section_name($course, $cw);
220 $fullmodulename = get_string('modulename', $module->name
);
222 if ($data->section
&& $course->format
!= 'site') {
223 $heading = new stdClass();
224 $heading->what
= $fullmodulename;
225 $heading->in
= $sectionname;
226 $pageheading = get_string('updatingain', 'moodle', $heading);
228 $pageheading = get_string('updatinga', 'moodle', $fullmodulename);
233 print_error('invalidaction');
236 $pagepath = 'mod-' . $module->name
. '-';
237 if (!empty($type)) { //TODO: hopefully will be removed in 2.0
242 $PAGE->set_pagetype($pagepath);
243 $PAGE->set_pagelayout('admin');
245 $modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
246 if (file_exists($modmoodleform)) {
247 require_once($modmoodleform);
249 print_error('noformdesc');
252 $modlib = "$CFG->dirroot/mod/$module->name/lib.php";
253 if (file_exists($modlib)) {
254 include_once($modlib);
256 print_error('modulemissingcode', '', '', $modlib);
259 $mformclassname = 'mod_'.$module->name
.'_mod_form';
260 $mform = new $mformclassname($data, $cw->section
, $cm, $course);
261 $mform->set_data($data);
263 if ($mform->is_cancelled()) {
264 if ($return && !empty($cm->id
)) {
265 redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id");
267 redirect(course_get_url($course, $cw->section
, array('sr' => $sectionreturn)));
269 } else if ($fromform = $mform->get_data()) {
270 if (empty($fromform->coursemodule
)) {
273 $course = $DB->get_record('course', array('id'=>$fromform->course
), '*', MUST_EXIST
);
274 $fromform->instance
= '';
275 $fromform->coursemodule
= '';
278 $cm = get_coursemodule_from_id('', $fromform->coursemodule
, 0, false, MUST_EXIST
);
279 $course = $DB->get_record('course', array('id'=>$cm->course
), '*', MUST_EXIST
);
280 $fromform->instance
= $cm->instance
;
281 $fromform->coursemodule
= $cm->id
;
284 if (!empty($fromform->coursemodule
)) {
285 $context = get_context_instance(CONTEXT_MODULE
, $fromform->coursemodule
);
287 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
290 $fromform->course
= $course->id
;
291 $fromform->modulename
= clean_param($fromform->modulename
, PARAM_PLUGIN
); // For safety
293 $addinstancefunction = $fromform->modulename
."_add_instance";
294 $updateinstancefunction = $fromform->modulename
."_update_instance";
296 if (!isset($fromform->groupingid
)) {
297 $fromform->groupingid
= 0;
300 if (!isset($fromform->groupmembersonly
)) {
301 $fromform->groupmembersonly
= 0;
304 if (!isset($fromform->name
)) { //label
305 $fromform->name
= $fromform->modulename
;
308 if (!isset($fromform->completion
)) {
309 $fromform->completion
= COMPLETION_DISABLED
;
311 if (!isset($fromform->completionview
)) {
312 $fromform->completionview
= COMPLETION_VIEW_NOT_REQUIRED
;
315 // Convert the 'use grade' checkbox into a grade-item number: 0 if
316 // checked, null if not
317 if (isset($fromform->completionusegrade
) && $fromform->completionusegrade
) {
318 $fromform->completiongradeitemnumber
= 0;
320 $fromform->completiongradeitemnumber
= null;
323 // the type of event to trigger (mod_created/mod_updated)
326 if (!empty($fromform->update
)) {
328 if (!empty($course->groupmodeforce
) or !isset($fromform->groupmode
)) {
329 $fromform->groupmode
= $cm->groupmode
; // keep original
332 // update course module first
333 $cm->groupmode
= $fromform->groupmode
;
334 $cm->groupingid
= $fromform->groupingid
;
335 $cm->groupmembersonly
= $fromform->groupmembersonly
;
337 $completion = new completion_info($course);
338 if ($completion->is_enabled()) {
339 // Update completion settings
340 $cm->completion
= $fromform->completion
;
341 $cm->completiongradeitemnumber
= $fromform->completiongradeitemnumber
;
342 $cm->completionview
= $fromform->completionview
;
343 $cm->completionexpected
= $fromform->completionexpected
;
345 if (!empty($CFG->enableavailability
)) {
346 $cm->availablefrom
= $fromform->availablefrom
;
347 $cm->availableuntil
= $fromform->availableuntil
;
348 $cm->showavailability
= $fromform->showavailability
;
349 condition_info
::update_cm_from_form($cm,$fromform,true);
351 if (isset($fromform->showdescription
)) {
352 $cm->showdescription
= $fromform->showdescription
;
354 $cm->showdescription
= 0;
357 $DB->update_record('course_modules', $cm);
359 $modcontext = get_context_instance(CONTEXT_MODULE
, $fromform->coursemodule
);
361 // update embedded links and save files
362 if (plugin_supports('mod', $fromform->modulename
, FEATURE_MOD_INTRO
, true)) {
363 $fromform->intro
= file_save_draft_area_files($fromform->introeditor
['itemid'], $modcontext->id
,
364 'mod_'.$fromform->modulename
, 'intro', 0,
365 array('subdirs'=>true), $fromform->introeditor
['text']);
366 $fromform->introformat
= $fromform->introeditor
['format'];
367 unset($fromform->introeditor
);
370 if (!$updateinstancefunction($fromform, $mform)) {
371 print_error('cannotupdatemod', '', course_get_url($course, $cw->section
), $fromform->modulename
);
374 // make sure visibility is set correctly (in particular in calendar)
375 if (has_capability('moodle/course:activityvisibility', $modcontext)) {
376 set_coursemodule_visible($fromform->coursemodule
, $fromform->visible
);
379 if (isset($fromform->cmidnumber
)) { //label
380 // set cm idnumber - uniqueness is already verified by form validation
381 set_coursemodule_idnumber($fromform->coursemodule
, $fromform->cmidnumber
);
384 // Now that module is fully updated, also update completion data if
385 // required (this will wipe all user completion data and recalculate it)
386 if ($completion->is_enabled() && !empty($fromform->completionunlocked
)) {
387 $completion->reset_all_state($cm);
390 $eventname = 'mod_updated';
392 add_to_log($course->id
, "course", "update mod",
393 "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
394 "$fromform->modulename $fromform->instance");
395 add_to_log($course->id
, $fromform->modulename
, "update",
396 "view.php?id=$fromform->coursemodule",
397 "$fromform->instance", $fromform->coursemodule
);
399 } else if (!empty($fromform->add
)) {
401 if (!empty($course->groupmodeforce
) or !isset($fromform->groupmode
)) {
402 $fromform->groupmode
= 0; // do not set groupmode
405 if (!course_allowed_module($course, $fromform->modulename
)) {
406 print_error('moduledisable', '', '', $fromform->modulename
);
409 // first add course_module record because we need the context
410 $newcm = new stdClass();
411 $newcm->course
= $course->id
;
412 $newcm->module
= $fromform->module
;
413 $newcm->instance
= 0; // not known yet, will be updated later (this is similar to restore code)
414 $newcm->visible
= $fromform->visible
;
415 $newcm->groupmode
= $fromform->groupmode
;
416 $newcm->groupingid
= $fromform->groupingid
;
417 $newcm->groupmembersonly
= $fromform->groupmembersonly
;
418 $completion = new completion_info($course);
419 if ($completion->is_enabled()) {
420 $newcm->completion
= $fromform->completion
;
421 $newcm->completiongradeitemnumber
= $fromform->completiongradeitemnumber
;
422 $newcm->completionview
= $fromform->completionview
;
423 $newcm->completionexpected
= $fromform->completionexpected
;
425 if(!empty($CFG->enableavailability
)) {
426 $newcm->availablefrom
= $fromform->availablefrom
;
427 $newcm->availableuntil
= $fromform->availableuntil
;
428 $newcm->showavailability
= $fromform->showavailability
;
430 if (isset($fromform->showdescription
)) {
431 $newcm->showdescription
= $fromform->showdescription
;
433 $newcm->showdescription
= 0;
436 if (!$fromform->coursemodule
= add_course_module($newcm)) {
437 print_error('cannotaddcoursemodule');
440 if (plugin_supports('mod', $fromform->modulename
, FEATURE_MOD_INTRO
, true)) {
441 $introeditor = $fromform->introeditor
;
442 unset($fromform->introeditor
);
443 $fromform->intro
= $introeditor['text'];
444 $fromform->introformat
= $introeditor['format'];
447 $returnfromfunc = $addinstancefunction($fromform, $mform);
449 if (!$returnfromfunc or !is_number($returnfromfunc)) {
450 // undo everything we can
451 $modcontext = get_context_instance(CONTEXT_MODULE
, $fromform->coursemodule
);
452 delete_context(CONTEXT_MODULE
, $fromform->coursemodule
);
453 $DB->delete_records('course_modules', array('id'=>$fromform->coursemodule
));
455 if (!is_number($returnfromfunc)) {
456 print_error('invalidfunction', '', course_get_url($course, $cw->section
));
458 print_error('cannotaddnewmodule', '', course_get_url($course, $cw->section
), $fromform->modulename
);
462 $fromform->instance
= $returnfromfunc;
464 $DB->set_field('course_modules', 'instance', $returnfromfunc, array('id'=>$fromform->coursemodule
));
466 // update embedded links and save files
467 $modcontext = get_context_instance(CONTEXT_MODULE
, $fromform->coursemodule
);
468 if (!empty($introeditor)) {
469 $fromform->intro
= file_save_draft_area_files($introeditor['itemid'], $modcontext->id
,
470 'mod_'.$fromform->modulename
, 'intro', 0,
471 array('subdirs'=>true), $introeditor['text']);
472 $DB->set_field($fromform->modulename
, 'intro', $fromform->intro
, array('id'=>$fromform->instance
));
475 // course_modules and course_sections each contain a reference
476 // to each other, so we have to update one of them twice.
477 $sectionid = add_mod_to_section($fromform);
479 $DB->set_field('course_modules', 'section', $sectionid, array('id'=>$fromform->coursemodule
));
481 // make sure visibility is set correctly (in particular in calendar)
482 // note: allow them to set it even without moodle/course:activityvisibility
483 set_coursemodule_visible($fromform->coursemodule
, $fromform->visible
);
485 if (isset($fromform->cmidnumber
)) { //label
486 // set cm idnumber - uniqueness is already verified by form validation
487 set_coursemodule_idnumber($fromform->coursemodule
, $fromform->cmidnumber
);
491 if ($CFG->enableavailability
) {
492 condition_info
::update_cm_from_form((object)array('id'=>$fromform->coursemodule
), $fromform, false);
495 $eventname = 'mod_created';
497 add_to_log($course->id
, "course", "add mod",
498 "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
499 "$fromform->modulename $fromform->instance");
500 add_to_log($course->id
, $fromform->modulename
, "add",
501 "view.php?id=$fromform->coursemodule",
502 "$fromform->instance", $fromform->coursemodule
);
504 print_error('invaliddata');
507 // Trigger mod_created/mod_updated event with information about this module.
508 $eventdata = new stdClass();
509 $eventdata->modulename
= $fromform->modulename
;
510 $eventdata->name
= $fromform->name
;
511 $eventdata->cmid
= $fromform->coursemodule
;
512 $eventdata->courseid
= $course->id
;
513 $eventdata->userid
= $USER->id
;
514 events_trigger($eventname, $eventdata);
516 // sync idnumber with grade_item
517 if ($grade_item = grade_item
::fetch(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename
,
518 'iteminstance'=>$fromform->instance
, 'itemnumber'=>0, 'courseid'=>$course->id
))) {
519 if ($grade_item->idnumber
!= $fromform->cmidnumber
) {
520 $grade_item->idnumber
= $fromform->cmidnumber
;
521 $grade_item->update();
525 $items = grade_item
::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename
,
526 'iteminstance'=>$fromform->instance
, 'courseid'=>$course->id
));
528 // create parent category if requested and move to correct parent category
529 if ($items and isset($fromform->gradecat
)) {
530 if ($fromform->gradecat
== -1) {
531 $grade_category = new grade_category();
532 $grade_category->courseid
= $course->id
;
533 $grade_category->fullname
= $fromform->name
;
534 $grade_category->insert();
536 $parent = $grade_item->get_parent_category();
537 $grade_category->set_parent($parent->id
);
539 $fromform->gradecat
= $grade_category->id
;
541 foreach ($items as $itemid=>$unused) {
542 $items[$itemid]->set_parent($fromform->gradecat
);
543 if ($itemid == $grade_item->id
) {
544 // use updated grade_item
545 $grade_item = $items[$itemid];
550 // add outcomes if requested
551 if ($outcomes = grade_outcome
::fetch_all_available($course->id
)) {
552 $grade_items = array();
554 // Outcome grade_item.itemnumber start at 1000, there is nothing above outcomes
555 $max_itemnumber = 999;
557 foreach($items as $item) {
558 if ($item->itemnumber
> $max_itemnumber) {
559 $max_itemnumber = $item->itemnumber
;
564 foreach($outcomes as $outcome) {
565 $elname = 'outcome_'.$outcome->id
;
567 if (property_exists($fromform, $elname) and $fromform->$elname) {
568 // so we have a request for new outcome grade item?
570 foreach($items as $item) {
571 if ($item->outcomeid
== $outcome->id
) {
572 //outcome aready exists
580 $outcome_item = new grade_item();
581 $outcome_item->courseid
= $course->id
;
582 $outcome_item->itemtype
= 'mod';
583 $outcome_item->itemmodule
= $fromform->modulename
;
584 $outcome_item->iteminstance
= $fromform->instance
;
585 $outcome_item->itemnumber
= $max_itemnumber;
586 $outcome_item->itemname
= $outcome->fullname
;
587 $outcome_item->outcomeid
= $outcome->id
;
588 $outcome_item->gradetype
= GRADE_TYPE_SCALE
;
589 $outcome_item->scaleid
= $outcome->scaleid
;
590 $outcome_item->insert();
592 // move the new outcome into correct category and fix sortorder if needed
594 $outcome_item->set_parent($grade_item->categoryid
);
595 $outcome_item->move_after_sortorder($grade_item->sortorder
);
597 } else if (isset($fromform->gradecat
)) {
598 $outcome_item->set_parent($fromform->gradecat
);
604 if (plugin_supports('mod', $fromform->modulename
, FEATURE_ADVANCED_GRADING
, false)
605 and has_capability('moodle/grade:managegradingforms', $modcontext)) {
606 require_once($CFG->dirroot
.'/grade/grading/lib.php');
607 $gradingman = get_grading_manager($modcontext, 'mod_'.$fromform->modulename
);
608 $showgradingmanagement = false;
609 foreach ($gradingman->get_available_areas() as $areaname => $aretitle) {
610 $formfield = 'advancedgradingmethod_'.$areaname;
611 if (isset($fromform->{$formfield})) {
612 $gradingman->set_area($areaname);
613 $methodchanged = $gradingman->set_active_method($fromform->{$formfield});
614 if (empty($fromform->{$formfield})) {
615 // going back to the simple direct grading is not a reason
616 // to open the management screen
617 $methodchanged = false;
619 $showgradingmanagement = $showgradingmanagement ||
$methodchanged;
624 rebuild_course_cache($course->id
);
625 grade_regrade_final_grades($course->id
);
626 plagiarism_save_form_elements($fromform); //save plagiarism settings
628 if (isset($fromform->submitbutton
)) {
629 if (empty($showgradingmanagement)) {
630 redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$fromform->coursemodule");
632 $returnurl = new moodle_url("/mod/$module->name/view.php", array('id' => $fromform->coursemodule
));
633 redirect($gradingman->get_management_url($returnurl));
636 redirect(course_get_url($course, $cw->section
, array('sr' => $sectionreturn)));
642 $streditinga = get_string('editinga', 'moodle', $fullmodulename);
643 $strmodulenameplural = get_string('modulenameplural', $module->name
);
645 if (!empty($cm->id
)) {
646 $context = get_context_instance(CONTEXT_MODULE
, $cm->id
);
648 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
651 $PAGE->set_heading($course->fullname
);
652 $PAGE->set_title($streditinga);
653 $PAGE->set_cacheable(false);
654 echo $OUTPUT->header();
656 if (get_string_manager()->string_exists('modulename_help', $module->name
)) {
657 echo $OUTPUT->heading_with_help($pageheading, 'modulename', $module->name
, 'icon');
659 echo $OUTPUT->heading_with_help($pageheading, '', $module->name
, 'icon');
664 echo $OUTPUT->footer();