Пример #1
0
 public function listAttendance()
 {
     if ($this->data['users']->role != "admin" and $this->data['users']->role != "teacher") {
         exit;
     }
     $toReturn = array();
     $toReturn['class'] = classes::where('id', Input::get('classId'))->first()->toArray();
     if (Input::get('subjectId')) {
         $toReturn['subject'] = subject::where('id', Input::get('subjectId'))->first()->toArray();
     }
     $toReturn['students'] = array();
     $studentArray = User::where('role', 'student')->where('studentClass', Input::get('classId'))->get();
     foreach ($studentArray as $stOne) {
         $toReturn['students'][$stOne->id] = array('name' => $stOne->fullName, 'studentRollId' => $stOne->studentRollId, 'attendance' => '');
     }
     $vacationList = vacation::where('vacDate', Input::get('attendanceDay'))->where('acYear', $this->panelInit->selectAcYear)->where('role', 'student')->get();
     if (Input::get('subjectId')) {
         $attendanceArray = attendance::where('classId', Input::get('classId'))->where('subjectId', Input::get('subjectId'))->where('date', Input::get('attendanceDay'))->get();
     } else {
         $attendanceArray = attendance::where('classId', Input::get('classId'))->where('date', Input::get('attendanceDay'))->get();
     }
     foreach ($attendanceArray as $stAttendance) {
         if (isset($toReturn['students'][$stAttendance->studentId])) {
             $toReturn['students'][$stAttendance->studentId]['attendance'] = $stAttendance->status;
         }
     }
     foreach ($vacationList as $vacation) {
         if (isset($toReturn['students'][$vacation->userid])) {
             $toReturn['students'][$vacation->userid]['vacation'] = true;
             $toReturn['students'][$vacation->userid]['vacationStat'] = $vacation->acceptedVacation;
         }
     }
     return json_encode($toReturn);
 }
Пример #2
0
 public function listAll()
 {
     $toReturn = array();
     $toReturn['classes'] = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get()->toArray();
     $classesArray = array();
     while (list(, $class) = each($toReturn['classes'])) {
         $classesArray[$class['id']] = array("classTitle" => $class['className'], "subjects" => json_decode($class['classSubjects']));
     }
     if ($this->data['users']->role == "teacher") {
         $subjects = subject::where('teacherId', $this->data['users']->id)->get()->toArray();
     } else {
         $subjects = subject::get()->toArray();
     }
     $subjectArray = array();
     while (list(, $subject) = each($subjects)) {
         $subjectArray[$subject['id']] = $subject['subjectTitle'];
     }
     $toReturn['onlineExams'] = array();
     $onlineExams = new onlineExams();
     if ($this->data['users']->role == "teacher") {
         $onlineExams = $onlineExams->where('examTeacher', $this->data['users']->id);
     }
     if ($this->data['users']->role == "student") {
         $onlineExams = $onlineExams->where('examClass', 'LIKE', '%"' . $this->data['users']->studentClass . '"%');
     }
     $onlineExams = $onlineExams->where('exAcYear', $this->panelInit->selectAcYear);
     $onlineExams = $onlineExams->get();
     foreach ($onlineExams as $key => $onlineExam) {
         $classId = json_decode($onlineExam->examClass);
         if ($this->data['users']->role == "student" and !in_array($this->data['users']->studentClass, $classId)) {
             continue;
         }
         $toReturn['onlineExams'][$key]['id'] = $onlineExam->id;
         $toReturn['onlineExams'][$key]['examTitle'] = $onlineExam->examTitle;
         $toReturn['onlineExams'][$key]['examDescription'] = $onlineExam->examDescription;
         if (isset($subjectArray[$onlineExam->examSubject])) {
             $toReturn['onlineExams'][$key]['examSubject'] = $subjectArray[$onlineExam->examSubject];
         }
         $toReturn['onlineExams'][$key]['ExamEndDate'] = date("F j, Y", $onlineExam->ExamEndDate);
         $toReturn['onlineExams'][$key]['ExamShowGrade'] = $onlineExam->ExamShowGrade;
         $toReturn['onlineExams'][$key]['classes'] = "";
         while (list(, $value) = each($classId)) {
             if (isset($classesArray[$value])) {
                 $toReturn['onlineExams'][$key]['classes'] .= $classesArray[$value]['classTitle'] . ", ";
             }
         }
     }
     $toReturn['userRole'] = $this->data['users']->role;
     return $toReturn;
 }
Пример #3
0
 public function proceed()
 {
     if (Input::get('nextStep') == "1") {
         if (filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
             if (!Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => 1, 'role' => 'admin'))) {
                 $loginError = false;
                 $this->data['loginError'] = "loginError";
             }
         } else {
             if (!Auth::attempt(array('username' => Input::get('email'), 'password' => Input::get('password'), 'activated' => 1, 'role' => 'admin'))) {
                 $loginError = false;
                 $this->data['loginError'] = "loginError";
             }
         }
         if (!isset($loginError)) {
             file_put_contents('app/storage/meta/lc', Input::get('cpc'));
             if ($this->sbApi() == "err") {
                 @unlink('app/storage/meta/lc');
                 $this->data['installErrors'][] = "Purchase code is missing";
                 $loginError = false;
                 $this->data['loginError'] = "loginError";
             }
         }
         $this->data['currStep'] = "welcome";
         if (!isset($loginError)) {
             $this->data['currStep'] = "1";
             $this->data['nextStep'] = "2";
             $testData = uniqid();
             @file_put_contents("uploads/assignments/test", $testData);
             @file_put_contents("uploads/books/test", $testData);
             @file_put_contents("uploads/cache/test", $testData);
             @file_put_contents("uploads/media/test", $testData);
             @file_put_contents("uploads/profile/test", $testData);
             @file_put_contents("uploads/studyMaterial/test", $testData);
             @file_put_contents("uploads/assignmentsAnswers/test", $testData);
             @file_put_contents("app/storage/cache/test", $testData);
             @file_put_contents("app/storage/logs/test", $testData);
             @file_put_contents("app/storage/meta/test", $testData);
             @file_put_contents("app/storage/sessions/test", $testData);
             @file_put_contents("app/storage/views/test", $testData);
             if (@file_get_contents("uploads/assignments/test") != $testData) {
                 $this->data['perrors'][] = "uploads/assignments";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/assignments";
             }
             if (@file_get_contents("uploads/books/test") != $testData) {
                 $this->data['perrors'][] = "uploads/books";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/books";
             }
             if (@file_get_contents("uploads/cache/test") != $testData) {
                 $this->data['perrors'][] = "uploads/cache";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/cache";
             }
             if (@file_get_contents("uploads/media/test") != $testData) {
                 $this->data['perrors'][] = "uploads/media";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/media";
             }
             if (@file_get_contents("uploads/profile/test") != $testData) {
                 $this->data['perrors'][] = "uploads/profile";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/profile";
             }
             if (@file_get_contents("uploads/studyMaterial/test") != $testData) {
                 $this->data['perrors'][] = "uploads/studyMaterial";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/studyMaterial";
             }
             if (@file_get_contents("uploads/assignmentsAnswers/test") != $testData) {
                 $this->data['perrors'][] = "uploads/assignmentsAnswers";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/assignmentsAnswers";
             }
             if (@file_get_contents("app/storage/cache/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/cache";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/cache";
             }
             if (@file_get_contents("app/storage/logs/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/logs";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/logs";
             }
             if (@file_get_contents("app/storage/meta/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/meta";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/meta";
             }
             if (@file_get_contents("app/storage/sessions/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/sessions";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/sessions";
             }
             if (@file_get_contents("app/storage/views/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/views";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/views";
             }
         }
     }
     if (Input::get('nextStep') == "2") {
         $this->data['currStep'] = "2";
         $this->data['nextStep'] = "3";
         $testInstalled = settings::where('fieldName', 'thisVersion')->first();
         if ($testInstalled->fieldValue == "1.2" || $testInstalled->fieldValue == "1.3") {
             //Upgrade from first version to 1.4
             DB::unprepared(file_get_contents('app/storage/dbsqlUp14'));
             $settings = settings::where('fieldName', 'thisVersion')->first();
             $settings->fieldValue = '1.4';
             $settings->save();
             $testInstalled->fieldValue = "1.4";
         }
         if ($testInstalled->fieldValue == "1.4") {
             //Upgrade from first version to 1.4
             DB::unprepared(file_get_contents('app/storage/dbsqlUp20'));
             //Classes and relation with subjects
             $classes = classes::get();
             foreach ($classes as $class) {
                 $classesUpdateArray = array();
                 $subjects = subject::where('classId', $class->id)->get();
                 foreach ($subjects as $subject) {
                     $classesUpdateArray[] = $subject->id;
                 }
                 $classesUpdateArray = json_encode($classesUpdateArray);
                 classes::where('id', $class->id)->update(array('classSubjects' => $classesUpdateArray));
                 unset($classesUpdateArray);
             }
             //create academic years
             $users = User::where('role', 'student')->get();
             foreach ($users as $user) {
                 $studentAcademicYears = new studentAcademicYears();
                 $studentAcademicYears->studentId = $user->id;
                 $studentAcademicYears->academicYearId = 1;
                 $studentAcademicYears->classId = $user->studentClass;
                 $studentAcademicYears->save();
             }
             DB::unprepared('ALTER TABLE `subject` CHANGE `teacherId` `teacherId` int(250)   NOT NULL after `subjectTitle` ,DROP COLUMN `classId` ;');
             $settings = settings::where('fieldName', 'thisVersion')->first();
             $settings->fieldValue = '2.0';
             $settings->save();
         }
     }
     if (Input::get('nextStep') == "3") {
         $this->data['currStep'] = "3";
         $settings = settings::where('fieldName', 'thisVersion')->first();
         $settings->fieldValue = '1.4';
         $settings->save();
     }
     return View::make('upgrade', $this->data);
 }
Пример #4
0
 function fetch($id)
 {
     return subject::where('id', $id)->first();
 }
Пример #5
0
 function fetchMarks($exam, $class, $subject)
 {
     if ($this->data['users']->role == "student" || $this->data['users']->role == "parent") {
         exit;
     }
     $toReturn = array();
     $toReturn['exam'] = examsList::where('id', $exam)->first()->toArray();
     $toReturn['subject'] = subject::where('id', $subject)->first()->toArray();
     $toReturn['students'] = array();
     $studentArray = User::where('role', 'student')->where('studentClass', $class)->get();
     foreach ($studentArray as $stOne) {
         $toReturn['students'][$stOne->id] = array('id' => $stOne->id, 'name' => $stOne->fullName, 'studentRollId' => $stOne->studentRollId, 'examMark' => '', 'attendanceMark' => '', 'markComments' => '');
     }
     $examMarks = examMarks::where('examId', $exam)->where('classId', $class)->where('subjectId', $subject)->get();
     foreach ($examMarks as $stMark) {
         if (isset($toReturn['students'][$stMark->studentId])) {
             $toReturn['students'][$stMark->studentId]['examMark'] = $stMark->examMark;
             $toReturn['students'][$stMark->studentId]['attendanceMark'] = $stMark->attendanceMark;
             $toReturn['students'][$stMark->studentId]['markComments'] = $stMark->markComments;
         }
     }
     echo json_encode($toReturn);
     exit;
 }
Пример #6
0
 function editSub($id)
 {
     if ($this->data['users']->role != "admin") {
         exit;
     }
     $classSchedule = classSchedule::find($id);
     $classSchedule->subjectId = Input::get('subjectId');
     $classSchedule->dayOfWeek = Input::get('dayOfWeek');
     $startTime = "";
     if (Input::get('startTimeHour') < 10) {
         $startTime .= "0";
     }
     $startTime .= Input::get('startTimeHour');
     if (Input::get('startTimeMin') < 10) {
         $startTime .= "0";
     }
     $startTime .= Input::get('startTimeMin');
     $classSchedule->startTime = $startTime;
     $endTime = "";
     if (Input::get('endTimeHour') < 10) {
         $endTime .= "0";
     }
     $endTime .= Input::get('endTimeHour');
     if (Input::get('endTimeMin') < 10) {
         $endTime .= "0";
     }
     $endTime .= Input::get('endTimeMin');
     $classSchedule->endTime = $endTime;
     $classSchedule->save();
     $classSchedule->startTime = wordwrap($classSchedule->startTime, 2, ':', true);
     $classSchedule->endTime = wordwrap($classSchedule->endTime, 2, ':', true);
     $classSchedule->subjectId = subject::where('id', Input::get('subjectId'))->first()->subjectTitle;
     return $this->panelInit->apiOutput(true, $this->panelInit->language['editSch'], $this->panelInit->language['schModSucc'], $classSchedule->toArray());
 }