mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-30771: Enable students to view rubric definition prior to submission
Also allow advanced grading plugin to extend course module navigation, it is not necessary only definition previewing Added option to rubric whether to show it to the students before submission and option to view description
This commit is contained in:
parent
baa5cd8240
commit
577c89644f
7 changed files with 152 additions and 12 deletions
|
@ -202,6 +202,19 @@ abstract class gradingform_controller {
|
||||||
// do not extend by default
|
// do not extend by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the module navigation
|
||||||
|
*
|
||||||
|
* This function is called when the context for the page is an activity module with the
|
||||||
|
* FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.
|
||||||
|
*
|
||||||
|
* @param global_navigation $navigation {@link global_navigation}
|
||||||
|
* @param navigation_node $node {@link navigation_node}
|
||||||
|
*/
|
||||||
|
public function extend_navigation(global_navigation $navigation, navigation_node $node=null) {
|
||||||
|
// do not extend by default
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the grading form definition structure
|
* Returns the grading form definition structure
|
||||||
*
|
*
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$string['addcriterion'] = 'Add criterion';
|
$string['addcriterion'] = 'Add criterion';
|
||||||
|
$string['alwaysshowdefinition'] = 'Allow users to preview rubric used in the module (otherwise rubric will only become visible after grading)';
|
||||||
$string['backtoediting'] = 'Back to editing';
|
$string['backtoediting'] = 'Back to editing';
|
||||||
$string['confirmdeletecriterion'] = 'Are you sure you want to delete this criterion?';
|
$string['confirmdeletecriterion'] = 'Are you sure you want to delete this criterion?';
|
||||||
$string['confirmdeletelevel'] = 'Are you sure you want to delete this level?';
|
$string['confirmdeletelevel'] = 'Are you sure you want to delete this level?';
|
||||||
|
@ -42,11 +43,13 @@ $string['err_nodefinition'] = 'Level definition can not be empty';
|
||||||
$string['err_nodescription'] = 'Criterion description can not be empty';
|
$string['err_nodescription'] = 'Criterion description can not be empty';
|
||||||
$string['err_scoreformat'] = 'Number of points for each level must be a valid non-negative number';
|
$string['err_scoreformat'] = 'Number of points for each level must be a valid non-negative number';
|
||||||
$string['err_totalscore'] = 'Maximum number of points possible when graded by the rubric must be more than zero';
|
$string['err_totalscore'] = 'Maximum number of points possible when graded by the rubric must be more than zero';
|
||||||
|
$string['gradingof'] = '{$a} grading';
|
||||||
$string['leveldelete'] = 'Delete level';
|
$string['leveldelete'] = 'Delete level';
|
||||||
$string['levelempty'] = 'Click to edit level';
|
$string['levelempty'] = 'Click to edit level';
|
||||||
$string['name'] = 'Name';
|
$string['name'] = 'Name';
|
||||||
$string['needregrademessage'] = 'The rubric definition was changed after this student had been graded. The student can not see this rubric until you check the rubric and update the grade.';
|
$string['needregrademessage'] = 'The rubric definition was changed after this student had been graded. The student can not see this rubric until you check the rubric and update the grade.';
|
||||||
$string['pluginname'] = 'Rubric';
|
$string['pluginname'] = 'Rubric';
|
||||||
|
$string['previewrubric'] = 'Preview rubric';
|
||||||
$string['regrademessage1'] = 'You are about to save changes to a rubric that has already been used for grading. Please indicate if existing grades need to be reviewed. If you set this then the rubric will be hidden from students until their item is regraded.';
|
$string['regrademessage1'] = 'You are about to save changes to a rubric that has already been used for grading. Please indicate if existing grades need to be reviewed. If you set this then the rubric will be hidden from students until their item is regraded.';
|
||||||
$string['regrademessage5'] = 'You are about to save significant changes to a rubric that has already been used for grading. The gradebook value will be unchanged, but the rubric will be hidden from students until their item is regraded.';
|
$string['regrademessage5'] = 'You are about to save significant changes to a rubric that has already been used for grading. The gradebook value will be unchanged, but the rubric will be hidden from students until their item is regraded.';
|
||||||
$string['regradeoption0'] = 'Do not mark for regrade';
|
$string['regradeoption0'] = 'Do not mark for regrade';
|
||||||
|
|
|
@ -37,8 +37,10 @@ class gradingform_rubric_controller extends gradingform_controller {
|
||||||
const DISPLAY_EDIT_FULL = 1;
|
const DISPLAY_EDIT_FULL = 1;
|
||||||
/** Rubric display mode: Preview the rubric design with hidden fields */
|
/** Rubric display mode: Preview the rubric design with hidden fields */
|
||||||
const DISPLAY_EDIT_FROZEN = 2;
|
const DISPLAY_EDIT_FROZEN = 2;
|
||||||
/** Rubric display mode: Preview the rubric design */
|
/** Rubric display mode: Preview the rubric design (for person with manage permission) */
|
||||||
const DISPLAY_PREVIEW = 3;
|
const DISPLAY_PREVIEW = 3;
|
||||||
|
/** Rubric display mode: Preview the rubric (for people being graded) */
|
||||||
|
const DISPLAY_PREVIEW_GRADED= 8;
|
||||||
/** Rubric display mode: For evaluation, enabled (teacher grades a student) */
|
/** Rubric display mode: For evaluation, enabled (teacher grades a student) */
|
||||||
const DISPLAY_EVAL = 4;
|
const DISPLAY_EVAL = 4;
|
||||||
/** Rubric display mode: For evaluation, with hidden fields */
|
/** Rubric display mode: For evaluation, with hidden fields */
|
||||||
|
@ -64,6 +66,27 @@ class gradingform_rubric_controller extends gradingform_controller {
|
||||||
null, null, new pix_icon('icon', '', 'gradingform_rubric'));
|
null, null, new pix_icon('icon', '', 'gradingform_rubric'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the module navigation
|
||||||
|
*
|
||||||
|
* This function is called when the context for the page is an activity module with the
|
||||||
|
* FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.
|
||||||
|
*
|
||||||
|
* @param global_navigation $navigation {@link global_navigation}
|
||||||
|
* @param navigation_node $node {@link navigation_node}
|
||||||
|
*/
|
||||||
|
public function extend_navigation(global_navigation $navigation, navigation_node $node=null) {
|
||||||
|
if (has_capability('moodle/grade:managegradingforms', $this->get_context())) {
|
||||||
|
// no need for preview if user can manage forms, he will have link to manage.php in settings instead
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($this->is_form_defined() && ($options = $this->get_options()) && !empty($options['alwaysshowdefinition'])) {
|
||||||
|
$node->add(get_string('gradingof', 'gradingform_rubric', get_grading_manager($this->get_areaid())->get_area_title()),
|
||||||
|
new moodle_url('/grade/grading/form/'.$this->get_method_name().'/preview.php', array('areaid' => $this->get_areaid())),
|
||||||
|
settings_navigation::TYPE_CUSTOM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the rubric definition into the database
|
* Saves the rubric definition into the database
|
||||||
*
|
*
|
||||||
|
@ -330,14 +353,14 @@ class gradingform_rubric_controller extends gradingform_controller {
|
||||||
public static function get_default_options() {
|
public static function get_default_options() {
|
||||||
$options = array(
|
$options = array(
|
||||||
'sortlevelsasc' => 1,
|
'sortlevelsasc' => 1,
|
||||||
//'showdescriptionteacher' => 1,
|
'alwaysshowdefinition' => 1,
|
||||||
//'showdescriptionstudent' => 1,
|
'showdescriptionteacher' => 1,
|
||||||
|
'showdescriptionstudent' => 1,
|
||||||
'showscoreteacher' => 1,
|
'showscoreteacher' => 1,
|
||||||
'showscorestudent' => 1,
|
'showscorestudent' => 1,
|
||||||
'enableremarks' => 1,
|
'enableremarks' => 1,
|
||||||
'showremarksstudent' => 1
|
'showremarksstudent' => 1
|
||||||
);
|
);
|
||||||
// TODO description options
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,8 +507,13 @@ class gradingform_rubric_controller extends gradingform_controller {
|
||||||
$output = $this->get_renderer($page);
|
$output = $this->get_renderer($page);
|
||||||
$criteria = $this->definition->rubric_criteria;
|
$criteria = $this->definition->rubric_criteria;
|
||||||
$options = $this->get_options();
|
$options = $this->get_options();
|
||||||
$rubric = $output->display_rubric_mapping_explained($this->get_min_max_score());
|
$rubric = '';
|
||||||
|
if (has_capability('moodle/grade:managegradingforms', $page->context)) {
|
||||||
|
$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');
|
||||||
|
} else {
|
||||||
|
$rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW_GRADED, 'rubric');
|
||||||
|
}
|
||||||
|
|
||||||
return $rubric;
|
return $rubric;
|
||||||
}
|
}
|
||||||
|
@ -812,6 +840,9 @@ class gradingform_rubric_instance extends gradingform_instance {
|
||||||
if ($this->get_data('isrestored') && $haschanges) {
|
if ($this->get_data('isrestored') && $haschanges) {
|
||||||
$html .= html_writer::tag('div', get_string('restoredfromdraft', 'gradingform_rubric'), array('class' => 'gradingform_rubric-restored'));
|
$html .= html_writer::tag('div', get_string('restoredfromdraft', 'gradingform_rubric'), array('class' => 'gradingform_rubric-restored'));
|
||||||
}
|
}
|
||||||
|
if (!empty($options['showdescriptionteacher'])) {
|
||||||
|
$html .= html_writer::tag('div', $this->get_controller()->get_formatted_description(), array('class' => 'gradingform_rubric-description'));
|
||||||
|
}
|
||||||
$html .= $this->get_controller()->get_renderer($page)->display_rubric($criteria, $options, $mode, $gradingformelement->getName(), $value);
|
$html .= $this->get_controller()->get_renderer($page)->display_rubric($criteria, $options, $mode, $gradingformelement->getName(), $value);
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
56
grade/grading/form/rubric/preview.php
Normal file
56
grade/grading/form/rubric/preview.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preview rubric page
|
||||||
|
*
|
||||||
|
* @package gradingform_rubric
|
||||||
|
* @copyright 2011 Marina Glancy
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))).'/config.php');
|
||||||
|
require_once(dirname(__FILE__).'/lib.php');
|
||||||
|
require_once(dirname(__FILE__).'/edit_form.php');
|
||||||
|
require_once($CFG->dirroot.'/grade/grading/lib.php');
|
||||||
|
|
||||||
|
$areaid = required_param('areaid', PARAM_INT);
|
||||||
|
|
||||||
|
$manager = get_grading_manager($areaid);
|
||||||
|
|
||||||
|
list($context, $course, $cm) = get_context_info_array($manager->get_context()->id);
|
||||||
|
|
||||||
|
require_login($course, true, $cm);
|
||||||
|
|
||||||
|
$controller = $manager->get_controller('rubric');
|
||||||
|
$options = $controller->get_options();
|
||||||
|
|
||||||
|
if (!$controller->is_form_defined() || empty($options['alwaysshowdefinition'])) {
|
||||||
|
throw new moodle_exception('nopermissions', 'error', '', get_string('previewrubric', 'gradingform_rubric'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = get_string('gradingof', 'gradingform_rubric', $manager->get_area_title());
|
||||||
|
$PAGE->set_url(new moodle_url('/grade/grading/form/rubric/preview.php', array('areaid' => $areaid)));
|
||||||
|
$PAGE->set_title($title);
|
||||||
|
$PAGE->set_heading($title);
|
||||||
|
|
||||||
|
echo $OUTPUT->header();
|
||||||
|
echo $OUTPUT->heading($title);
|
||||||
|
if (!empty($options['showdescriptionstudent'])) {
|
||||||
|
echo $OUTPUT->box($controller->get_formatted_description(), 'gradingform_rubric-description');
|
||||||
|
}
|
||||||
|
echo $controller->render_preview($PAGE);
|
||||||
|
echo $OUTPUT->footer();
|
|
@ -191,7 +191,7 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
|
||||||
if (!$options['showscoreteacher'] && in_array($mode, array(gradingform_rubric_controller::DISPLAY_EVAL, gradingform_rubric_controller::DISPLAY_EVAL_FROZEN, gradingform_rubric_controller::DISPLAY_REVIEW))) {
|
if (!$options['showscoreteacher'] && in_array($mode, array(gradingform_rubric_controller::DISPLAY_EVAL, gradingform_rubric_controller::DISPLAY_EVAL_FROZEN, gradingform_rubric_controller::DISPLAY_REVIEW))) {
|
||||||
$displayscore = false;
|
$displayscore = false;
|
||||||
}
|
}
|
||||||
if (!$options['showscorestudent'] && $mode == gradingform_rubric_controller::DISPLAY_VIEW) {
|
if (!$options['showscorestudent'] && in_array($mode, array(gradingform_rubric_controller::DISPLAY_VIEW, gradingform_rubric_controller::DISPLAY_PREVIEW_GRADED))) {
|
||||||
$displayscore = false;
|
$displayscore = false;
|
||||||
}
|
}
|
||||||
if ($displayscore) {
|
if ($displayscore) {
|
||||||
|
@ -241,6 +241,7 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
|
||||||
case gradingform_rubric_controller::DISPLAY_EDIT_FROZEN:
|
case gradingform_rubric_controller::DISPLAY_EDIT_FROZEN:
|
||||||
$classsuffix = ' editor frozen'; break;
|
$classsuffix = ' editor frozen'; break;
|
||||||
case gradingform_rubric_controller::DISPLAY_PREVIEW:
|
case gradingform_rubric_controller::DISPLAY_PREVIEW:
|
||||||
|
case gradingform_rubric_controller::DISPLAY_PREVIEW_GRADED:
|
||||||
$classsuffix = ' editor preview'; break;
|
$classsuffix = ' editor preview'; break;
|
||||||
case gradingform_rubric_controller::DISPLAY_EVAL:
|
case gradingform_rubric_controller::DISPLAY_EVAL:
|
||||||
$classsuffix = ' evaluate editable'; break;
|
$classsuffix = ' evaluate editable'; break;
|
||||||
|
@ -277,7 +278,7 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
|
||||||
if ($mode != gradingform_rubric_controller::DISPLAY_EDIT_FULL
|
if ($mode != gradingform_rubric_controller::DISPLAY_EDIT_FULL
|
||||||
&& $mode != gradingform_rubric_controller::DISPLAY_EDIT_FROZEN
|
&& $mode != gradingform_rubric_controller::DISPLAY_EDIT_FROZEN
|
||||||
&& $mode != gradingform_rubric_controller::DISPLAY_PREVIEW) {
|
&& $mode != gradingform_rubric_controller::DISPLAY_PREVIEW) {
|
||||||
// Options are displayed only in edit mode
|
// Options are displayed only for people who can manage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$html = html_writer::start_tag('div', array('class' => 'options'));
|
$html = html_writer::start_tag('div', array('class' => 'options'));
|
||||||
|
@ -431,10 +432,17 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
|
||||||
$values = $instance->get_rubric_filling();
|
$values = $instance->get_rubric_filling();
|
||||||
if ($cangrade) {
|
if ($cangrade) {
|
||||||
$mode = gradingform_rubric_controller::DISPLAY_REVIEW;
|
$mode = gradingform_rubric_controller::DISPLAY_REVIEW;
|
||||||
|
$showdescription = $options['showdescriptionteacher'];
|
||||||
} else {
|
} else {
|
||||||
$mode = gradingform_rubric_controller::DISPLAY_VIEW;
|
$mode = gradingform_rubric_controller::DISPLAY_VIEW;
|
||||||
|
$showdescription = $options['showdescriptionstudent'];
|
||||||
}
|
}
|
||||||
return $this->display_rubric($criteria, $options, $mode, 'rubric'.$idx, $values);
|
$output = '';
|
||||||
|
if ($showdescription) {
|
||||||
|
$output .= $this->box($instance->get_controller()->get_formatted_description(), 'gradingform_rubric-description');
|
||||||
|
}
|
||||||
|
$output .= $this->display_rubric($criteria, $options, $mode, 'rubric'.$idx, $values);
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function display_regrade_confirmation($elementname, $changelevel, $value) {
|
public function display_regrade_confirmation($elementname, $changelevel, $value) {
|
||||||
|
|
|
@ -454,6 +454,27 @@ class grading_manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the module navigation with the advanced grading information
|
||||||
|
*
|
||||||
|
* This function is called when the context for the page is an activity module with the
|
||||||
|
* FEATURE_ADVANCED_GRADING.
|
||||||
|
*
|
||||||
|
* @param global_navigation $navigation
|
||||||
|
* @param navigation_node $modulenode
|
||||||
|
*/
|
||||||
|
public function extend_navigation(global_navigation $navigation, navigation_node $modulenode=null) {
|
||||||
|
$this->ensure_isset(array('context', 'component'));
|
||||||
|
|
||||||
|
$areas = $this->get_available_areas();
|
||||||
|
foreach ($areas as $areaname => $areatitle) {
|
||||||
|
$this->set_area($areaname);
|
||||||
|
if ($controller = $this->get_active_controller()) {
|
||||||
|
$controller->extend_navigation($navigation, $modulenode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the given method's controller in the gradable area
|
* Returns the given method's controller in the gradable area
|
||||||
*
|
*
|
||||||
|
|
|
@ -1854,6 +1854,7 @@ class global_navigation extends navigation_node {
|
||||||
$cm = $modinfo->get_cm($cm->id);
|
$cm = $modinfo->get_cm($cm->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$activity->nodetype = navigation_node::NODETYPE_LEAF;
|
||||||
$activity->make_active();
|
$activity->make_active();
|
||||||
$file = $CFG->dirroot.'/mod/'.$cm->modname.'/lib.php';
|
$file = $CFG->dirroot.'/mod/'.$cm->modname.'/lib.php';
|
||||||
$function = $cm->modname.'_extend_navigation';
|
$function = $cm->modname.'_extend_navigation';
|
||||||
|
@ -1863,11 +1864,18 @@ class global_navigation extends navigation_node {
|
||||||
if (function_exists($function)) {
|
if (function_exists($function)) {
|
||||||
$activtyrecord = $DB->get_record($cm->modname, array('id' => $cm->instance), '*', MUST_EXIST);
|
$activtyrecord = $DB->get_record($cm->modname, array('id' => $cm->instance), '*', MUST_EXIST);
|
||||||
$function($activity, $course, $activtyrecord, $cm);
|
$function($activity, $course, $activtyrecord, $cm);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$activity->nodetype = navigation_node::NODETYPE_LEAF;
|
|
||||||
return false;
|
// Allow the active advanced grading method plugin to append module navigation
|
||||||
|
$featuresfunc = $cm->modname.'_supports';
|
||||||
|
if (function_exists($featuresfunc) && $featuresfunc(FEATURE_ADVANCED_GRADING)) {
|
||||||
|
require_once($CFG->dirroot.'/grade/grading/lib.php');
|
||||||
|
$gradingman = get_grading_manager($cm->context, $cm->modname);
|
||||||
|
$gradingman->extend_navigation($this, $activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $activity->has_children();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Loads user specific information into the navigation in the appropriate place.
|
* Loads user specific information into the navigation in the appropriate place.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue