]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20183 Uses some of the new Navigation API
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:00:12 +0000 (18:00 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:00:12 +0000 (18:00 +0000)
mod/workshop/allocation.php
mod/workshop/assessment.php
mod/workshop/develtools.php
mod/workshop/editform.php
mod/workshop/index.php
mod/workshop/lang/en_utf8/workshop.php
mod/workshop/lib.php
mod/workshop/locallib.php
mod/workshop/submission.php
mod/workshop/view.php

index fb8d421bb5b88931c4d95b75e8881c1d7724fbd8..d3e35b65c45979d8d5d0b887f5b092045ece9407 100644 (file)
@@ -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();
index 6eee1f5c75b4215bba2d8b87ae3ceff52b2340a6..d2da52f6e16ce009e5cdf93202f07b4a71f43ec2 100644 (file)
@@ -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) {
index 010e69298d5f935a73cdacca66de3456b6adf5c7..623a5e89b76146ed805c38f7d497dacfe5e5cede 100644 (file)
@@ -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>';
index ef6c7d0e3187f1e01786bbb9826967dedc3eef97..6e613cd2f8c393945b3b96a4280aabbec4006360 100644 (file)
@@ -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();
index 3edeb398e4ba9e9f27e7bae06202086b08b9f62c..aa0f67aff818bcb921061155b4bc0b6dc4dfe874 100644 (file)
@@ -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
 
index 8741436cad6c65befca96f20a081afe1134755d0..45f93c29da4d3bac5317ae625e3a80a00ed4ae4e 100644 (file)
 
 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';
index 46ae8192fd75e2a74b081151704ca8360d5d08e6..57443bc46b675fde566741f01dcab6e03e8a97df 100644 (file)
@@ -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) //
index 1edb6cd6e7ae3241e5c46fa1d5832f357a806781..e740532b3830cea092415c44454a27ab3486f40b 100644 (file)
@@ -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
      *
index e5f2f7bffa55d5182a509f30101e77abbd73077e..ed84de8a6eebbe52472b496d2362388a7dfa4164 100644 (file)
@@ -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) {
index d32aaec1efb330f79fc4a112d242a25a992a1d81..090b1d67d2bbc3eacea84900edd9c13dff6dc2a3 100644 (file)
@@ -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();