From 9e4eb676e4f30b6c09c0b43e6ddc5fd151084d26 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Wed, 2 Nov 2011 22:25:32 +0100 Subject: [PATCH] MDL-29483 The list of gradable areas is now obtained from the module At the moment, only activity modules are supported. --- grade/grading/lib.php | 25 ++++++++++++++++++------- mod/assignment/lib.php | 9 +++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/grade/grading/lib.php b/grade/grading/lib.php index 50f5af068f3..8d29bb3928a 100644 --- a/grade/grading/lib.php +++ b/grade/grading/lib.php @@ -260,14 +260,25 @@ class grading_manager { $this->ensure_isset(array('context', 'component')); - // example: if the given context+component lead to mod_assignment, this method - // will do something like - // require_once($CFG->dirroot.'/mod/assignment/lib.php'); - // return assignment_gradable_area_list(); + if ($this->get_context()->contextlevel == CONTEXT_SYSTEM) { + if ($this->get_component() !== 'core_grading') { + throw new coding_exception('Unsupported component at the system context'); + } else { + return array(); + } - // todo - what to return for bank areas in the system context - // todo - hardcoded list for now - return array('submission' => 'Submissions'); + } else if ($this->get_context()->contextlevel >= CONTEXT_COURSE) { + list($context, $course, $cm) = get_context_info_array($this->get_context()->id); + + if (empty($cm->modname)) { + throw new coding_exception('Unsupported area location'); + } else { + return plugin_callback('mod', $cm->modname, 'grading', 'areas_list', null, array()); + } + + } else { + throw new coding_exception('Unsupported gradable area context level'); + } } /** diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 7288f4bd4c0..e89705c7920 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -3892,3 +3892,12 @@ function assignment_page_type_list($pagetype, $parentcontext, $currentcontext) { ); return $module_pagetype; } + +/** + * Lists all gradable areas for the advanced grading methods gramework + * + * @return array + */ +function assignment_grading_areas_list() { + return array('submission' => get_string('submissions', 'mod_assignment')); +}