コード例 #1
0
ファイル: ExamsController.php プロジェクト: hisambahaa/DARES
 public function index(Request $request)
 {
     $student_id = $this->student->id;
     $order_dir = in_array($request->input('order_dir'), ['ASC', 'DESC']) ? $request->input('order_dir') : 'ASC';
     $exams = Exam::select('exams.type', 'exams.start_at', 'exams.finish_at', 'exams.name', 'exams.id')->join('subject_subjects as subsub', 'subsub.id', '=', 'exams.subject_id')->join('student_subjects as stusub', function ($j) use($student_id) {
         $j->on('stusub.subject_id', '=', 'subsub.id')->where('stusub.student_id', '=', $student_id)->where('stusub.state', '=', 'study');
     })->where(function ($query) use($request, $student_id) {
         $query->orWhereIn('exams.type', ['midterm', 'remidterm', 'activity'])->orWhereRaw('exams.id IN (SELECT ce.exam_id FROM classrooms_exam as ce
                             JOIN classrooms as c ON c.id = ce.classroom_id
                             JOIN classroom_students as cs ON cs.classroom_id = c.id
                                 AND cs.student_id = ' . $student_id . '
                             WHERE exam_id = exams.id GROUP BY ce.id)');
         if ($request->has('finalExam') == 'true') {
             $query->orWhereIn('exams.type', ['final', 'summer', 'refinal']);
         }
     })->where('exams.semester_id', semester()->id)->where('finish_at', '>=', date('Y-m-d H:i:s'))->groupBy('exams.id')->orderBy('exams.start_at', $order_dir)->with(['questions' => function ($w) {
         $w->select('questionbank_questions.id', 'questionbank_questions.question', 'questionbank_questions.type');
         if ($this->randomize_questions) {
             $w->orderByRaw('RAND()');
         } else {
             $w->orderBy('questionbank_questions.type', 'DESC');
         }
     }, 'questions.choices' => function ($w) {
         $w->select('questionbank_choices.id', 'questionbank_choices.question_id', 'questionbank_choices.choice', 'questionbank_choices.istrue');
     }])->get();
     return response()->json(compact('exams'), 200, [], JSON_NUMERIC_CHECK);
 }
コード例 #2
0
ファイル: ExamsController.php プロジェクト: hisambahaa/DARES
 public function index()
 {
     $exams = Exam::select('exams.*')->join('academycycle_semesters as acsem', function ($join) {
         $join->on('acsem.id', '=', 'exams.semester_id')->where('acsem.active', '=', 1);
     })->join('academycycle_semesterevents AS acsemevts', function ($join) {
         $join->on('acsemevts.semester_id', '=', 'acsem.id');
     })->join('academycycle_semesterevent_types AS ast', function ($join) {
         $join->on('ast.id', '=', 'acsemevts.type_id')->where('ast.slug', '=', 'midterm');
     })->whereDate('exams.start_at', '<=', date('Y-m-d'))->whereDate('exams.finish_at', '>=', date('Y-m-d'))->groupBy('exams.id')->with('questions', 'questions.choices')->get();
     return $exams;
 }
コード例 #3
0
ファイル: MyTest.php プロジェクト: hisambahaa/DARES
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $sessions = ClassroomSession::select('id', 'classroom_id')->whereIn('classroom_id', [157, 168, 176, 186, 198, 213, 217])->get();
     // $this->comment(PHP_EOL.$sessions->count().PHP_EOL);
     foreach ($sessions as $session) {
         $students = ClassroomStudent::select('student_id')->where('student_id', 1841)->where('classroom_id', $session->classroom_id)->get();
         // $this->comment(PHP_EOL.$students->count().PHP_EOL);
         foreach ($students as $student) {
             $exist = StudentClassroomSession::where('classroom_session_id', $session->id)->where('student_id', $student->student_id)->value('id');
             if ($exist) {
                 $this->comment(PHP_EOL . ' HAS ' . $exist . PHP_EOL);
             } else {
                 $data = ['student_id' => $student->student_id, 'attendee_id' => $student->student_id, 'classroom_session_id' => $session->id, 'student_link' => '', 'semester_id' => 9];
                 $attendance = ['entry_time' => null, 'exit_time' => null, 'attended_minutes' => null, 'teacher_id' => null, 'classroom_session_id' => $session->id, 'student_id' => $student->id, 'valid' => 0, 'manual' => 0];
                 StudentClassroomSession::create($data);
                 ClassroomSessionAttendance::create($attendance);
                 $this->comment(PHP_EOL . ' NOT ' . PHP_EOL);
             }
         }
     }
     // Student::with('classrooms', 'subjects')->has('classrooms',  '=', 3)->leftJoin('subject_sub')
     exit;
     \DB::connection()->enableQueryLog();
     Exam::select('exams.type', 'exams.start_at', 'exams.finish_at', 'exams.name', 'exams.id')->join('subject_subjects as subsub', 'subsub.id', '=', 'exams.subject_id')->join('student_subjects as stusub', function ($j) {
         $j->on('stusub.subject_id', '=', 'subsub.id')->where('stusub.student_id', '=', 10001)->where('stusub.state', '=', 'study');
     })->where(function ($query) {
         $query->orWhereIn('exams.type', ['midterm', 'remidterm', 'activity'])->orWhereRaw('exams.id IN (SELECT ce.exam_id FROM classrooms_exam as ce
                             JOIN classrooms as c ON c.id = ce.classroom_id
                             JOIN classroom_students as cs ON cs.classroom_id = c.id
                                 AND cs.student_id = 10001
                             WHERE exam_id = exams.id GROUP BY ce.id)');
         // if ($request->has('finalExam') == 'true') {
         //     $query->orWhereIn('exams.type',
         //         [
         //     'final',
         //                 'summer',
         //                 'refinal'
         //         ]);
         // }
     })->where('exams.semester_id', 9)->where('finish_at', '>=', date('Y-m-d H:i:s'))->groupBy('exams.id')->orderBy('exams.start_at', 'ASC')->get();
     // Exam::count();
     $query = \DB::getQueryLog();
     $lastQuery = end($query);
     var_dump($lastQuery);
     // echo "done";
     exit;
     // $sessions = ClassroomSession::select('id')->whereIn('interval_id', [2,14,15])->get();
     // foreach ($sessions as $session) {
     //     ClassroomSessionAttendance::where('classroom_session_id', $session->id)->update(['valid' => 1]);
     // }
 }
コード例 #4
0
 public function unloadexam($subject_id, $exam_type, $msg = 0)
 {
     $exam_ids = Exam::select('id')->where('subject_id', $subject_id)->where('type', $exam_type)->get()->toArray();
     $statistics = Student::with(['examresults' => function ($q) use($exam_ids) {
         $q->whereIn('exam_id', $exam_ids);
         $q->where('filename', '');
     }])->whereHas('examresults', function ($q) use($exam_ids) {
         $q->whereIn('exam_id', $exam_ids);
         $q->where('filename', '');
     });
     if ($msg == 1) {
         $statistics = $statistics->pluck('username')->toArray();
         return redirect()->route('students.messages.create', compact('statistics'));
     }
     $statistics = $statistics->get();
     return view('exams::reports.unloadexam', compact('statistics', 'subject_id', 'exam_type'));
 }
コード例 #5
0
ファイル: AdminController.php プロジェクト: hisambahaa/DARES
 public function test(Request $request)
 {
     ClassroomSessionExcuse::truncate();
     ClassroomSessionAttendance::where('student_id', 10001)->update(['valid' => 0]);
     exit;
     $student_id = 4796;
     $order_dir = in_array($request->input('order_dir'), ['ASC', 'DESC']) ? $request->input('order_dir') : 'ASC';
     $exams = Exam::select('exams.type', 'exams.start_at', 'exams.finish_at', 'exams.name', 'exams.id')->join('subject_subjects as subsub', 'subsub.id', '=', 'exams.subject_id')->join('student_subjects as stusub', function ($j) use($student_id) {
         $j->on('stusub.subject_id', '=', 'subsub.id')->where('stusub.student_id', '=', $student_id)->where('stusub.state', '=', 'study');
     })->where(function ($query) use($request, $student_id) {
         $query->orWhereIn('exams.type', ['midterm', 'remidterm'])->orWhereRaw('exams.id IN (SELECT ce.exam_id FROM classrooms_exam as ce
                             JOIN classrooms as c ON c.id = ce.classroom_id
                             JOIN classroom_students as cs ON cs.classroom_id = c.id
                                 AND cs.student_id = ' . $student_id . '
                             WHERE exam_id = exams.id GROUP BY ce.id)');
         if ($request->has('finalExam')) {
             $query->orWhereIn('exams.type', ['final', 'summer', 'refinal']);
         }
     })->where('exams.semester_id', semester()->id)->where('finish_at', '>=', date('Y-m-d H:i:s'))->groupBy('exams.id')->orderBy('exams.start_at', $order_dir)->with(['questions' => function ($w) {
         $w->select('questionbank_questions.id', 'questionbank_questions.question', 'questionbank_questions.type');
         if (false) {
             $w->orderByRaw('RAND()');
         } else {
             $w->orderBy('questionbank_questions.type', 'DESC');
         }
     }, 'questions.choices' => function ($w) {
         $w->select('questionbank_choices.id', 'questionbank_choices.question_id', 'questionbank_choices.choice', 'questionbank_choices.istrue');
     }])->get();
     return $exams;
     exit;
     $specialities = Specialty::selectRaw('asp.id, asp.name, asp.short_description, asp.description, GROUP_CONCAT(adp.subject_ids) as subject_ids, COUNT(adt.id) as terms, COUNT(DISTINCT ady.id) as years')->leftJoin('academystructure_departments as adp', 'adp.spec_id', '=', 'asp.id')->leftJoin('academystructure_terms as adt', 'adt.id', '=', 'adp.term_id')->leftJoin('academystructure_years as ady', 'ady.id', '=', 'adt.year_id')->from('academystructure_specialties as asp')->groupBy('asp.id')->with('departments')->get();
     foreach ($specialities as $specialty) {
         $subject_ids = explode(",", preg_replace(['/\\[/', "/\\]/"], "", $specialty->subject_ids));
         $specialty->hours = Subject::whereIn('id', $subject_ids)->sum('hour');
         foreach ($specialty->departments as $department) {
             $subject_ids = explode(",", preg_replace(['/\\[/', "/\\]/", '/"/', "/'/"], "", $department->subject_ids));
             // var_dump($subject_ids);
             $department->subjects = Subject::whereIn('id', $subject_ids)->get();
         }
     }
     $specialities->makeHidden(['subject_ids']);
     return $specialities;
     exit;
     $status_ping_url = \App::environment('local') ? 'http://46.40.236.186:9090/DARES/public/classrooms/classrooms/status_ping' : route('classrooms.sessions.status-ping');
     $WiziqApi = new WiziqApi();
     try {
         $wiziqclassroom = WiziqClassroom::build("test", new DateTime("2016-08-10 23:55:00"))->withPresenter(20, "test teacher")->withAttendeeLimit(config("classrooms.attendee_limit"))->withReturnUrl('https://el-css.edu.om')->withDuration(10)->withExtendDuration(0)->withStatusPingUrl($status_ping_url)->withTimeZone("Asia/Muscat")->withLanguageCultureName("ar-SA")->withCreateRecording(true);
         $response = $WiziqApi->create($wiziqclassroom);
         \Log::info($response);
         exit(var_dump($response));
         $data = ['wiziq_id' => $response['class_id'], 'recording_link' => $response['recording_url'], 'presenter_link' => $response['presenter_url']];
         /** add attendees to virtual classroom */
         Log::info($response);
         if ($session->fill($data)->save() && $response) {
             $error = $this->createStudentsSessions($classroom->students, $session);
         }
     } catch (\mikemix\Wiziq\Common\Api\Exception\CallException $e) {
         $error = 1;
     } catch (\mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
         $error = 1;
     } catch (\PDOException $e) {
         $error = 1;
     }
     if ($error == 0) {
         event(new VirtualClassroomsCreated());
     } else {
         $session->wiziq_status = 'error';
         $session->save();
     }
 }