Workshop: uses navigation block + settings block instead of own tabs

This commit is contained in:
David Mudrak 2010-05-04 22:56:22 +00:00
parent a345de6e59
commit 08af32afbd
8 changed files with 22 additions and 89 deletions

View File

@ -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');

View File

@ -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();

View File

@ -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);

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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

View File

@ -1,74 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines and prints the workshop navigation tabs
*
* Can be included from within a workshop script only
*
* @package mod-workshop
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
* @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}&amp;method={$methodid}", $methodname);
if ($methodid == $method) {
$currenttab = $methodid;
}
}
$tabs[] = $row;
}
print_tabs($tabs, $currenttab, $inactive, $activated);

View File

@ -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));