Skip to content
Snippets Groups Projects
Commit 8e490af8 authored by Roger W Feese's avatar Roger W Feese
Browse files

Check for existence of course before importing enrollment or staff assignment.

parent 7272f465
No related branches found
No related tags found
1 merge request!4Check for existence of course before importing enrollment or staff assignment.
......@@ -776,12 +776,14 @@ function load_enrol($db, $filesBaseDir)
);
$findPeople = "SELECT nuid FROM people WHERE nuid = ?";
$findEnrol = "SELECT enrollment_id FROM enrollments WHERE course_id = ? AND nuid = ?";
$findEnrol = "SELECT enrollment_id FROM enrollments WHERE course_id = ? AND nuid = ?";
$findCourse = "SELECT course_id FROM courses WHERE course_id = ?";
$existingPerson = $db->GetOne($findPeople, array($nuid));
$existingEnrol = $db->GetOne($findEnrol, array($courseId, $nuid));
$existingEnrol = $db->GetOne($findEnrol, array($courseId, $nuid));
$existingCourse = $db->GetOne($findCourse, array($courseId));
if ($lineItems[2] != 'W') {
if ($existingCourse && $lineItems[2] != 'W') {
if ( !$existingPerson)
{
import_person_from_ldap($nuid);
......@@ -832,23 +834,28 @@ function load_staff($db, $filesBaseDir)
);
$findPeople = "SELECT nuid FROM people WHERE nuid = ?";
$findStaff = "SELECT assignment_id FROM staff_assignments WHERE course_id = ? AND nuid = ?";
$findStaff = "SELECT assignment_id FROM staff_assignments WHERE course_id = ? AND nuid = ?";
$findCourse = "SELECT course_id FROM courses WHERE course_id = ?";
$existingPerson = $db->GetOne($findPeople, array($nuid));
$existingStaff = $db->GetOne($findStaff, array($courseId, $nuid));
$existingStaff = $db->GetOne($findStaff, array($courseId, $nuid));
$existingCourse = $db->GetOne($findCourse, array($courseId));
if ( !$existingPerson )
if ( $existingCourse )
{
import_person_from_ldap($nuid);
}
if ( !$existingPerson )
{
import_person_from_ldap($nuid);
}
if ($existingStaff)
{
auto_update($db, 'staff_assignments', $staffData, 'assignment_id', $existingStaff['assignment_id']);
}
else if ($existingPerson)
{
auto_insert($db, 'staff_assignments', $staffData);
if ($existingStaff)
{
auto_update($db, 'staff_assignments', $staffData, 'assignment_id', $existingStaff['assignment_id']);
}
else if ($existingPerson)
{
auto_insert($db, 'staff_assignments', $staffData);
}
}
}
fclose($handle);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment