Skip to content

Commit

Permalink
MDL-20183 Uses some of the new Navigation API
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jan 4, 2010
1 parent c333a49 commit 3986105
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 58 deletions.
6 changes: 2 additions & 4 deletions mod/workshop/allocation.php
Expand Up @@ -46,9 +46,7 @@

$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();
Expand All @@ -57,7 +55,7 @@
// Output starts here
//
$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE);
echo $OUTPUT->header($navigation);
echo $OUTPUT->header();

$allocators = $workshop->installed_allocators();
$tabrow = array();
Expand Down
30 changes: 6 additions & 24 deletions mod/workshop/assessment.php
Expand Up @@ -58,6 +58,9 @@
$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)) {
Expand All @@ -67,30 +70,9 @@
$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();

Expand All @@ -107,7 +89,7 @@
}
$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());
Expand All @@ -122,7 +104,7 @@

// Output starts here

echo $OUTPUT->header($navigation);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('assessmentform', 'workshop'), 2);

if ('assessment' === $mode) {
Expand Down
8 changes: 3 additions & 5 deletions mod/workshop/develtools.php
Expand Up @@ -47,18 +47,16 @@
$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
Expand Down Expand Up @@ -102,7 +100,7 @@
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>';
Expand Down
1 change: 1 addition & 0 deletions mod/workshop/editform.php
Expand Up @@ -43,6 +43,7 @@
$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();
Expand Down
12 changes: 3 additions & 9 deletions mod/workshop/index.php
Expand Up @@ -41,20 +41,14 @@

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

Expand Down
7 changes: 6 additions & 1 deletion mod/workshop/lang/en_utf8/workshop.php
Expand Up @@ -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';
Expand Down Expand Up @@ -59,6 +61,7 @@
$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';
Expand All @@ -79,6 +82,7 @@
$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';
Expand Down Expand Up @@ -119,5 +123,6 @@
$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';
46 changes: 46 additions & 0 deletions mod/workshop/lib.php
Expand Up @@ -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) //
Expand Down
8 changes: 8 additions & 0 deletions mod/workshop/locallib.php
Expand Up @@ -582,6 +582,14 @@ public function assess_url($assessmentid) {
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
*
Expand Down
10 changes: 7 additions & 3 deletions mod/workshop/submission.php
Expand Up @@ -102,11 +102,15 @@
$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) {
Expand Down
13 changes: 1 addition & 12 deletions mod/workshop/view.php
Expand Up @@ -71,20 +71,9 @@
$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();
Expand Down

0 comments on commit 3986105

Please sign in to comment.