MDL-54056 gradingform_guide: Conditionally render comments chooser

Render the frequently-used comments only if there are defined
 frequently used comments
This commit is contained in:
Jun Pataleta 2016-05-05 10:26:27 +08:00
parent fc1ef59fbe
commit f8a5c98eb6

View File

@ -235,10 +235,13 @@ class gradingform_guide_renderer extends plugin_renderer_base {
// Grading remark text area.
$input = html_writer::tag('textarea', s($currentremark), $remarkparams);
// Show the frequently-used comments chooser only if there are defined entries.
if (!empty($comments)) {
// Frequently used comments chooser.
$chooserbuttonid = 'criteria-' . $criterion['id'] . '-commentchooser';
$commentchooserparams = array('id' => $chooserbuttonid, 'class' => 'commentchooser');
$commentchooser = html_writer::tag('button', get_string('insertcomment', 'gradingform_guide'), $commentchooserparams);
$commentchooser = html_writer::tag('button', get_string('insertcomment', 'gradingform_guide'),
$commentchooserparams);
// Option items for the frequently used comments chooser dialog.
$commentoptions = array();
@ -254,6 +257,7 @@ class gradingform_guide_renderer extends plugin_renderer_base {
// Include comment_chooser module.
$PAGE->requires->js_call_amd('gradingform_guide/comment_chooser', 'initialise',
array($criterion['id'], $chooserbuttonid, $remarkid, $commentoptions));
}
// Hidden marking guide remark label.
$remarklabelparams = array(