diff --git a/grade/grading/lib.php b/grade/grading/lib.php index ce96d87f541..6ad77b65980 100644 --- a/grade/grading/lib.php +++ b/grade/grading/lib.php @@ -347,30 +347,34 @@ class grading_manager { if (empty($areas)) { // no money, no funny return; - } - $managementnode = $modulenode->add(get_string('gradingmanagement', 'core_grading'), - $this->get_management_url(), settings_navigation::TYPE_CUSTOM); - - foreach ($areas as $areaname => $areatitle) { + } else if (count($areas) == 1) { + // make just a single node for the management screen + $areatitle = reset($areas); + $areaname = key($areas); $this->set_area($areaname); $method = $this->get_active_method(); - - if (empty($method)) { - // no grading method selected for the given area - nothing to display - continue; + $managementnode = $modulenode->add(get_string('gradingmanagement', 'core_grading'), + $this->get_management_url(), settings_navigation::TYPE_CUSTOM); + if ($method) { + $controller = $this->get_controller($method); + $controller->extend_settings_navigation($settingsnav, $managementnode); } - if (count($areas) > 1) { - // if the module supports multiple gradable areas, make a node for each of them - $node = $managementnode->add($areatitle, null, settings_navigation::NODETYPE_BRANCH); - } else { - // otherwise put the items directly into the module's node - $node = $managementnode; + } else { + // make management screen node for each area + $managementnode = $modulenode->add(get_string('gradingmanagement', 'core_grading'), + null, settings_navigation::TYPE_CUSTOM); + foreach ($areas as $areaname => $areatitle) { + $this->set_area($areaname); + $method = $this->get_active_method(); + $node = $managementnode->add($areatitle, + $this->get_management_url(), settings_navigation::TYPE_CUSTOM); + if ($method) { + $controller = $this->get_controller($method); + $controller->extend_settings_navigation($settingsnav, $node); + } } - - $controller = $this->get_controller($method); - $controller->extend_settings_navigation($settingsnav, $node); } } @@ -439,10 +443,9 @@ class grading_manager { * Returns the URL of the grading area management page * * @param moodle_url $returnurl optional URL of the page where the user should be sent back to - * @param string $area optional area name for multi-area components * @return moodle_url */ - public function get_management_url(moodle_url $returnurl = null, $area = null) { + public function get_management_url(moodle_url $returnurl = null) { $this->ensure_isset(array('context', 'component')); @@ -450,8 +453,8 @@ class grading_manager { $params = array('areaid' => $this->areacache->id); } else { $params = array('contextid' => $this->context->id, 'component' => $this->component); - if (!is_null($area)) { - $params['area'] = $area; + if ($this->area) { + $params['area'] = $this->area; } } diff --git a/grade/grading/manage.php b/grade/grading/manage.php index 96cbfe7657c..ec29d9f1455 100644 --- a/grade/grading/manage.php +++ b/grade/grading/manage.php @@ -37,13 +37,16 @@ if (!is_null($areaid)) { $manager = get_grading_manager($areaid); } else { // get manager by context and component - if (is_null($contextid) or is_null($component)) { + if (is_null($contextid) or is_null($component) or is_null($area)) { throw new coding_exception('The caller script must identify the gradable area.'); } $context = get_context_instance_by_id($contextid, MUST_EXIST); $manager = get_grading_manager($context, $component, $area); } +// currently active method +$method = $manager->get_active_method(); + list($context, $course, $cm) = get_context_info_array($manager->get_context()->id); if (is_null($returnurl)) { @@ -55,34 +58,12 @@ if (is_null($returnurl)) { require_login($course, true, $cm); require_capability('moodle/grade:managegradingforms', $context); -$PAGE->set_url($manager->get_management_url($returnurl, $area)); +$PAGE->set_url($manager->get_management_url($returnurl)); navigation_node::override_active_url($manager->get_management_url()); $PAGE->set_title(get_string('gradingmanagement', 'core_grading')); $PAGE->set_heading(get_string('gradingmanagement', 'core_grading')); $output = $PAGE->get_renderer('core_grading'); -if (is_null($manager->get_area())) { - $areas = $manager->get_available_areas(); - - if (empty($areas)) { - throw new moodle_exception('no_gradable_area_available', 'core_grading'); - } - - if (count($areas) == 1) { - // if there is just one area available, set it automatically - $area = reset(array_keys($areas)); - $manager->set_area($area); - - } else { - // display area selector (we will make this page nicer once we have some real multi-area component) - echo $output->header(); - echo $output->heading($manager->get_component_title()); - echo $output->single_select($PAGE->url, 'area', $areas); - echo $output->footer(); - die(); - } -} - // process the eventual change of the active grading method if (!empty($activemethod)) { require_sesskey(); @@ -102,7 +83,6 @@ echo $output->heading(get_string('gradingmanagementtitle', 'core_grading', array echo $output->management_method_selector($manager, $PAGE->url); // get the currently active method's controller -$method = $manager->get_active_method(); if (!empty($method)) { $controller = $manager->get_controller($method); // display relevant actions