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
|
@ -2252,7 +2252,7 @@ function add_mod_to_section($mod, $beforemod=NULL) {
|
|||
} else if ($beforemod) {
|
||||
$modarray = explode(",", $section->sequence);
|
||||
|
||||
if ($key = array_keys ($modarray, $beforemod->id)) {
|
||||
if ($key = array_keys($modarray, $beforemod->id)) {
|
||||
$insertarray = array($mod->id, $beforemod->id);
|
||||
array_splice($modarray, $key[0], 1, $insertarray);
|
||||
$newsequence = implode(",", $modarray);
|
||||
|
@ -2285,41 +2285,11 @@ function set_coursemodule_groupmode($id, $groupmode) {
|
|||
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) {
|
||||
global $DB;
|
||||
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
|
||||
* 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 (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
|
||||
print_error("cmunknown");
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
} else {
|
||||
|
@ -2848,7 +2818,7 @@ function print_grouping_settings($form, $course=NULL) {
|
|||
}
|
||||
if ($form->coursemodule) {
|
||||
if (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
|
||||
print_error("cmunknown");
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
} else {
|
||||
$cm = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue