mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-46546 core_grades: Notice display for bad import.
If the initial import of csv data is bad, a notification will be displayed to the user.
This commit is contained in:
parent
d3ff82257e
commit
a2809ae2c9
@ -77,17 +77,21 @@ class gradeimport_csv_load_data {
|
|||||||
$csvimport->load_csv_content($text, $encoding, $separator);
|
$csvimport->load_csv_content($text, $encoding, $separator);
|
||||||
$this->error = $csvimport->get_error();
|
$this->error = $csvimport->get_error();
|
||||||
|
|
||||||
// Get header (field names).
|
// If there are no import errors then proceed.
|
||||||
$this->headers = $csvimport->get_columns();
|
if (empty($this->error)) {
|
||||||
$this->trim_headers();
|
|
||||||
|
|
||||||
$csvimport->init();
|
// Get header (field names).
|
||||||
$this->previewdata = array();
|
$this->headers = $csvimport->get_columns();
|
||||||
|
$this->trim_headers();
|
||||||
|
|
||||||
for ($numlines = 0; $numlines <= $previewrows; $numlines++) {
|
$csvimport->init();
|
||||||
$lines = $csvimport->next();
|
$this->previewdata = array();
|
||||||
if ($lines) {
|
|
||||||
$this->previewdata[] = $lines;
|
for ($numlines = 0; $numlines <= $previewrows; $numlines++) {
|
||||||
|
$lines = $csvimport->next();
|
||||||
|
if ($lines) {
|
||||||
|
$this->previewdata[] = $lines;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ if (!$iid) {
|
|||||||
$csvimport->load_csv_content($text, $formdata->encoding, 'tab', $formdata->previewrows);
|
$csvimport->load_csv_content($text, $formdata->encoding, 'tab', $formdata->previewrows);
|
||||||
$csvimporterror = $csvimport->get_error();
|
$csvimporterror = $csvimport->get_error();
|
||||||
if (!empty($csvimporterror)) {
|
if (!empty($csvimporterror)) {
|
||||||
echo $renderer->errors($csvimport->get_error());
|
echo $renderer->errors(array($csvimport->get_error()));
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user