Skip to content

Commit

Permalink
MDL-39710 Don't display rubric and guide preview unless option checked
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed May 31, 2013
1 parent 8df87c1 commit 5117347
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions grade/grading/form/guide/lib.php
Expand Up @@ -501,10 +501,16 @@ public function render_preview(moodle_page $page) {
throw new coding_exception('It is the caller\'s responsibility to make sure that the form is actually defined'); throw new coding_exception('It is the caller\'s responsibility to make sure that the form is actually defined');
} }


$output = $this->get_renderer($page); // Check if current user is able to see preview
$options = $this->get_options();
if (empty($options['alwaysshowdefinition']) && !has_capability('moodle/grade:managegradingforms', $page->context)) {
return '';
}

$criteria = $this->definition->guide_criteria; $criteria = $this->definition->guide_criteria;
$comments = $this->definition->guide_comment; $comments = $this->definition->guide_comment;
$options = $this->get_options(); $output = $this->get_renderer($page);

$guide = ''; $guide = '';
$guide .= $output->box($this->get_formatted_description(), 'gradingform_guide-description'); $guide .= $output->box($this->get_formatted_description(), 'gradingform_guide-description');
if (has_capability('moodle/grade:managegradingforms', $page->context)) { if (has_capability('moodle/grade:managegradingforms', $page->context)) {
Expand Down
9 changes: 6 additions & 3 deletions grade/grading/form/rubric/lib.php
Expand Up @@ -505,23 +505,26 @@ public function render_preview(moodle_page $page) {
throw new coding_exception('It is the caller\'s responsibility to make sure that the form is actually defined'); throw new coding_exception('It is the caller\'s responsibility to make sure that the form is actually defined');
} }


$output = $this->get_renderer($page);
$criteria = $this->definition->rubric_criteria; $criteria = $this->definition->rubric_criteria;
$options = $this->get_options(); $options = $this->get_options();
$rubric = ''; $rubric = '';
if (has_capability('moodle/grade:managegradingforms', $page->context)) { if (has_capability('moodle/grade:managegradingforms', $page->context)) {
$showdescription = true; $showdescription = true;
} else { } else {
if (empty($options['alwaysshowdefinition'])) {
// ensure we don't display unless show rubric option enabled
return '';
}
$showdescription = $options['showdescriptionstudent']; $showdescription = $options['showdescriptionstudent'];
} }
$output = $this->get_renderer($page);
if ($showdescription) { if ($showdescription) {
$rubric .= $output->box($this->get_formatted_description(), 'gradingform_rubric-description'); $rubric .= $output->box($this->get_formatted_description(), 'gradingform_rubric-description');
} }
if (has_capability('moodle/grade:managegradingforms', $page->context)) { if (has_capability('moodle/grade:managegradingforms', $page->context)) {
$rubric .= $output->display_rubric_mapping_explained($this->get_min_max_score()); $rubric .= $output->display_rubric_mapping_explained($this->get_min_max_score());
$rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW, 'rubric'); $rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW, 'rubric');
// ensure we don't display unless show rubric option enabled } else {
} else if ( !empty($options['alwaysshowdefinition']) ) {
$rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW_GRADED, 'rubric'); $rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW_GRADED, 'rubric');
} }


Expand Down

0 comments on commit 5117347

Please sign in to comment.