Exemple #1
0
 public static function mass_enroll($student_ids, $sid)
 {
     $messages = array();
     foreach ($student_ids as $student_id) {
         $user = User::findUserByStudentId($student_id);
         if ($user != null) {
             Enrollment::enroll($user->id, $sid);
             $messages[] = $student_id . " enrolled successfully";
         } else {
             $messages[] = $student_id . " does not exist";
         }
     }
     return $messages;
 }
 public function enroll()
 {
     $section_id = Request::input('id');
     $user = Auth::user();
     $enrollment_count = Enrollment::where('student_id', '=', $user->id)->count();
     if ($enrollment_count > 3) {
         return json_encode(array("status" => "error", "message" => "You have already enrolled in maximum courses. Please contact the advisor"));
     }
     $section = Section::find($section_id);
     if ($section->filled >= $section->capacity) {
         return json_encode(array("status" => "error", "message" => "The section your requested is full. Please pick a diffrent section"));
     }
     $k = Enrollment::enroll($user->id, $section_id);
     file_put_contents("enroll_drop.log", date("F j, Y, g:i a") . " " . $user->student_id . "(" . $user->name . ") enrolled in Section Id: " . $section_id . "\n", FILE_APPEND);
     return json_encode(array("status" => "success", "message" => "Enrollment Successfull"));
 }
 public function run()
 {
     DB::table('enrollments')->delete();
     Enrollment::enroll(1, 1);
     Enrollment::enroll(1, 4);
 }