From: David Mudrak <david.mudrak@gmail.com> Date: Mon, 4 Jan 2010 18:00:12 +0000 (+0000) Subject: MDL-20183 Uses some of the new Navigation API X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=39861053c4c5382079bba1e0532e5d4b2ea6469a;p=moodle.git MDL-20183 Uses some of the new Navigation API --- diff --git a/mod/workshop/allocation.php b/mod/workshop/allocation.php index fb8d421bb5..d3e35b65c4 100644 --- a/mod/workshop/allocation.php +++ b/mod/workshop/allocation.php @@ -46,9 +46,7 @@ require_capability('mod/workshop:allocate', $context); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); -// -// TODO navigation will be changed yet for Moodle 2.0 -$navigation = build_navigation(get_string('allocation', 'workshop'), $cm); +$PAGE->navbar->add(get_string('allocation', 'workshop')); $allocator = $workshop->allocator_instance($method); $initresult = $allocator->init(); @@ -57,7 +55,7 @@ $initresult = $allocator->init(); // Output starts here // $wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE); -echo $OUTPUT->header($navigation); +echo $OUTPUT->header(); $allocators = $workshop->installed_allocators(); $tabrow = array(); diff --git a/mod/workshop/assessment.php b/mod/workshop/assessment.php index 6eee1f5c75..d2da52f6e1 100644 --- a/mod/workshop/assessment.php +++ b/mod/workshop/assessment.php @@ -58,6 +58,9 @@ if ('preview' == $mode) { $PAGE->set_url($workshop->previewform_url()); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); + $PAGE->navbar->add(get_string('editingassessmentform', 'workshop'), null, null, navigation_node::TYPE_CUSTOM, + $workshop->editform_url()); + $PAGE->navbar->add(get_string('previewassessmentform', 'workshop')); } elseif ('assessment' == $mode) { if (!has_any_capability(array('mod/workshop:peerassess', 'mod/workshop:assessallsubmissions'), $PAGE->context)) { @@ -67,30 +70,9 @@ if ('preview' == $mode) { $PAGE->set_url($workshop->assess_url($assessment->id)); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); + $PAGE->navbar->add(get_string('assessingsubmission', 'workshop')); } -// build the navigation and the header - todo this will be changed by the new navigation api -$navlinks = array(); -$navlinks[] = array('name' => get_string('modulenameplural', 'workshop'), - 'link' => "index.php?id=$course->id", - 'type' => 'activity'); -$navlinks[] = array('name' => format_string($workshop->name), - 'link' => "view.php?id=$cm->id", - 'type' => 'activityinstance'); -if ($mode == 'preview') { - $navlinks[] = array('name' => get_string('editingassessmentform', 'workshop'), - 'link' => $workshop->editform_url()->out(), - 'type' => 'title'); - $navlinks[] = array('name' => get_string('previewassessmentform', 'workshop'), - 'link' => '', - 'type' => 'title'); -} elseif ($mode == 'assessment') { - $navlinks[] = array('name' => get_string('assessingsubmission', 'workshop'), - 'link' => '', - 'type' => 'title'); -} -$navigation = build_navigation($navlinks); - // load the grading strategy logic $strategy = $workshop->grading_strategy_instance(); @@ -107,7 +89,7 @@ if ($mform->is_cancelled()) { } $rawgrade = $strategy->save_assessment($assessment, $data); if (!is_null($rawgrade) and isset($data->saveandclose)) { - echo $OUTPUT->header($navigation); + echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('assessmentresult', 'workshop'), 2); echo $OUTPUT->box('Given grade: ' . sprintf("%01.2f", $rawgrade * 100) . ' %'); // todo more detailed info using own renderer echo $OUTPUT->continue_button($workshop->view_url()); @@ -122,7 +104,7 @@ if ($mform->is_cancelled()) { // Output starts here -echo $OUTPUT->header($navigation); +echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('assessmentform', 'workshop'), 2); if ('assessment' === $mode) { diff --git a/mod/workshop/develtools.php b/mod/workshop/develtools.php index 010e69298d..623a5e89b7 100644 --- a/mod/workshop/develtools.php +++ b/mod/workshop/develtools.php @@ -47,18 +47,16 @@ $PAGE->set_url('mod/workshop/develtools.php', array('cmid' => $cm->id)); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'workshop')); +$PAGE->navbar->add('Development tools'); $wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE); -$navigation = build_navigation('Development tools', $cm); -// todo $menu = navmenu($course, $cm); - switch ($tool) { case 'mksubmissions': $authors = $workshop->get_peer_authors(false); $authorswithsubmission = $workshop->get_peer_authors(true); $authors = array_diff_key($authors, $authorswithsubmission); - echo $OUTPUT->header($navigation); + echo $OUTPUT->header(); $c = 0; // counter foreach ($authors as $authorid => $author) { $timenow = time() - rand(0, 60 * 60 * 24 * 7); // submitted sometimes during last week @@ -102,7 +100,7 @@ case 'mksubmissions': case 'menu': // no break, skip to default default: - echo $OUTPUT->header($navigation); + echo $OUTPUT->header(); echo $OUTPUT->heading('Workshop development tools', 1); echo '<ul>'; echo '<li><a href="' . $PAGE->url->out(false, array('tool' => 'mksubmissions')) . '">Fake submissions</a></li>'; diff --git a/mod/workshop/editform.php b/mod/workshop/editform.php index ef6c7d0e31..6e613cd2f8 100644 --- a/mod/workshop/editform.php +++ b/mod/workshop/editform.php @@ -43,6 +43,7 @@ $workshop = new workshop($workshop, $cm, $course); $PAGE->set_url($workshop->editform_url()); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); +$PAGE->navbar->add(get_string('editingassessmentform', 'workshop')); // load the grading strategy logic $strategy = $workshop->grading_strategy_instance(); diff --git a/mod/workshop/index.php b/mod/workshop/index.php index 3edeb398e4..aa0f67aff8 100644 --- a/mod/workshop/index.php +++ b/mod/workshop/index.php @@ -41,20 +41,14 @@ require_course_login($course); add_to_log($course->id, 'workshop', 'view all', "index.php?id=$course->id", ''); -/// Print the header - $PAGE->set_url('mod/workshop/view.php', array('id' => $id)); $PAGE->set_title($course->fullname); $PAGE->set_heading($course->shortname); +$PAGE->navbar->add(get_string('modulenameplural', 'workshop')); -// todo navigation will be changed yet for Moodle 2.0 -$navlinks = array(); -$navlinks[] = array('name' => get_string('modulenameplural', 'workshop'), - 'link' => '', - 'type' => 'activity'); -$navigation = build_navigation($navlinks); +/// Output starts here -echo $OUTPUT->header($navigation); +echo $OUTPUT->header(); /// Get all the appropriate data diff --git a/mod/workshop/lang/en_utf8/workshop.php b/mod/workshop/lang/en_utf8/workshop.php index 8741436cad..45f93c29da 100644 --- a/mod/workshop/lang/en_utf8/workshop.php +++ b/mod/workshop/lang/en_utf8/workshop.php @@ -25,12 +25,14 @@ defined('MOODLE_INTERNAL') || die(); +$string[''] = ''; $string['accesscontrol'] = 'Access control'; $string['agreeassessments'] = 'Assessments must be agreed'; $string['agreeassessmentsdesc'] = 'Authors may comment assessments of their work and agree/disagree with it'; -$string['allocation'] = 'Submission allocation'; +$string['allocate'] = 'Allocate submissions'; $string['allocationdone'] = 'Allocation done'; $string['allocationerror'] = 'Allocation error'; +$string['allocation'] = 'Submission allocation'; $string['areadimensiondescription'] = 'Assessment form fields'; $string['areasubmissionattachment'] = 'Submission attachments'; $string['areasubmissioncontent'] = 'Submission texts'; @@ -59,6 +61,7 @@ $string['configmaxbytes'] = 'Default maximum submission file size for all worksh $string['confignexassessments'] = 'Default number of examples to be reviewed by a user in the example assessment phase'; $string['confignsassessments'] = 'Default number of allocated submissions to be reviewed by a user in the assessment phase'; $string['configstrategy'] = 'Default grading strategy for workshops'; +$string['editassessmentform'] = 'Edit assessment form'; $string['editingassessmentform'] = 'Editing assessment form'; $string['editingsubmission'] = 'Editing submission'; $string['editsubmission'] = 'Edit submission'; @@ -79,6 +82,7 @@ $string['maxbytes'] = 'Maximum file size'; $string['messageclose'] = '(hide)'; $string['modulenameplural'] = 'Workshops'; $string['modulename'] = 'Workshop'; +$string['mysubmission'] = 'My submission'; $string['nattachments'] = 'Maximum number of submission attachments'; $string['nexassessments'] = 'Number of required assessments of examples'; $string['nogradeyet'] = 'No grade yet'; @@ -119,5 +123,6 @@ $string['userdatemodified'] = 'modified on <span>$a</span>'; $string['useselfassessmentdesc'] = 'Users perform self assessment of their own work'; $string['useselfassessment'] = 'Use self assessment'; $string['withoutsubmission'] = 'Warning - reviewer without own submission'; +$string['workshopadministration'] = 'Workshop administration'; $string['workshopfeatures'] = 'Workshop features'; $string['workshopname'] = 'Workshop name'; diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index 46ae8192fd..57443bc46b 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -433,6 +433,52 @@ function workshop_get_file_info($browser, $areas, $course, $cm, $context, $filea } } +/** + * Extends the global navigation tree by adding workshop nodes if there is a relevant content + * + * @param navigation_node $navref An object representing the navigation tree node of the workshop module instance + * @param stdClass $course + * @param stdClass $module + * @param stdClass $cm + */ +function workshop_extend_navigation(navigation_node $navref, stdClass $course, stdClass $module, stdClass $cm) { + global $CFG; + + if (has_capability('mod/workshop:submit', $cm->context)) { + $url = new moodle_url($CFG->wwwroot.'/mod/workshop/submission.php', array('cmid' => $cm->id)); + $mysubmissionkey = $navref->add(get_string('mysubmission', 'workshop'), null, null, navigation_node::TYPE_CUSTOM, $url); + } +} + +/** + * Extends the settings navigation with the Workshop settings + + * This function is called when the context for the page is a workshop module. + * + * @param settings_navigation $settingsnav {@link settings_navigation} + * @param stdClass $module + * @return void|mixed The key to the modules branch + */ +function workshop_extend_settings_navigation(settings_navigation $settingsnav, stdClass $module=null) { + global $CFG, $PAGE; + + $workshopkey = $settingsnav->add(get_string('workshopadministration', 'workshop')); + $workshopnode = $settingsnav->get($workshopkey); + $workshopnode->forceopen = true; + //$workshopobject = $DB->get_record("workshop", array("id" => $PAGE->cm->instance)); + + if (has_capability('mod/workshop:editdimensions', $PAGE->context)) { + $url = new moodle_url($CFG->wwwroot . '/mod/workshop/editform.php', array('cmid' => $PAGE->cm->id)); + $workshopnode->add(get_string('editassessmentform', 'workshop'), null, null, settings_navigation::TYPE_SETTING, $url); + } + if (has_capability('mod/workshop:allocate', $PAGE->context)) { + $url = new moodle_url($CFG->wwwroot . '/mod/workshop/allocation.php', array('cmid' => $PAGE->cm->id)); + $workshopnode->add(get_string('allocate', 'workshop'), null, null, settings_navigation::TYPE_SETTING, $url); + } +} + + + //////////////////////////////////////////////////////////////////////////////// // Other functions needed by Moodle core follows. They can't be put into // // locallib.php because they are used by some core scripts (like modedit.php) // diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 1edb6cd6e7..e740532b38 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -582,6 +582,14 @@ class workshop { return new moodle_url($CFG->wwwroot . '/mod/workshop/assessment.php', array('asid' => $assessmentid)); } + /** + * @return stdClass {@link moodle_url} the URL of the page to view own submission + */ + public function submission_url() { + global $CFG; + return new moodle_url($CFG->wwwroot . '/mod/workshop/submission.php', array('cmid' => $this->cm->id)); + } + /** * Returns an object containing all data to display the user's full name and picture * diff --git a/mod/workshop/submission.php b/mod/workshop/submission.php index e5f2f7bffa..ed84de8a6e 100644 --- a/mod/workshop/submission.php +++ b/mod/workshop/submission.php @@ -102,11 +102,15 @@ if ($mform->is_cancelled()) { $PAGE->set_url('mod/workshop/submission.php', array('cmid' => $cm->id)); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); +// the default navbar node for non-editing mode is set in {@link workshop_extend_navigation()} +if ($edit) { + $PAGE->navbar->add(get_string('mysubmission', 'workshop'), null, null, navigation_node::TYPE_CUSTOM, + $workshop->submission_url()); + $PAGE->navbar->add(get_string('editingsubmission', 'workshop')); +} // Output starts here -$stredit = empty($submission->id) ? get_string('editingsubmission', 'workshop') : get_string('edit'); -$navigation = build_navigation($stredit, $cm); -echo $OUTPUT->header($navigation); +echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($workshop->name), 2); if ($edit) { diff --git a/mod/workshop/view.php b/mod/workshop/view.php index d32aaec1ef..090b1d67d2 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -71,20 +71,9 @@ if ($PAGE->user_allowed_editing()) { $buttons[] = $OUTPUT->update_module_button($cm->id, 'workshop'); $PAGE->set_button(implode('', $buttons)); -// todo navigation will be changed yet for Moodle 2.0 -$navlinks = array(); -$navlinks[] = array('name' => get_string('modulenameplural', 'workshop'), - 'link' => "index.php?id=$course->id", - 'type' => 'activity'); -$navlinks[] = array('name' => format_string($workshop->name), - 'link' => '', - 'type' => 'activityinstance'); -$navigation = build_navigation($navlinks); -//$menu = navmenu($course, $cm); todo - /// Output starts here -echo $OUTPUT->header($navigation); +echo $OUTPUT->header(); /// Print the main part of the page - todo these are just links to help during development echo $OUTPUT->box_start();