Commit 9784aa23 authored by Adrian Greeve's avatar Adrian Greeve
Browse files

MDL-30315 gradebook: Uploading feedback doesn't override grades.

parent 7da2ed7a
......@@ -577,6 +577,7 @@ class gradeimport_csv_load_data {
} else {
// The grade item for this is not updated.
$newfeedback->importonlyfeedback = true;
$insertid = self::insert_grade_record($newfeedback, $this->studentid);
// Check to see if the insert was successful.
if (empty($insertid)) {
......
......@@ -210,6 +210,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$testarray[$key]->feedback = $record->feedback;
$testarray[$key]->importcode = $testobject->get_importcode();
$testarray[$key]->importer = $USER->id;
$testarray[$key]->importonlyfeedback = 0;
// Check that the record was inserted into the database.
$this->assertEquals($gradeimportvalues, $testarray);
......
......@@ -114,6 +114,10 @@ function grade_import_commit($courseid, $importcode, $importfeedback=true, $verb
if (!$importfeedback) {
$grade->feedback = false; // ignore it
}
if ($grade->importonlyfeedback) {
// False means do not change. See grade_itme::update_final_grade().
$grade->finalgrade = false;
}
if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, 'import', $grade->feedback)) {
$errordata = new stdClass();
$errordata->itemname = $gradeitem->itemname;
......
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20141017" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20150811" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
......@@ -1951,6 +1951,7 @@
<FIELD NAME="feedback" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="importcode" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="similar to backup_code, a unique batch code for identifying one batch of imports"/>
<FIELD NAME="importer" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="importonlyfeedback" TYPE="int" LENGTH="1" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
......@@ -4136,5 +4136,20 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2014111006.10);
}
if ($oldversion < 2014111007.07) {
// Define field importtype to be added to grade_import_values.
$table = new xmldb_table('grade_import_values');
$field = new xmldb_field('importonlyfeedback', XMLDB_TYPE_INTEGER, '1', null, null, null, '0', 'importer');
// Conditionally launch add field importtype.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2014111007.07);
}
return true;
}
......@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2014111007.06; // 20141110 = branching date YYYYMMDD - do not modify!
$version = 2014111007.07; // 20141110 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment