mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Merge branch 'MDL-48991-master' of git://github.com/merrill-oakland/moodle
This commit is contained in:
commit
dfdb99d9d5
@ -180,7 +180,7 @@ class gradeimport_csv_load_data {
|
||||
* @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;
|
||||
@ -204,9 +204,9 @@ class gradeimport_csv_load_data {
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,7 +385,7 @@ class gradeimport_csv_load_data {
|
||||
}
|
||||
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) {
|
||||
|
@ -41,9 +41,9 @@ require_once($CFG->libdir . '/grade/tests/fixtures/lib.php');
|
||||
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"
|
||||
@ -109,6 +109,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@mail.com,75.00,,75.00,{exportdate}'
|
||||
'student7@mail.com',
|
||||
56.00,
|
||||
'We welcome feedback',
|
||||
44.0,
|
||||
56.00
|
||||
),
|
||||
array(
|
||||
@ -120,6 +121,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@mail.com,75.00,,75.00,{exportdate}'
|
||||
'student5@mail.com',
|
||||
75.00,
|
||||
'',
|
||||
45.0,
|
||||
75.00
|
||||
)
|
||||
);
|
||||
@ -133,6 +135,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@mail.com,75.00,,75.00,{exportdate}'
|
||||
'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.
|
||||
@ -371,6 +374,13 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@mail.com,75.00,,75.00,{exportdate}'
|
||||
// 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user