Course request feature. Allows normal users to 'request' courses they would like created,

and admins can approve or reject pending courses.

Also, contains the ability to restrict activity modules on a per course basic. Strict config options:
  enable restricting modules at ALL (for all courses, no courses, requested courses), what to do by default for newly created courses
  as well as what modules to enable for above category by default.

This feature was created for the aim of building a community side to moodle - for institutes that have strict courses and enrolments, allowing normal users to request interest courses is a good feature,
but some modules may be redundant (assignment, lesson, quiz etc)

  Please test!
This commit is contained in:
mjollnir_ 2005-08-16 06:15:49 +00:00
parent 575122f98e
commit 0705ff843b
18 changed files with 690 additions and 11 deletions

View file

@ -1120,17 +1120,32 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
foreach ($resourceraw as $type => $name) {
$resources["resource&type=$type"] = $name;
}
$resources['label'] = get_string('resourcetypelabel', 'resource');
if (course_allowed_module($course,'label')) {
$resources['label'] = get_string('resourcetypelabel', 'resource');
}
}
$output = '<div style="text-align: right">';
$output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&amp;sesskey=$USER->sesskey&amp;add=",
$resources, "ressection$section", "", $straddresource, 'resource/types', $straddresource, true);
if (course_allowed_module($course,'resource')) {
$output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&amp;sesskey=$USER->sesskey&amp;add=",
$resources, "ressection$section", "", $straddresource, 'resource/types', $straddresource, true);
}
if ($vertical) {
$output .= '<div>';
}
// we need to loop through the forms and check to see if we can add them.
foreach ($modnames as $key) {
if (!course_allowed_module($course,$key))
unset($modnames[strtolower($key)]);
}
// this is stupid but labels get put into resource, so if resource is hidden and label is not, we're in trouble.
if (course_allowed_module($course,'label') && empty($resourceallowed)) {
$modnames['label'] = get_string('modulename', 'label');
}
$output .= ' ';
$output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&amp;sesskey=$USER->sesskey&amp;add=",
$modnames, "section$section", "", $straddactivity, 'mods', $straddactivity, true);
@ -1238,11 +1253,26 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli
$down = $last ? false : true;
$first = false;
print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1);
print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1, $printfunction);
}
}
}
// this function will return $options array for choose_from_menu, with whitespace to denote nesting.
function make_categories_options() {
make_categories_list($cats,$parents);
foreach ($cats as $key => $value) {
if (array_key_exists($key,$parents)) {
if ($indent = count($parents[$key])) {
for ($i = 0; $i < $indent; $i++) {
$cats[$key] = '&nbsp;'.$cats[$key];
}
}
}
}
return $cats;
}
function print_category_info($category, $depth) {
/// Prints the category info in indented fashion
@ -1890,4 +1920,46 @@ function print_visible_setting($form, $course=NULL) {
echo '</td></tr>';
}
function update_restricted_mods($course,$mods) {
delete_records("course_allowed_modules","course",$course->id);
if (empty($course->restrictmodules)) {
return;
}
else {
foreach ($mods as $mod) {
if ($mod == 0)
continue; // this is the 'allow none' option
$am->course = $course->id;
$am->module = $mod;
insert_record("course_allowed_modules",$am);
}
}
}
/**
* This function will take an int (module id) or a string (module name)
* and return true or false, whether it's allowed in the given course (object)
* $mod is not allowed to be an object, as the field for the module id is inconsistent
* depending on where in the code it's called from (sometimes $mod->id, sometimes $mod->module)
*/
function course_allowed_module($course,$mod) {
if (empty($course->restrictmodules)) {
return true;
}
if (isadmin()) {
return true;
}
if (is_numeric($mod)) {
$modid = $mod;
} else if (is_string($mod)) {
if ($mod = get_field("modules","id","name",strtolower($mod)))
$modid = $mod;
}
if (empty($modid)) {
return false;
}
return (record_exists("course_allowed_modules","course",$course->id,"module",$modid));
}
?>