/** * Get list of registered course for current semester per prodi * @param $prodi_id * @return mixed */ public static function courseByUserProdi($prodi_id) { $id_semester = Kalender::getRunningSemester()->id; $instances = DB::select('SELECT e.id, c.seksi, c.Kode_Matkul,c.Nama_Matkul, c.day, c.time, c.Kode_Dosen, e.noreg, max(p.pertemuan_ke) as pertemuan, w.kode_waktu, w.waktu_start, w.waktu_end FROM `enrollments` as e inner join courses as c inner join presences as p inner join waktu_kuliah as w on e.kode_seksi=c.seksi and c.seksi=p.kode_seksi and w.id=c.time where c.prodi_id=? and c.id_semester=? group by c.seksi', [$prodi_id, $id_semester]); return $instances; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Kalender::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['tgl' => $this->tgl]); $query->andFilterWhere(['like', 'Ket', $this->Ket]); return $dataProvider; }
public static function topicsByKodeMatkul($course_id) { $id_semester = Kalender::getRunningSemester()->id; $topic = DB::table('topics')->where('courses.Kode_Matkul', $course_id)->where('courses.id_semester', $id_semester)->join('courses', 'courses.seksi', '=', 'topics.kode_seksi')->select('topics.*', 'courses.Kode_Matkul', 'courses.Nama_Matkul', 'courses.id_semester')->get(); return $topic; }
public function rekapDosen(Request $request) { //get list of semester $kalender = Kalender::all('id', 'semester'); $kalender_array = Helpers::modelAsAssociativeArray($kalender, 'id', 'semester'); //get list of course sections for current semester and lecturer $lecturer = Auth::user()->lecturer; $kode_dosen = $lecturer->Kode_Dosen; $semester = Kalender::getRunningSemester(); //for debugging $course_model = DB::table('courses')->where('Kode_Dosen', $kode_dosen)->where('id_semester', $semester->id); $course = $course_model->get(); $course_array = Helpers::modelAsAssociativeArray($course, 'seksi', 'Nama_Matkul'); //make default showing first course on the list $enrollment = array(); $seksi = array(); if (empty($course)) { $enrollment = array(); } else { $seksi = $course[0]->seksi; //pass along list of enrolled students $enrollment = $course_model->where('seksi', $seksi)->join('enrollments as e', 'e.kode_seksi', '=', 'courses.seksi')->join('students as s', 's.Noreg', '=', 'e.noreg')->get(); } return view('lecturers.rekap')->with('kalender_options', $kalender_array)->with('course_options', $course_array)->with('course', $course)->with('enrolls', $enrollment)->with('semester_id', $semester->id)->with('kode_seksi', $seksi); }
/** * Finds the Kalender model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Kalender the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Kalender::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function instanceByKodeMatkul($course_id) { $id_semester = Kalender::getRunningSemester()->id; $instance = DB::table('courses')->where('Kode_Matkul', $course_id)->where('id_semester', $id_semester)->orderBy('Kode_Matkul', 'asc')->first(); return $instance; }
/** * Show all course only taught by this lecturer on current semester * @return $this */ public function viewCourseByLecturer() { //get current user $user = Auth::user(); //get the mapping for lecturer $kode_dosen = $user->lecturer->Kode_Dosen; $id_semester = Kalender::getRunningSemester()->id; $courses = Course::where('Kode_Dosen', $kode_dosen)->where('id_semester', $id_semester)->get(); return view('lecturers.showcourse')->with('Courses', $courses); }
protected function checkSectionId($validator) { $seksi = $validator->getData()['kode_seksi']; $id_semester = Kalender::getRunningSemester()->id; $instance = Course::where('seksi', $seksi)->where('id_semester', $id_semester)->get(); if (count($instance) == 0) { return true; } return false; //the precondition for being add, section id must not exist for current user or has been registered }