Permalink
Browse files

MDL-29108 Advanced grading - renaming DB field forminstanceid to inst…

…anceid

As a response to Sam's review (7.4)
  • Loading branch information...
mudrd8mz committed Nov 13, 2011
1 parent 71ab436 commit 6f07a6a2ea674883cf480a2640707aa87683688f
@@ -107,7 +107,7 @@ protected function define_instance_plugin_structure() {
// Set sources to populate the data
$filling->set_source_table('gradingform_rubric_fillings',
- array('forminstanceid' => backup::VAR_PARENTID));
+ 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)
@@ -105,7 +105,7 @@ public function process_gradinform_rubric_filling($data) {
global $DB;
$data = (object)$data;
- $data->forminstanceid = $this->get_new_parentid('grading_instance');
+ $data->instanceid = $this->get_new_parentid('grading_instance');
$data->criterionid = $this->get_mappingid('gradingform_rubric_criterion', $data->criterionid);
$data->levelid = $this->get_mappingid('gradingform_rubric_level', $data->levelid);
@@ -32,18 +32,18 @@
</TABLE>
<TABLE NAME="gradingform_rubric_fillings" COMMENT="Stores the data of how the rubric is filled by a particular rater" PREVIOUS="gradingform_rubric_levels">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="forminstanceid"/>
- <FIELD NAME="forminstanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The ID of the grading form instance" PREVIOUS="id" NEXT="criterionid"/>
- <FIELD NAME="criterionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The ID of the criterion (row) in the rubric" PREVIOUS="forminstanceid" NEXT="levelid"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="instanceid"/>
+ <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The ID of the grading form instance" PREVIOUS="id" NEXT="criterionid"/>
+ <FIELD NAME="criterionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The ID of the criterion (row) in the rubric" PREVIOUS="instanceid" NEXT="levelid"/>
<FIELD NAME="levelid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="If a particular level was selected during the assessment, its ID is stored here" PREVIOUS="criterionid" NEXT="remark"/>
<FIELD NAME="remark" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Side note feedback regarding this particular criterion" PREVIOUS="levelid" NEXT="remarkformat"/>
<FIELD NAME="remarkformat" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The format of the remark field" PREVIOUS="remark"/>
</FIELDS>
<KEYS>
- <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_forminstanceid"/>
- <KEY NAME="fk_forminstanceid" TYPE="foreign" FIELDS="forminstanceid" REFTABLE="grading_instances" REFFIELDS="id" PREVIOUS="primary" NEXT="fk_criterionid"/>
- <KEY NAME="fk_criterionid" TYPE="foreign" FIELDS="criterionid" REFTABLE="gradingform_rubric_criteria" REFFIELDS="id" PREVIOUS="fk_forminstanceid" NEXT="uq_instance_criterion"/>
- <KEY NAME="uq_instance_criterion" TYPE="unique" FIELDS="forminstanceid, criterionid" PREVIOUS="fk_criterionid"/>
+ <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_rubric_criteria" REFFIELDS="id" PREVIOUS="fk_instanceid" NEXT="uq_instance_criterion"/>
+ <KEY NAME="uq_instance_criterion" TYPE="unique" FIELDS="instanceid, criterionid" PREVIOUS="fk_criterionid"/>
</KEYS>
<INDEXES>
<INDEX NAME="ix_levelid" UNIQUE="false" FIELDS="levelid" COMMENT="levelid acts as a foreign key but null values are allowed"/>
@@ -472,7 +472,7 @@ protected function delete_plugin_definition() {
// get the list of instances
$instances = array_keys($DB->get_records('grading_instances', array('definitionid' => $this->definition->id), '', 'id'));
// delete all fillings
- $DB->delete_records_list('gradingform_rubric_fillings', 'forminstanceid', $instances);
+ $DB->delete_records_list('gradingform_rubric_fillings', 'instanceid', $instances);
// delete instances
$DB->delete_records_list('grading_instances', 'id', $instances);
// get the list of criteria records
@@ -585,7 +585,7 @@ class gradingform_rubric_instance extends gradingform_instance {
public function cancel() {
global $DB;
parent::cancel();
- $DB->delete_records('gradingform_rubric_fillings', array('forminstanceid' => $this->get_id()));
+ $DB->delete_records('gradingform_rubric_fillings', array('instanceid' => $this->get_id()));
}
/**
@@ -601,7 +601,7 @@ public function copy($raterid, $itemid) {
$instanceid = parent::copy($raterid, $itemid);
$currentgrade = $this->get_rubric_filling();
foreach ($currentgrade['criteria'] as $criterionid => $record) {
- $params = array('forminstanceid' => $instanceid, 'criterionid' => $criterionid,
+ $params = array('instanceid' => $instanceid, 'criterionid' => $criterionid,
'levelid' => $record['levelid'], 'remark' => $record['remark'], 'remarkformat' => $record['remarkformat']);
$DB->insert_record('gradingform_rubric_fillings', $params);
}
@@ -635,7 +635,7 @@ public function validate_grading_element($elementvalue) {
public function get_rubric_filling($force = false) {
global $DB;
if ($this->rubric === null || $force) {
- $records = $DB->get_records('gradingform_rubric_fillings', array('forminstanceid' => $this->get_id()));
+ $records = $DB->get_records('gradingform_rubric_fillings', array('instanceid' => $this->get_id()));
$this->rubric = array('criteria' => array());
foreach ($records as $record) {
$this->rubric['criteria'][$record->criterionid] = (array)$record;
@@ -657,7 +657,7 @@ public function update($data) {
parent::update($data);
foreach ($data['criteria'] as $criterionid => $record) {
if (!array_key_exists($criterionid, $currentgrade['criteria'])) {
- $newrecord = array('forminstanceid' => $this->get_id(), 'criterionid' => $criterionid,
+ $newrecord = array('instanceid' => $this->get_id(), 'criterionid' => $criterionid,
'levelid' => $record['levelid'], 'remarkformat' => FORMAT_MOODLE);
if (isset($record['remark'])) {
$newrecord['remark'] = $record['remark'];

0 comments on commit 6f07a6a

Please sign in to comment.