mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-16223, MDL-16222 - module context now available in xxx_add_instance() module method and $mform is passed as second parameter; $cm is updated/inserted before the activity insert/update hook; other related refactoring and cleanup; error string improvements
This commit is contained in:
parent
455a8fede8
commit
d857e8b627
3 changed files with 147 additions and 148 deletions
|
@ -2285,41 +2285,11 @@ function set_coursemodule_groupmode($id, $groupmode) {
|
||||||
return $DB->set_field("course_modules", "groupmode", $groupmode, array("id"=>$id));
|
return $DB->set_field("course_modules", "groupmode", $groupmode, array("id"=>$id));
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_coursemodule_groupingid($id, $groupingid) {
|
|
||||||
global $DB;
|
|
||||||
return $DB->set_field("course_modules", "groupingid", $groupingid, array("id"=>$id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_coursemodule_groupmembersonly($id, $groupmembersonly) {
|
|
||||||
global $DB;
|
|
||||||
return $DB->set_field("course_modules", "groupmembersonly", $groupmembersonly, array("id"=>$id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_coursemodule_idnumber($id, $idnumber) {
|
function set_coursemodule_idnumber($id, $idnumber) {
|
||||||
global $DB;
|
global $DB;
|
||||||
return $DB->set_field("course_modules", "idnumber", $idnumber, array("id"=>$id));
|
return $DB->set_field("course_modules", "idnumber", $idnumber, array("id"=>$id));
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_coursemodule_completion($id, $completion) {
|
|
||||||
global $DB;
|
|
||||||
return $DB->set_field("course_modules", "completion", $completion, array('id'=>$id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_coursemodule_completionview($id, $completionview) {
|
|
||||||
global $DB;
|
|
||||||
return $DB->set_field("course_modules", "completionview", $completionview, array('id'=>$id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_coursemodule_completiongradeitemnumber($id, $completiongradeitemnumber) {
|
|
||||||
global $DB;
|
|
||||||
return $DB->set_field("course_modules", "completiongradeitemnumber", $completiongradeitemnumber, array('id'=>$id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_coursemodule_completionexpected($id, $completionexpected) {
|
|
||||||
global $DB;
|
|
||||||
return $DB->set_field("course_modules", "completionexpected", $completionexpected, array('id'=>$id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $prevstateoverrides = true will set the visibility of the course module
|
* $prevstateoverrides = true will set the visibility of the course module
|
||||||
* to what is defined in visibleold. This enables us to remember the current
|
* to what is defined in visibleold. This enables us to remember the current
|
||||||
|
@ -2814,7 +2784,7 @@ function print_groupmode_setting($form, $course=NULL) {
|
||||||
}
|
}
|
||||||
if ($form->coursemodule) {
|
if ($form->coursemodule) {
|
||||||
if (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
|
if (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
|
||||||
print_error("cmunknown");
|
print_error('invalidcoursemodule');
|
||||||
}
|
}
|
||||||
$groupmode = groups_get_activity_groupmode($cm);
|
$groupmode = groups_get_activity_groupmode($cm);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2848,7 +2818,7 @@ function print_grouping_settings($form, $course=NULL) {
|
||||||
}
|
}
|
||||||
if ($form->coursemodule) {
|
if ($form->coursemodule) {
|
||||||
if (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
|
if (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
|
||||||
print_error("cmunknown");
|
print_error('invalidcoursemodule');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$cm = null;
|
$cm = null;
|
||||||
|
|
|
@ -5,34 +5,35 @@
|
||||||
require_once("../config.php");
|
require_once("../config.php");
|
||||||
require_once("lib.php");
|
require_once("lib.php");
|
||||||
require_once($CFG->libdir.'/gradelib.php');
|
require_once($CFG->libdir.'/gradelib.php');
|
||||||
|
require_once($CFG->libdir.'/completionlib.php');
|
||||||
require_login();
|
|
||||||
|
|
||||||
$add = optional_param('add', 0, PARAM_ALPHA);
|
$add = optional_param('add', 0, PARAM_ALPHA);
|
||||||
$update = optional_param('update', 0, PARAM_INT);
|
$update = optional_param('update', 0, PARAM_INT);
|
||||||
$return = optional_param('return', 0, PARAM_BOOL); //return to course/view.php if false or mod/modname/view.php if true
|
$return = optional_param('return', 0, PARAM_BOOL); //return to course/view.php if false or mod/modname/view.php if true
|
||||||
$type = optional_param('type', '', PARAM_ALPHANUM);
|
$type = optional_param('type', '', PARAM_ALPHANUM);
|
||||||
|
|
||||||
|
require_login();
|
||||||
|
|
||||||
if (!empty($add)) {
|
if (!empty($add)) {
|
||||||
$section = required_param('section', PARAM_INT);
|
$section = required_param('section', PARAM_INT);
|
||||||
$course = required_param('course', PARAM_INT);
|
$course = required_param('course', PARAM_INT);
|
||||||
|
|
||||||
if (! $course = $DB->get_record("course", array("id"=>$course))) {
|
if (!$course = $DB->get_record('course', array('id'=>$course))) {
|
||||||
print_error("invalidcourseid");
|
print_error('invalidcourseid');
|
||||||
}
|
}
|
||||||
|
|
||||||
require_login($course);
|
require_login($course);
|
||||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||||
require_capability('moodle/course:manageactivities', $context);
|
require_capability('moodle/course:manageactivities', $context);
|
||||||
|
|
||||||
if (! $module = $DB->get_record("modules", array("name"=>$add))) {
|
if (!$module = $DB->get_record('modules', array('name'=>$add))) {
|
||||||
print_error("moduledoesnotexist");
|
print_error('moduledoesnotexist');
|
||||||
}
|
}
|
||||||
|
|
||||||
$cw = get_course_section($section, $course->id);
|
$cw = get_course_section($section, $course->id);
|
||||||
|
|
||||||
if (!course_allowed_module($course, $module->id)) {
|
if (!course_allowed_module($course, $module->id)) {
|
||||||
print_error("moduledisable");
|
print_error('moduledisable');
|
||||||
}
|
}
|
||||||
|
|
||||||
$cm = null;
|
$cm = null;
|
||||||
|
@ -61,14 +62,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$sectionname = get_section_name($course->format);
|
$sectionname = get_section_name($course->format);
|
||||||
$fullmodulename = get_string("modulename", $module->name);
|
$fullmodulename = get_string('modulename', $module->name);
|
||||||
|
|
||||||
if ($form->section && $course->format != 'site') {
|
if ($form->section && $course->format != 'site') {
|
||||||
$heading->what = $fullmodulename;
|
$heading->what = $fullmodulename;
|
||||||
$heading->to = "$sectionname $form->section";
|
$heading->to = "$sectionname $form->section";
|
||||||
$pageheading = get_string("addinganewto", "moodle", $heading);
|
$pageheading = get_string('addinganewto', 'moodle', $heading);
|
||||||
} else {
|
} else {
|
||||||
$pageheading = get_string("addinganew", "moodle", $fullmodulename);
|
$pageheading = get_string('addinganew', 'moodle', $fullmodulename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$CFG->pagepath = 'mod/'.$module->name;
|
$CFG->pagepath = 'mod/'.$module->name;
|
||||||
|
@ -81,28 +82,28 @@
|
||||||
$navlinksinstancename = '';
|
$navlinksinstancename = '';
|
||||||
|
|
||||||
} else if (!empty($update)) {
|
} else if (!empty($update)) {
|
||||||
if (! $cm = $DB->get_record("course_modules", array("id"=>$update))) {
|
if (!$cm = get_coursemodule_from_id('', $update, 0)) {
|
||||||
print_error("cmunknown");
|
print_error('invalidcoursemodule');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||||
print_error("invalidcourseid");
|
print_error('invalidcourseid');
|
||||||
}
|
}
|
||||||
|
|
||||||
require_login($course); // needed to setup proper $COURSE
|
require_login($course); // needed to setup proper $COURSE
|
||||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||||
require_capability('moodle/course:manageactivities', $context);
|
require_capability('moodle/course:manageactivities', $context);
|
||||||
|
|
||||||
if (! $module = $DB->get_record("modules", array("id"=>$cm->module))) {
|
if (!$module = $DB->get_record('modules', array('id'=>$cm->module))) {
|
||||||
print_error("moduledoesnotexist");
|
print_error('moduledoesnotexist');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $form = $DB->get_record($module->name, array("id"=>$cm->instance))) {
|
if (!$form = $DB->get_record($module->name, array('id'=>$cm->instance))) {
|
||||||
print_error("moduleinstancedoesnotexist");
|
print_error('moduleinstancedoesnotexist');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $cw = $DB->get_record("course_sections", array("id"=>$cm->section))) {
|
if (!$cw = $DB->get_record('course_sections', array('id'=>$cm->section))) {
|
||||||
print_error("sectionnotexist");
|
print_error('sectionnotexist');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->coursemodule = $cm->id;
|
$form->coursemodule = $cm->id;
|
||||||
|
@ -124,7 +125,7 @@
|
||||||
$form->completionusegrade = is_null($cm->completiongradeitemnumber) ? 0 : 1;
|
$form->completionusegrade = is_null($cm->completiongradeitemnumber) ? 0 : 1;
|
||||||
|
|
||||||
if ($items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$form->modulename,
|
if ($items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$form->modulename,
|
||||||
'iteminstance'=>$form->instance, 'courseid'=>$COURSE->id))) {
|
'iteminstance'=>$form->instance, 'courseid'=>$course->id))) {
|
||||||
// add existing outcomes
|
// add existing outcomes
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if (!empty($item->outcomeid)) {
|
if (!empty($item->outcomeid)) {
|
||||||
|
@ -152,14 +153,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$sectionname = get_section_name($course->format);
|
$sectionname = get_section_name($course->format);
|
||||||
$fullmodulename = get_string("modulename", $module->name);
|
$fullmodulename = get_string('modulename', $module->name);
|
||||||
|
|
||||||
if ($form->section && $course->format != 'site') {
|
if ($form->section && $course->format != 'site') {
|
||||||
$heading->what = $fullmodulename;
|
$heading->what = $fullmodulename;
|
||||||
$heading->in = "$sectionname $cw->section";
|
$heading->in = "$sectionname $cw->section";
|
||||||
$pageheading = get_string("updatingain", "moodle", $heading);
|
$pageheading = get_string('updatingain', 'moodle', $heading);
|
||||||
} else {
|
} else {
|
||||||
$pageheading = get_string("updatinga", "moodle", $fullmodulename);
|
$pageheading = get_string('updatinga', 'moodle', $fullmodulename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$navlinksinstancename = array('name' => format_string($form->name, true), 'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id", 'type' => 'activityinstance');
|
$navlinksinstancename = array('name' => format_string($form->name, true), 'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id", 'type' => 'activityinstance');
|
||||||
|
@ -186,11 +187,11 @@
|
||||||
if (file_exists($modlib)) {
|
if (file_exists($modlib)) {
|
||||||
include_once($modlib);
|
include_once($modlib);
|
||||||
} else {
|
} else {
|
||||||
print_error("modulemissingcode", '', '', $modlib);
|
print_error('modulemissingcode', '', '', $modlib);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mformclassname = 'mod_'.$module->name.'_mod_form';
|
$mformclassname = 'mod_'.$module->name.'_mod_form';
|
||||||
$mform =& new $mformclassname($form->instance, $cw->section, $cm);
|
$mform = new $mformclassname($form->instance, $cw->section, $cm);
|
||||||
$mform->set_data($form);
|
$mform->set_data($form);
|
||||||
|
|
||||||
if ($mform->is_cancelled()) {
|
if ($mform->is_cancelled()) {
|
||||||
|
@ -199,27 +200,28 @@
|
||||||
} else {
|
} else {
|
||||||
redirect("$CFG->wwwroot/course/view.php?id=$course->id#section-".$cw->section);
|
redirect("$CFG->wwwroot/course/view.php?id=$course->id#section-".$cw->section);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ($fromform = $mform->get_data()) {
|
} else if ($fromform = $mform->get_data()) {
|
||||||
if (empty($fromform->coursemodule)) { //add
|
if (empty($fromform->coursemodule)) { //add
|
||||||
$cm = null;
|
$cm = null;
|
||||||
if (! $course = $DB->get_record("course", array("id"=>$fromform->course))) {
|
if (!$course = $DB->get_record('course', array('id'=>$fromform->course))) {
|
||||||
print_error("invalidcourseid");
|
print_error('invalidcourseid');
|
||||||
}
|
}
|
||||||
$fromform->instance = '';
|
$fromform->instance = '';
|
||||||
$fromform->coursemodule = '';
|
$fromform->coursemodule = '';
|
||||||
} else { //update
|
} else { //update
|
||||||
if (! $cm = $DB->get_record("course_modules", array("id"=>$fromform->coursemodule))) {
|
if (!$cm = get_coursemodule_from_id('', $fromform->coursemodule, 0)) {
|
||||||
print_error("cmunknown");
|
print_error('invalidcoursemodule');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||||
print_error("invalidcourseid");
|
print_error('invalidcourseid');
|
||||||
}
|
}
|
||||||
$fromform->instance = $cm->instance;
|
$fromform->instance = $cm->instance;
|
||||||
$fromform->coursemodule = $cm->id;
|
$fromform->coursemodule = $cm->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_login($course->id); // needed to setup proper $COURSE
|
require_login($course); // needed to setup proper $COURSE
|
||||||
|
|
||||||
if (!empty($fromform->coursemodule)) {
|
if (!empty($fromform->coursemodule)) {
|
||||||
$context = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
|
$context = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
|
||||||
|
@ -265,22 +267,11 @@
|
||||||
$fromform->groupmode = $cm->groupmode; // keep original
|
$fromform->groupmode = $cm->groupmode; // keep original
|
||||||
}
|
}
|
||||||
|
|
||||||
$returnfromfunc = $updateinstancefunction($fromform);
|
// update course module first
|
||||||
if (!$returnfromfunc) {
|
$cm->groupmode = $fromform->groupmode;
|
||||||
print_error('cannotupdatemod', '', 'view.php?id=$course->id', $fromform->modulename);
|
$cm->groupingid = $fromform->groupingid;
|
||||||
}
|
$cm->groupmembersonly = $fromform->groupmembersonly;
|
||||||
if (is_string($returnfromfunc)) {
|
$completion = new completion_info($course);
|
||||||
//TODO: need more detailed error info
|
|
||||||
print_error('invalidfunction', '', '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);
|
|
||||||
|
|
||||||
require_once($CFG->libdir.'/completionlib.php');
|
|
||||||
$completion=new completion_info($COURSE);
|
|
||||||
if ($completion->is_enabled()) {
|
if ($completion->is_enabled()) {
|
||||||
// Handle completion settings. If necessary, wipe existing completion
|
// Handle completion settings. If necessary, wipe existing completion
|
||||||
// data first.
|
// data first.
|
||||||
|
@ -288,15 +279,26 @@
|
||||||
$completion = new completion_info($course);
|
$completion = new completion_info($course);
|
||||||
$completion->reset_all_state($cm);
|
$completion->reset_all_state($cm);
|
||||||
}
|
}
|
||||||
set_coursemodule_completion($fromform->coursemodule, $fromform->completion);
|
|
||||||
set_coursemodule_completionview($fromform->coursemodule, $fromform->completionview);
|
$cm->completion = $fromform->completion;
|
||||||
set_coursemodule_completionexpected($fromform->coursemodule, $fromform->completionexpected);
|
$cm->completiongradeitemnumber = $fromform->completiongradeitemnumber;
|
||||||
set_coursemodule_completiongradeitemnumber(
|
$cm->completionview = $fromform->completionview;
|
||||||
$fromform->coursemodule,$fromform->completiongradeitemnumber);
|
$cm->completionexpected = $fromform->completionexpected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$DB->update_record('course_modules', $cm)) {
|
||||||
|
print_error('cannotupdatecoursemodule');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$updateinstancefunction($fromform, $mform)) {
|
||||||
|
print_error('cannotupdatemod', '', 'view.php?id=$course->id', $fromform->modulename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure visibility is set correctly (in particular in calendar)
|
||||||
|
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
|
||||||
|
|
||||||
if (isset($fromform->cmidnumber)) { //label
|
if (isset($fromform->cmidnumber)) { //label
|
||||||
// set cm idnumber
|
// set cm idnumber - uniqueness is already verified by form validation
|
||||||
set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
|
set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,36 +319,65 @@
|
||||||
print_error('moduledisable', '', '', $fromform->modulename);
|
print_error('moduledisable', '', '', $fromform->modulename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$returnfromfunc = $addinstancefunction($fromform);
|
// first add course_module record because we need the context
|
||||||
if (!$returnfromfunc) {
|
$newcm = new object();
|
||||||
print_error("cannotaddnewmodule", '', "view.php?id=$course->id", $fromform->modulename);
|
$newcm->course = $course->id;
|
||||||
|
$newcm->module = $fromform->module;
|
||||||
|
$newcm->instance = 0; // not known yet, will be updated later (this is similar to restore code)
|
||||||
|
$newcm->visible = $fromform->visible;
|
||||||
|
$newcm->groupmode = $fromform->groupmode;
|
||||||
|
$newcm->groupingid = $fromform->groupingid;
|
||||||
|
$newcm->groupmembersonly = $fromform->groupmembersonly;
|
||||||
|
$completion = new completion_info($course);
|
||||||
|
if ($completion->is_enabled()) {
|
||||||
|
$newcm->completion = $fromform->completion;
|
||||||
|
$newcm->completiongradeitemnumber = $fromform->completiongradeitemnumber;
|
||||||
|
$newcm->completionview = $fromform->completionview;
|
||||||
|
$newcm->completionexpected = $fromform->completionexpected;
|
||||||
}
|
}
|
||||||
if (is_string($returnfromfunc)) {
|
|
||||||
//TODO: need more detailed error info
|
if (!$fromform->coursemodule = add_course_module($newcm)) {
|
||||||
|
print_error('cannotaddcoursemodule');
|
||||||
|
}
|
||||||
|
|
||||||
|
$returnfromfunc = $addinstancefunction($fromform, $mform);
|
||||||
|
|
||||||
|
if (!$returnfromfunc or !is_number($returnfromfunc)) {
|
||||||
|
// undo everything we can
|
||||||
|
$modcontext = get_context_instance(COURSE_MODULE, $fromform->coursemodule);
|
||||||
|
$fs = get_file_storage();
|
||||||
|
$fs->delete_area_files($modcontext->id);
|
||||||
|
delete_context(CONTEXT_MODULE, $fromform->coursemodule);
|
||||||
|
$DB->delete_records('course_modules', array('id'=>$fromform->coursemodule));
|
||||||
|
|
||||||
|
if (!is_number($returnfromfunc)) {
|
||||||
print_error('invalidfunction', '', 'view.php?id=$course->id');
|
print_error('invalidfunction', '', 'view.php?id=$course->id');
|
||||||
|
} else {
|
||||||
|
print_error('cannotaddnewmodule', '', "view.php?id=$course->id", $fromform->modulename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fromform->instance = $returnfromfunc;
|
$fromform->instance = $returnfromfunc;
|
||||||
|
|
||||||
|
if (!$DB->set_field('course_modules', 'instance', $returnfromfunc, array('id'=>$fromform->coursemodule))) {
|
||||||
|
print_error('cannotaddcoursemodule');
|
||||||
|
}
|
||||||
|
|
||||||
// course_modules and course_sections each contain a reference
|
// course_modules and course_sections each contain a reference
|
||||||
// to each other, so we have to update one of them twice.
|
// to each other, so we have to update one of them twice.
|
||||||
|
|
||||||
if (! $fromform->coursemodule = add_course_module($fromform) ) {
|
|
||||||
print_error("cannotaddcoursemodule");
|
|
||||||
}
|
|
||||||
if (!$sectionid = add_mod_to_section($fromform)) {
|
if (!$sectionid = add_mod_to_section($fromform)) {
|
||||||
print_error("cannotaddcmtosection");
|
print_error('cannotaddcmtosection');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $DB->set_field("course_modules", "section", $sectionid, array("id"=>$fromform->coursemodule))) {
|
if (!$DB->set_field('course_modules', 'section', $sectionid, array('id'=>$fromform->coursemodule))) {
|
||||||
print_error("cannotupdatecm");
|
print_error('cannotupdatecm');
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure visibility is set correctly (in particular in calendar)
|
// make sure visibility is set correctly (in particular in calendar)
|
||||||
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
|
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
|
||||||
|
|
||||||
if (isset($fromform->cmidnumber)) { //label
|
if (isset($fromform->cmidnumber)) { //label
|
||||||
// set cm idnumber
|
// set cm idnumber - uniqueness is already verified by form validation
|
||||||
set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
|
set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,12 +388,12 @@
|
||||||
"view.php?id=$fromform->coursemodule",
|
"view.php?id=$fromform->coursemodule",
|
||||||
"$fromform->instance", $fromform->coursemodule);
|
"$fromform->instance", $fromform->coursemodule);
|
||||||
} else {
|
} else {
|
||||||
print_error("invaliddata");
|
print_error('invaliddata');
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync idnumber with grade_item
|
// sync idnumber with grade_item
|
||||||
if ($grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
|
if ($grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
|
||||||
'iteminstance'=>$fromform->instance, 'itemnumber'=>0, 'courseid'=>$COURSE->id))) {
|
'iteminstance'=>$fromform->instance, 'itemnumber'=>0, 'courseid'=>$course->id))) {
|
||||||
if ($grade_item->idnumber != $fromform->cmidnumber) {
|
if ($grade_item->idnumber != $fromform->cmidnumber) {
|
||||||
$grade_item->idnumber = $fromform->cmidnumber;
|
$grade_item->idnumber = $fromform->cmidnumber;
|
||||||
$grade_item->update();
|
$grade_item->update();
|
||||||
|
@ -370,13 +401,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
|
$items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
|
||||||
'iteminstance'=>$fromform->instance, 'courseid'=>$COURSE->id));
|
'iteminstance'=>$fromform->instance, 'courseid'=>$course->id));
|
||||||
|
|
||||||
// create parent category if requested and move to correct parent category
|
// create parent category if requested and move to correct parent category
|
||||||
if ($items and isset($fromform->gradecat)) {
|
if ($items and isset($fromform->gradecat)) {
|
||||||
if ($fromform->gradecat == -1) {
|
if ($fromform->gradecat == -1) {
|
||||||
$grade_category = new grade_category();
|
$grade_category = new grade_category();
|
||||||
$grade_category->courseid = $COURSE->id;
|
$grade_category->courseid = $course->id;
|
||||||
$grade_category->fullname = $fromform->name;
|
$grade_category->fullname = $fromform->name;
|
||||||
$grade_category->insert();
|
$grade_category->insert();
|
||||||
if ($grade_item) {
|
if ($grade_item) {
|
||||||
|
@ -395,7 +426,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// add outcomes if requested
|
// add outcomes if requested
|
||||||
if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
|
if ($outcomes = grade_outcome::fetch_all_available($course->id)) {
|
||||||
$grade_items = array();
|
$grade_items = array();
|
||||||
|
|
||||||
// Outcome grade_item.itemnumber start at 1000, there is nothing above outcomes
|
// Outcome grade_item.itemnumber start at 1000, there is nothing above outcomes
|
||||||
|
@ -425,7 +456,7 @@
|
||||||
$max_itemnumber++;
|
$max_itemnumber++;
|
||||||
|
|
||||||
$outcome_item = new grade_item();
|
$outcome_item = new grade_item();
|
||||||
$outcome_item->courseid = $COURSE->id;
|
$outcome_item->courseid = $course->id;
|
||||||
$outcome_item->itemtype = 'mod';
|
$outcome_item->itemtype = 'mod';
|
||||||
$outcome_item->itemmodule = $fromform->modulename;
|
$outcome_item->itemmodule = $fromform->modulename;
|
||||||
$outcome_item->iteminstance = $fromform->instance;
|
$outcome_item->iteminstance = $fromform->instance;
|
||||||
|
@ -466,8 +497,8 @@
|
||||||
}
|
}
|
||||||
require_capability('moodle/course:manageactivities', $context);
|
require_capability('moodle/course:manageactivities', $context);
|
||||||
|
|
||||||
$streditinga = get_string("editinga", "moodle", $fullmodulename);
|
$streditinga = get_string('editinga', 'moodle', $fullmodulename);
|
||||||
$strmodulenameplural = get_string("modulenameplural", $module->name);
|
$strmodulenameplural = get_string('modulenameplural', $module->name);
|
||||||
|
|
||||||
$navlinks = array();
|
$navlinks = array();
|
||||||
$navlinks[] = array('name' => $strmodulenameplural, 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id", 'type' => 'activity');
|
$navlinks[] = array('name' => $strmodulenameplural, 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id", 'type' => 'activity');
|
||||||
|
@ -485,11 +516,11 @@
|
||||||
$overridableroles = get_overridable_roles($context);
|
$overridableroles = get_overridable_roles($context);
|
||||||
$assignableroles = get_assignable_roles($context);
|
$assignableroles = get_assignable_roles($context);
|
||||||
$currenttab = 'update';
|
$currenttab = 'update';
|
||||||
include_once($CFG->dirroot.'/'.$CFG->admin.'/roles/tabs.php');
|
require($CFG->dirroot.'/'.$CFG->admin.'/roles/tabs.php');
|
||||||
}
|
}
|
||||||
$icon = '<img src="'.$CFG->modpixpath.'/'.$module->name.'/icon.gif" alt=""/>';
|
$icon = '<img src="'.$CFG->modpixpath.'/'.$module->name.'/icon.gif" alt=""/>';
|
||||||
|
|
||||||
print_heading_with_help($pageheading, "mods", $module->name, $icon);
|
print_heading_with_help($pageheading, 'mods', $module->name, $icon);
|
||||||
$mform->display();
|
$mform->display();
|
||||||
print_footer($course);
|
print_footer($course);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ $string['cannotupgradeblock'] = 'Upgrade of blocks system failed! (Could not upd
|
||||||
$string['cannotupgradecaps'] = 'Had difficulties upgrading the core capabilities for the Roles system';
|
$string['cannotupgradecaps'] = 'Had difficulties upgrading the core capabilities for the Roles system';
|
||||||
$string['cannotupdateblock'] = 'Could not update block $a record in block table!';
|
$string['cannotupdateblock'] = 'Could not update block $a record in block table!';
|
||||||
$string['cannotupdatecategory'] = 'Could not update the category ($a)';
|
$string['cannotupdatecategory'] = 'Could not update the category ($a)';
|
||||||
$string['cannotupdatecoursemodule'] = 'Could not update the course module with the correct section';
|
$string['cannotupdatecoursemodule'] = 'Could not update the course module';
|
||||||
$string['cannotupdatecomment'] = 'Could not update this comment';
|
$string['cannotupdatecomment'] = 'Could not update this comment';
|
||||||
$string['cannotupdatecm'] = 'Could not update the course module with the correct section';
|
$string['cannotupdatecm'] = 'Could not update the course module with the correct section';
|
||||||
$string['cannotupdatefield'] = 'Error updating field';
|
$string['cannotupdatefield'] = 'Error updating field';
|
||||||
|
@ -161,11 +161,9 @@ $string['cannotviewprofile'] = 'You cannot view the profile of this user';
|
||||||
$string['cannotwritefile'] = 'Cannot write to file ($a)';
|
$string['cannotwritefile'] = 'Cannot write to file ($a)';
|
||||||
$string['cantunenrollfrommetacourse'] = 'You cannot unenrol from this meta course';
|
$string['cantunenrollfrommetacourse'] = 'You cannot unenrol from this meta course';
|
||||||
$string['cantunenrollinthisrole'] = 'You cannot unenrol from this course while you are in your current role';
|
$string['cantunenrollinthisrole'] = 'You cannot unenrol from this course while you are in your current role';
|
||||||
$string['cmunknown'] = 'Couldn\'t find this course module';
|
|
||||||
$string['commentmisconf'] = 'Comment ID is misconfigured';
|
$string['commentmisconf'] = 'Comment ID is misconfigured';
|
||||||
$string['componentisuptodate'] = 'Component is up-to-date';
|
$string['componentisuptodate'] = 'Component is up-to-date';
|
||||||
$string['confirmsesskeybad'] = 'Sorry, but your session key could not be confirmed to carry out this action. This security feature prevents against accidental or malicious execution of important functions in your name. Please make sure you really wanted to execute this function.';
|
$string['confirmsesskeybad'] = 'Sorry, but your session key could not be confirmed to carry out this action. This security feature prevents against accidental or malicious execution of important functions in your name. Please make sure you really wanted to execute this function.';
|
||||||
$string['copiedcmnotexist'] = 'The copied course module does not exist!';
|
|
||||||
$string['couldnotassignrole'] = 'A serious but unspecified error occurred while trying to assign a role to you';
|
$string['couldnotassignrole'] = 'A serious but unspecified error occurred while trying to assign a role to you';
|
||||||
$string['coursegroupunknown'] = 'Course corresponding to group $a not specified';
|
$string['coursegroupunknown'] = 'Course corresponding to group $a not specified';
|
||||||
$string['coursemisconf'] = 'Course is misconfigured';
|
$string['coursemisconf'] = 'Course is misconfigured';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue