Skip to content

Commit

Permalink
Merge branch 'MDL-48991-master' of git://github.com/merrill-oakland/m…
Browse files Browse the repository at this point in the history
…oodle
  • Loading branch information
David Monllao committed Feb 17, 2015
2 parents d908797 + 502aa0f commit dfdb99d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions grade/import/csv/classes/load_data.php
Expand Up @@ -180,7 +180,7 @@ protected function insert_grade_record($record, $studentid) {
* @param array $header The column headers from the CSV file.
* @param int $key Current row identifier.
* @param string $value The value for this row (final grade).
* @return array new grades that are ready for commiting to the gradebook.
* @return object new grade that is ready for commiting to the gradebook.
*/
protected function import_new_grade_item($header, $key, $value) {
global $DB, $USER;
Expand All @@ -204,9 +204,9 @@ protected function import_new_grade_item($header, $key, $value) {
// Instead of omitting the grade we could insert one with finalgrade set to 0.
// We do not have access to grade item min grade.
$newgrade->finalgrade = $value;
$newgrades[] = $newgrade;
}
return $newgrades;
$this->newgrades[] = $newgrade;
return $newgrade;
}

/**
Expand Down Expand Up @@ -385,7 +385,7 @@ protected function map_user_data_with_value($mappingidentifier, $value, $header,
}
break;
case 'new':
$this->newgrades = $this->import_new_grade_item($header, $key, $value);
$this->import_new_grade_item($header, $key, $value);
break;
case 'feedback':
if ($feedbackgradeid) {
Expand Down
16 changes: 13 additions & 3 deletions grade/import/csv/tests/load_data_test.php
Expand Up @@ -41,9 +41,9 @@
class gradeimport_csv_load_data_testcase extends grade_base_testcase {

/** @var string $oktext Text to be imported. This data should have no issues being imported. */
protected $oktext = '"First name",Surname,"ID number",Institution,Department,"Email address","Assignment: Assignment for grape group", "Feedback: Assignment for grape group","Course total"
Anne,Able,,"Moodle HQ","Rock on!",student7@mail.com,56.00,"We welcome feedback",56.00
Bobby,Bunce,,"Moodle HQ","Rock on!",student5@mail.com,75.00,,75.00';
protected $oktext = '"First name",Surname,"ID number",Institution,Department,"Email address","Assignment: Assignment for grape group", "Feedback: Assignment for grape group","Assignment: Second new grade item","Course total"
Anne,Able,,"Moodle HQ","Rock on!",student7@mail.com,56.00,"We welcome feedback",44.0,56.00
Bobby,Bunce,,"Moodle HQ","Rock on!",student5@mail.com,75.00,,45.0,75.00';

/** @var string $badtext Text to be imported. This data has an extra column and should not succeed in being imported. */
protected $badtext = '"First name",Surname,"ID number",Institution,Department,"Email address","Assignment: Assignment for grape group","Course total"
Expand Down Expand Up @@ -109,6 +109,7 @@ public function test_load_csv_content() {
'student7@mail.com',
56.00,
'We welcome feedback',
44.0,
56.00
),
array(
Expand All @@ -120,6 +121,7 @@ public function test_load_csv_content() {
'student5@mail.com',
75.00,
'',
45.0,
75.00
)
);
Expand All @@ -133,6 +135,7 @@ public function test_load_csv_content() {
'Email address',
'Assignment: Assignment for grape group',
'Feedback: Assignment for grape group',
'Assignment: Second new grade item',
'Course total'
);
// Check that general data is returned as expected.
Expand Down Expand Up @@ -371,6 +374,13 @@ public function test_map_user_data_with_value() {
// Check that the final grade is the same as the one inserted.
$this->assertEquals($testarray[0][6], $newgrades[0]->finalgrade);

$newgrades = $testobject->test_map_user_data_with_value('new', $testarray[0][8], $this->columns, $map, $key,
$this->courseid, $map[$key], $verbosescales);
// Check that the final grade is the same as the one inserted.
// The testobject should now contain 2 new grade items.
$this->assertEquals(2, count($newgrades));
$this->assertEquals($testarray[0][8], $newgrades[1]->finalgrade);

$feedback = $testobject->test_map_user_data_with_value('feedback', $testarray[0][7], $this->columns, $map, $key,
$this->courseid, $map[$key], $verbosescales);
// Expected result.
Expand Down

0 comments on commit dfdb99d

Please sign in to comment.