grade-outcomes MDL-23354 Fixed up navigation problems and added courseid to links where required to maintain that

This commit is contained in:
Sam Hemelryk 2010-07-21 06:51:12 +00:00
parent 8c5ce0ec59
commit 1f3e25963a
4 changed files with 21 additions and 24 deletions

View File

@ -23,10 +23,9 @@ $courseid = required_param('id', PARAM_INT);
$PAGE->set_url('/grade/edit/outcome/course.php', array('id'=>$courseid));
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
/// Make sure they can even access this course
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:update', $context);

View File

@ -63,7 +63,7 @@
if (has_capability('moodle/grade:manageoutcomes', $context)) {
?>
<p class="mdl-align">
<a href="<?php echo $CFG->wwwroot ?>/grade/edit/outcome/index.php"><?php echo get_string('editoutcomes','grades'); ?></a>
<a href="<?php echo $CFG->wwwroot ?>/grade/edit/outcome/index.php?id=<?php echo $courseid; ?>"><?php echo get_string('editoutcomes','grades'); ?></a>
</p>
<?php
}

View File

@ -32,8 +32,12 @@ $courseid = optional_param('courseid', 0, PARAM_INT);
$id = optional_param('id', 0, PARAM_INT);
$url = new moodle_url('/grade/edit/outcome/edit.php');
if ($courseid !== 0) $url->param('courseid', $courseid);
if ($id !== 0) $url->param('id', $id);
if ($courseid !== 0) {
$url->param('courseid', $courseid);
}
if ($id !== 0) {
$url->param('id', $id);
}
$PAGE->set_url($url);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
@ -71,23 +75,23 @@ if ($id) {
} else if ($courseid){
$heading = get_string('addoutcome', 'grades');
/// adding new outcome from course
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
print_error('nocourseid');
}
$outcome_rec = new object();
$outcome_rec->standard = 0;
$outcome_rec->courseid = $courseid;
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/grade:manage', $context);
navigation_node::override_active_url(new moodle_url('/grade/edit/outcome/course.php', array('id'=>$courseid)));
$outcome_rec = new object();
$outcome_rec->standard = 0;
$outcome_rec->courseid = $courseid;
} else {
require_login();
require_capability('moodle/grade:manage', $systemcontext);
/// adding new outcome from admin section
$outcome_rec = new object();
$outcome_rec->standard = 1;
$outcome_rec->courseid = 0;
require_login();
require_capability('moodle/grade:manage', $systemcontext);
}
// default return url

View File

@ -31,12 +31,11 @@ $courseid = optional_param('id', 0, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
$PAGE->set_url('/grade/edit/outcome/index.php', array('id' => $courseid));
$PAGE->set_pagelayout('admin');
/// Make sure they can even access this course
if ($courseid) {
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
print_error('nocourseid');
}
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/grade:manageoutcomes', $context);
@ -44,7 +43,8 @@ if ($courseid) {
if (empty($CFG->enableoutcomes)) {
redirect('../../index.php?id='.$courseid);
}
// This page doesn't exist on the navigation so map it to another
navigation_node::override_active_url(new moodle_url('/grade/edit/outcome/course.php', array('id'=>$courseid)));
} else {
if (empty($CFG->enableoutcomes)) {
redirect('../../../');
@ -56,12 +56,6 @@ if ($courseid) {
/// return tracking object
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'outcome', 'courseid'=>$courseid));
$strgrades = get_string('grades');
$pagename = get_string('outcomes', 'grades');
$navigation = grade_build_nav(__FILE__, $pagename, $courseid);
$strshortname = get_string('shortname');
$strfullname = get_string('fullname');
$strscale = get_string('scale');