mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
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:
parent
575122f98e
commit
0705ff843b
18 changed files with 690 additions and 11 deletions
|
@ -21,6 +21,9 @@
|
|||
if (!isset($form->metacourse)) {
|
||||
$form->metacourse = 0;
|
||||
}
|
||||
if(!isset($form->restrictmodules)) {
|
||||
$form->restrictmodules = 0;
|
||||
}
|
||||
?>
|
||||
<form method="post" action="edit.php" name="form">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
|
@ -294,6 +297,43 @@
|
|||
} ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (isadmin() && ((!empty($course->requested) && $CFG->restrictmodulesfor == 'requested') || $CFG->restrictmodulesfor == 'all')) { ?>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("restrictmodules") ?>:</td>
|
||||
<td valign="top"><table cellpadding="0" border="0"><tr valign="top"><td>
|
||||
<script language="JavaScript">
|
||||
function togglemodules(index) {
|
||||
if (index == 0) {
|
||||
document.getElementById('allowedmods').disabled=true;
|
||||
}
|
||||
else {
|
||||
document.getElementById('allowedmods').disabled=false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
choose_from_menu($options,"restrictmodules",$form->restrictmodules,"","togglemodules(this.selectedIndex);","");
|
||||
?> </td><td> <?php p(strtolower(get_string('to'))); ?> </td><td>
|
||||
<select name="allowedmods[]" id="allowedmods" multiple="multiple" size="10" <?php echo ((empty($form->restrictmodules)) ? "disabled=\"disabled\"" : ""); ?>>
|
||||
<?php
|
||||
$mods = get_records("modules");
|
||||
$s = "selected=\"selected\"";
|
||||
echo '<option value="0" '.((empty($allowedmods)) ? $s : '').'>'.get_string('allownone').'</option>'."\n";
|
||||
foreach ($mods as $mod) {
|
||||
$selected = "";
|
||||
if (in_array($mod->id,$allowedmods))
|
||||
$selected = $s;
|
||||
echo '<option '.$selected.' value="'.$mod->id.'">'.$mod->name.'</option>'."\n";
|
||||
}
|
||||
?>
|
||||
</select></td></tr></table></td>
|
||||
</tr>
|
||||
<?php } else { ?>
|
||||
<input type="hidden" name="restrictmodules" value="<?php p($form->restrictmodules); ?>" />
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
|
||||
|
|
|
@ -66,8 +66,14 @@
|
|||
|
||||
if (count($err) == 0) {
|
||||
|
||||
$allowedmods = array();
|
||||
if (!empty($form->allowedmods)) {
|
||||
$allowedmods = $form->allowedmods;
|
||||
unset($form->allowedmods);
|
||||
}
|
||||
|
||||
$form->timemodified = time();
|
||||
|
||||
|
||||
if (!empty($course)) {
|
||||
// Test for and remove blocks which aren't appropriate anymore
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, $course->id);
|
||||
|
@ -76,6 +82,10 @@
|
|||
// Update with the new data
|
||||
if (update_record('course', $form)) {
|
||||
add_to_log($course->id, "course", "update", "edit.php?id=$id", "");
|
||||
if (isadmin()) {
|
||||
$course->restrictmodules = $form->restrictmodules;
|
||||
update_restricted_mods($course,$allowedmods);
|
||||
}
|
||||
fix_course_sortorder();
|
||||
redirect($page->url_get_full(), get_string('changessaved'));
|
||||
} else {
|
||||
|
@ -97,6 +107,11 @@
|
|||
$page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
|
||||
if (isadmin()) {
|
||||
$course = get_record("course","id",$newcourseid);
|
||||
update_restricted_mods($course,$allowedmods);
|
||||
}
|
||||
|
||||
$section = NULL;
|
||||
$section->course = $newcourseid; // Create a default section.
|
||||
$section->section = 0;
|
||||
|
@ -193,6 +208,29 @@
|
|||
$form->courseformats["$courseformat"] = get_string("format$courseformat");
|
||||
}
|
||||
|
||||
if (empty($allowedmods)) {
|
||||
$allowedmods = array();
|
||||
if (!empty($course)) {
|
||||
if ($am = get_records("course_allowed_modules","course",$course->id)) {
|
||||
foreach ($am as $m) {
|
||||
$allowedmods[] = $m->module;
|
||||
}
|
||||
} else {
|
||||
if (empty($course->restrictmodules)) {
|
||||
$allowedmods = explode(',',$CFG->defaultallowedmodules);
|
||||
} // it'll be greyed out but we want these by default anyway.
|
||||
}
|
||||
} else {
|
||||
if ($CFG->restrictmodulesfor == 'all') {
|
||||
$allowedmods = explode(',',$CFG->defaultallowedmodules);
|
||||
if (!empty($CFG->restrictbydefault)) {
|
||||
$form->restrictmodules = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
$streditcoursesettings = get_string("editcoursesettings");
|
||||
|
|
|
@ -58,12 +58,14 @@
|
|||
print_courses(0, "80%");
|
||||
}
|
||||
|
||||
echo "<center>";
|
||||
if (iscreator()) { // Print link to create a new course
|
||||
echo "<center>";
|
||||
print_single_button("edit.php", NULL, get_string("addnewcourse"), "get");
|
||||
echo "</center>";
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablecourserequests)) {
|
||||
print_single_button('request.php',NULL, get_string('requestcourse'),"get");
|
||||
}
|
||||
echo "</center>";
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
@ -309,6 +311,7 @@
|
|||
unset($options);
|
||||
$options["category"] = $category->id;
|
||||
print_single_button("edit.php", $options, get_string("addnewcourse"), "get");
|
||||
print_single_button('pending.php',NULL, get_string('coursespending'),"get");
|
||||
echo "<br />";
|
||||
echo "</center>";
|
||||
|
||||
|
|
|
@ -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&section=$section&sesskey=$USER->sesskey&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&section=$section&sesskey=$USER->sesskey&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&section=$section&sesskey=$USER->sesskey&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] = ' '.$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));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -110,6 +110,10 @@
|
|||
|
||||
case "add":
|
||||
|
||||
if (!course_allowed_module($course,$mod->modulename)) {
|
||||
error("This module ($mod->modulename) has been disabled for this particular course");
|
||||
}
|
||||
|
||||
if (trim($mod->name) == '') {
|
||||
$mod->name = get_string("modulename", $mod->modulename);
|
||||
}
|
||||
|
@ -560,6 +564,10 @@
|
|||
error("This module type doesn't exist");
|
||||
}
|
||||
|
||||
if (!course_allowed_module($course,$module->id)) {
|
||||
error("This module has been disabled for this particular course");
|
||||
}
|
||||
|
||||
$form->section = $section; // The section number itself
|
||||
$form->course = $course->id;
|
||||
$form->module = $module->id;
|
||||
|
|
6
course/pending-reject.html
Normal file
6
course/pending-reject.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<form action="pending.php" method="post" name="reject">
|
||||
<input type="hidden" name="reject" value="<?php p($reject->id); ?>" />
|
||||
<textarea name="rejectnotice" rows="10" cols="50"></textarea><br />
|
||||
<input type="submit" value="<?php print_string("savechanges");?>" />
|
||||
<input type="button" value="<?php print_string("cancel"); ?>" onClick="window.location='pending.php';" />
|
||||
</form>
|
139
course/pending.php
Normal file
139
course/pending.php
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
// allow the administrators to look through a list of course requests and either approve them or reject them.
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/lib/pagelib.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/lib/blocklib.php');
|
||||
require_once(dirname(__FILE__).'/lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$approve = optional_param('approve',NULL,PARAM_INT);
|
||||
$reject = optional_param('reject',NULL,PARAM_INT);
|
||||
|
||||
if (!empty($approve)) {
|
||||
if ($course = get_record("course_request","id",$approve)) {
|
||||
foreach (array_keys((array)$course) as $key) {
|
||||
$course->$key = addslashes($course->$key);
|
||||
}
|
||||
|
||||
// place at beginning of category
|
||||
fix_course_sortorder();
|
||||
if (empty($CFG->defaultrequestedcategory)) {
|
||||
$CFG->defaultrequestedcategory = 1; //yuk, but default to miscellaneous.
|
||||
}
|
||||
$course->category = $CFG->defaultrequestedcategory;
|
||||
$course->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category=$course->category");
|
||||
if (empty($course->sortorder)) {
|
||||
$course->sortorder = 1000;
|
||||
}
|
||||
$course->requested = 1;
|
||||
unset($course->reason);
|
||||
unset($course->id);
|
||||
$teacherid = $course->requester;
|
||||
unset($course->requester);
|
||||
$course->teacher = get_string("defaultcourseteacher");
|
||||
if (!empty($CFG->requestedteachername)) {
|
||||
$course->teacher = $CFG->requestedteachername;
|
||||
}
|
||||
$course->teachers = get_string("defaultcourseteachers");
|
||||
if (!empty($CFG->requestedteachersname)) {
|
||||
$course->teachers = $CFG->requestedteachersname;
|
||||
}
|
||||
$course->student = get_string("defaultcoursestudent");
|
||||
if (!empty($CFG->requestedstudentname)) {
|
||||
$course->student = $CFG->requestedstudentname;
|
||||
}
|
||||
$course->students = get_string("defaultcoursestudents");
|
||||
if (!empty($CFG->requestedstudentsname)) {
|
||||
$course->students = $CFG->requestedstudentsname;
|
||||
}
|
||||
if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) {
|
||||
$course->restrictmodules = 1;
|
||||
}
|
||||
if ($courseid = insert_record("course",$course)) {
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, $courseid);
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
add_teacher($teacherid,$courseid);
|
||||
$course->id = $courseid;
|
||||
if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) { // if we're all or requested we're ok.
|
||||
$allowedmods = explode(',',$CFG->defaultallowedmodules);
|
||||
update_restricted_mods($course,$allowedmods);
|
||||
}
|
||||
delete_records('course_request','id',$approve);
|
||||
$success = 1;
|
||||
}
|
||||
if (!empty($success)) {
|
||||
$user = get_record('user','id',$teacherid);
|
||||
$a->name = $course->fullname;
|
||||
$a->url = $CFG->wwwroot.'/course/view.php?id='.$courseid;
|
||||
$a->teacher = $course->teacher;
|
||||
email_to_user($user,$USER,get_string('courseapprovedsubject'),get_string('courseapprovedemail','moodle',$a));
|
||||
redirect($CFG->wwwroot.'/course/edit.php?id='.$courseid);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
error(get_string('courseapprovedfailed'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$strtitle = get_string('coursespending');
|
||||
$strheading = get_string(((!empty($reject)) ? 'coursereject' : 'coursespending'));
|
||||
|
||||
print_header($strtitle,$strheading,$strheading);
|
||||
|
||||
if (!empty($reject)) {
|
||||
if ($reject = get_record("course_request","id",$reject)) {
|
||||
$rejectnotice = stripslashes(optional_param('rejectnotice',NULL,PARAM_CLEAN));
|
||||
if (empty($rejectnotice)) {
|
||||
// display a form for writing a reason
|
||||
print_simple_box_start('center');
|
||||
print_string('courserejectreason');
|
||||
include('pending-reject.html');
|
||||
print_simple_box_end();
|
||||
}
|
||||
else {
|
||||
$user = get_record("user","id",$reject->requester);
|
||||
email_to_user($user,$USER,get_string('courserejectsubject'),get_string('courserejectemail','moodle',$rejectnotice));
|
||||
delete_records("course_request","id",$reject->id);
|
||||
notice(get_string('courserejected'),'pending.php');
|
||||
}
|
||||
}
|
||||
} else if ($pending = get_records("course_request")) {
|
||||
// loop through
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 3;
|
||||
$table->align = array('center','center','center','center','center','center');
|
||||
$table->head = array(get_string('shortname'),get_string('fullname'),get_string('requestedby'),get_string('summary'),
|
||||
get_string('requestreason'),'');
|
||||
foreach ($pending as $course) {
|
||||
$requester = get_record('user','id',$course->requester);
|
||||
// check here for shortname collisions and warn about them.
|
||||
if ($match = get_record("course","shortname",$course->shortname)) {
|
||||
$course->shortname .= ' [*]';
|
||||
$collision = 1;
|
||||
}
|
||||
$table->data[] = array($course->shortname,$course->fullname,fullname($requester),
|
||||
$course->summary,$course->reason,
|
||||
'<a href="pending.php?approve='.$course->id.'">'.get_string('approve').'</a> | '
|
||||
.'<a href="pending.php?reject='.$course->id.'">'.get_string('reject').'</a>');
|
||||
}
|
||||
print_table($table);
|
||||
if (!empty($collision)) {
|
||||
print_string('shortnamecollisionwarning');
|
||||
}
|
||||
} else {
|
||||
notice(get_string('nopendingcourses'));
|
||||
// no pending messages.
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
?>
|
59
course/request.html
Normal file
59
course/request.html
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
// make sure all variables are defined
|
||||
if (empty($form->shortname)) {
|
||||
$form->shortname = '';
|
||||
}
|
||||
if (empty($form->fullname)) {
|
||||
$form->fullname = '';
|
||||
}
|
||||
if (empty($form->summary)) {
|
||||
$form->summary = '';
|
||||
}
|
||||
if (empty($form->reason)) {
|
||||
$form->reason = '';
|
||||
}
|
||||
if (empty($usehtmleditor)) {
|
||||
$usehtmleditor = 0;
|
||||
}
|
||||
?>
|
||||
<form method="post" action="request.php" name="request">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("fullname") ?>:</td>
|
||||
<td><input type="text" name="fullname" maxlength="254" size="50" value="<?php p($form->fullname) ?>" alt="<?php print_string("fullname") ?>" />
|
||||
<?php helpbutton("coursefullname", get_string("fullname")) ?>
|
||||
<?php if (isset($err["fullname"])) formerr($err["fullname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("shortname") ?>:</td>
|
||||
<td><input type="text" name="shortname" maxlength="15" size="10" value="<?php p($form->shortname) ?>" alt="<?php print_string("shortname") ?>" />
|
||||
<?php helpbutton("courseshortname", get_string("shortname")) ?>
|
||||
<?php if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("summary") ?>:</td>
|
||||
<td><?php
|
||||
print_textarea($usehtmleditor, 10, 50, 660, 200, "summary", $form->summary);
|
||||
helpbutton("text", get_string("helptext"));
|
||||
if (isset($err["summary"])) formerr($err["summary"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("courserequestreason") ?>:</td>
|
||||
<td><?php
|
||||
print_textarea($usehtmleditor, 10, 50, 660, 200, "reason", $form->reason);
|
||||
helpbutton("text", get_string("helptext"));
|
||||
if (isset($err["reason"])) formerr($err["reason"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $form->sesskey ?>" />
|
||||
</form>
|
102
course/request.php
Normal file
102
course/request.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
/// this allows a student to request a course be created for them.
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablecourserequests)) {
|
||||
error(get_string('courserequestdisabled'));
|
||||
}
|
||||
|
||||
$strtitle = get_string('courserequest');
|
||||
|
||||
print_header($strtitle,$strtitle,$strtitle);
|
||||
|
||||
$form = data_submitted();
|
||||
if (!empty($form) && confirm_sesskey()) {
|
||||
validate_form($form,$err) ;
|
||||
|
||||
if (empty($err)) {
|
||||
$form->requester = $USER->id;
|
||||
|
||||
if (insert_record('course_request',$form)) {
|
||||
notice(get_string('courserequestsuccess'));
|
||||
}
|
||||
else {
|
||||
notice(get_string('courserequestfailed'));
|
||||
}
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$form->sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
// print_simple_box(get_string('courserequestintro'),'center');
|
||||
print_simple_box_start("center");
|
||||
print_string('courserequestintro');
|
||||
include("request.html");
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer($course);
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor("summary");
|
||||
use_html_editor("reason");
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
function validate_form(&$form,&$err) {
|
||||
|
||||
if (empty($form->shortname)) {
|
||||
$err['shortname'] = get_string('missingshortname');
|
||||
}
|
||||
|
||||
if (empty($form->fullname)) {
|
||||
$err['fullname'] = get_string('missingfullname');
|
||||
}
|
||||
|
||||
if (empty($form->summary)) {
|
||||
$err["summary"] = get_string("missingsummary");
|
||||
}
|
||||
|
||||
if (empty($form->reason)) {
|
||||
$err["reason"] = get_string("missingreqreason");
|
||||
}
|
||||
|
||||
$foundcourses = get_records("course", "shortname", $form->shortname);
|
||||
$foundreqcourses = get_records("course_request", "shortname", $form->shortname);
|
||||
if (!empty($foundreqcourses)) {
|
||||
$foundcourses = array_merge($foundcourses,$foundreqcourses);
|
||||
}
|
||||
|
||||
if (!empty($foundcourses)) {
|
||||
if (!empty($course->id)) {
|
||||
unset($foundcourses[$course->id]);
|
||||
}
|
||||
if (!empty($foundcourses)) {
|
||||
foreach ($foundcourses as $foundcourse) {
|
||||
if ($foundcourse->requester) {
|
||||
$pending = 1;
|
||||
$foundcoursenames[] = $foundcourse->fullname.' [*]';
|
||||
}
|
||||
else {
|
||||
$foundcoursenames[] = $foundcourse->fullname;
|
||||
}
|
||||
}
|
||||
$foundcoursenamestring = addslashes(implode(',', $foundcoursenames));
|
||||
|
||||
$err["shortname"] = get_string("shortnametaken", "", $foundcoursenamestring);
|
||||
if (!empty($pending)) {
|
||||
$err["shortname"] .= '<br />'.get_string('starpending');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue