Exemplo n.º 1
0
 public function showDashboard()
 {
     $data = [];
     $loginid = Session::get('user')->id;
     $collegeid = Session::get('user')->collegeid;
     $flag = Session::get('user')->flag;
     $tb = "";
     if ($flag == 1) {
         $tb = "Admin";
     } else {
         if ($flag == 2) {
             $tb = "Teacher";
         } else {
             if ($flag == 3) {
                 $tb = "Student";
             } else {
                 $tb = "Staff";
             }
         }
     }
     $dt = $tb::where('loginid', '=', $loginid)->first();
     $data['name'] = $dt->name;
     $data['pic'] = $dt->profilepic;
     $data['id'] = $loginid;
     //Cards value
     $data['students'] = Student::where('collegeid', '=', $collegeid)->count();
     $data['teachers'] = Teacher::where('collegeid', '=', $collegeid)->count();
     $data['subjects'] = Subject::where('collegeid', '=', $collegeid)->count();
     $data['parents'] = $data['students'] * 2;
     return View::make('pages.dashboard', array('data' => $data, 'flag' => $flag));
 }
 /**
  * 計算課表
  */
 public static function caculate($param)
 {
     // 設定執行時間
     set_time_limit(60);
     // 產生教室使用時間,提供排課使用
     $classroom = Classroom::all();
     foreach ($classroom as $classroomItem) {
         $GLOBALS['classroomCourseTime'][$classroomItem->classroom_id] = str_replace('1', $classroomItem->count, $classroomItem->course_time);
     }
     // 取得教師排課需求,計算適應值用
     $teacher = Teacher::where('course_time', '<>', str_repeat(0, 35))->get();
     foreach ($teacher as $teacherItem) {
         $GLOBALS['teacherRequire'][$teacherItem->teacher_id]['require'] = $teacherItem->course_time;
         $GLOBALS['teacherRequire'][$teacherItem->teacher_id]['classes_id'] = $teacherItem->classes_id;
         if ($teacherItem->classes_id != 0) {
             $GLOBALS['teacherRequire'][$teacherItem->teacher_id]['courseTime'] = $teacherItem->classes->year->course_time;
         }
     }
     // 產生課表,速度、計算適應值
     $seed = self::_generateSeed($param['seedCount']);
     // 發生錯誤,回傳錯誤結果
     if ($seed[0] == 'error') {
         return $seed;
     }
     // 進行粒子最佳化計算
     $seedProgressHistory = array();
     $extinctionTimes = 1;
     while ($param['extinctionCount'] > 0) {
         $withoutProgressCount = 0;
         $bestSeed = self::_getBestSeed($seed);
         $seedProgressHistory[] = number_format($bestSeed['fitness'], 2, '.', '');
         while ($withoutProgressCount < $param['executeCount']) {
             // 更新種子速度
             self::_updateSeedV($seed, $bestSeed);
             // 依照速度更新課表排課、計算適應值
             $seed = self::_updateSeed($seed);
             // 取得新的全域最佳值
             $newBestSeed = self::_getBestSeed($seed);
             // 判斷是否改進
             if ($bestSeed['fitness'] < $newBestSeed['fitness']) {
                 $bestSeed = $newBestSeed;
                 $withoutProgressCount = 0;
                 $seedProgressHistory[] = number_format($bestSeed['fitness'], 2, '.', '') . '<sup class="progross">&nbsp;&nbsp;改進</sup>';
             } else {
                 $withoutProgressCount++;
                 $seedProgressHistory[] = number_format($bestSeed['fitness'], 2, '.', '');
             }
         }
         // 進行判斷是否改進毀滅結果
         if (!isset($historyBestSeed) || $historyBestSeed['fitness'] < $bestSeed['fitness']) {
             $historyBestSeed = $bestSeed;
         }
         $seedProgressHistory[] = '<strong>' . number_format($historyBestSeed['fitness'], 2, '.', '') . '<sup>&nbsp;&nbsp;全域最佳</sup></strong>';
         $seedProgressHistory[] = 'Extinction ' . $extinctionTimes;
         $param['extinctionCount']--;
         $extinctionTimes++;
     }
     file_put_contents(storage_path() . '\\result.json', json_encode($historyBestSeed['timetable']));
     return $seedProgressHistory;
 }
Exemplo n.º 3
0
 /**
  * 同步更新教師的班級資料
  */
 public static function syncTeacher()
 {
     $classes = Classes::find(self::$lastClassesId);
     try {
         $teacher = Teacher::where('classes_id', '=', $classes->classes_id)->update(array('classes_id' => 0));
         if ($classes->teacher_id > 0) {
             $teacher = Teacher::find($classes->teacher_id)->update(array('classes_id' => $classes->classes_id));
         }
     } catch (Exception $e) {
     }
 }
 public function index()
 {
     $id = Auth::id();
     $student = Student::where('id_user', '=', $id)->get()->first();
     $teacher = Teacher::where('id_user', '=', $id)->get()->first();
     if (isset($student)) {
         return View::make('users.hello', compact('student'));
         //
     } else {
         if (isset($teacher)) {
             return View::make('users.hello', compact('teacher'));
             //
         }
     }
 }
 public function store()
 {
     $title = Input::get('title');
     $score = Input::get('minimunScore');
     $numberOfquestions = Input::get('numberQuestions');
     $Creator = Teacher::where('id_user', '=', Auth::id())->get()->first();
     $exam = new Exam();
     $exam->title = $title;
     $exam->creator = $Creator->id;
     $exam->score = $score;
     $exam->save();
     $ex = Exam::where('title', '=', $title)->get()->first();
     $id = $ex->id;
     return View::make('questions.create', compact('id', 'numberOfquestions'));
 }
 public function run()
 {
     //DB::table('exams')->delete();
     $teacher = Teacher::where('first_name', '=', 'Luis')->get()->first();
     $exam = new Exam();
     $exam->title = 'Sumas basicas';
     $exam->creator = $teacher->id;
     $exam->score = 2;
     $exam->save();
     $teacher2 = Teacher::where('first_name', '=', 'Luis')->get()->first();
     $exam2 = new Exam();
     $exam2->title = 'Restas basicas';
     $exam2->creator = $teacher2->id;
     $exam2->score = 2;
     $exam2->save();
 }
Exemplo n.º 7
0
     return View::make('timetable')->with($viewData);
 });
 // 顯示教師排課清單
 Route::get('view_title/{titleId}/{teacherId}', function ($titleId, $teacherId) {
     $teacherList = $titleId == 'all' ? Teacher::orderBy('teacher_name') : Teacher::where('title_id', '=', $titleId)->orderBy('teacher_name');
     $viewData['teacherList'] = $teacherList->get();
     $viewData['titleList'] = Title::orderBy('title_name')->get();
     $viewData['titleId'] = $titleId;
     $viewData['teacher'] = Teacher::find($teacherId);
     $viewData['teacherId'] = $teacherId;
     $viewData['courseUnits'] = $viewData['teacher']->courseunit;
     return View::make('timetable')->with($viewData);
 });
 // 顯示教師排課編輯畫面
 Route::get('view_title/{titleId}/{teacherId}/{courseUnitId}', function ($titleId, $teacherId, $courseUnitId) {
     $teacherList = $titleId == 'all' ? Teacher::orderBy('teacher_name') : Teacher::where('title_id', '=', $titleId)->orderBy('teacher_name');
     $viewData['teacherList'] = $teacherList->get();
     $viewData['titleList'] = Title::orderBy('title_name')->get();
     $viewData['titleId'] = $titleId;
     $viewData['teacher'] = Teacher::find($teacherId);
     $viewData['teacherId'] = $teacherId;
     $viewData['courseUnits'] = $viewData['teacher']->courseunit;
     $viewData['courseUnit'] = Courseunit::find($courseUnitId);
     return View::make('timetable')->with($viewData);
 });
 // 執行更新排課設定
 Route::post('edit/{titleId}/{teacherId}/{courseUnitId}', function ($titleId, $teacherId, $courseUnitId) {
     // 設定為編輯模式,方便驗證功能
     $validator = FormValidator::courseUnit(array_merge(Input::all(), array('mode' => 'edit' . $courseUnitId)));
     if ($validator->fails()) {
         return Redirect::to('/timetable/view_title/' . $titleId . '/' . $teacherId . '/' . $courseUnitId)->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
Exemplo n.º 8
0
 /**
  * Performs teacher account authentification and returns boolean information about success.
  * @param string $eamil teacher account e-mail address.
  * @param string $password teacher account password in plain text form.
  * @return boolean TRUE, if teacher authentification is successful, FALSE otherwise (i.e. bad e-mail of password).
  */
 public function authenticate_teacher_login($email, $password)
 {
     $teacher = new Teacher();
     $teacher->where('email', $email);
     $teacher->where('password', sha1($password));
     $teacher->get();
     if ($teacher->exists()) {
         $userdata = $teacher->to_array();
         unset($userdata['password']);
         unset($userdata['created']);
         unset($userdata['updated']);
         $this->CI->session->set_userdata(SESSION_AUTH_LOGIN_TEACHER, $userdata);
         $this->validate_teacher_login_verification(TRUE);
         return TRUE;
     } else {
         $this->validate_teacher_login_verification(FALSE);
         $this->add_login_failed_record($email, self::ACCOUNT_TYPE_TEACHER);
         return FALSE;
     }
 }
Exemplo n.º 9
0
 /**
  * Remove the subjects of an University
  * 
  * @return JSON Ajax
  */
 public function drop()
 {
     if (Request::ajax()) {
         $subject = Subject::find(Input::get('subject_id'));
         foreach (Teacher::where('university_id', Auth::id())->get() as $teacher) {
             if ($teacher->whereIn('subjects_id', array(new MongoId($subject->_id)))->count() > 0) {
                 return Response::json(Lang::get('add_subject.subject_used'));
             }
         }
         $subject->delete();
         return Response::json($subject->trashed() ? "00" : "99");
     }
 }
Exemplo n.º 10
0
 public function search_teachers()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["actions"] = Session::get('actions');
         if (in_array('side_listar_profesores', $data["actions"])) {
             $data["search"] = Input::get('search');
             $search_criteria = $data["search"];
             $data["teachers_data"] = Teacher::where('names', 'LIKE', "%{$search_criteria}%")->orWhere('lastname', 'LIKE', "%{$search_criteria}%")->whereNull('deleted_at')->orderBy('lastname')->paginate(20);
             return View::make('people/list_teachers', $data);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registerLog(10, $log_description);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
Exemplo n.º 11
0
 /**
  * 刪除職稱會讓該職稱教師title_id設定為0
  */
 public function delete()
 {
     $classes = Teacher::where('title_id', '=', $this->title_id)->update(array('title_id' => 0));
     parent::delete();
 }
Exemplo n.º 12
0
 public function delete_teacher()
 {
     $this->output->set_content_type('application/json');
     $this->usermanager->teacher_login_protected_redirect();
     $url = $this->uri->ruri_to_assoc(3);
     $teacher_id = isset($url['teacher_id']) ? intval($url['teacher_id']) : 0;
     if ($teacher_id != 0) {
         $this->_transaction_isolation();
         $this->db->trans_begin();
         $teacher = new Teacher();
         $teacher->where('id !=', $this->usermanager->get_teacher_id())->get_by_id($teacher_id);
         $teacher->delete();
         if ($this->db->trans_status()) {
             $this->db->trans_commit();
             $this->output->set_output(json_encode(TRUE));
             $this->_action_success();
         } else {
             $this->db->trans_rollback();
             $this->output->set_output(json_encode(FALSE));
         }
     } else {
         $this->output->set_output(json_encode(FALSE));
     }
 }
Exemplo n.º 13
0
 /**
  * Function that return a teacher information array
  *
  * @return Array
  */
 public function find()
 {
     if (Request::ajax()) {
         $teacher = Teacher::where('email', Input::get('email'))->first();
         return Response::json($teacher);
     }
 }