/** * Show the form for creating a new resource. * @return Response */ public function create() { $classrooms = Classroom::inCurrentSemester()->pluck('code', 'id')->toArray(); $subjects = Subject::isCurrent()->pluck('name', 'id')->toArray(); $years = Year::leftJoin('academystructure_terms as acaterm', 'acaterm.year_id', '=', 'ay.id')->leftJoin('academystructure_departments as acadep', 'acadep.term_id', '=', 'acaterm.id')->Leftjoin('students as s', 's.academystructure_department_id', '=', 'acadep.id')->groupBy('ay.id')->from('academystructure_years as ay')->havingRaw('COUNT(s.id)>0')->pluck('ay.name', 'ay.id')->toArray(); return view('exams::Extend.create', compact('years', 'subjects', 'classrooms')); }
public function create() { $classrooms = Classroom::inCurrentSemester()->pluck('code', 'id')->toArray(); $subjects = Subject::isCurrent()->lists('name', 'id')->toArray(); $intervals = ClassroomInterval::inCurrentSemester()->pluck('title', 'id')->toArray(); $teachers = Teacher::isActive()->pluck('name', 'id')->toArray(); return view('classrooms::sessions.create', compact('classrooms', 'subjects', 'teachers', 'intervals')); }
/** * Show the form for creating a new resource. * @return Response */ public function students($subject_id = 0, $exam_type = null) { $semester_id = semester()->id; $classrooms = Classroom::inCurrentSemester()->where("teacher_id", teacher()->id)->where('subject_subject_id', $subject_id)->pluck('id')->toArray(); $students = Exam::selectRaw('exams.id as exam_id,exams.subject_id as subid , er.id as erid, s.id as studentid, s.name, s.username, er.id as attendees, er.enter_at, er.exit_at, er.filename, crs.classroom_id, case when sg.value IS NULL THEN -1 else sg.value end as value ')->rightJoin('exam_results AS er', function ($join) { $join->on('er.exam_id', '=', 'exams.id'); })->leftJoin('students AS s', function ($join) { $join->on('s.id', '=', 'student_id'); })->leftJoin('student_grades AS sg', function ($join) { $join->on('sg.student_id', '=', 's.id'); $join->on('exam_id', '=', 'sg.ref_value'); $join->on('sg.ref_key', '=', DB::raw('"examessay"')); })->leftJoin('classroom_students AS crs', function ($join) use($semester_id) { $join->on('crs.student_id', '=', 's.id'); $join->on('crs.semester_id', '=', DB::raw('"' . $semester_id . '"')); })->where('exams.subject_id', $subject_id)->where('exams.semester_id', $semester_id)->where('exams.type', $exam_type)->whereIn('crs.classroom_id', $classrooms)->orderBy('sg.id', 'asc')->get(); $students_correct = Exam::selectRaw('exams.id as exam_id,exams.subject_id as subid , er.id as erid, s.id as studentid, s.name, s.username, er.id as attendees, er.enter_at, er.exit_at, er.filename, crs.classroom_id, sg.value')->rightJoin('exam_results AS er', function ($join) { $join->on('er.exam_id', '=', 'exams.id'); })->leftJoin('students AS s', function ($join) { $join->on('s.id', '=', 'student_id'); })->leftJoin('student_grades AS sg', function ($join) { $join->on('sg.student_id', '=', 's.id'); $join->on('exam_id', '=', 'sg.ref_value'); $join->on('sg.ref_key', '=', DB::raw('"examessay"')); })->leftJoin('classroom_students AS crs', function ($join) use($semester_id) { $join->on('crs.student_id', '=', 's.id'); $join->on('crs.semester_id', '=', DB::raw('"' . $semester_id . '"')); })->where('exams.subject_id', $subject_id)->where('exams.semester_id', $semester_id)->where('exams.type', $exam_type)->whereIn('crs.classroom_id', $classrooms)->whereNotNull('sg.id')->orderBy('sg.id', 'asc')->count(); return view('teachers::profile.tests.students', compact('students', 'exam_type', 'students_correct')); }
public function classroomupdate(UpdateClassroomRequest $request, Classroom $classroomModel, $id) { $classroom = $classroomModel->inCurrentSemester()->findOrFail($id); ///////////////////////////////// check count classroom ////////////////////////////// $total_classroom = Classroom::where([['day', '=', $request->input('day')], ['hour', '=', $request->input('hour')]])->count(); if ($total_classroom > 19) { return redirect()->back()->with('error', 'تم الوصول إلى الحد الأقصى للاختيار في هذا الموعد... يرجى مشكوراً تحديد موعد آخر'); } $classroom->fill($request->all())->save(); $submit = $request->input('submit', 'save'); $message = trans('classrooms::classrooms.update_success', ['name' => $classroom->name]); if ($submit == 'exit') { return redirect()->route('teachers.profile.classrooms')->with('success', $message); } return redirect()->back()->with('success', $message); }
public function classrooms(Request $request, $export = 0) { $students = Student::isStudying()->with(['subjects' => function ($q) use($request) { $q->wherePivot('state', 'study'); $q->where('semester_id', semester()->id); if ($request->has('subject_subject_id')) { $q->where('subject_subjects.id', $request->input('subject_subject_id')); } }, 'classrooms' => function ($q) { $q->where('classrooms.semester_id', semester()->id); }]); if ($request->has('subject_subject_id')) { $students->whereHas('subjects', function ($q) use($request) { $q->where('subject_subjects.id', $request->input('subject_subject_id'))->where('semester_id', semester()->id)->where('state', 'study'); }); } if ($request->has('classroom_select_id')) { $selected = request('classroom_select_id'); $subject_id = request('subject_subject_id'); $students = $students->whereHas('classrooms', function ($query) use($subject_id) { $query->where('subject_subject_id', $subject_id); }, $selected); } if (request('spec_id')) { $spec_id = request('spec_id'); $students->wherehas('department', function ($q) use($spec_id) { $q->where('academystructure_departments.spec_id', $spec_id); }); } if (request('nationality_country_id')) { $nationality_country_id = request('nationality_country_id'); $students->whereHas('registration', function ($q) use($nationality_country_id) { $q->where('registrations.nationality_country_id', $nationality_country_id); }); } if (request('contact_country_id')) { $contact_country_id = request('contact_country_id'); $students->whereHas('registration', function ($q) use($contact_country_id) { $q->where('registrations.contact_country_id', $contact_country_id); }); } if ($export) { $students = $students->get(); Excel::create('students', function ($excel) use($students) { $excel->sheet('stu', function ($sheet) use($students) { $sheet->loadView('classrooms::reports.export', compact('students')); })->download('xlsx'); }); return redirect()->route('classrooms.sessions.index', $request->all()); } $per_page = request('per_page') ? request('per_page') : 30; $students = $students->paginate($per_page); $students = $students->appends($request->except("page")); $total_chosen = Student::join('classroom_students as cs', 'cs.student_id', '=', 'students.id')->join('classrooms as c', function ($j) { $j->on('c.id', '=', 'cs.classroom_id')->where('c.semester_id', '=', semester()->id); })->join('student_subjects as ss', function ($j) { $j->on('ss.subject_id', '=', 'c.subject_subject_id')->on('ss.student_id', '=', 'students.id')->where('ss.state', '=', 'study'); })->groupBy('students.id'); if ($request->has('subject_subject_id')) { $total_chosen->where('c.subject_subject_id', $request->input('subject_subject_id')); } if ($request->has('classroom_id')) { $total_chosen->where('c.id', $request->input('classroom_id')); } $total_chosen = $total_chosen->get()->count(); $total_unchosen = StudentSubject::whereIn('student_subjects.state', ['study'])->selectRaw('student_subjects.student_id')->join('classrooms', function ($j) { $j->on('classrooms.subject_subject_id', '=', 'student_subjects.subject_id')->where('classrooms.semester_id', '=', semester()->id); })->leftJoin('classroom_students', function ($j) { $j->on('classrooms.id', '=', 'classroom_students.classroom_id')->on('classroom_students.student_id', '=', 'student_subjects.student_id'); })->havingRaw('COUNT(classroom_students.id)=0')->groupBy('student_subjects.subject_id', 'student_subjects.student_id'); if ($request->has('subject_subject_id')) { $total_unchosen->where('student_subjects.subject_id', $request->input('subject_subject_id')); } $total_unchosen = $total_unchosen->get()->groupBy('student_id')->count(); $subjects = Subject::where('is_quran', 0)->pluck('name', 'id')->toArray(); $classrooms = Classroom::inCurrentSemester()->pluck('code', 'id')->toArray(); $classroom_select = config('classrooms.classroom_select'); $spec_id = Specialty::pluck('name', 'id')->toArray(); $county = Country::pluck('name', 'id')->toArray(); $inputs = request()->all(); return view('classrooms::reports.classrooms', compact('students', 'subjects', 'classrooms', 'total_chosen', 'total_unchosen', 'classroom_select', 'spec_id', 'county', 'inputs')); }
public function update(UpdateClassroomRequest $request, Classroom $classroomModel, $id) { $classroom = $classroomModel->inCurrentSemester()->findOrFail($id); $classroom->fill($request->all())->save(); $submit = $request->input('submit', 'save'); $message = trans('classrooms::classrooms.update_success', ['name' => $classroom->name]); if ($submit == 'exit') { return redirect()->route('classrooms.classrooms.index')->with('success', $message); } return redirect()->back()->with('success', $message); }