Skip to content

Commit

Permalink
Merge pull request #35 from catalyst/issue34
Browse files Browse the repository at this point in the history
issue #33 and issue #34
  • Loading branch information
marcusgreen authored Nov 19, 2024
2 parents 15f06e2 + 9f6a3ff commit 88c5334
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
defined('MOODLE_INTERNAL') || die;

require_once($CFG->dirroot.'/grade/grading/lib.php');
require_once($CFG->dirroot . '/report/advancedgrading/locallib.php');

global $PAGE;
/**
* Add an item to the dropdown when viewing the assignment
Expand All @@ -36,8 +38,10 @@
* @return void
*/
function report_advancedgrading_extend_navigation_module(navigation_node $navigation, cm_info $cm) {
$context = \context_module::instance($cm->id);
if ($cm->modname == 'assign' && has_capability('moodle/grade:edit', $context)) {
$context = $cm->context;
$assignid = $cm->instance;

if ($cm->modname == 'assign' && has_capability('moodle/grade:edit', $context) && !empty(get_grading_definition($assignid))) {
$gradingmanager = get_grading_manager($context, 'mod_assign', 'submissions');
switch ($gradingmanager->get_active_method()) {
case 'rubric_ranges':
Expand Down
6 changes: 3 additions & 3 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
* Get the structure of this grading definition
*
* @param int $assignid
* @return \stdClass
* @return false|\stdClass
*/
function get_grading_definition(int $assignid): \stdClass {
function get_grading_definition(int $assignid) {
global $DB;
$sql = "SELECT gdef.id AS definitionid, ga.activemethod, gdef.name AS definition
FROM {assign} assign
JOIN {course_modules} cm ON cm.instance = assign.id
JOIN {context} ctx ON ctx.instanceid = cm.id
JOIN {grading_areas} ga ON ctx.id=ga.contextid
JOIN {grading_definitions} gdef ON ga.id = gdef.areaid
JOIN {grading_definitions} gdef ON (ga.id = gdef.areaid AND ga.activemethod = gdef.method)
WHERE assign.id = :assignid";
$definition = $DB->get_record_sql($sql, ['assignid' => $assignid]);
return $definition;
Expand Down

0 comments on commit 88c5334

Please sign in to comment.