Skip to content

Commit

Permalink
Merge branch 'MDL-48993-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 fc8f8e6 + deb7f93 commit b87374b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions grade/import/csv/classes/load_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,12 @@ protected function import_new_grade_item($header, $key, $value) {
$newgrade = new stdClass();
$newgrade->newgradeitem = $this->newgradeitems[$key];

// If the user has a grade for this grade item.
if (trim($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.
$trimmed = trim($value);
if ($trimmed === '' or $trimmed == '-') {
// Blank or dash grade means null, ie "no grade".
$newgrade->finalgrade = null;
} else {
// We have an actual grade.
$newgrade->finalgrade = $value;
}
$this->newgrades[] = $newgrade;
Expand Down
7 changes: 4 additions & 3 deletions grade/import/csv/tests/load_data_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ 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","Assignment: Second new grade item","Course total"
Anne,Able,,"Moodle HQ","Rock on!",[email protected],56.00,"We welcome feedback",44.0,56.00
Anne,Able,,"Moodle HQ","Rock on!",[email protected],56.00,"We welcome feedback",,56.00
Bobby,Bunce,,"Moodle HQ","Rock on!",[email protected],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. */
Expand Down Expand Up @@ -109,7 +109,7 @@ public function test_load_csv_content() {
'[email protected]',
56.00,
'We welcome feedback',
44.0,
'',
56.00
),
array(
Expand Down Expand Up @@ -379,7 +379,8 @@ public function test_map_user_data_with_value() {
// 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);
// Because this grade item is empty, the value for final grade should be null.
$this->assertNull($newgrades[1]->finalgrade);

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

0 comments on commit b87374b

Please sign in to comment.