Index: moodle/admin/index.php
===================================================================
--- moodle/admin/index.php (revision 1768)
+++ moodle/admin/index.php (working copy)
@@ -416,7 +416,53 @@
error("A problem occurred inserting current version into databases");
}
}
+
+ if(!public_private_tables()){
+ if (empty($confirmupgrade)) {
+ $strdatabasechecking = get_string('publicprivateadd', 'admin');
+ $navigation = build_navigation(array(array('name'=>$strdatabasechecking, 'link'=>null, 'type'=>'misc')));
+ print_header($strdatabasechecking, $stradministration, $navigation,
+ "", "", false, " ", " ");
+ notice(get_string('publicprivateupgradesure', 'admin'), 'index.php?confirmupgrade=1');
+ print_footer('none');
+ exit;
+ }else{
+ $strdatabasesuccess = get_string("databasesuccess");
+ $navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
+ print_header($strdatabasechecking, $stradministration, $navigation,
+ "", upgrade_get_javascript(), false, " ", " ");
+
+ /// return to original debugging level
+ $CFG->debug = $origdebug;
+ error_reporting($CFG->debug);
+ upgrade_log_start();
+
+ print_heading($strdatabasechecking);
+ $db->debug=true;
+ /// Launch the old main upgrade (if exists)
+ $status = true;
+ if (function_exists('main_upgrade')) {
+ $status = main_upgrade($CFG->version);
+ }
+ /// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
+ if ($status && function_exists('xmldb_main_upgrade')) {
+ $status = xmldb_main_upgrade($CFG->version);
+ }
+ $db->debug=false;
+ /// If successful, continue upgrading roles and setting everything properly
+ if (!$status) {
+ notify('Public/Private Upgrade failed! See lib/db/upgrade.php');
+ print_continue('index.php?confirmupgrade=1&confirmrelease=1&confirmplugincheck=1');
+ print_footer('none');
+ die;
+ }
+ upgrade_log_finish();
+ }
+
+ }
+
+
/// Updated human-readable release version if necessary
if ($release <> $CFG->release) { // Update the release version
Index: moodle/admin/settings/misc.php
===================================================================
--- moodle/admin/settings/misc.php (revision 1768)
+++ moodle/admin/settings/misc.php (working copy)
@@ -18,6 +18,15 @@
$temp->add(new admin_setting_configcheckbox('experimentalsplitrestore', get_string('experimentalsplitrestore', 'admin'), get_string('configexperimentalsplitrestore', 'admin'), 0));
$ADMIN->add('misc', $temp);
+
+ $temp = new admin_settingpage('pubpri', get_string('publicprivate', 'admin'));
+
+ $temp->add(new admin_setting_configcheckbox('enablepublicprivate', get_string('publicprivateenable', 'admin'), get_string('publicprivateenable_description', 'admin'), 1));
+ $temp->add(new admin_setting_configcheckbox('default_publicprivate_on_restore', get_string('publicprivaterestore', 'admin'), get_string('publicprivaterestore_description', 'admin'), 1));
+ $temp->add(new admin_setting_configcheckbox('publicprivate_option_enable', get_string('publicprivate_option_enable', 'admin'), get_string('publicprivate_option_enable_description', 'admin'), 1));
+ $temp->add(new admin_setting_configcheckbox('publicprivate_option_aaenable', get_string('publicprivate_option_aaenable', 'admin'), get_string('publicprivate_option_aaenable_description', 'admin'), 0));
+
+ $ADMIN->add('misc', $temp);
// XMLDB editor
$ADMIN->add('misc', new admin_externalpage('xmldbeditor', get_string('xmldbeditor'), "$CFG->wwwroot/$CFG->admin/xmldb/"));
Index: moodle/backup/backuplib.php
===================================================================
--- moodle/backup/backuplib.php (revision 1768)
+++ moodle/backup/backuplib.php (working copy)
@@ -703,6 +703,12 @@
//fwrite ($bf,full_tag("SHOWRECENT",3,false,$course->showrecent)); INFO: This is out in 1.3
fwrite ($bf,full_tag("MAXBYTES",3,false,$course->maxbytes));
fwrite ($bf,full_tag("SHOWREPORTS",3,false,$course->showreports));
+ if(isset($course->grouppublicprivate)){
+ fwrite ($bf,full_tag("GROUPPUBLICPRIVATE",3,false,$course->grouppublicprivate));
+ }
+ if(isset($course->groupautoassign)){
+ fwrite ($bf,full_tag("GROUPAUTOASSIGN",3,false,$course->groupautoassign));
+ }
fwrite ($bf,full_tag("GROUPMODE",3,false,$course->groupmode));
fwrite ($bf,full_tag("GROUPMODEFORCE",3,false,$course->groupmodeforce));
fwrite ($bf,full_tag("DEFAULTGROUPINGID",3,false,$course->defaultgroupingid));
Index: moodle/backup/restorelib.php
===================================================================
--- moodle/backup/restorelib.php (revision 1768)
+++ moodle/backup/restorelib.php (working copy)
@@ -787,6 +787,14 @@
//$course->showrecent = addslashes($course_header->course_showrecent); INFO: This is out in 1.3
$course->maxbytes = addslashes($course_header->course_maxbytes);
$course->showreports = addslashes($course_header->course_showreports);
+ if (isset($course_header->course_grouppublicprivate)) {
+ $course->grouppublicprivate = addslashes($course_header->course_grouppublicprivate);
+ }elseif($CFG->default_publicprivate_on_restore && $CFG->enablepublicprivate){
+ $enable_publicprivate_on_restore = true;
+ }
+ if (isset($course_header->course_groupautoassign)) {
+ $course->groupautoassign = addslashes($course_header->course_groupautoassign);
+ }
if (isset($course_header->course_groupmode)) {
$course->groupmode = addslashes($course_header->course_groupmode);
}
@@ -857,6 +865,10 @@
} else {
$status = false;
}
+
+ if(isset($enable_publicprivate_on_restore) && $enable_publicprivate_on_restore == true){
+ groups_activate_publicprivate($newid);
+ }
}
return $status;
@@ -1092,6 +1104,10 @@
$info = restore_read_xml_sections($xml_file);
}
//Put the info in the DB, recoding ids and saving the in backup tables
+
+ if($CFG->default_publicprivate_on_restore){
+ $grouping_publicprivate = groups_get_grouping_publicprivate($restore->course_id);
+ }
$sequence = "";
@@ -1196,6 +1212,10 @@
}
$course_module->groupmembersonly = $mod->groupmembersonly;
$course_module->instance = 0;
+ if($course_module->groupingid == 0 && isset($grouping_publicprivate) && $grouping_publicprivate != 0){
+ $course_module->groupingid = $grouping_publicprivate;
+ $course_module->groupmembersonly = 1;
+ }
//NOTE: The instance (new) is calculated and updated in db in the
// final step of the restore. We don't know it yet.
//print_object($course_module); //Debug
@@ -3383,6 +3403,8 @@
}
$status = true;
+
+ $old_course_groupautoassign = get_field("course", "groupautoassign", "id", $restore->course_id);
//Iterate over each group
foreach ($groups as $group) {
@@ -3427,6 +3449,10 @@
//If it doesn't exist, create
$newid = insert_record('groups', $gro);
+ if($old_course_groupautoassign == $group->id){
+ set_field("course", "groupautoassign", $newid, "id", $restore->course_id);
+ }
+
} else {
//get current group id
$newid = $gro_db->id;
@@ -5488,6 +5514,13 @@
case "SHOWREPORTS":
$this->info->course_showreports = $this->getContents();
break;
+ // We have to parse this data out of the XML file if we want to use it!
+ case "GROUPPUBLICPRIVATE":
+ $this->info->course_grouppublicprivate = $this->getContents();
+ break;
+ case "GROUPAUTOASSIGN":
+ $this->info->course_groupautoassign = $this->getContents();
+ break;
case "GROUPMODE":
$this->info->course_groupmode = $this->getContents();
break;
Index: moodle/blocks/news_items/block_news_items.php
===================================================================
--- moodle/blocks/news_items/block_news_items.php (revision 1768)
+++ moodle/blocks/news_items/block_news_items.php (working copy)
@@ -27,10 +27,20 @@
require_once($CFG->dirroot.'/mod/forum/lib.php'); // We'll need this
$text = '';
+
+ $news_forum = get_records_select("forum", "course = '$COURSE->id' AND type = 'news' ");
if (!$forum = forum_get_course_forum($COURSE->id, 'news')) {
return '';
}
+
+ if (empty($news_forum))
+ {
+ $grouping_id = groups_get_grouping_publicprivate($COURSE->id);
+ $course_module = get_record("course_modules", "instance", $forum->id, "course", $COURSE->id);
+ set_coursemodule_groupingid($course_module->id, $grouping_id);
+ set_coursemodule_groupmembersonly($course_module->id,1);
+ }
$modinfo = get_fast_modinfo($COURSE);
if (empty($modinfo->instances['forum'][$forum->id])) {
Index: moodle/calendar/lib.php
===================================================================
--- moodle/calendar/lib.php (revision 1768)
+++ moodle/calendar/lib.php (working copy)
@@ -1594,6 +1594,14 @@
$allowed->groups = groups_get_all_groups($SESSION->cal_course_referer, $USER->id);
}
}
+
+ $tgroupsarr = $allowed->groups;
+ unset($allowed->groups);
+ foreach($tgroupsarr as $tgroup){
+ if($tgroup->id != $course->groupautoassign){
+ $allowed->groups[] = $tgroup;
+ }
+ }
}
}
Index: moodle/course/edit_form.php
===================================================================
--- moodle/course/edit_form.php (revision 1768)
+++ moodle/course/edit_form.php (working copy)
@@ -273,6 +273,48 @@
//--------------------------------------------------------------------------------
$mform->addElement('header','', get_string('groups', 'group'));
+ if(has_capability('moodle/course:setgrouppublicprivate', $coursecontext) || $CFG->publicprivate_option_enable == 1){
+
+ if($CFG->enablepublicprivate == 1 || $course->grouppublicprivate == 1){
+
+ $choices = array();
+ $choices[0] = get_string('disable');
+ $choices[1] = get_string('enable');
+
+ $mform->addElement('select', 'grouppublicprivate', get_string('publicprivate'), $choices);
+ $mform->setHelpButton('grouppublicprivate', array('grouppublicprivate', get_string('publicprivate')), true);
+ if(empty($course->grouppublicprivate)){
+ $mform->setDefault('grouppublicprivate', 1);
+ }else{
+ $mform->setDefault('grouppublicprivate', $course->grouppublicprivate);
+ }
+
+ }
+ }
+
+ if(has_capability('moodle/course:setgroupautoassign', $coursecontext) || $CFG->publicprivate_option_aaenable == 1){
+
+ $coursegroups = groups_get_all_groups($course->id);
+ $formcoursegroups = array();
+
+ $formcoursegroups[0] = "Do not auto-assign";
+
+ if ($coursegroups) {
+ foreach ($coursegroups as $group) {
+ $formcoursegroups[$group->id] = $group->name;
+ }
+ }
+
+ if($course->grouppublicprivate == 0){
+ $mform->addElement('select', 'groupautoassign', get_string('autoassignuserstogroup'), $formcoursegroups);
+ }else{
+ $mform->addElement('select', 'groupautoassign', get_string('autoassignuserstogroup'), $formcoursegroups, 'DISABLED');
+ }
+ $mform->setHelpButton('groupautoassign', array('groupautoassign', get_string('autoassignuserstogroup')), true);
+ $mform->setDefault('groupautoassign', $course->groupautoassign);
+
+ }
+
$choices = array();
$choices[NOGROUPS] = get_string('groupsnone', 'group');
$choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
Index: moodle/course/lib.php
===================================================================
--- moodle/course/lib.php (revision 1768)
+++ moodle/course/lib.php (working copy)
@@ -1,7 +1,6 @@
duplicate = get_string("duplicate");
$str->hide = get_string("hide");
$str->show = get_string("show");
+ $str->public = get_string("publicprivatemakepublic");
+ $str->private = get_string("publicprivatemakeprivate");
$str->clicktochange = get_string("clicktochange");
$str->forcedmode = get_string("forcedmode");
$str->groupsnone = get_string("groupsnone");
@@ -2722,7 +2723,22 @@
} else {
$hideshow = '';
}
-
+
+ $course = get_record('course', 'id', $mod->course);
+ if($course->grouppublicprivate == 1){
+ if(coursemodule_visible_for_user($mod, 1)){
+ $pubpriv = '
'."\n";
+ }else{
+ $pubpriv = '
'."\n";
+ }
+ }
+
if ($mod->groupmode !== false) {
if ($mod->groupmode == SEPARATEGROUPS) {
$grouptitle = $str->groupsseparate;
@@ -2806,7 +2822,7 @@
'
'."\n".$hideshow.$groupmode."\n".'';
+ ' alt="'.$str->delete.'" />'."\n".$hideshow.$pubpriv.$groupmode."\n".'';
}
/**
@@ -3290,6 +3306,14 @@
if (empty($data->sortorder)) {
$data->sortorder = 100;
}
+
+ if(empty($data->grouppublicprivate)){
+ if($CFG->enablepublicprivate){
+ $data->grouppublicprivate = 1;
+ }else{
+ $data->grouppublicprivate = 0;
+ }
+ }
if ($newcourseid = insert_record('course', $data)) { // Set up new course
@@ -3316,6 +3340,15 @@
// Trigger events
events_trigger('course_created', $course);
+ /******** START UCLA MOD *******/
+ // ERIC BOLLENS - CCLE-657
+
+ if($course->grouppublicprivate == 1){
+ groups_activate_publicprivate($course->id);
+ }
+
+ /********* END UCLA MOD ********/
+
return $course;
}
@@ -3378,6 +3411,32 @@
// Trigger events
events_trigger('course_updated', $course);
+
+ /******** START UCLA MOD *******/
+ // ERIC BOLLENS - CCLE-657
+
+ // only do something if the grouppublicprivate value has changed
+ if( (isset($oldcourse->grouppublicprivate) && isset($data->grouppublicprivate)) &&
+ $oldcourse->grouppublicprivate != $data->grouppublicprivate){
+ if($data->grouppublicprivate == 1){
+ $data->groupautoassign = groups_activate_publicprivate($course->id);
+ }else{
+ $data->groupautoassign = groups_deactivate_publicprivate($course->id, $oldcourse->groupautoassign);
+ }
+ }
+
+ /********* END UCLA MOD ********/
+
+ /******** START UCLA MOD *******/
+ // ERIC BOLLENS - CCLE-652
+
+ if( (isset($oldcourse->groupautoassign) && isset($data->groupautoassign)) &&
+ $oldcourse->groupautoassign != $data->groupautoassign){
+ groups_remove_autoassigned($data->groupautoassign, $course->id);
+ }
+ groups_add_autoassigned($data->groupautoassign, $course->id);
+
+ /********* END UCLA MOD ********/
return true;
Index: moodle/course/mod.php
===================================================================
--- moodle/course/mod.php (revision 1768)
+++ moodle/course/mod.php (working copy)
@@ -23,6 +23,8 @@
$duplicate = optional_param('duplicate', 0, PARAM_INT);
$cancel = optional_param('cancel', 0, PARAM_BOOL);
$cancelcopy = optional_param('cancelcopy', 0, PARAM_BOOL);
+ $private = optional_param('private', 0, PARAM_INT);
+ $public = optional_param('public', 0, PARAM_INT);
if (isset($SESSION->modform)) { // Variables are stored in the session
$mod = $SESSION->modform;
@@ -185,13 +187,25 @@
$mod->groupmode = $course->groupmode; /// Default groupmode the same as course
}
- if (isset($mod->groupingid)) {
- set_coursemodule_groupingid($mod->coursemodule, $mod->groupingid);
+ if(!isset($course->grouppublicprivate) || $course->grouppublicprivate == 0){
+
+ if (isset($mod->groupingid)) {
+ set_coursemodule_groupingid($mod->coursemodule, $mod->groupingid);
+ }
+
+ if (isset($mod->groupmembersonly)) {
+ set_coursemodule_groupmembersonly($mod->coursemodule, $mod->groupmembersonly);
+ }
+
+ }else{
+
+ $groupingid = groups_get_grouping_publicprivate($course->id);
+
+ set_coursemodule_groupingid($mod->coursemodule, $groupingid);
+ set_coursemodule_groupmembersonly($mod->coursemodule, 1);
+
}
- if (isset($mod->groupmembersonly)) {
- set_coursemodule_groupmembersonly($mod->coursemodule, $mod->groupmembersonly);
- }
$mod->instance = $return;
// course_modules and course_sections each contain a reference
@@ -389,6 +403,58 @@
}
exit;
+ } else if (!empty($private) and confirm_sesskey()) {
+
+ if (! $cm = get_record("course_modules", "id", $private)) {
+ error("This course module doesn't exist");
+ }
+
+ require_login($cm->course); // needed to setup proper $COURSE
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:activityvisibility', $context);
+
+ $groupingid = groups_get_grouping_publicprivate($cm->course);
+
+ if($groupingid != 0){
+
+ set_coursemodule_groupingid($cm->id, $groupingid);
+ set_coursemodule_groupmembersonly($cm->id, 1);
+
+ rebuild_course_cache($cm->course);
+
+ }
+
+ if (SITEID == $cm->course) {
+ redirect($CFG->wwwroot);
+ } else {
+ redirect("view.php?id=$cm->course#section-$sectionreturn");
+ }
+
+ exit;
+
+ } else if (!empty($public) and confirm_sesskey()) {
+
+ if (! $cm = get_record("course_modules", "id", $public)) {
+ error("This course module doesn't exist");
+ }
+
+ require_login($cm->course); // needed to setup proper $COURSE
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:activityvisibility', $context);
+
+ set_coursemodule_groupingid($cm->id, 0);
+ set_coursemodule_groupmembersonly($cm->id, 0);
+
+ rebuild_course_cache($cm->course);
+
+ if (SITEID == $cm->course) {
+ redirect($CFG->wwwroot);
+ } else {
+ redirect("view.php?id=$cm->course#section-$sectionreturn");
+ }
+
+ exit;
+
} else if ($groupmode > -1 and confirm_sesskey()) {
$id = required_param( 'id', PARAM_INT );
Index: moodle/course/modedit.php
===================================================================
--- moodle/course/modedit.php (revision 1768)
+++ moodle/course/modedit.php (working copy)
@@ -1,459 +1,465 @@
-libdir.'/gradelib.php');
-
- require_login();
-
- $add = optional_param('add', 0, PARAM_ALPHA);
- $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
- $type = optional_param('type', '', PARAM_ALPHANUM);
-
- if (!empty($add)) {
- $section = required_param('section', PARAM_INT);
- $course = required_param('course', PARAM_INT);
-
- if (! $course = get_record("course", "id", $course)) {
- error("This course doesn't exist");
- }
-
- require_login($course);
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
- require_capability('moodle/course:manageactivities', $context);
-
- if (! $module = get_record("modules", "name", $add)) {
- error("This module type doesn't exist");
- }
-
- $cw = get_course_section($section, $course->id);
-
- if (!course_allowed_module($course, $module->id)) {
- error("This module has been disabled for this particular course");
- }
-
- $cm = null;
-
- $form->section = $section; // The section number itself - relative!!! (section column in course_sections)
- $form->visible = $cw->visible;
- $form->course = $course->id;
- $form->module = $module->id;
- $form->modulename = $module->name;
- $form->groupmode = $course->groupmode;
- $form->groupingid = $course->defaultgroupingid;
- $form->groupmembersonly = 0;
- $form->instance = '';
- $form->coursemodule = '';
- $form->add = $add;
- $form->return = 0; //must be false if this is an add, go back to course view on cancel
-
- // Turn off default grouping for modules that don't provide group mode
- if($add=='resource' || $add=='glossary' || $add=='label') {
- $form->groupingid=0;
- }
-
- if (!empty($type)) {
- $form->type = $type;
- }
-
- $sectionname = get_section_name($course->format);
- $fullmodulename = get_string("modulename", $module->name);
-
- if ($form->section && $course->format != 'site') {
- $heading->what = $fullmodulename;
- $heading->to = "$sectionname $form->section";
- $pageheading = get_string("addinganewto", "moodle", $heading);
- } else {
- $pageheading = get_string("addinganew", "moodle", $fullmodulename);
- }
-
- $CFG->pagepath = 'mod/'.$module->name;
- if (!empty($type)) {
- $CFG->pagepath .= '/'.$type;
- } else {
- $CFG->pagepath .= '/mod';
- }
-
- $navlinksinstancename = '';
- } else if (!empty($update)) {
- if (! $cm = get_record("course_modules", "id", $update)) {
- error("This course module doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course); // needed to setup proper $COURSE
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('moodle/course:manageactivities', $context);
-
- if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
- }
-
- if (! $form = get_record($module->name, "id", $cm->instance)) {
- error("The required instance of this module doesn't exist");
- }
-
- if (! $cw = get_record("course_sections", "id", $cm->section)) {
- error("This course section doesn't exist");
- }
-
- $form->coursemodule = $cm->id;
- $form->section = $cw->section; // The section number itself - relative!!! (section column in course_sections)
- $form->visible = $cm->visible; //?? $cw->visible ? $cm->visible : 0; // section hiding overrides
- $form->cmidnumber = $cm->idnumber; // The cm IDnumber
- $form->groupmode = groups_get_activity_groupmode($cm); // locked later if forced
- $form->groupingid = $cm->groupingid;
- $form->groupmembersonly = $cm->groupmembersonly;
- $form->course = $course->id;
- $form->module = $module->id;
- $form->modulename = $module->name;
- $form->instance = $cm->instance;
- $form->return = $return;
- $form->update = $update;
-
- if ($items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$form->modulename,
- 'iteminstance'=>$form->instance, 'courseid'=>$COURSE->id))) {
- // add existing outcomes
- foreach ($items as $item) {
- if (!empty($item->outcomeid)) {
- $form->{'outcome_'.$item->outcomeid} = 1;
- }
- }
-
- // set category if present
- $gradecat = false;
- foreach ($items as $item) {
- if ($gradecat === false) {
- $gradecat = $item->categoryid;
- continue;
- }
- if ($gradecat != $item->categoryid) {
- //mixed categories
- $gradecat = false;
- break;
- }
- }
- if ($gradecat !== false) {
- // do not set if mixed categories present
- $form->gradecat = $gradecat;
- }
- }
-
- $sectionname = get_section_name($course->format);
- $fullmodulename = get_string("modulename", $module->name);
-
- if ($form->section && $course->format != 'site') {
- $heading->what = $fullmodulename;
- $heading->in = "$sectionname $cw->section";
- $pageheading = get_string("updatingain", "moodle", $heading);
- } else {
- $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');
-
- $CFG->pagepath = 'mod/'.$module->name;
- if (!empty($type)) {
- $CFG->pagepath .= '/'.$type;
- } else {
- $CFG->pagepath .= '/mod';
- }
- } else {
- error('Invalid operation.');
- }
-
- $modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
- if (file_exists($modmoodleform)) {
- require_once($modmoodleform);
-
- } else {
- error('No formslib form description file found for this activity.');
- }
-
- $modlib = "$CFG->dirroot/mod/$module->name/lib.php";
- if (file_exists($modlib)) {
- include_once($modlib);
- } else {
- error("This module is missing important code! ($modlib)");
- }
-
- $mformclassname = 'mod_'.$module->name.'_mod_form';
- $mform =& new $mformclassname($form->instance, $cw->section, $cm);
- $mform->set_data($form);
-
- if ($mform->is_cancelled()) {
- if ($return && !empty($cm->id)){
- redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id");
- } else {
- redirect("view.php?id=$course->id#section-".$cw->section);
- }
- } else if ($fromform = $mform->get_data()) {
- if (empty($fromform->coursemodule)) { //add
- $cm = null;
- if (! $course = get_record("course", "id", $fromform->course)) {
- error("This course doesn't exist");
- }
- $fromform->instance = '';
- $fromform->coursemodule = '';
- } else { //update
- if (! $cm = get_record("course_modules", "id", $fromform->coursemodule)) {
- error("This course module doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
- $fromform->instance = $cm->instance;
- $fromform->coursemodule = $cm->id;
- }
-
- require_login($course->id); // needed to setup proper $COURSE
-
- if (!empty($fromform->coursemodule)) {
- $context = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
- } else {
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
- }
- require_capability('moodle/course:manageactivities', $context);
-
- $fromform->course = $course->id;
- $fromform->modulename = clean_param($fromform->modulename, PARAM_SAFEDIR); // For safety
-
- $addinstancefunction = $fromform->modulename."_add_instance";
- $updateinstancefunction = $fromform->modulename."_update_instance";
-
- if (!isset($fromform->groupingid)) {
- $fromform->groupingid = 0;
- }
-
- if (!isset($fromform->groupmembersonly)) {
- $fromform->groupmembersonly = 0;
- }
-
- if (!isset($fromform->name)) { //label
- $fromform->name = $fromform->modulename;
- }
-
- 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");
- }
-
- $returnfromfunc = $addinstancefunction($fromform);
- if (!$returnfromfunc) {
- error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id");
- }
- if (is_string($returnfromfunc)) {
- error($returnfromfunc, "view.php?id=$course->id");
- }
-
- $fromform->instance = $returnfromfunc;
-
- // course_modules and course_sections each contain a reference
- // to each other, so we have to update one of them twice.
-
- if (! $fromform->coursemodule = add_course_module($fromform) ) {
- error("Could not add a new course module");
- }
- if (! $sectionid = add_mod_to_section($fromform) ) {
- error("Could not add the new course module to that section");
- }
-
- if (! set_field("course_modules", "section", $sectionid, "id", $fromform->coursemodule)) {
- error("Could not update the course module with the correct section");
- }
-
- // make sure visibility is set correctly (in particular in calendar)
- set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
-
- if (isset($fromform->cmidnumber)) { //label
- // set cm idnumber
- set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
- }
-
- add_to_log($course->id, "course", "add mod",
- "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
- "$fromform->modulename $fromform->instance");
- add_to_log($course->id, $fromform->modulename, "add",
- "view.php?id=$fromform->coursemodule",
- "$fromform->instance", $fromform->coursemodule);
- } else {
- error("Data submitted is invalid.");
- }
-
- // sync idnumber with grade_item
- if ($grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
- 'iteminstance'=>$fromform->instance, 'itemnumber'=>0, 'courseid'=>$COURSE->id))) {
- if ($grade_item->idnumber != $fromform->cmidnumber) {
- $grade_item->idnumber = $fromform->cmidnumber;
- $grade_item->update();
- }
- }
-
- $items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
- 'iteminstance'=>$fromform->instance, 'courseid'=>$COURSE->id));
-
- // create parent category if requested and move to correct parent category
- if ($items and isset($fromform->gradecat)) {
- if ($fromform->gradecat == -1) {
- $grade_category = new grade_category();
- $grade_category->courseid = $COURSE->id;
- $grade_category->fullname = stripslashes($fromform->name);
- $grade_category->insert();
- if ($grade_item) {
- $parent = $grade_item->get_parent_category();
- $grade_category->set_parent($parent->id);
- }
- $fromform->gradecat = $grade_category->id;
- }
- foreach ($items as $itemid=>$unused) {
- $items[$itemid]->set_parent($fromform->gradecat);
- if ($itemid == $grade_item->id) {
- // use updated grade_item
- $grade_item = $items[$itemid];
- }
- }
- }
-
- // add outcomes if requested
- if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
- $grade_items = array();
-
- // Outcome grade_item.itemnumber start at 1000, there is nothing above outcomes
- $max_itemnumber = 999;
- if ($items) {
- foreach($items as $item) {
- if ($item->itemnumber > $max_itemnumber) {
- $max_itemnumber = $item->itemnumber;
- }
- }
- }
-
- foreach($outcomes as $outcome) {
- $elname = 'outcome_'.$outcome->id;
-
- if (array_key_exists($elname, $fromform) and $fromform->$elname) {
- // so we have a request for new outcome grade item?
- if ($items) {
- foreach($items as $item) {
- if ($item->outcomeid == $outcome->id) {
- //outcome aready exists
- continue 2;
- }
- }
- }
-
- $max_itemnumber++;
-
- $outcome_item = new grade_item();
- $outcome_item->courseid = $COURSE->id;
- $outcome_item->itemtype = 'mod';
- $outcome_item->itemmodule = $fromform->modulename;
- $outcome_item->iteminstance = $fromform->instance;
- $outcome_item->itemnumber = $max_itemnumber;
- $outcome_item->itemname = $outcome->fullname;
- $outcome_item->outcomeid = $outcome->id;
- $outcome_item->gradetype = GRADE_TYPE_SCALE;
- $outcome_item->scaleid = $outcome->scaleid;
- $outcome_item->insert();
-
- // move the new outcome into correct category and fix sortorder if needed
- if ($grade_item) {
- $outcome_item->set_parent($grade_item->categoryid);
- $outcome_item->move_after_sortorder($grade_item->sortorder);
-
- } else if (isset($fromform->gradecat)) {
- $outcome_item->set_parent($fromform->gradecat);
- }
- }
- }
- }
-
- rebuild_course_cache($course->id);
- grade_regrade_final_grades($course->id);
-
- if (isset($fromform->submitbutton)) {
- redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$fromform->coursemodule");
- } else {
- redirect("$CFG->wwwroot/course/view.php?id=$course->id");
- }
- exit;
-
- } else {
- if (!empty($cm->id)) {
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- } else {
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
- }
- require_capability('moodle/course:manageactivities', $context);
-
- $streditinga = get_string("editinga", "moodle", $fullmodulename);
- $strmodulenameplural = get_string("modulenameplural", $module->name);
-
- $navlinks = array();
- $navlinks[] = array('name' => $strmodulenameplural, 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id", 'type' => 'activity');
- if ($navlinksinstancename) {
- $navlinks[] = $navlinksinstancename;
- }
- $navlinks[] = array('name' => $streditinga, 'link' => '', 'type' => 'title');
-
- $navigation = build_navigation($navlinks);
-
- print_header_simple($streditinga, '', $navigation, $mform->focus(), "", false);
-
- if (!empty($cm->id)) {
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- $overridableroles = get_overridable_roles($context);
- $assignableroles = get_assignable_roles($context);
- $currenttab = 'update';
- include_once($CFG->dirroot.'/'.$CFG->admin.'/roles/tabs.php');
- }
- $icon = '
';
-
- print_heading_with_help($pageheading, "mods", $module->name, $icon);
- $mform->display();
- print_footer($course);
- }
-?>
+libdir.'/gradelib.php');
+
+ require_login();
+
+ $add = optional_param('add', 0, PARAM_ALPHA);
+ $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
+ $type = optional_param('type', '', PARAM_ALPHANUM);
+
+ if (!empty($add)) {
+ $section = required_param('section', PARAM_INT);
+ $course = required_param('course', PARAM_INT);
+
+ if (! $course = get_record("course", "id", $course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course);
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ if (! $module = get_record("modules", "name", $add)) {
+ error("This module type doesn't exist");
+ }
+
+ $cw = get_course_section($section, $course->id);
+
+ if (!course_allowed_module($course, $module->id)) {
+ error("This module has been disabled for this particular course");
+ }
+
+ $cm = null;
+
+ $form->section = $section; // The section number itself - relative!!! (section column in course_sections)
+ $form->visible = $cw->visible;
+ $form->course = $course->id;
+ $form->module = $module->id;
+ $form->modulename = $module->name;
+ $form->groupmode = $course->groupmode;
+ $form->groupingid = $course->defaultgroupingid;
+ $form->groupmembersonly = 0;
+ $form->instance = '';
+ $form->coursemodule = '';
+ $form->add = $add;
+ $form->return = 0; //must be false if this is an add, go back to course view on cancel
+
+ if($course->grouppublicprivate == 1){
+
+ $form->groupingid = groups_get_grouping_publicprivate($course->id);
+ $form->groupmembersonly = 1;
+
+ }
+ // Turn off default grouping for modules that don't provide group mode but only if public/private is off
+ elseif($add=='resource' || $add=='glossary' || $add=='label') {
+ $form->groupingid=0;
+ }
+
+ if (!empty($type)) {
+ $form->type = $type;
+ }
+
+ $sectionname = get_section_name($course->format);
+ $fullmodulename = get_string("modulename", $module->name);
+
+ if ($form->section && $course->format != 'site') {
+ $heading->what = $fullmodulename;
+ $heading->to = "$sectionname $form->section";
+ $pageheading = get_string("addinganewto", "moodle", $heading);
+ } else {
+ $pageheading = get_string("addinganew", "moodle", $fullmodulename);
+ }
+
+ $CFG->pagepath = 'mod/'.$module->name;
+ if (!empty($type)) {
+ $CFG->pagepath .= '/'.$type;
+ } else {
+ $CFG->pagepath .= '/mod';
+ }
+
+ $navlinksinstancename = '';
+ } else if (!empty($update)) {
+ if (! $cm = get_record("course_modules", "id", $update)) {
+ error("This course module doesn't exist");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course); // needed to setup proper $COURSE
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ if (! $module = get_record("modules", "id", $cm->module)) {
+ error("This module doesn't exist");
+ }
+
+ if (! $form = get_record($module->name, "id", $cm->instance)) {
+ error("The required instance of this module doesn't exist");
+ }
+
+ if (! $cw = get_record("course_sections", "id", $cm->section)) {
+ error("This course section doesn't exist");
+ }
+
+ $form->coursemodule = $cm->id;
+ $form->section = $cw->section; // The section number itself - relative!!! (section column in course_sections)
+ $form->visible = $cm->visible; //?? $cw->visible ? $cm->visible : 0; // section hiding overrides
+ $form->cmidnumber = $cm->idnumber; // The cm IDnumber
+ $form->groupmode = groups_get_activity_groupmode($cm); // locked later if forced
+ $form->groupingid = $cm->groupingid;
+ $form->groupmembersonly = $cm->groupmembersonly;
+ $form->course = $course->id;
+ $form->module = $module->id;
+ $form->modulename = $module->name;
+ $form->instance = $cm->instance;
+ $form->return = $return;
+ $form->update = $update;
+
+ if ($items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$form->modulename,
+ 'iteminstance'=>$form->instance, 'courseid'=>$COURSE->id))) {
+ // add existing outcomes
+ foreach ($items as $item) {
+ if (!empty($item->outcomeid)) {
+ $form->{'outcome_'.$item->outcomeid} = 1;
+ }
+ }
+
+ // set category if present
+ $gradecat = false;
+ foreach ($items as $item) {
+ if ($gradecat === false) {
+ $gradecat = $item->categoryid;
+ continue;
+ }
+ if ($gradecat != $item->categoryid) {
+ //mixed categories
+ $gradecat = false;
+ break;
+ }
+ }
+ if ($gradecat !== false) {
+ // do not set if mixed categories present
+ $form->gradecat = $gradecat;
+ }
+ }
+
+ $sectionname = get_section_name($course->format);
+ $fullmodulename = get_string("modulename", $module->name);
+
+ if ($form->section && $course->format != 'site') {
+ $heading->what = $fullmodulename;
+ $heading->in = "$sectionname $cw->section";
+ $pageheading = get_string("updatingain", "moodle", $heading);
+ } else {
+ $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');
+
+ $CFG->pagepath = 'mod/'.$module->name;
+ if (!empty($type)) {
+ $CFG->pagepath .= '/'.$type;
+ } else {
+ $CFG->pagepath .= '/mod';
+ }
+ } else {
+ error('Invalid operation.');
+ }
+
+ $modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
+ if (file_exists($modmoodleform)) {
+ require_once($modmoodleform);
+
+ } else {
+ error('No formslib form description file found for this activity.');
+ }
+
+ $modlib = "$CFG->dirroot/mod/$module->name/lib.php";
+ if (file_exists($modlib)) {
+ include_once($modlib);
+ } else {
+ error("This module is missing important code! ($modlib)");
+ }
+
+ $mformclassname = 'mod_'.$module->name.'_mod_form';
+ $mform =& new $mformclassname($form->instance, $cw->section, $cm);
+ $mform->set_data($form);
+
+ if ($mform->is_cancelled()) {
+ if ($return && !empty($cm->id)){
+ redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id");
+ } else {
+ redirect("view.php?id=$course->id#section-".$cw->section);
+ }
+ } else if ($fromform = $mform->get_data()) {
+ if (empty($fromform->coursemodule)) { //add
+ $cm = null;
+ if (! $course = get_record("course", "id", $fromform->course)) {
+ error("This course doesn't exist");
+ }
+ $fromform->instance = '';
+ $fromform->coursemodule = '';
+ } else { //update
+ if (! $cm = get_record("course_modules", "id", $fromform->coursemodule)) {
+ error("This course module doesn't exist");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+ $fromform->instance = $cm->instance;
+ $fromform->coursemodule = $cm->id;
+ }
+
+ require_login($course->id); // needed to setup proper $COURSE
+
+ if (!empty($fromform->coursemodule)) {
+ $context = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
+ } else {
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ }
+ require_capability('moodle/course:manageactivities', $context);
+
+ $fromform->course = $course->id;
+ $fromform->modulename = clean_param($fromform->modulename, PARAM_SAFEDIR); // For safety
+
+ $addinstancefunction = $fromform->modulename."_add_instance";
+ $updateinstancefunction = $fromform->modulename."_update_instance";
+
+ if (!isset($fromform->groupingid)) {
+ $fromform->groupingid = 0;
+ }
+
+ if (!isset($fromform->groupmembersonly)) {
+ $fromform->groupmembersonly = 0;
+ }
+
+ if (!isset($fromform->name)) { //label
+ $fromform->name = $fromform->modulename;
+ }
+
+ 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");
+ }
+
+ $returnfromfunc = $addinstancefunction($fromform);
+ if (!$returnfromfunc) {
+ error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id");
+ }
+ if (is_string($returnfromfunc)) {
+ error($returnfromfunc, "view.php?id=$course->id");
+ }
+
+ $fromform->instance = $returnfromfunc;
+
+ // course_modules and course_sections each contain a reference
+ // to each other, so we have to update one of them twice.
+
+ if (! $fromform->coursemodule = add_course_module($fromform) ) {
+ error("Could not add a new course module");
+ }
+ if (! $sectionid = add_mod_to_section($fromform) ) {
+ error("Could not add the new course module to that section");
+ }
+
+ if (! set_field("course_modules", "section", $sectionid, "id", $fromform->coursemodule)) {
+ error("Could not update the course module with the correct section");
+ }
+
+ // make sure visibility is set correctly (in particular in calendar)
+ set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
+
+ if (isset($fromform->cmidnumber)) { //label
+ // set cm idnumber
+ set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
+ }
+
+ add_to_log($course->id, "course", "add mod",
+ "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
+ "$fromform->modulename $fromform->instance");
+ add_to_log($course->id, $fromform->modulename, "add",
+ "view.php?id=$fromform->coursemodule",
+ "$fromform->instance", $fromform->coursemodule);
+ } else {
+ error("Data submitted is invalid.");
+ }
+
+ // sync idnumber with grade_item
+ if ($grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
+ 'iteminstance'=>$fromform->instance, 'itemnumber'=>0, 'courseid'=>$COURSE->id))) {
+ if ($grade_item->idnumber != $fromform->cmidnumber) {
+ $grade_item->idnumber = $fromform->cmidnumber;
+ $grade_item->update();
+ }
+ }
+
+ $items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
+ 'iteminstance'=>$fromform->instance, 'courseid'=>$COURSE->id));
+
+ // create parent category if requested and move to correct parent category
+ if ($items and isset($fromform->gradecat)) {
+ if ($fromform->gradecat == -1) {
+ $grade_category = new grade_category();
+ $grade_category->courseid = $COURSE->id;
+ $grade_category->fullname = stripslashes($fromform->name);
+ $grade_category->insert();
+ if ($grade_item) {
+ $parent = $grade_item->get_parent_category();
+ $grade_category->set_parent($parent->id);
+ }
+ $fromform->gradecat = $grade_category->id;
+ }
+ foreach ($items as $itemid=>$unused) {
+ $items[$itemid]->set_parent($fromform->gradecat);
+ if ($itemid == $grade_item->id) {
+ // use updated grade_item
+ $grade_item = $items[$itemid];
+ }
+ }
+ }
+
+ // add outcomes if requested
+ if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
+ $grade_items = array();
+
+ // Outcome grade_item.itemnumber start at 1000, there is nothing above outcomes
+ $max_itemnumber = 999;
+ if ($items) {
+ foreach($items as $item) {
+ if ($item->itemnumber > $max_itemnumber) {
+ $max_itemnumber = $item->itemnumber;
+ }
+ }
+ }
+
+ foreach($outcomes as $outcome) {
+ $elname = 'outcome_'.$outcome->id;
+
+ if (array_key_exists($elname, $fromform) and $fromform->$elname) {
+ // so we have a request for new outcome grade item?
+ if ($items) {
+ foreach($items as $item) {
+ if ($item->outcomeid == $outcome->id) {
+ //outcome aready exists
+ continue 2;
+ }
+ }
+ }
+
+ $max_itemnumber++;
+
+ $outcome_item = new grade_item();
+ $outcome_item->courseid = $COURSE->id;
+ $outcome_item->itemtype = 'mod';
+ $outcome_item->itemmodule = $fromform->modulename;
+ $outcome_item->iteminstance = $fromform->instance;
+ $outcome_item->itemnumber = $max_itemnumber;
+ $outcome_item->itemname = $outcome->fullname;
+ $outcome_item->outcomeid = $outcome->id;
+ $outcome_item->gradetype = GRADE_TYPE_SCALE;
+ $outcome_item->scaleid = $outcome->scaleid;
+ $outcome_item->insert();
+
+ // move the new outcome into correct category and fix sortorder if needed
+ if ($grade_item) {
+ $outcome_item->set_parent($grade_item->categoryid);
+ $outcome_item->move_after_sortorder($grade_item->sortorder);
+
+ } else if (isset($fromform->gradecat)) {
+ $outcome_item->set_parent($fromform->gradecat);
+ }
+ }
+ }
+ }
+
+ rebuild_course_cache($course->id);
+ grade_regrade_final_grades($course->id);
+
+ if (isset($fromform->submitbutton)) {
+ redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$fromform->coursemodule");
+ } else {
+ redirect("$CFG->wwwroot/course/view.php?id=$course->id");
+ }
+ exit;
+
+ } else {
+ if (!empty($cm->id)) {
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ } else {
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ }
+ require_capability('moodle/course:manageactivities', $context);
+
+ $streditinga = get_string("editinga", "moodle", $fullmodulename);
+ $strmodulenameplural = get_string("modulenameplural", $module->name);
+
+ $navlinks = array();
+ $navlinks[] = array('name' => $strmodulenameplural, 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id", 'type' => 'activity');
+ if ($navlinksinstancename) {
+ $navlinks[] = $navlinksinstancename;
+ }
+ $navlinks[] = array('name' => $streditinga, 'link' => '', 'type' => 'title');
+
+ $navigation = build_navigation($navlinks);
+
+ print_header_simple($streditinga, '', $navigation, $mform->focus(), "", false);
+
+ if (!empty($cm->id)) {
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $overridableroles = get_overridable_roles($context);
+ $assignableroles = get_assignable_roles($context);
+ $currenttab = 'update';
+ include_once($CFG->dirroot.'/'.$CFG->admin.'/roles/tabs.php');
+ }
+ $icon = '
';
+
+ print_heading_with_help($pageheading, "mods", $module->name, $icon);
+ $mform->display();
+ print_footer($course);
+ }
+?>
Index: moodle/course/rest.php
===================================================================
--- moodle/course/rest.php (revision 1768)
+++ moodle/course/rest.php (working copy)
@@ -95,6 +95,19 @@
case 'visible':
set_coursemodule_visible($mod->id, $value);
break;
+
+ case 'private':
+ $groupingid = groups_get_grouping_publicprivate($mod->course);
+ if($groupingid != 0){
+ set_coursemodule_groupingid($mod->id, $groupingid);
+ set_coursemodule_groupmembersonly($mod->id, 1);
+ }
+ break;
+
+ case 'public':
+ set_coursemodule_groupingid($mod->id, 0);
+ set_coursemodule_groupmembersonly($mod->id, 0);
+ break;
case 'groupmode':
set_coursemodule_groupmode($mod->id, $value);
Index: moodle/course/view.php
===================================================================
--- moodle/course/view.php (revision 1768)
+++ moodle/course/view.php (working copy)
@@ -198,6 +198,10 @@
$PAGE->print_header(get_string('course').': %fullname%', NULL, '', $bodytags);
// Course wrapper start.
echo '
This is the public display of the course site. If you are enrolled, please log in to view private course materials.WARNING: You may not add or remove the Course Members group, for it is a component of public/private functionality.
+