|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00030 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); 00031 require_once(dirname(__FILE__).'/locallib.php'); 00032 require_once(dirname(__FILE__).'/allocation/lib.php'); 00033 00034 $cmid = required_param('cmid', PARAM_INT); // course module 00035 $method = optional_param('method', 'manual', PARAM_ALPHA); // method to use 00036 00037 $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); 00038 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 00039 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); 00040 $workshop = new workshop($workshop, $cm, $course); 00041 00042 $PAGE->set_url($workshop->allocation_url($method)); 00043 00044 require_login($course, false, $cm); 00045 $context = $PAGE->context; 00046 require_capability('mod/workshop:allocate', $context); 00047 00048 $PAGE->set_title($workshop->name); 00049 $PAGE->set_heading($course->fullname); 00050 $PAGE->navbar->add(get_string('allocation', 'workshop')); 00051 00052 $allocator = $workshop->allocator_instance($method); 00053 $initresult = $allocator->init(); 00054 00055 // 00056 // Output starts here 00057 // 00058 $output = $PAGE->get_renderer('mod_workshop'); 00059 echo $output->header(); 00060 00061 $allocators = workshop::installed_allocators(); 00062 if (!empty($allocators)) { 00063 $tabs = array(); 00064 $row = array(); 00065 $inactive = array(); 00066 $activated = array(); 00067 foreach ($allocators as $methodid => $methodname) { 00068 $row[] = new tabobject($methodid, $workshop->allocation_url($methodid)->out(), $methodname); 00069 if ($methodid == $method) { 00070 $currenttab = $methodid; 00071 } 00072 } 00073 } 00074 $tabs[] = $row; 00075 print_tabs($tabs, $currenttab, $inactive, $activated); 00076 00077 if (!empty($initresult)) { 00078 echo $output->container_start('allocator-init-results'); 00079 echo $output->render(new workshop_allocation_init_result($initresult, $workshop->allocation_url($method))); 00080 echo $output->container_end(); 00081 } else { 00082 echo $output->container_start('allocator-ui'); 00083 echo $allocator->ui(); 00084 echo $output->container_end(); 00085 } 00086 echo $output->footer();