コード例 #1
0
 public static function retrieveOrCreate($student, $course_subject_id = null, $date, $career_school_year_id)
 {
     $student_attendance = self::retrieveByDateAndStudent($date, $student, $course_subject_id, $career_school_year_id);
     if (null != $student_attendance) {
         return $student_attendance;
     } else {
         $student_attendance = new StudentAttendance();
         $student_attendance->setStudent($student);
         $student_attendance->setDay($date);
         $student_attendance->setCourseSubjectId($course_subject_id);
         $student_attendance->setCareerSchoolYearId($career_school_year_id);
         return $student_attendance;
     }
 }
コード例 #2
0
 protected function createStudentAttendance($student, $day, $course, $absenceType)
 {
     $absence = new StudentAttendance();
     $absence->setCareerSchoolYearId($course->getCareerSchoolYear()->getId());
     $absence->setStudentId($student->getId());
     $absence->setDay($day);
     $absence->setAbsenceTypeId($absenceType->getId());
     $absence->setValue($absenceType->getValue());
     $absence->save();
     return $absence;
 }
コード例 #3
0
 public function absences($id)
 {
     $class_id = substr($id, 0, 1);
     $student_id = substr($id, 1);
     $student = Student::find($student_id);
     $absences = StudentAttendance::where('student_id', '=', $student_id)->where('class_id', '=', $class_id)->orderBy('date', 'ASC')->get();
     $class = DB::table('classes')->where('id', $class_id)->pluck('name');
     $page_data = array('student' => $student, 'absences' => $absences, 'class' => $class);
     $this->layout->title = 'Absences';
     $this->layout->content = View::make('admin.absences', $page_data);
 }
コード例 #4
0
ファイル: routes.php プロジェクト: anchetaWern/absentist
    Route::post('/claim', 'AdminController@updateStudentStatus');
    Route::get('/absences/{id}', 'AdminController@absences');
    Route::get('/semester', 'AdminController@semesterSettings');
    Route::post('/semester', 'AdminController@updateSemesterSettings');
});
Route::get('/password/forgot', 'RemindersController@getRemind');
Route::post('/password/remind', 'RemindersController@postRemind');
Route::get('/password/reset/{token}', 'RemindersController@getReset');
Route::post('/password/reset', 'RemindersController@postReset');
Route::get('/import', function () {
    $class_id = 2;
    $student_id = '1100723';
    $date = '2015-09-12';
    $id = $class_id . $student_id;
    $drop_absences_count = 1;
    $attendance = new StudentAttendance();
    $attendance->student_id = $student_id;
    $attendance->class_id = $class_id;
    $attendance->date = $date;
    $attendance->type = 'absent';
    $attendance->save();
    $current_absence_count = DB::table('student_classes')->where('id', '=', $id)->pluck('current_absence_count');
    $current_absence_count += 1;
    if ($current_absence_count == $drop_absences_count) {
        //update status to: to_drop
        DB::table('student_classes')->where('id', '=', $id)->update(array('status' => 'to_drop'));
    }
    //increment current_absence_count
    DB::table('student_classes')->where('id', $id)->increment('current_absence_count');
    return 'done!';
});