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

102
course/request.php Normal file
View 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');
}
}
}
}
?>