MDL-12913 - Error messages when doing an XML grade import are not very helpful, include the idnumber that is causing the problem in the error message.

This commit is contained in:
tjhunt 2008-01-10 15:38:48 +00:00
parent cb3883c297
commit 18159e20db
2 changed files with 10 additions and 5 deletions

View File

@ -41,15 +41,16 @@ function import_xml_grades($text, $course, &$error) {
$results = $content['results']['#']['result'];
foreach ($results as $i => $result) {
if (!$grade_items = grade_item::fetch_all(array('idnumber'=>$result['#']['assignment'][0]['#'], 'courseid'=>$course->id))) {
$gradeidnumber = $result['#']['assignment'][0]['#'];
if (!$grade_items = grade_item::fetch_all(array('idnumber'=>$gradeidnumber, 'courseid'=>$course->id))) {
// gradeitem does not exist
// no data in temp table so far, abort
$status = false;
$error = get_string('errincorrectidnumber', 'gradeimport_xml');
$error = get_string('errincorrectgradeidnumber', 'gradeimport_xml', $gradeidnumber);
break;
} else if (count($grade_items) != 1) {
$status = false;
$error = get_string('errduplicateidnumber', 'gradeimport_xml');
$error = get_string('errduplicategradeidnumber', 'gradeimport_xml', $gradeidnumber);
break;
} else {
$grade_item = reset($grade_items);
@ -63,10 +64,11 @@ function import_xml_grades($text, $course, &$error) {
}
// check if user exist and convert idnumber to user id
if (!$user = get_record('user', 'idnumber', addslashes($result['#']['student'][0]['#']))) {
$useridnumber = $result['#']['student'][0]['#'];
if (!$user = get_record('user', 'idnumber', addslashes($useridnumber))) {
// no user found, abort
$status = false;
$error = get_string('baduser', 'grades');
$error = get_string('errincorrectuseridnumber', 'gradeimport_xml', $useridnumber);
break;
}

View File

@ -3,6 +3,9 @@
$string['errbadxmlformat'] = 'Error - bad XML format';
$string['errduplicateidnumber'] = 'Error - duplicate idnumber';
$string['errincorrectidnumber'] = 'Error - incorrect idnumber';
$string['errduplicategradeidnumber'] = 'Error - there are two grade items with idnumber \'$a\' in this course. This should be impossible.';
$string['errincorrectgradeidnumber'] = 'Error - idnumber \'$a\' from the import file does not match any grade item.';
$string['errincorrectuseridnumber'] = 'Error - idnumber \'$a\' from the import file does not match any user.';
$string['fileurl'] = 'Remote file URL';
$string['modulename'] = 'XML file';
$string['xml:view'] = 'Import grades from XML';