Skip to content

Commit

Permalink
MDL-31731 - new grading form - Marking Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Apr 29, 2012
1 parent aa753ac commit 7714321
Show file tree
Hide file tree
Showing 17 changed files with 2,968 additions and 1 deletion.
4 changes: 4 additions & 0 deletions grade/grading/form/guide/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Marking Guide grading form written by Dan Marsden <[email protected]>

based on Lightwork Rubric type 2 format and the spec available here:
http://docs.moodle.org/dev/Lightwork
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?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/>.

/**
* Support for backup API
*
* @package gradingform_guide
* @copyright 2012 Dan Marsden <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Defines marking guide backup structures
*
* @package gradingform_guide
* @copyright 2012 Dan Marsden <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_gradingform_guide_plugin extends backup_gradingform_plugin {

/**
* Declares marking guide structures to append to the grading form definition
* @return backup_plugin_element
*/
protected function define_definition_plugin_structure() {

// Append data only if the grand-parent element has 'method' set to 'guide'.
$plugin = $this->get_plugin_element(null, '../../method', 'guide');

// Create a visible container for our data.
$pluginwrapper = new backup_nested_element($this->get_recommended_name());

// Connect our visible container to the parent.
$plugin->add_child($pluginwrapper);

// Define our elements.

$criteria = new backup_nested_element('guidecriteria');

$criterion = new backup_nested_element('guidecriterion', array('id'), array(
'sortorder', 'shortname', 'description', 'descriptionformat',
'descriptionmarkers', 'descriptionmarkersformat', 'maxscore'));

$comments = new backup_nested_element('guidecomments');

$comment = new backup_nested_element('guidecomment', array('id'), array(
'sortorder', 'description', 'descriptionformat'));

// Build elements hierarchy.

$pluginwrapper->add_child($criteria);
$criteria->add_child($criterion);
$criteria->add_child($comments);
$comments->add_child($comment);

// Set sources to populate the data.

$criterion->set_source_table('gradingform_guide_criteria',
array('definitionid' => backup::VAR_PARENTID));

$comment->set_source_table('gradingform_guide_comments',
array('definitionid' => backup::VAR_PARENTID));

// No need to annotate ids or files yet (one day when criterion definition supports
// embedded files, they must be annotated here).

return $plugin;
}

/**
* Declares marking guide structures to append to the grading form instances
* @return backup_plugin_element
*/
protected function define_instance_plugin_structure() {

// Append data only if the ancestor 'definition' element has 'method' set to 'guide'.
$plugin = $this->get_plugin_element(null, '../../../../method', 'guide');

// Create a visible container for our data.
$pluginwrapper = new backup_nested_element($this->get_recommended_name());

// Connect our visible container to the parent.
$plugin->add_child($pluginwrapper);

// Define our elements.

$fillings = new backup_nested_element('fillings');

$filling = new backup_nested_element('filling', array('id'), array(
'criterionid', 'remark', 'remarkformat', 'score'));

// Build elements hierarchy.

$pluginwrapper->add_child($fillings);
$fillings->add_child($filling);

// Set sources to populate the data.

$filling->set_source_table('gradingform_guide_fillings',
array('instanceid' => backup::VAR_PARENTID));

// No need to annotate ids or files yet (one day when remark field supports
// embedded fileds, they must be annotated here).

return $plugin;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?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/>.

/**
* Support for restore API
*
* @package gradingform_guide
* @copyright 2012 Dan Marsden <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Restores the marking guide specific data from grading.xml file
*
* @package gradingform_guide
* @copyright 2012 Dan Marsden <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_gradingform_guide_plugin extends restore_gradingform_plugin {

/**
* Declares the marking guide XML paths attached to the form definition element
*
* @return array of {@link restore_path_element}
*/
protected function define_definition_plugin_structure() {

$paths = array();

$paths[] = new restore_path_element('gradingform_guide_criterion',
$this->get_pathfor('/guidecriteria/guidecriterion'));

$paths[] = new restore_path_element('gradingform_guide_comment',
$this->get_pathfor('/guidecomments/guidecomment'));

return $paths;
}

/**
* Declares the marking guide XML paths attached to the form instance element
*
* @return array of {@link restore_path_element}
*/
protected function define_instance_plugin_structure() {

$paths = array();

$paths[] = new restore_path_element('gradinform_guide_filling',
$this->get_pathfor('/fillings/filling'));

return $paths;
}

/**
* Processes criterion element data
*
* Sets the mapping 'gradingform_guide_criterion' to be used later by
* {@link self::process_gradinform_guide_filling()}
*
* @param array|stdClass $data
*/
public function process_gradingform_guide_criterion($data) {
global $DB;

$data = (object)$data;
$oldid = $data->id;
$data->definitionid = $this->get_new_parentid('grading_definition');

$newid = $DB->insert_record('gradingform_guide_criteria', $data);
$this->set_mapping('gradingform_guide_criterion', $oldid, $newid);
}

/**
* Processes comments element data
*
* @param array|stdClass $data The data to insert as a comment
*/
public function process_gradingform_guide_comment($data) {
global $DB;

$data = (object)$data;
$data->definitionid = $this->get_new_parentid('grading_definition');

$DB->insert_record('gradingform_guide_comments', $data);
}

/**
* Processes filling element data
*
* @param array|stdClass $data The data to insert as a filling
*/
public function process_gradinform_guide_filling($data) {
global $DB;

$data = (object)$data;
$data->instanceid = $this->get_new_parentid('grading_instance');
$data->criterionid = $this->get_mappingid('gradingform_guide_criterion', $data->criterionid);

$DB->insert_record('gradingform_guide_fillings', $data);
}
}
54 changes: 54 additions & 0 deletions grade/grading/form/guide/db/install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="grade/grading/form/markingguide/db" VERSION="20120404" COMMENT="XMLDB file for Moodle marking guide"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="gradingform_guide_criteria" COMMENT="Stores the rows of the criteria grid." NEXT="gradingform_guide_fillings">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="definitionid"/>
<FIELD NAME="definitionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The ID of the form definition this criterion is part of" PREVIOUS="id" NEXT="sortorder"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Defines the order of the criterion in the guide" PREVIOUS="definitionid" NEXT="shortname"/>
<FIELD NAME="shortname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="shortname of this criterion" PREVIOUS="sortorder" NEXT="description"/>
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="The criterion description for students" PREVIOUS="shortname" NEXT="descriptionformat"/>
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description" NEXT="descriptionmarkers"/>
<FIELD NAME="descriptionmarkers" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Description for Markers" PREVIOUS="descriptionformat" NEXT="descriptionmarkersformat"/>
<FIELD NAME="descriptionmarkersformat" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" PREVIOUS="descriptionmarkers" NEXT="maxscore"/>
<FIELD NAME="maxscore" TYPE="number" LENGTH="10" NOTNULL="true" SEQUENCE="false" DECIMALS="5" COMMENT="maximum grade that can be assigned using this criterion" PREVIOUS="descriptionmarkersformat"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_definitionid"/>
<KEY NAME="fk_definitionid" TYPE="foreign" FIELDS="definitionid" REFTABLE="grading_definitions" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
</TABLE>
<TABLE NAME="gradingform_guide_fillings" COMMENT="Stores the data of how the guide is filled by a particular rater" PREVIOUS="gradingform_guide_criteria" NEXT="gradingform_guide_comments">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="instanceid"/>
<FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The ID of the grading form instance" PREVIOUS="id" NEXT="criterionid"/>
<FIELD NAME="criterionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The ID of the criterion (row) in the guide" PREVIOUS="instanceid" NEXT="remark"/>
<FIELD NAME="remark" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Side note feedback regarding this particular criterion" PREVIOUS="criterionid" NEXT="remarkformat"/>
<FIELD NAME="remarkformat" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="The format of the remark field" PREVIOUS="remark" NEXT="score"/>
<FIELD NAME="score" TYPE="number" LENGTH="10" NOTNULL="true" SEQUENCE="false" DECIMALS="5" COMMENT="The score assigned" PREVIOUS="remarkformat"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_instanceid"/>
<KEY NAME="fk_instanceid" TYPE="foreign" FIELDS="instanceid" REFTABLE="grading_instances" REFFIELDS="id" PREVIOUS="primary" NEXT="fk_criterionid"/>
<KEY NAME="fk_criterionid" TYPE="foreign" FIELDS="criterionid" REFTABLE="gradingform_guide_criteria" REFFIELDS="id" PREVIOUS="fk_instanceid" NEXT="uq_instance_criterion"/>
<KEY NAME="uq_instance_criterion" TYPE="unique" FIELDS="instanceid, criterionid" PREVIOUS="fk_criterionid"/>
</KEYS>
</TABLE>
<TABLE NAME="gradingform_guide_comments" COMMENT="frequently used comments used in marking guide" PREVIOUS="gradingform_guide_fillings">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="definitionid"/>
<FIELD NAME="definitionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The ID of the form definition this faq is part of" PREVIOUS="id" NEXT="sortorder"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Defines the order of the comments" PREVIOUS="definitionid" NEXT="description"/>
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="The comment description" PREVIOUS="sortorder" NEXT="descriptionformat"/>
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_definitionid"/>
<KEY NAME="fk_definitionid" TYPE="foreign" FIELDS="definitionid" REFTABLE="grading_definitions" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
62 changes: 62 additions & 0 deletions grade/grading/form/guide/edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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/>.

/**
* Rubric editor page
*
* @package gradingform_guide
* @copyright 2012 Dan Marsden <[email protected]>
* @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);
require_capability('moodle/grade:managegradingforms', $context);

$controller = $manager->get_controller('guide');

$PAGE->set_url(new moodle_url('/grade/grading/form/guide/edit.php', array('areaid' => $areaid)));
$PAGE->set_title(get_string('definemarkingguide', 'gradingform_guide'));
$PAGE->set_heading(get_string('definemarkingguide', 'gradingform_guide'));

$mform = new gradingform_guide_editguide(null, array('areaid' => $areaid, 'context' => $context,
'allowdraft' => !$controller->has_active_instances()), 'post', '', array('class' => 'gradingform_guide_editform'));
$data = $controller->get_definition_for_editing(true);

$returnurl = optional_param('returnurl', $manager->get_management_url(), PARAM_LOCALURL);
$data->returnurl = $returnurl;
$mform->set_data($data);
if ($mform->is_cancelled()) {
redirect($returnurl);
} else if ($mform->is_submitted() && $mform->is_validated() && !$mform->need_confirm_regrading($controller)) {
// Everything ok, validated, re-grading confirmed if needed. Make changes to the rubric.
$controller->update_definition($mform->get_data());
redirect($returnurl);
}

echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();
Loading

0 comments on commit 7714321

Please sign in to comment.