Example #1
0
 public function edit(Teacher $teacher)
 {
     $degrees = $this->degrees;
     $teacher = teacher();
     $banks = Bank::lists('title', 'id')->toArray();
     return view('teachers::profile.edit', compact('teacher', 'degrees', 'banks'));
 }
Example #2
0
 /**
  * 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 storequestion(QuestionRequest $request, $activity_id)
 {
     $question = new Question();
     Session::put('typeQ', $request->get('type'));
     $question->fill($request->all());
     $question->user_id = teacher()->id;
     $question->save();
     $exam = Exam::findOrFail($activity_id);
     $exam->questions()->detach($question->id);
     $exam->questions()->attach($question->id);
     $choices = $request->input('choices');
     if (!empty($choices)) {
         //not essay
         foreach ($choices as $key => $choice) {
             if ($request->get('type') != 'multiple_choice') {
                 if ($request->input('choices_correct_new_00') == $key) {
                     // TF or Single choice
                     $istrue = 1;
                 } else {
                     $istrue = 0;
                 }
             } else {
                 if (!empty($request->choices_correct_new)) {
                     //multiple_choice
                     //if(!empty($request->choices_correct_new))
                     if (array_key_exists($key, $request->choices_correct_new)) {
                         $istrue = 1;
                     } else {
                         $istrue = 0;
                     }
                     //$istrue = $request->input('choices_correct_new['.$key.']');
                 } else {
                     $istrue = 0;
                 }
             }
             Choice::create(['choice' => $choice, 'question_id' => $question->id, 'istrue' => $istrue]);
         }
     }
     $message = 'تم اضافة السؤال بنجاح';
     if (request('submit') == 'save') {
         return redirect()->route('teachers.profile.createquestion', array('id' => $activity_id))->with('success', $message);
     } else {
         $request->session()->forget('typeQ');
         return redirect()->route('teachers.profile.questions', array('id' => $activity_id))->with('success', $message);
     }
 }
Example #4
0
 public function scopeTeacher($query, $teacher_id = false)
 {
     if ($teacher_id || (teacher() and $teacher_id = teacher()->id)) {
         return $query->where('teacher_id', $teacher_id);
     }
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     return ['code' => 'required|unique:classrooms,code,' . $this->id, 'day' => 'required|in:0,1,2,3,4,5,6|unique:classrooms,day,' . $this->id . ',id,hour,' . $this->hour . ',teacher_id,' . teacher()->id, 'hour' => 'required|date_format:H:i:s', 'gender' => 'required|in:f,m,b', 'teacher_id' => 'required|exists:teachers,id', 'subject_subject_id' => 'required|exists:subject_subjects,id', 'attendees_limit' => 'numeric|min:10'];
 }