MDL-43127 tool_uploadcourse: Add support for more enrolment methods

This commit is contained in:
Frederic Massart
2014-11-25 11:01:30 +08:00
parent 702e65c9ed
commit 086199c4e9
7 changed files with 233 additions and 18 deletions
+11 -2
View File
@@ -207,6 +207,7 @@ class tool_uploadcourse_processor {
$course = $this->get_course($data);
if ($course->prepare()) {
$course->proceed();
$outcome = 1;
$status = $course->get_statuses();
if (array_key_exists('coursecreated', $status)) {
@@ -217,11 +218,19 @@ class tool_uploadcourse_processor {
$deleted++;
}
// Errors can occur even though the course preparation returned true, often because
// some checks could not be done in course::prepare() because it requires the course to exist.
if ($course->has_errors()) {
$status += $course->get_errors();
$errors++;
$outcome = 2;
}
$data = array_merge($data, $course->get_data(), array('id' => $course->get_id()));
$tracker->output($this->linenb, true, $status, $data);
$tracker->output($this->linenb, $outcome, $status, $data);
} else {
$errors++;
$tracker->output($this->linenb, false, $course->get_errors(), $data);
$tracker->output($this->linenb, 0, $course->get_errors(), $data);
}
}