Skip to content

Commit

Permalink
MDL-29108 Do not display grading method selector for non-privileged u…
Browse files Browse the repository at this point in the history
…sers

The patch checks the required capability before it displays the grading
method selectors in the modform.
  • Loading branch information
mudrd8mz committed Nov 11, 2011
1 parent 217116d commit 1dea75b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions course/modedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
$data->introeditor = array('text'=>'', 'format'=>FORMAT_HTML, 'itemid'=>$draftid_editor); // TODO: add better default
}

if (plugin_supports('mod', $data->modulename, FEATURE_ADVANCED_GRADING, false)) {
if (plugin_supports('mod', $data->modulename, FEATURE_ADVANCED_GRADING, false)
and has_capability('moodle/grade:managegradingforms', $context)) {
require_once($CFG->dirroot.'/grade/grading/lib.php');

$data->_advancedgradingdata['methods'] = grading_manager::available_methods();
Expand Down Expand Up @@ -164,7 +165,8 @@
$data->introeditor = array('text'=>$currentintro, 'format'=>$data->introformat, 'itemid'=>$draftid_editor);
}

if (plugin_supports('mod', $data->modulename, FEATURE_ADVANCED_GRADING, false)) {
if (plugin_supports('mod', $data->modulename, FEATURE_ADVANCED_GRADING, false)
and has_capability('moodle/grade:managegradingforms', $context)) {
require_once($CFG->dirroot.'/grade/grading/lib.php');
$gradingman = get_grading_manager($context, 'mod_'.$data->modulename);
$data->_advancedgradingdata['methods'] = $gradingman->get_available_methods();
Expand Down Expand Up @@ -594,10 +596,10 @@
}
}

if (plugin_supports('mod', $fromform->modulename, FEATURE_ADVANCED_GRADING, false)) {
if (plugin_supports('mod', $fromform->modulename, FEATURE_ADVANCED_GRADING, false)
and has_capability('moodle/grade:managegradingforms', $modcontext)) {
require_once($CFG->dirroot.'/grade/grading/lib.php');
$context = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
$gradingman = get_grading_manager($context, 'mod_'.$fromform->modulename);
$gradingman = get_grading_manager($modcontext, 'mod_'.$fromform->modulename);
$showgradingmanagement = false;
foreach ($gradingman->get_available_areas() as $areaname => $aretitle) {
$formfield = 'advancedgradingmethod_'.$areaname;
Expand Down

0 comments on commit 1dea75b

Please sign in to comment.