From 08af32afbd3602f5ad33f46af89474d5833444dc Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 4 May 2010 22:56:22 +0000 Subject: [PATCH] Workshop: uses navigation block + settings block instead of own tabs --- mod/workshop/allocation.php | 18 +++++++-- mod/workshop/editform.php | 2 - mod/workshop/excompare.php | 3 -- mod/workshop/exsubmission.php | 2 - mod/workshop/locallib.php | 9 ++++- mod/workshop/submission.php | 2 - mod/workshop/tabs.php | 74 ----------------------------------- mod/workshop/view.php | 1 - 8 files changed, 22 insertions(+), 89 deletions(-) delete mode 100644 mod/workshop/tabs.php diff --git a/mod/workshop/allocation.php b/mod/workshop/allocation.php index b89d71a42fd..48fc1b08f11 100644 --- a/mod/workshop/allocation.php +++ b/mod/workshop/allocation.php @@ -38,7 +38,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EX $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); -$PAGE->set_url($workshop->allocation_url(), array('cmid' => $cmid, 'method' => $method)); +$PAGE->set_url($workshop->allocation_url($method)); require_login($course, false, $cm); $context = $PAGE->context; @@ -58,8 +58,20 @@ $wsoutput = $PAGE->get_renderer('mod_workshop'); echo $OUTPUT->header(); $allocators = workshop::installed_allocators(); -$currenttab = 'allocation'; -include(dirname(__FILE__) . '/tabs.php'); +if (!empty($allocators)) { + $tabs = array(); + $row = array(); + $inactive = array(); + $activated = array(); + foreach ($allocators as $methodid => $methodname) { + $row[] = new tabobject($methodid, $workshop->allocation_url($methodid)->out(), $methodname); + if ($methodid == $method) { + $currenttab = $methodid; + } + } +} +$tabs[] = $row; +print_tabs($tabs, $currenttab, $inactive, $activated); if (!empty($initresult)) { echo $OUTPUT->container_start('allocator-init-results'); diff --git a/mod/workshop/editform.php b/mod/workshop/editform.php index dc7b0ffc0bf..becd081dcdd 100644 --- a/mod/workshop/editform.php +++ b/mod/workshop/editform.php @@ -73,8 +73,6 @@ if ($mform->is_cancelled()) { // Output starts here echo $OUTPUT->header(); -$currenttab = 'editform'; -include(dirname(__FILE__) . '/tabs.php'); echo $OUTPUT->heading(get_string('pluginname', 'workshopform_' . $workshop->strategy)); $mform->display(); diff --git a/mod/workshop/excompare.php b/mod/workshop/excompare.php index f698e57409d..6a497302436 100644 --- a/mod/workshop/excompare.php +++ b/mod/workshop/excompare.php @@ -73,9 +73,6 @@ $wsoutput = $PAGE->get_renderer('mod_workshop'); // Output starts here echo $OUTPUT->header(); -//$currenttab = 'example'; -//include(dirname(__FILE__) . '/tabs.php'); -//$currenttab = 'example'; echo $OUTPUT->heading(get_string('assessedexample', 'workshop'), 2); echo $wsoutput->example_full($example, true); diff --git a/mod/workshop/exsubmission.php b/mod/workshop/exsubmission.php index 0aa63bdb9de..169d68c8c7d 100644 --- a/mod/workshop/exsubmission.php +++ b/mod/workshop/exsubmission.php @@ -155,8 +155,6 @@ if ($edit) { // Output starts here echo $OUTPUT->header(); -$currenttab = 'example'; -include(dirname(__FILE__) . '/tabs.php'); echo $OUTPUT->heading(format_string($workshop->name), 2); // if in edit mode, display the form to edit the example diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index d4cff8fb949..0c2c34ecc2c 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -879,11 +879,16 @@ class workshop { } /** + * @param string $method allocation method * @return moodle_url to the allocation page */ - public function allocation_url() { + public function allocation_url($method=null) { global $CFG; - return new moodle_url('/mod/workshop/allocation.php', array('cmid' => $this->cm->id)); + $params = array('cmid' => $this->cm->id); + if (!empty($method)) { + $params['method'] = $method; + } + return new moodle_url('/mod/workshop/allocation.php', $params); } /** diff --git a/mod/workshop/submission.php b/mod/workshop/submission.php index 80aaafa662b..00907bf5013 100644 --- a/mod/workshop/submission.php +++ b/mod/workshop/submission.php @@ -149,8 +149,6 @@ if ($edit) { // Output starts here echo $OUTPUT->header(); -$currenttab = 'submission'; -include(dirname(__FILE__) . '/tabs.php'); echo $OUTPUT->heading(format_string($workshop->name), 2); // if in edit mode, display the form to edit the submission diff --git a/mod/workshop/tabs.php b/mod/workshop/tabs.php deleted file mode 100644 index 63da7289c84..00000000000 --- a/mod/workshop/tabs.php +++ /dev/null @@ -1,74 +0,0 @@ -. - -/** - * Defines and prints the workshop navigation tabs - * - * Can be included from within a workshop script only - * - * @package mod-workshop - * @copyright 2009 David Mudrak - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -if (empty($workshop) or !is_a($workshop, 'workshop')) { - print_error('cannotcallscript'); -} -if (!isset($currenttab)) { - $currenttab = 'info'; -} - -$tabs = array(); -$row = array(); -$inactive = array(); -$activated = array(); - -// top level tabs -if (has_capability('mod/workshop:view', $PAGE->context)) { - $row[] = new tabobject('info', $workshop->view_url()->out(), get_string('info', 'workshop')); -} -if (has_capability('mod/workshop:editdimensions', $PAGE->context)) { - $row[] = new tabobject('editform', $workshop->editform_url()->out(), get_string('editassessmentform', 'workshop')); -} -if ($currenttab == 'example' and has_any_capability(array('mod/workshop:submit', 'mod/workshop:manageexamples'), $PAGE->context)) { - $row[] = new tabobject('example', '', get_string('example', 'workshop')); -} -if (has_capability('mod/workshop:submit', $PAGE->context)) { - $row[] = new tabobject('submission', $workshop->submission_url()->out(), get_string('submission', 'workshop')); -} -if (has_capability('mod/workshop:allocate', $PAGE->context)) { - $row[] = new tabobject('allocation', $workshop->allocation_url()->out(), get_string('allocate', 'workshop')); -} -$tabs[] = $row; - -if ($currenttab == 'allocation' and !empty($allocators)) { - // this is included from allocation.php so we rely of some variables defined there - $activated[] = 'allocation'; - $row = array(); - foreach ($allocators as $methodid => $methodname) { - $row[] = new tabobject($methodid, "allocation.php?cmid={$cmid}&method={$methodid}", $methodname); - if ($methodid == $method) { - $currenttab = $methodid; - } - } - $tabs[] = $row; -} - - -print_tabs($tabs, $currenttab, $inactive, $activated); diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 7397d5997cd..1ce9ac5cfef 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -62,7 +62,6 @@ $wsoutput = $PAGE->get_renderer('mod_workshop'); /// Output starts here echo $OUTPUT->header(); -include(dirname(__FILE__) . '/tabs.php'); echo $OUTPUT->heading(format_string($workshop->name), 2); echo $wsoutput->user_plan($workshop->prepare_user_plan($USER->id, $PAGE->context));