Пример #1
0
 /**
  * @desc show list of terms per year
  * @param Year $year int to load terms
  * @param Department $department fro breadcrumbs
  **/
 public function index(Year $year, Department $department, Faculty $faculty)
 {
     $year->load('terms');
     $terms = Term::where('year_id', $year->id)->select('academystructure_terms.*')->selectRaw('COUNT(sh.id) as total_students')->leftJoin('academystructure_departments as acadep', 'acadep.term_id', '=', 'academystructure_terms.id')->Leftjoin('student_histories as sh', 'sh.academystructure_department_id', '=', 'acadep.id')->groupBy('academystructure_terms.id')->get();
     $breadcrumbs = $faculty->breadcrumbs()->where('ay.id', '=', $year->id)->first();
     return view('academystructure::terms.index', compact('terms', 'year', 'breadcrumbs'));
 }
Пример #2
0
 /**
  * @desc show list of terms per year
  * @param Year $year int to load terms 
  * @param Department $department fro breadcrumbs
  **/
 public function index(Year $year, Department $department, Faculty $faculty)
 {
     $year->load('terms');
     $terms = $year->terms;
     $breadcrumbs = $faculty->breadcrumbs()->where('ay.id', '=', $year->id)->first();
     //dd($breadcrumbs);
     return view('academystructure::terms.index', compact('terms', 'year', 'breadcrumbs'));
 }
Пример #3
0
 /**
  * Display a listing of the resource.
  * @return Response
  */
 public function index(Request $request)
 {
     $excuses = ExamExcuse::where('semester_id', semester()->id)->with('student', 'subject', 'exam');
     if (request('subject_id')) {
         $subject_id = request('subject_id');
         $excuses->whereHas('exam.subject', function ($q) use($subject_id) {
             $q->where('subject_subjects.id', $subject_id);
         });
     }
     if (request('exam_year_term')) {
         $excuses->whereIn('subject_id', explode(',', request('exam_year_term')));
     }
     $per_page = request('per_page') ? request('per_page') : 50;
     $excuses = $excuses->paginate($per_page);
     $excuses->appends($request->except("page"));
     $subjects = Subject::lists('name', 'id')->toArray();
     $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->join('academystructure_departments', 'academystructure_terms.id', '=', 'academystructure_departments.term_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name,
                                     GROUP_CONCAT(DISTINCT(academystructure_departments.subject_ids)) as sid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->get()->toArray();
     $year_term_options;
     foreach ($year_term as $key => &$aa) {
         $a = implode(',', array_unique(array_merge(json_decode(str_replace('],[', ',', $aa['sid']), TRUE))));
         $year_term_options[$a] = $aa['name'];
     }
     return view('exams::excuses.index', compact('excuses', 'subjects', 'year_term_options'));
 }
Пример #4
0
 /**
  * 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'));
 }
Пример #5
0
 public function index()
 {
     $semester = semester();
     //    $finish = $semester ? $semester->finish_at : date('Y-m-d');
     //    if ($semester->order != 'first') {
     //    $semester= Semester::where('order', 'first')
     //                       ->where('start_at', '>', $finish)
     //                       ->orderBy('start_at', 'ASC')
     //                       ->first();
     //    }
     //    return $semester;
     $students_by_years = Year::selectRaw("\n            academystructure_years.name,\n            SUM(IF(stu.gender='m',1,0)) AS males,\n            SUM(IF(stu.gender='f',1,0)) AS females")->leftJoin('academystructure_terms AS at', 'at.year_id', '=', 'academystructure_years.id')->leftJoin('academystructure_departments AS ad', 'ad.term_id', '=', 'at.id')->leftJoin('student_histories AS sh', function ($join) {
         $join->on('sh.academystructure_department_id', '=', 'ad.id')->where('academycycle_semester_id', '=', semester()->id);
     })->leftJoin('students AS stu', 'stu.id', '=', 'sh.student_id')->groupBy('academystructure_years.id')->get();
     $students_by_state = Student::selectRaw("DISTINCT students.id,\n          students.state,\n        \tSUM(IF(students.state='active',1,0)) AS active_all_students,\n        \tSUM(IF(students.state='delayed',1,0)) AS delayed_all_students,\n        \tSUM(IF(students.state='discontinuous',1,0)) AS discontinuous_all_students,\n        \tSUM(IF(students.state='withdrawn',1,0)) AS withdrawn_all_students,\n        \tSUM(IF(students.state='fired',1,0)) AS fired_all_students,\n        \tSUM(IF(students.state='graduate',1,0)) AS graduate_all_students,\n\n        \tSUM(IF(students.gender='m' AND students.state='active',1,0)) AS active_male_students,\n        \tSUM(IF(students.gender='m' AND students.state='delayed',1,0)) AS delayed_male_students,\n        \tSUM(IF(students.gender='m' AND students.state='discontinuous',1,0)) AS discontinuous_male_students,\n        \tSUM(IF(students.gender='m' AND students.state='withdrawn',1,0)) AS withdrawn_male_students,\n        \tSUM(IF(students.gender='m' AND students.state='fired',1,0)) AS fired_male_students,\n        \tSUM(IF(students.gender='m' AND students.state='graduate',1,0)) AS graduate_male_students,\n\n        \tSUM(IF(students.gender='f' AND students.state='active',1,0)) AS active_female_students,\n        \tSUM(IF(students.gender='f' AND students.state='delayed',1,0)) AS delayed_female_students,\n        \tSUM(IF(students.gender='f' AND students.state='discontinuous',1,0)) AS discontinuous_female_students,\n        \tSUM(IF(students.gender='f' AND students.state='withdrawn',1,0)) AS withdrawn_female_students,\n        \tSUM(IF(students.gender='f' AND students.state='fired',1,0)) AS fired_female_students,\n        \tSUM(IF(students.gender='f' AND students.state='graduate',1,0)) AS graduate_female_students\n        \t")->first();
     // return $students_by_state;
     $genders = Student::selectRaw("\n            SUM(IF(students.gender='m',1,0)) AS males,\n            SUM(IF(students.gender='f',1,0)) AS females")->join('student_histories AS sh', function ($join) {
         $join->on('sh.student_id', '=', 'students.id')->whereIn('sh.study_state', ['active', 'success', 'fail'])->where('academycycle_semester_id', '=', semester()->id);
     })->isStudying()->first();
     $sessions = ClassroomSession::selectRaw("DATE(start_at) as start_at,SUM(IF(canceled=0,1,0)) AS held, SUM(IF(canceled=1,1,0)) AS canceled")->whereDate('start_at', '>=', date('Y-m-d', strtotime('-30 days')))->groupBy(\DB::raw('DATE(start_at)'))->get();
     $session_per_days = [];
     for ($i = 30; $i > 0; $i--) {
         if ($session = $sessions->whereLoose('start_at', date('Y-m-d 00:00:00', strtotime("-" . $i . " days")))->first()) {
             $session_per_days[] = $session;
         } else {
             $session_per_days[] = ['held' => 0, 'canceled' => 0, 'start_at' => date('Y-m-d 00:00:00', strtotime("-" . $i . " days"))];
         }
     }
     return view('dashboards.admin', compact('semester', 'genders', 'students_by_years', 'students_by_state', 'session_per_days'));
 }
Пример #6
0
 public function edit($announcement_id)
 {
     $announcement = Announcement::with('years', 'specialities', 'classrooms', 'students')->findOrFail($announcement_id);
     $specialty_id = Specialty::pluck('name', 'id');
     $year_id = Year::pluck('name', 'id');
     $classroom_id = Classroom::pluck('code', 'id');
     $student_id = Student::pluck('username', 'id');
     return view('announcements::edit', compact('announcement', 'specialty_id', 'year_id', 'classroom_id', 'student_id'));
 }
Пример #7
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //Faculty
     Faculty::created(function ($faculty) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Faculty', 'reference_id' => $faculty->id]);
     });
     Faculty::updated(function ($faculty) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Faculty', 'reference_id' => $faculty->id]);
     });
     Faculty::deleted(function ($faculty) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Faculty', 'reference_id' => $faculty->id]);
     });
     //Year
     Year::created(function ($year) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Year', 'reference_id' => $year->id]);
     });
     Year::updated(function ($year) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Year', 'reference_id' => $year->id]);
     });
     Year::deleted(function ($year) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_Year', 'reference_id' => $year->id]);
     });
     //Term
     Term::created(function ($term) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_term', 'reference_id' => $term->id]);
     });
     Term::updated(function ($term) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_term', 'reference_id' => $term->id]);
     });
     Term::deleted(function ($term) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_term', 'reference_id' => $term->id]);
     });
     //Department
     Department::created(function ($department) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_department', 'reference_id' => $department->id]);
     });
     Department::updated(function ($department) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_department', 'reference_id' => $department->id]);
     });
     Department::deleted(function ($department) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_department', 'reference_id' => $department->id]);
     });
     //Specailty
     Specialty::created(function ($specialty) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_specialty', 'reference_id' => $specialty->id]);
     });
     Specialty::updated(function ($specialty) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_specialty', 'reference_id' => $specialty->id]);
     });
     Specialty::deleted(function ($specialty) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Academystructure_specialty', 'reference_id' => $specialty->id]);
     });
 }
Пример #8
0
    public function index(Request $request)
    {
        $per_page = request('per_page', 20);
        $students = $this->prepQuery($request->all());
        $students = $students->paginate($per_page);
        $students->appends($request->except('page'));
        $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name,
										academystructure_terms.id as tid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->orderBy('academystructure_terms.id')->pluck('name', 'tid')->toArray();
        $spec_id = Specialty::pluck('name', 'id')->toArray();
        $county = Country::pluck('name', 'id')->toArray();
        $city = City::pluck('name', 'id')->toArray();
        // return $students->pluck('sps');
        return view('students::students.index', compact('students', 'year_term', 'spec_id', 'county', 'city'));
    }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     if (Department::count()) {
         return;
     }
     Year::truncate();
     Department::truncate();
     Faculty::truncate();
     Specialty::truncate();
     Term::truncate();
     $specialties = [['name' => 'العلوم الشرعية', 'type' => 'dep', 'code' => 'G'], ['name' => 'الفقه و علومه', 'type' => 'bac', 'code' => 'O'], ['name' => 'الدراسات الاسلامية', 'type' => 'bac', 'code' => 'I']];
     foreach ($specialties as $s) {
         Specialty::create($s);
     }
     $structure = [['name' => 'كلية العلوم الشرعية', 'years' => [['name' => 'السنة الأولى', 'terms' => [['name' => 'الفصل الأول', 'departments' => [['subject_ids' => json_encode([1, 2, 3, 4, 5, 6]), 'spec_id' => 1], ['subject_ids' => json_encode([1, 2, 3, 4, 5, 6]), 'spec_id' => 2], ['subject_ids' => json_encode([1, 2, 3, 4, 5, 6]), 'spec_id' => 3]]], ['name' => 'الفصل الثاني', 'departments' => [['subject_ids' => json_encode([12, 11, 10, 14, 9, 8]), 'spec_id' => 1], ['subject_ids' => json_encode([12, 11, 10, 14, 9, 8]), 'spec_id' => 2], ['subject_ids' => json_encode([12, 11, 10, 14, 9, 8]), 'spec_id' => 3]]]]], ['name' => 'السنة الثانية', 'terms' => [['name' => 'الفصل الثالث', 'departments' => [['subject_ids' => json_encode([15, 16, 17, 18, 19, 20, 21]), 'spec_id' => 1], ['subject_ids' => json_encode([15, 16, 17, 18, 19, 20, 21]), 'spec_id' => 2], ['subject_ids' => json_encode([15, 16, 17, 18, 19, 20, 21]), 'spec_id' => 3]]], ['name' => 'الفصل الرابع', 'departments' => [['subject_ids' => json_encode([22, 23, 24, 29, 26, 27, 29]), 'spec_id' => 1], ['subject_ids' => json_encode([22, 23, 24, 29, 26, 27, 29]), 'spec_id' => 2], ['subject_ids' => json_encode([22, 23, 24, 29, 26, 27, 29]), 'spec_id' => 3]]]]], ['name' => 'السنة الثالثة', 'terms' => [['name' => 'الفصل الخامس', 'departments' => [['subject_ids' => json_encode([31, 32, 33, 34, 30, 35, 36, 39]), 'spec_id' => 2], ['subject_ids' => json_encode([32, 33, 30, 34, 37, 36, 39]), 'spec_id' => 3], ['subject_ids' => json_encode([33, 37]), 'spec_id' => 1]]], ['name' => 'الفصل السادس', 'departments' => [['subject_ids' => json_encode([41, 42, 43, 44, 45, 46, 47, 52]), 'spec_id' => 2], ['subject_ids' => json_encode([31, 50, 46, 47, 48, 49, 51, 52]), 'spec_id' => 3]]]]], ['name' => 'السنة الرابعة', 'terms' => [['name' => 'الفصل السابع', 'departments' => [['subject_ids' => json_encode([53, 54, 55, 56, 57, 58, 59, 77]), 'spec_id' => 2], ['subject_ids' => json_encode([55, 59, 60, 67, 68, 69, 75, 77]), 'spec_id' => 3]]], ['name' => 'الفصل الثامن', 'departments' => [['subject_ids' => json_encode([58, 61, 62, 63, 64, 65, 76, 78]), 'spec_id' => 2], ['subject_ids' => json_encode([58, 66, 70, 71, 72, 73, 74, 78]), 'spec_id' => 3]]]]]]]];
     $last_1_id = null;
     $last_2_id = null;
     $last_3_id = null;
     foreach ($structure as $f) {
         $faculty = Faculty::create(['name' => $f['name']]);
         foreach ($f['years'] as $y) {
             $year = Year::create(['name' => $y['name'], 'faculty_id' => $faculty->id]);
             foreach ($y['terms'] as $t) {
                 $term = Term::create(['year_id' => $year->id, 'name' => $t['name']]);
                 foreach ($t['departments'] as $d) {
                     $department = Department::create(['spec_id' => $d['spec_id'], 'subject_ids' => $d['subject_ids'], 'parent_id' => ${'last_' . $d['spec_id'] . '_id'}, 'term_id' => $term->id]);
                     if ($d['spec_id'] == 1) {
                         $last_1_id = $department->id;
                     } elseif ($d['spec_id'] == 2) {
                         $last_2_id = $department->id;
                     } elseif ($d['spec_id'] == 3) {
                         $last_3_id = $department->id;
                     }
                 }
             }
         }
     }
 }
Пример #10
0
    public function index(Request $request)
    {
        $exams = Exam::selectRaw('exams.*,COUNT(DISTINCT er.id) AS resultsCount,COUNT(DISTINCT eques.id) AS questionsCount')->leftJoin('exam_results AS er', function ($join) {
            $join->on('er.exam_id', '=', 'exams.id');
        })->leftJoin('exam_questions AS eques', function ($join) {
            $join->on('eques.exam_id', '=', 'exams.id');
        })->groupBy('exams.id')->orderBy('exams.id', 'desc');
        if (request('exam_subject')) {
            $exams->where('subject_id', request('exam_subject'));
        }
        if (request('exam_type')) {
            $exams->where('type', request('exam_type'));
        }
        if ($request->has('start_at')) {
            $exams->whereDate('start_at', '=', $request->input('start_at'));
        }
        if (request('exam_semester')) {
            $exams->where('exams.semester_id', request('exam_semester'));
        } else {
            //$exams->inCurrentSemester();
        }
        if (request('exam_year_term')) {
            $exams->whereIn('subject_id', explode(',', request('exam_year_term')));
        }
        $per_page = request('per_page') ? request('per_page') : 30;
        $exams = $exams->paginate($per_page);
        $exams->appends($request->except("page"));
        $subjects = Subject::lists('name', 'id')->toArray();
        $years = Year::lists('name', 'id')->toArray();
        $semesters = Semester::pluck('name', 'id')->toArray();
        $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->join('academystructure_departments', 'academystructure_terms.id', '=', 'academystructure_departments.term_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name,
										GROUP_CONCAT(DISTINCT(academystructure_departments.subject_ids)) as sid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->get()->toArray();
        $year_term_options;
        foreach ($year_term as $key => &$aa) {
            $a = implode(',', array_unique(array_merge(json_decode(str_replace('],[', ',', $aa['sid']), TRUE))));
            $year_term_options[$a] = $aa['name'];
        }
        return view('exams::exams.index', compact('exams', 'subjects', 'years', 'semesters', 'year_term_options'));
    }
Пример #11
0
 public function studentexam(Request $request)
 {
     $subjects = Subject::lists('name', 'id')->toArray();
     $semesters = Semester::select(\DB::raw('CONCAT(academycycle_semesters.name , "-", academycycle_years.name) as name , academycycle_semesters.id as id'))->join('academycycle_years', 'academycycle_years.id', '=', 'academycycle_semesters.academycycle_year_id')->pluck('name', 'id')->toArray();
     $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->join('academystructure_departments', 'academystructure_terms.id', '=', 'academystructure_departments.term_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name,
                                     GROUP_CONCAT(DISTINCT(academystructure_departments.subject_ids)) as sid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->get()->toArray();
     $year_term_options;
     foreach ($year_term as $key => &$aa) {
         $a = implode(',', array_unique(array_merge(json_decode(str_replace('],[', ',', $aa['sid']), TRUE))));
         $year_term_options[$a] = $aa['name'];
     }
     $types = config('exams.types');
     if (request('student_id')) {
         $semester_id = semester()->id;
         $student_id = request('student_id');
         $exam_type = request('exam_type');
         $camera_work = request('camera_work');
         $results = DB::select("SELECT student_subjects.subject_id,\n                exams.id as exam_id,\n                exam_results.id as exam_result_id,\n                s.id,\n                s.name,\n                s.username,\n                s.mobile,\n                exam_results.id as attendees,\n                exam_results.enter_at,\n                exam_results.exit_at,\n                exam_results.created_at,\n                exam_results.filename,\n                student_grades.value,subject_subjects.name as subject_name,\n                exam_recordings.id as record,\n                (select COUNT(*) from exam_result_answers  where  exam_result_answers.exam_result_id = exam_results.id and exam_result_answers.answer != '') as count_q\n\n                from students as s\n                inner join student_subjects on student_subjects.student_id = s.id\n                and student_subjects.state = 'study' and student_subjects.semester_id = " . $semester_id . "\n                left join subject_subjects on  subject_subjects.id = student_subjects.subject_id\n                inner join exams on student_subjects.subject_id = exams.subject_id and exams.semester_id = " . $semester_id . "\n                and (exams.type in ('midterm', 'remidterm') or exams.id IN (\n                SELECT ce.exam_id FROM classrooms_exam as ce\n                JOIN classrooms as c ON c.id = ce.classroom_id\n                JOIN classroom_students as cs ON cs.classroom_id = c.id\n                WHERE exam_id = exams.id AND cs.student_id = s.id GROUP BY ce.exam_id)\n                )\n                left join exam_results on exams.id = exam_results.exam_id and s.id = exam_results.student_id\n                left join `exam_recordings` on `exam_recordings`.`student_id` = exam_results.`student_id` and `exam_recordings`.`exam_id` = exam_results.`exam_id` \n                \n                left join student_grades on s.id = student_grades.student_id and student_grades.ref_key = 'exam' and exams.id = student_grades.ref_value\n                where s.id  = " . $student_id . " and finish_at  < '" . date("Y/m/d H:i:s") . "' and exams.type = '" . $exam_type . "' group by exam_id ORDER BY s.id ASC");
         $exams = collect($results);
         return view('exams::reports.studentexamdetails', compact('subjects', 'semesters', 'year_term_options', 'types', 'exams'));
     } else {
         if (request('exam_attendee') == 1) {
             $exams = Exam::selectRaw('exam_recordings.student_id, s.id , exams.id as exam_id,
                         er.id as erid,
                         s.name,
                         s.username,
                         er.id as attendees,
                         er.enter_at,
                         er.created_at ,
                         er.exit_at,
                         er.filename,
                         sg.value,exam_recordings.id as record,
                         (select COUNT(*) from exam_result_answers  where  exam_result_answers.exam_result_id = er.id and exam_result_answers.answer != "") as count_q')->leftJoin('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');
             })->leftJoin('exam_recordings', function ($join) {
                 $join->on('exam_recordings.student_id', '=', 'er.student_id');
                 $join->on('exam_recordings.exam_id', '=', 'er.exam_id');
             })->where('finish_at', '<', date("Y/m/d H:i:s"))->where('exams.subject_id', request('exam_subject'))->where('exams.semester_id', request('exam_semester'))->where('exams.type', request('exam_type'));
             if (request('camera_work') == 'not_work') {
                 $exams = $exams->where('exam_recordings.id', '=', null);
             } else {
                 $exams = $exams->where('exam_recordings.id', '!=', null);
             }
             $exams = $exams->groupBy('s.id')->orderBy('exams.id', 'desc')->get();
         } else {
             $exams = StudentSubject::whereIn('student_subjects.state', ['study'])->selectRaw('s.id,
                     s.name,
                     s.username')->leftJoin('students AS s', function ($join) {
                 $join->on('student_subjects.student_id', '=', 's.id');
             })->where('student_subjects.semester_id', request('exam_semester'))->where('subject_id', request('exam_subject'))->whereNotIn('s.id', function ($query) {
                 $query->select('s.id')->from('exams')->leftJoin('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');
                 })->where('finish_at', '<', date("Y/m/d H:i:s"))->where('exams.subject_id', request('exam_subject'))->where('exams.semester_id', request('exam_semester'))->where('exams.type', request('exam_type'))->orderBy('exams.id', 'desc')->get();
             })->get();
         }
         return view('exams::reports.studentexam', compact('subjects', 'semesters', 'year_term_options', 'types', 'exams'));
     }
 }
Пример #12
0
    public function index(Request $request)
    {
        $years = Year::pluck('name', 'id')->toArray();
        $semester = semester();
        $current_semester_id = $semester->id;
        $statuses = ["r" => trans('students::success.repeaters'), 's' => trans('students::success.successful')];
        $students = Student::selectRaw('sh2.study_state as shstudy,students.*, GROUP_CONCAT(at.id) AS terms,
			GROUP_CONCAT(sh.academycycle_semester_id) AS semesters')->join('student_histories AS sh', function ($join) use($current_semester_id) {
            $join->on('sh.student_id', '=', 'students.id')->where('sh.academycycle_semester_id', '<=', $current_semester_id);
        })->leftJoin('student_histories AS sh2', function ($join) use($current_semester_id) {
            $join->on('sh2.student_id', '=', 'students.id')->where('sh2.academycycle_semester_id', '=', $current_semester_id);
        })->join('academystructure_departments AS ad', 'ad.id', '=', 'sh.academystructure_department_id')->join('academystructure_terms AS at', 'at.id', '=', 'ad.term_id')->join('academystructure_years AS ay', 'ay.id', '=', 'at.year_id')->where('students.state', 'active')->whereNotIn('sh2.study_state', ['success', 'fail', 'stop', 'repeat'])->isStudying();
        if ($request->has('year')) {
            //$students->where('ay.id', $request->input('year'));
        }
        $students = $students->groupBy('students.id')->paginate(50);
        $students->each(function ($student) use($current_semester_id) {
            $terms_arr = explode(",", $student->terms);
            $sems_arr = explode(",", $student->semesters);
            $all_failed_subjects = StudentSubject::groupBy('subject_id')->where(function ($query) {
                return $query->orWhere(function ($query) {
                    return $query->where('state', 'fail')->where('semester_id', '<', semester()->id);
                })->orWhere(function ($query) {
                    return $query->where('state', 'study')->where('semester_id', semester()->id);
                });
            })->where('student_id', $student->id)->pluck('subject_id')->toArray();
            // dd($all_failed_subjects);
            $all_passed_subjects = StudentSubject::groupBy('subject_id')->where('state', 'success')->where('student_id', $student->id)->pluck('subject_id')->toArray();
            $accumulation_hours = 0;
            $term_average = 0;
            $accumulation_points = 0;
            $terms = collect();
            foreach ($terms_arr as $term_id) {
                $terms->push(Term::find($term_id));
            }
            $failed_subjects = [];
            $passed_subjects = [];
            // beging foreach terms
            foreach ($terms as $key => $term) {
                $semester_id = $sems_arr[$key];
                $term->subjects = StudentSubject::selectRaw("subsub.id as subject_id,SUM(stugr.value) AS subject_points,\n\t\t\t\tstudent_subjects.state as subject_state,subsub.name AS subject_name, subsub.hour AS subject_hours")->join('subject_subjects AS subsub', function ($join) {
                    $join->on('subsub.id', '=', 'student_subjects.subject_id');
                })->where('student_subjects.student_id', $student->id)->leftJoin('student_grades AS stugr', function ($join) use($semester_id, $student) {
                    $join->on('stugr.subject_id', '=', 'subsub.id')->where('stugr.semester_id', '=', $semester_id)->where('stugr.student_id', '=', $student->id);
                })->whereIn('state', ['study', 'success', 'fail'])->where('student_subjects.semester_id', '=', $semester_id)->where('student_subjects.student_id', $student->id)->groupBy('subject_id')->get();
                $term->subjects->each(function ($subject) use(&$passed_subjects, &$failed_subjects, $student, $current_semester_id, $semester_id, &$all_failed_subjects, &$all_passed_subjects) {
                    $subject->details = grade_details($subject->subject_points, $subject->subject_hours);
                    if ($semester_id == $current_semester_id) {
                        if ((double) $subject->subject_points < 50) {
                            $all_failed_subjects[] = $subject->subject_id;
                            $failed_subjects[] = $subject->subject_id;
                        } else {
                            $all_passed_subjects[] = $subject->subject_id;
                            $passed_subjects[] = $subject->subject_id;
                        }
                    }
                });
                $hours = $term->subjects->sum('subject_hours');
                $quran_hours = $term->subjects->sum(function ($s) {
                    return $s->is_quran ? $s->subject_hours : 0;
                });
                $points = number_format($term->subjects->sum(function ($subject) {
                    return $subject->details->points;
                }), 2);
                $term_average = $hours ? number_format($points / ($hours - $quran_hours), 2) : 0.0;
                $student->term_average = $term_average;
                $accumulation_points += $points;
                $accumulation_hours += $hours - $quran_hours;
                if ($key == $terms->count() - 2 && $terms->count() > 1) {
                    $student->term_previous = $term_average;
                    $student->accum_previous = $accumulation_hours ? number_format($accumulation_points / $accumulation_hours, 2) : 0;
                }
            }
            // $all_failed_subjects = array_diff($all_failed_subjects, $failed_subjects);
            $old_failed_subjects = array_diff(array_unique(array_diff($all_failed_subjects, $failed_subjects)), array_unique($all_passed_subjects));
            // dd($failed_subjects);
            $student->old_failed_subjects = count($old_failed_subjects);
            // end foreach terms
            if ($accumulation_hours) {
                $student->accumulation_average = number_format($accumulation_points / $accumulation_hours, 2);
            }
            $student->terms = $terms;
            $student->failed = $student->accumulation_average < 1.67 || $student->accum_previous < 2.0 && $student->accum_previous > 1.67 && ($student->accumulation_average < 2.0 && $student->accumulation_average > 1.67);
            $student->failed_subjects = count(array_unique($failed_subjects));
            $student->passed_subjects = count(array_unique($passed_subjects));
            if (semester()->order != 'summer' && count($old_failed_subjects) + count($failed_subjects) >= 4) {
                $student->failed = true;
            }
            if (semester()->order == 'summer') {
                $student->failed = false;
            }
        });
        $students = $students->filter(function ($student) use($request) {
            return $student->failed == ($request->input('status', 's') == 'r') ? 1 : 0;
        });
        return view('students::success.index', compact('years', 'students', 'statuses', 'semester'));
    }
Пример #13
0
 /**
  * @desc Delete Year 
  * @param Year $year (get year from provider route model binding $router->model)
  * @redirect to year index with faculty_id
  **/
 public function delete(Year $year)
 {
     $faculty_id = $year->faculty_id;
     $year->delete();
     return redirect()->route('as.years.index', [$faculty_id]);
 }
 public function edit($id = 0)
 {
     $elements = EvaluationElement::findOrFail($id);
     $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('quran::elements.edit', compact('elements', 'years'));
 }
Пример #15
0
    public function report(Request $request)
    {
        # code...
        $per_page = request('per_page', 20);
        $students = $this->prepQuery($request->all());
        $students = $students->paginate($per_page);
        $students->appends($request->except('page'));
        $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name,
										academystructure_terms.id as tid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->orderBy('academystructure_terms.id')->pluck('name', 'tid')->toArray();
        $spec_id = Specialty::pluck('name', 'id')->toArray();
        $exam_center_id = ExamCenter::pluck('name', 'id')->toArray();
        // return $students->pluck('sps');
        return view('exams::centers.report', compact('students', 'year_term', 'spec_id', 'exam_center_id'));
    }