Permalink
Browse files

course request: MDL-9854 major cleanup to the course request code.

* Rewrite all the forms to use formslib and improve usability.
* Put the place where admins need to go to process approvals in the admin menu.
* Show the request course/pending requests button on the page for the category that requested courses get added to.
  • Loading branch information...
1 parent 32b1759 commit 7f2e6a23a96097e8bb0aa2d213087d432ebb9f9b tjhunt committed Dec 5, 2008
View
9 admin/settings/courses.php
@@ -5,7 +5,8 @@
if ($hassiteconfig
or has_capability('moodle/site:backup', $systemcontext)
or has_capability('moodle/category:manage', $systemcontext)
- or has_capability('moodle/course:create', $systemcontext)) { // speedup for non-admins, add all caps used on this page
+ or has_capability('moodle/course:create', $systemcontext)
+ or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
$ADMIN->add('courses', new admin_externalpage('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on',
array('moodle/category:manage', 'moodle/course:create')));
@@ -18,6 +19,12 @@
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1));
$ADMIN->add('courses', $temp);
+ // Pending course requests.
+ if (!empty($CFG->enablecourserequests)) {
+ $ADMIN->add('courses', new admin_externalpage('coursespending', get_string('pendingrequests'),
+ $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
+ }
+
// "backups" settingpage
if (!empty($CFG->backup_version)) {
$bi = array();
View
4 course/category.php
@@ -456,6 +456,10 @@
$options['category'] = $category->id;
print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
}
+
+ if (!empty($CFG->enablecourserequests) && $category->id == $CFG->enablecourserequests) {
+ print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
+ }
echo '</div>';
print_course_search();
View
12 course/index.php
@@ -74,19 +74,13 @@
}
echo '<div class="buttons">';
- if ($CFG->enablecourserequests and isloggedin() and !isguest() and !has_capability('moodle/course:create', $systemcontext)) {
- /// Print link to request a new course
- print_single_button('request.php', NULL, get_string('courserequest'), 'get');
- }
if (has_capability('moodle/course:create', $systemcontext)) {
/// Print link to create a new course
/// Get the 1st available category
$options = array('category' => $CFG->defaultrequestcategory);
print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
}
- if (has_capability('moodle/site:approvecourse', $systemcontext) and !empty($CFG->enablecourserequests)) {
- print_single_button('pending.php',NULL, get_string('coursespending'),'get');
- }
+ print_course_request_buttons($systemcontext);
echo '</div>';
print_footer();
exit;
@@ -293,9 +287,7 @@
print_single_button('editcategory.php', $options, get_string('addnewcategory'), 'get');
}
- if (has_capability('moodle/site:approvecourse', $systemcontext) and !empty($CFG->enablecourserequests)) {
- print_single_button('pending.php',NULL, get_string('coursespending'), 'get');
- }
+ print_course_request_buttons($systemcontext);
// admin page does not allow custom buttons in the navigation bar
echo '<div class="singlebutton">';
echo update_category_button();
View
20 course/lib.php
@@ -1865,6 +1865,26 @@ function print_category_info($category, $depth, $showcourses = false) {
}
/**
+ * Print the buttons relating to course requests.
+ *
+ * @param object $systemcontext the system context.
+ */
+function print_course_request_buttons($systemcontext) {
+ global $CFG;
+ if (empty($CFG->enablecourserequests)) {
+ return;
+ }
+ if (isloggedin() && !isguestuser() && !has_capability('moodle/course:create', $systemcontext)) {
+ /// Print a button to request a new course
+ print_single_button('request.php', NULL, get_string('requestcourse'), 'get');
+ }
+ /// Print a button to manage pending requests
+ if (has_capability('moodle/site:approvecourse', $systemcontext)) {
+ print_single_button('pending.php', NULL, get_string('coursespending'), 'get', '_self', false, '', !record_exists('course_request'));
+ }
+}
+
+/**
* Prints the turn editing on/off button on course/index.php or course/category.php.
*
* @param integer $categoryid The id of the category we are showing, or 0 for system context.
View
7 course/pending-reject.html
@@ -1,7 +0,0 @@
-<form action="pending.php" method="post" id="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';" />
-<input type="hidden" name="sesskey" value="<?php echo sesskey();?>" />
-</form>
View
280 course/pending.php
@@ -1,133 +1,209 @@
<?php // $Id$
- // allow the administrators to look through a list of course requests and either approve them or reject them.
- require_once('../config.php');
- require_once($CFG->libdir.'/pagelib.php');
- require_once($CFG->libdir.'/blocklib.php');
- require_once('lib.php');
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.org //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
- require_login();
+/**
+ * Allow the administrator to look through a list of course requests and approve or reject them.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package course
+ *//** */
+
+ require_once(dirname(__FILE__) . '/../config.php');
+ require_once($CFG->libdir . '/pagelib.php');
+ require_once($CFG->libdir . '/blocklib.php');
+ require_once($CFG->libdir . '/adminlib.php');
+ require_once($CFG->dirroot . '/course/lib.php');
+ require_once($CFG->dirroot . '/course/request_form.php');
+ require_login();
require_capability('moodle/site:approvecourse', get_context_instance(CONTEXT_SYSTEM));
- $approve = optional_param('approve', 0, PARAM_INT);
- $reject = optional_param('reject', 0, PARAM_INT);
- $rejectnotice = optional_param('rejectnotice', '', PARAM_CLEANHTML);
+ $approve = optional_param('approve', 0, PARAM_INT);
+ $reject = optional_param('reject', 0, PARAM_INT);
+ $baseurl = $CFG->wwwroot . '/course/pending.php';
+ admin_externalpage_setup('coursespending');
+
+/// Process approval of a course.
if (!empty($approve) and confirm_sesskey()) {
- if ($course = get_record("course_request","id",$approve)) {
- foreach (array_keys((array)$course) as $key) {
- $course->$key = addslashes($course->$key);
- }
+ /// Load the request.
+ if (!$course = get_record('course_request', 'id', $approve)) {
+ print_error('unknowncourserequest');
+ }
+ foreach (array_keys((array)$course) as $key) {
+ $course->$key = addslashes($course->$key);
+ }
- // place at beginning of category
- fix_course_sortorder();
+ /// Ensure all is well before proceeding.
+ fix_course_sortorder();
+ if (empty($CFG->defaultrequestcategory) or !record_exists('course_categories', 'id', $CFG->defaultrequestcategory)) {
+ /// default to first top level directory, hacky but means things don't break
+ $CFG->defaultrequestcategory = get_field('course_categories', 'id', 'parent', '0');
+ }
- if (empty($CFG->defaultrequestcategory) or !record_exists('course_categories', 'id', $CFG->defaultrequestcategory)) {
- // default to first top level directory, hacky but means things don't break
- $CFG->defaultrequestcategory = get_field('course_categories', 'id', 'parent', '0');
- }
+ /// Build up a course record based on the request.
+ $course->category = $CFG->defaultrequestcategory;
+ $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");
+ $course->teachers = get_string("defaultcourseteachers");
+ $course->student = get_string("defaultcoursestudent");
+ $course->students = get_string("defaultcoursestudents");
+ if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) {
+ $course->restrictmodules = 1;
+ }
- $course->category = $CFG->defaultrequestcategory;
- $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");
- $course->teachers = get_string("defaultcourseteachers");
- $course->student = get_string("defaultcoursestudent");
- $course->students = get_string("defaultcoursestudents");
- 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
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
- role_assign($CFG->creatornewroleid, $teacherid, 0, $context->id); // assing teacher role
- $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 {
- print_error('courseapprovedfailed');
- exit;
+ /// Insert the record.
+ 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
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ role_assign($CFG->creatornewroleid, $teacherid, 0, $context->id); // assing teacher role
+ $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);
+
+ } else {
+ print_error('courseapprovedfailed');
}
}
- $strtitle = get_string('coursespending');
- $strheading = get_string(((!empty($reject)) ? 'coursereject' : 'coursespending'));
+/// Process rejection of a course.
+ if (!empty($reject)) {
+ /// Load the request.
+ if (!$course = get_record('course_request', 'id', $reject)) {
+ print_error('unknowncourserequest');
+ }
- print_header($strtitle,$strheading,build_navigation(array(array('name'=>$strheading,'link'=>'','type'=>'misc'))));
+ /// Prepare the form.
+ $rejectform = new reject_request_form($baseurl);
+ $default = new stdClass();
+ $default->reject = $reject;
+ $rejectform->set_data($default);
- if (!empty($reject) and confirm_sesskey()) {
- if ($reject = get_record("course_request","id",$reject)) {
- 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');
- }
+ /// Standard form processing if statement.
+ if ($rejectform->is_cancelled()){
+ redirect($baseurl);
+
+ } else if ($data = $rejectform->get_data()) {
+ /// Send an email to the requester.
+ $user = get_record('user', 'id', $course->requester);
+ email_to_user($user, $USER, get_string('courserejectsubject'),
+ get_string('courserejectemail', '', $data->rejectnotice));
+
+ /// Delete the request
+ delete_records('course_request', 'id', $course->id);
+
+ /// Redirect back to the course listing.
+ redirect($baseurl, get_string('courserejected'));
}
- } else if ($pending = get_records("course_request")) {
- // loop through
- $table->cellpadding = 4;
- $table->cellspacing = 3;
- $table->align = array('center','center','center','center','center','center','center');
- $table->head = array('&nbsp;',get_string('shortname'),get_string('fullname'),get_string('requestedby'),get_string('summary'),
- get_string('requestreason'),'');
+
+ /// Display the form for giving a reason for rejecting the request.
+ admin_externalpage_print_header($rejectform->focus());
+ $rejectform->display();
+ admin_externalpage_print_footer();
+ exit;
+ }
+
+/// Print a list of all the pending requests.
+ admin_externalpage_print_header();
+
+ $pending = get_records('course_request');
+ if (empty($pending)) {
+ print_heading(get_string('nopendingcourses'));
+ } else {
+ print_heading(get_string('coursespending'));
+
+ /// Build a table of all the requests.
+ $table->class = 'pendingcourserequests generaltable';
+ $table->align = array('center', 'center', 'center', 'center', 'center', 'center', 'center');
+ $table->head = array('&nbsp;', get_string('shortname'), get_string('fullname'),
+ get_string('requestedby'), get_string('summary'), get_string('requestreason'), get_string('action'));
$strrequireskey = get_string('requireskey');
+
+ /// Loop over requested courses.
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)) {
+ $requester = get_record('user', 'id', $course->requester);
+ $row = array();
+
+ /// Check here for shortname collisions and warn about them.
+ if (record_exists('course', 'shortname', $course->shortname)) {
$course->shortname .= ' [*]';
$collision = 1;
}
- //do not output raw html from request, quote html entities using s()!!
- $table->data[] = array(((!empty($course->password)) ?
- '<img hspace="1" alt="'.$strrequireskey.'" class="icon" src="'.$CFG->pixpath.'/i/key.gif" />' : ''),
- format_string($course->shortname),format_string($course->fullname),fullname($requester),
- format_string($course->summary),format_string($course->reason),
- '<a href="pending.php?approve='.$course->id.'&amp;sesskey='.sesskey().'">'.get_string('approve').'</a> | '
- .'<a href="pending.php?reject='.$course->id.'&amp;sesskey='.sesskey().'">'.get_string('reject').'</a>');
+
+ /// Show an enrolment key icon in the first column if applicable.
+ if (!empty($course->password)) {
+ $row[] = '<img hspace="1" alt="'.$strrequireskey.'" class="icon" src="'.$CFG->pixpath.'/i/key.gif" />';
+ } else {
+ $row[] = '';
+ }
+
+ /// Info in the other columns.
+ $row[] = format_string($course->shortname);
+ $row[] = format_string($course->fullname);
+ $row[] = fullname($requester);
+ $row[] = format_string($course->summary);
+ $row[] = format_string($course->reason);
+ $row[] = print_single_button($baseurl, array('approve' => $course->id, 'sesskey' => sesskey()), get_string('approve'), 'get', '', true) .
+ print_single_button($baseurl, array('reject' => $course->id), get_string('rejectdots'), 'get', '', true);
+
+ /// Add the row to the table.
+ $table->data[] = $row;
}
+
+ /// Display the table.
print_table($table);
+
+ /// Message about name collisions, if necessary.
if (!empty($collision)) {
print_string('shortnamecollisionwarning');
}
- } else {
- notice(get_string('nopendingcourses'));
- // no pending messages.
}
-print_footer();
-
-
+/// Finish off the page.
+ print_single_button($CFG->wwwroot . '/course/index.php', array(), get_string('backtocourselisting'));
+ admin_externalpage_print_footer();
?>
View
91 course/request.php
@@ -1,52 +1,73 @@
<?php // $Id$
- /// this allows a student to request a course be created for them.
-
- require_once('../config.php');
- require_once('request_form.php');
-
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.org //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Allows a user to request a course be created for them.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package course
+ *//** */
+
+ require_once(dirname(__FILE__) . '/../config.php');
+ require_once($CFG->dirroot . '/course/request_form.php');
+
+/// Where we came from. Used in a number of redirects.
+ $returnurl = $CFG->wwwroot . '/course/index.php';
+
+/// Check permissions.
require_login();
-
- if (isguest()) {
- error("No guests here!");
+ if (isguestuser()) {
+ print_error('guestsarenotallowed', '', $returnurl);
}
-
if (empty($CFG->enablecourserequests)) {
- print_error('courserequestdisabled');
+ print_error('courserequestdisabled', '', $returnurl);
}
- $requestform = new course_request_form();
-
- $strtitle = get_string('courserequest');
- $navlinks = array();
- $navlinks[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
- $navigation = build_navigation($navlinks);
-
- print_header($strtitle, $strtitle, $navigation, $requestform->focus());
-
- print_simple_box_start('center');
- print_string('courserequestintro');
- print_simple_box_end();
-
+/// Set up the form.
+ $requestform = new course_request_form($CFG->wwwroot . '/course/request.php');
+/// Standard form processing if statement.
if ($requestform->is_cancelled()){
+ redirect($returnurl);
- redirect($CFG->wwwroot);
-
- }elseif ($data = $requestform->get_data()) {
+ } else if ($data = $requestform->get_data()) {
+ /// Record the request.
$data->requester = $USER->id;
-
- if (insert_record('course_request', $data)) {
- notice(get_string('courserequestsuccess'));
- } else {
- notice(get_string('courserequestfailed'));
+ if (!insert_record('course_request', $data)) {
+ print_error('errorsavingrequest', '', $returnurl);
}
- } else {
-
- $requestform->display();
+ /// and redirect back to the course listing.
+ notice(get_string('courserequestsuccess'), $returnurl);
}
+/// Show the request form.
+ $strtitle = get_string('courserequest');
+ print_header($strtitle, $strtitle, build_navigation($strtitle), $requestform->focus());
+ print_heading($strtitle);
+ $requestform->display();
print_footer();
-?>
+?>
View
102 course/request_form.php
@@ -1,34 +1,73 @@
<?php // $Id$
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.org //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Forms associated with requesting courses, and having requests approved.
+ * Note that several related forms are defined in this one file.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package course
+ *//** */
+
require_once($CFG->libdir.'/formslib.php');
+/**
+ * A form for a user to request a course.
+ */
class course_request_form extends moodleform {
function definition() {
$mform =& $this->_form;
+ $mform->addElement('header','coursedetails', get_string('courserequestdetails'));
+
$mform->addElement('text', 'fullname', get_string('fullname'), 'maxlength="254" size="50"');
+ $mform->setHelpButton('fullname', array('coursefullname', get_string('fullname')), true);
$mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
- $mform->setType('fullname', PARAM_TEXT);
+ $mform->setType('fullname', PARAM_MULTILANG);
$mform->addElement('text', 'shortname', get_string('shortname'), 'maxlength="100" size="20"');
+ $mform->setHelpButton('shortname', array('courseshortname', get_string('shortname')), true);
$mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
- $mform->setType('shortname', PARAM_TEXT);
+ $mform->setType('shortname', PARAM_MULTILANG);
$mform->addElement('htmleditor', 'summary', get_string('summary'), array('rows'=>'15', 'cols'=>'50'));
- $mform->addRule('summary', get_string('missingsummary'), 'required', null, 'client');
+ $mform->setHelpButton('summary', array('text', get_string('helptext')), true);
$mform->setType('summary', PARAM_RAW);
- $mform->setHelpButton('summary', array('text', get_string('helptext')));
+ $mform->addElement('passwordunmask', 'password', get_string('enrolmentkey'), 'size="25"');
+ $mform->setHelpButton('password', array('enrolmentkey', get_string('enrolmentkey')), true);
+ $mform->setDefault('password', '');
+ $mform->setType('password', PARAM_RAW);
- $mform->addElement('textarea', 'reason', get_string('courserequestreason'), array('rows'=>'15', 'cols'=>'50'));
+ $mform->addElement('header','requestreason', get_string('courserequestreason'));
+
+ $mform->addElement('textarea', 'reason', get_string('courserequestsupport'), array('rows'=>'15', 'cols'=>'50'));
$mform->addRule('reason', get_string('missingreqreason'), 'required', null, 'client');
$mform->setType('reason', PARAM_TEXT);
- $mform->addElement('text', 'password', get_string('enrolmentkey'), 'size="25"');
- $mform->setType('password', PARAM_RAW);
-
-
- $this->add_action_buttons();
+ $this->add_action_buttons(true, get_string('requestcourse'));
}
function validation($data, $files) {
@@ -49,27 +88,42 @@ function validation($data, $files) {
}
if (!empty($foundcourses)) {
-
- if (!empty($foundcourses)) {
- foreach ($foundcourses as $foundcourse) {
- if (isset($foundcourse->requester) && $foundcourse->requester) {
- $pending = 1;
- $foundcoursenames[] = $foundcourse->fullname.' [*]';
- } else {
- $foundcoursenames[] = $foundcourse->fullname;
- }
+ foreach ($foundcourses as $foundcourse) {
+ if (!empty($foundcourse->requester)) {
+ $pending = 1;
+ $foundcoursenames[] = $foundcourse->fullname.' [*]';
+ } else {
+ $foundcoursenames[] = $foundcourse->fullname;
}
- $foundcoursenamestring = addslashes(implode(',', $foundcoursenames));
+ }
+ $foundcoursenamestring = implode(',', $foundcoursenames);
- $errors['shortname'] = get_string('shortnametaken', '', $foundcoursenamestring);
- if (!empty($pending)) {
- $errors['shortname'] .= get_string('starpending');
- }
+ $errors['shortname'] = get_string('shortnametaken', '', $foundcoursenamestring);
+ if (!empty($pending)) {
+ $errors['shortname'] .= get_string('starpending');
}
}
return $errors;
}
+}
+
+/**
+ * A form for an administrator to reject a course request.
+ */
+class reject_request_form extends moodleform {
+ function definition() {
+ $mform =& $this->_form;
+ $mform->addElement('hidden', 'reject', 0);
+
+ $mform->addElement('header','coursedetails', get_string('coursereasonforrejecting'));
+
+ $mform->addElement('textarea', 'rejectnotice', get_string('coursereasonforrejectingemail'), array('rows'=>'15', 'cols'=>'50'));
+ $mform->addRule('rejectnotice', get_string('missingreqreason'), 'required', null, 'client');
+ $mform->setType('rejectnotice', PARAM_TEXT);
+
+ $this->add_action_buttons(true, get_string('reject'));
+ }
}
?>
View
3 lang/en_utf8/error.php
@@ -38,6 +38,7 @@
$string['errorcreatingfile'] = 'Error creating file \"$a\"';
$string['erroronline'] = 'Error on line $a';
$string['errorreadingfile'] = 'Error reading file \"$a\"';
+$string['errorsavingrequest'] = 'An error occurred when trying to save your request.';
$string['errorunzippingfiles'] = 'Error unzipping files';
$string['fieldrequired'] = '\"$a\" is a required field';
$string['filenotfound'] = 'Sorry, the requested file could not be found';
@@ -48,6 +49,7 @@
$string['groupunknown'] = 'Group $a not associated to specified course';
$string['guestnoeditprofile'] = 'The guest user cannot edit their profile';
$string['guestnoeditprofileother'] = 'The guest user profile cannot be edited';
+$string['guestsarenotallowed'] = 'The guest user is not allowed to do this';
$string['invalidcontext'] = 'Invalid context';
$string['invalidcourse'] = 'Invalid course';
$string['invalidcourseid'] = 'You are trying to use an invalid course ID ($a)';
@@ -108,6 +110,7 @@
$string['unicodeupgradeerror'] = 'Sorry, but your database is not already in Unicode, and this version of Moodle is not able to migrate your database to Unicode. Please upgrade to Moodle 1.7.x first and perform the Unicode migration from the Admin page. After that is done you should be able to migrate to Moodle $a';
$string['unknowncourse'] = 'Unknown course named \"$a\"';
$string['unknowncourseidnumber'] = 'Unknown Course ID \"$a\"';
+$string['unknowncourserequest'] = 'Unknown course request';
$string['unknowngroup'] = 'Unknown group \"$a\"';
$string['unknownrole'] = 'Unknown role \"$a\"';
$string['unknownuseraction'] = 'Sorry, I do not understand this user action';
View
7 lang/en_utf8/moodle.php
@@ -135,6 +135,7 @@
$string['availablecourses'] = 'Available Courses';
$string['backtoparticipants'] = 'Back to participants list';
$string['back'] = 'Back';
+$string['backtocourselisting'] = 'Back to course listing';
$string['backup'] = 'Backup';
$string['backupactivehelp'] = 'Choose whether or not to do automated backups.';
$string['backupcancelled'] = 'Backup Cancelled';
@@ -282,6 +283,8 @@
$string['coursenotaccessible'] = 'This course does not allow public access';
$string['courseoverview'] = 'Course overview';
$string['courseoverviewgraph'] = 'Course overview graph';
+$string['coursereasonforrejecting'] = 'Your reasons for rejecting this request';
+$string['coursereasonforrejectingemail'] = 'This will be emailed to the requester';
$string['coursereject'] = 'Reject a course request';
$string['courserejected'] = 'Course has been rejected and the requester has been notified.';
$string['courserejectemail'] = 'Sorry, but the course you requested has been rejected. Here is the reason provided:
@@ -291,11 +294,13 @@
$string['courserejectsubject'] = 'Your course has been rejected';
$string['coursereports'] = 'Course reports';
$string['courserequest'] = 'Course request';
+$string['courserequestdetails'] = 'Details of the course you are requesting';
$string['courserequestdisabled'] = 'Sorry, but requesting courses has been disabled by the administrator';
$string['courserequestfailed'] = 'For some reason, your course request could not be saved';
$string['courserequestintro'] = 'Use this form to request a course to be created for you.<br />Try and fill in as much information as you can to allow<br />the administrators to understand your reasons for wanting this course.';
$string['courserequestreason'] = 'Reasons for wanting this course';
$string['courserequestsuccess'] = 'Successfully saved your course request. Expect an email within a few days with the outcome';
+$string['courserequestsupport'] = 'Supporting information to help the administrator evaluate this request';
$string['courserestore'] = 'Course restore';
$string['courses'] = 'Courses';
$string['coursescategory'] = 'Courses in the same category';
@@ -1170,6 +1175,7 @@
$string['paymentsorry'] = 'Thank you for your payment! Unfortunately your payment has not yet been fully processed, and you are not yet registered to enter the course \"$a->fullname\". Please try continuing to the course in a few seconds, but if you continue to have trouble then please alert the $a->teacher or the site administrator';
$string['paymentthanks'] = 'Thank you for your payment! You are now enrolled in your course:<br />\"$a\"';
$string['people'] = 'People';
+$string['pendingrequests'] = 'Pending requests';
$string['periodending'] = 'Period ending ($a)';
$string['personal'] = 'Personal';
$string['personalprofile'] = 'Personal profile';
@@ -1239,6 +1245,7 @@
$string['registrationsend'] = 'Send registration information to moodle.org';
$string['registrationyes'] = 'Yes, please notify me about important issues';
$string['reject'] = 'Reject';
+$string['rejectdots'] = 'Reject...';
$string['reload'] = 'Reload';
$string['remoteappuser'] = 'Remote $a User';
$string['remove'] = 'Remove';
View
16 theme/standard/styles_layout.css
@@ -2012,7 +2012,21 @@ body#course-info .generalbox.info {
#my-index .name {
margin-left: 5px;
}
-
+#course-pending .pendingcourserequests {
+ margin-bottom: 1em;
+}
+#course-pending .pendingcourserequests .singlebutton {
+ display: inline;
+}
+#course-pending .pendingcourserequests .cell {
+ padding: 0 5px;
+}
+#course-pending .pendingcourserequests .cell.c6 {
+ white-space: nowrap;
+}
+#course-pending .singlebutton {
+ text-align: center;
+}
.categorylist {
width: 90%;
margin-left: auto;

0 comments on commit 7f2e6a2

Please sign in to comment.