Пример #1
0
}
//Attempt to create a schedule with the 5 preferred courses
$s = Schedule::buildConflictFreeSchedule($scheduling, $year, $term, $alternatives);
//If we couln't find a schedule with those courses and their alternatives, reduce the number of courses we are trying to schedule
if (count($s->getSchedules()) == 0 && count($electives) == 0) {
    $iter = 0;
    while ($iter < count($scheduling) && ($s == null or count($s->getSchedules() == 0))) {
        $s = Schedule::buildConflictFreeSchedule(array_slice($scheduling, $iter), $year, $term, array_slice($pattern, $endIndex + 1));
        $iter++;
    }
    echo '<noschedulemessage> Could not generate a conflict free schedule</noschedulemessage>';
} else {
    if ($s == null) {
        $s = new Schedule();
    }
    //Output the schedule
    foreach ($s->getSchedules() as $sched) {
        $sched->to_xml();
    }
    //Output the elective options
    echo '<electives>';
    foreach ($electives as $elective) {
        echo '<elective group="' . $elective[2] . '">';
        foreach (Elective::getElectives($_GET['program_select'], $elective[1], $elective[2]) as $option) {
            echo "<option>" . $option[0] . "</option>";
        }
        echo '</elective>';
    }
    echo '</electives>';
}
echo '</response>';