예제 #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>';
예제 #2
0
 public function elective($course_plan_id, $course_id = 0, $course_type, $department_id, $semester_id)
 {
     $Department = new Department();
     $success = false;
     $depts = $Department->read('dept_number', $department_id);
     // 	$depts=$Departments->getChildren($department_id);
     // 	$conditions['Student.stu_number LIKE']=$depts['Department']['dept_number'].'%';
     $options = array('conditions' => array('dept_number like' => $depts['Department']['dept_number'] . '%'));
     //debug($options);
     $Student = new Student();
     $students = $Student->find('all', $options);
     // 		debug($students);
     $data = array();
     foreach ($students as $student) {
         $data[] = array('stu_number' => $student['Student']['stu_number'], 'dept_number' => $student['Student']['dept_number'], 'course_plan_id' => $course_plan_id, 'course_type' => $course_type, 'course_id' => $course_id);
     }
     // 					debug($data);
     if ($data != array()) {
         $Elective = new Elective();
         $success = $Elective->saveAll($data);
     }
     // 	$dept_number=
     // 	$students=
     // 			die();
     return $success;
 }