Exemplo n.º 1
0
function photo_POST($id)
{
    $teacher = new Teacher($id);
    $src = make_image('photo');
    $teacher->update('photo', $src);
    redirect("teacher/{$id}");
}
Exemplo n.º 2
0
 protected function getAsObject($row)
 {
     $result = new Teacher();
     $result->setNew(false);
     $result->setTeacherId(Singleton::create("NullConverter")->fromDBtoDOM($row["teacherId"]));
     $result->setName(Singleton::create("NullConverter")->fromDBtoDOM($row["name"]));
     return $result;
 }
Exemplo n.º 3
0
function edit_teacher_POST($id)
{
    $description = _post('description');
    $teacher = new Teacher($id);
    if ($description) {
        $teacher->update('description', $description);
    }
    redirect("teacher/{$id}/edit");
}
Exemplo n.º 4
0
 public function testTeacher()
 {
     $teacher = new Teacher("Teacher");
     $groupLeader = new GroupLeader("GroupLeader");
     $number = 10;
     for ($i = 1; $i <= $number; $i++) {
         $groupLeader->addGirl(new Girl("girl:{$i}"));
     }
     $teacher->commond($groupLeader);
 }
 function testForTeacher()
 {
     $x = new Teacher(2);
     $y = $x->consultation_requests();
     $this->assertType('array', $y);
     $this->assertEquals(3, count($y));
     $z = array_shift($y);
     $this->assertType('ConsultationRequest', $z);
     $this->assertEquals(3, $z->id);
 }
Exemplo n.º 6
0
/**
 * @author  ryan <*****@*****.**>
 */
function teacher_GET($id)
{
    $teacher = new Teacher($id);
    $comments = Comment::search()->filterBy('teacher', $id)->find();
    $has_login = $GLOBALS['has_login'];
    if ($has_login) {
        $teacher->commentedByMe = $teacher->commentedByUser($GLOBALS['user']);
    }
    $schools = $GLOBALS['config']['school'];
    render_view('master', compact('teacher', 'courses', 'comments', 'has_login', 'schools'));
}
Exemplo n.º 7
0
 public function selected_teachers()
 {
     if (!is_null($this->id)) {
         $teachers = new Teacher();
         $teachers->where_related($this);
         $teachers->get_iterated();
         $output = array();
         foreach ($teachers as $teacher) {
             $output[$teacher->id] = $teacher->id;
         }
         return $output;
     }
     return array();
 }
Exemplo n.º 8
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new Teacher();
     if (isset($_POST['Teacher'])) {
         $acl = $this->_gets->getPost('acl');
         $model->attributes = $_POST['Teacher'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('teacher_create', array('model' => $model));
 }
Exemplo n.º 9
0
 public function createTeacher(PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $teacher = new Teacher();
     $teacher->setPerson($this->getPerson());
     $teacher->save($con);
     $guard_user = $this->getPersonSfGuardUser();
     if (!is_null($guard_user)) {
         $teacher_group = BaseCustomOptionsHolder::getInstance('GuardGroups')->getStringFor(GuardGroups::TEACHER);
         if (!array_key_exists($teacher_group, $guard_user->getGroups())) {
             $guard_user->addGroupByName($teacher_group);
             $guard_user->save($con);
         }
     }
 }
Exemplo n.º 10
0
 function testDocumentAdd()
 {
     $d = new Document(false);
     $set = array('teacher_id' => 1, 'mediatype' => 'wma', 'url' => 'newsong.wma', 'description' => 'new song', 'pricecode' => 'b');
     $new_id = $d->add($set);
     $d = new Document($new_id);
     $d->add_teacher($set['teacher_id']);
     $this->assertEquals($set['description'], $d->description());
     $t = new Teacher($set['teacher_id']);
     $ds = $t->documents();
     $this->assertType('array', $ds);
     $this->assertArrayHasKey($new_id, $ds);
     $d = $ds[$new_id];
     $this->assertEquals($set['description'], $d->description());
 }
Exemplo n.º 11
0
 public function addSectionCode()
 {
     $section_code = new SectionCode();
     $teacher = Teacher::find(Auth::Id());
     $subject_id = Input::get('subject');
     $section_id = Input::get('section');
     $current_period = Input::get('current_period');
     $section_code->teacher_id = new MongoId($teacher->_id);
     $section_code->subject_id = new MongoId($subject_id);
     $section_code->section_id = new MongoId($section_id);
     $section_code->current_period = $current_period;
     $section_code->teamleaders_id = array();
     $section_code->students_id = array();
     $section_code->status = true;
     $subject = Subject::find($subject_id);
     $section = $subject->sections()->find($section_id);
     $code = $this->getInitialLetters($subject->name) . '-' . $section->code . '-' . $current_period;
     $section_code->code = $code;
     if (!is_null($section->current_code)) {
         $sectionCode = SectionCode::where('code', $section->current_code)->first();
         if (isset($sectionCode->_id)) {
             $sectionCode->status = false;
             $sectionCode->save();
         }
     }
     try {
         $section_code->save();
         $section->current_code = $code;
         $section->save();
     } catch (MongoDuplicateKeyException $e) {
         return Redirect::back()->withErrors(array('error' => Lang::get('section_codes.duplicate_code')));
     }
     return Redirect::to(Lang::get('routes.section_codes'))->with(array('message' => Lang::get('section_codes.success_message')));
 }
Exemplo n.º 12
0
 /**
  * This is construct base of the class.
  *
  * A public constructor; initializes the variable $instanceDataBase.
  *
  */
 public function __construct($instanceDataBase)
 {
     parent::__construct($instanceDataBase);
     Teacher::setDataOperationBusiness($instanceDataBase);
     Teacher::getBusiness();
     Teacher::getDescriptionBusiness();
 }
Exemplo n.º 13
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Teacher::create(['name' => $faker->firstName, 'lastName' => $faker->lastName, 'dob' => $faker->date(), 'pob' => $faker->city, 'gender' => $faker->word, 'email' => $faker->email, 'password' => Hash::make('buffer'), 'grade' => $faker->word]);
     }
 }
Exemplo n.º 14
0
 public function actionView($id)
 {
     $lesson = $this->loadModel($id);
     $userId = $this->_cookiesGet('userId');
     $userType = $this->_cookiesGet('userType');
     $this->_seoTitle = '课程 - ' . $lesson->name;
     //取报名人数
     $actual_students_criteria = new CDbCriteria();
     $actual_students = StudentLesson::model()->count($actual_students_criteria->addCondition("lesson_id =" . $id));
     $lesson->actual_students = $actual_students;
     $teacher = Teacher::model()->findByPk($lesson->teacher_id);
     $place = Place::model()->findByPk($lesson->place_id);
     //教学环境图片显示
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     //判断学员已收藏的课程
     if ($userType === 'student') {
         $is_focus = StudentLesson::model()->findByAttributes(array('student_id' => $userId, 'lesson_id' => $id, 'is_collection' => 1));
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($place->pic_other) {
         $imageList = unserialize($place->pic_other);
     }
     $this->render('view', array('is_focus' => $is_focus, 'isJoin' => $this->isJoin($userId, $id, 1), 'userType' => $userType, 'lesson' => $lesson, 'place' => $place, 'teacher' => $teacher, 'imageList' => $imageList));
 }
Exemplo n.º 15
0
 private function getModel()
 {
     if (!$this->isGuest && $this->_model === null) {
         $this->_model = Teacher::model()->findByPk($this->id, array('select' => 'role'));
     }
     return $this->_model;
 }
Exemplo n.º 16
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.º 18
0
 public function run()
 {
     DB::table('teachers')->delete();
     $extra = array('1', '2', '3', '4');
     $extra = serialize($extra);
     Teacher::create(array('user_id' => 1, 'email' => '*****@*****.**', 'dob' => '1996-01-01', 'extra' => $extra));
 }
Exemplo n.º 19
0
 public function actionIndex()
 {
     Yii::app()->getModule('aud');
     Yii::app()->getModule('group');
     Yii::app()->getModule('lesson');
     Yii::app()->getModule('sch');
     Yii::app()->getModule('spec');
     Yii::app()->getModule('teacher');
     $schs = Sch::model()->findAll(array('order' => 'modified_time DESC', 'limit' => 100));
     $auds = Aud::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $specs = Spec::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $groups = Group::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $lessons = Lesson::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $teachers = Teacher::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $entries = $this->addEntries(array($auds, $specs, $groups, $lessons, $teachers));
     foreach ($schs as $value) {
         $entries[] = array('id' => $value->group_id, 'module' => strtolower(get_class($value)), 'time' => $value->modified_time . rand(100000, 999999), 'time' => $value->modified_time, 'user' => $value->modified_by, 'action' => 'update');
     }
     $entriesNew = array();
     foreach ($entries as $value) {
         $entriesNew[$value['time'] . rand(10000, 99999)] = $value;
     }
     krsort($entriesNew);
     $this->render('index', array('entries' => $entriesNew));
 }
Exemplo n.º 20
0
 public static function getLastTitleId()
 {
     try {
         return Teacher::find(self::$lastTeacherId)->title->title_id;
     } catch (Exception $e) {
         return 'all';
     }
 }
Exemplo n.º 21
0
 /**
  * This method will return data by filter name.
  * If the second and third parameters are set, it will check teacher data for his prefered course and
  * inject this value into filter by specified conditions, only if these filter data are empty.
  * @param string $filter_name name of filter.
  * @param integer|Teacher $teacher teacher id or teacher object.
  * @param string $course_field field in filter which contain course id in filter.
  * @return array<midex> filter data.
  */
 public function restore_filter($filter_name, $teacher = NULL, $course_field = NULL)
 {
     $filters = $this->CI->session->userdata(self::FILTERS_ARRAY);
     $filters = empty($filters) || is_null($filters) || !is_array($filters) ? array() : $filters;
     $filter = array_key_exists($filter_name, $filters) ? $filters[$filter_name] : array();
     if (!is_null($teacher) && !is_null($course_field) && is_string($course_field) && empty($filter)) {
         if (!is_object($teacher) || !$teacher instanceof Teacher) {
             $teacher_id = $teacher;
             $teacher = new Teacher();
             $teacher->get_by_id(intval($teacher_id));
         }
         if ($teacher->exists()) {
             $filter[$course_field] = $teacher->prefered_course_id;
         }
     }
     return $filter;
 }
Exemplo n.º 22
0
 public function searchTeacher($teacher_name)
 {
     $teacherCriteria = new CDbCriteria();
     $teacherCriteria->select = "*";
     $teacherCriteria->addSearchCondition('teacher_name', $teacher_name);
     $teacher_result = Teacher::model()->findAll($teacherCriteria);
     return $teacher_result;
 }
 /**
  * Отображение главной страницы
  *
  * @return void
  */
 public function actionIndex()
 {
     $branch = \Branch::model()->findAll();
     $teacher = \Teacher::model()->findAll();
     $positions = $this->gavno();
     $salary = \User::model()->findBySql('SELECT DAY(t1.salary_date) FROM spbp_user_user t1 WHERE t1.is_test <> 1 AND DAY(t1.salary_date)=' . date('d'));
     $this->render('index', ['branchs' => $branch, 'teachers' => $teacher, 'salary' => $salary, 'positions' => $positions]);
 }
 public function loadModel($id)
 {
     $model = Teacher::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 25
0
function show_form()
{
    $name = _req('name');
    $teacher = _req('teacher');
    $description = _req('description');
    $teachers = Teacher::search()->find(Searcher::KEY_VALUE_PAIR);
    render_view('master', compact('teachers', 'name', 'teacher', 'description'));
}
 public function actionSubject()
 {
     $subject_id = "";
     if (isset($_GET["subject_id"])) {
         $subject_id = StringHelper::filterString($_GET["subject_id"]);
     } else {
         if (isset($_GET["subject_code"])) {
             $subject_code = StringHelper::filterString($_GET["subject_code"]);
             $subject_by_code = Subject::model()->findByAttributes(array('subject_code' => $subject_code));
             $subject_id = $subject_by_code->subject_id;
         }
     }
     $subjectCriteria = new CDbCriteria();
     $subjectCriteria->select = "*";
     $subjectCriteria->condition = "subject_id = :subject_id";
     $subjectCriteria->params = array(":subject_id" => $subject_id);
     $subject = Subject::model()->findAll($subjectCriteria);
     $teachers = Teacher::model()->with(array("subject_teacher" => array("select" => false, "condition" => "subject_id = :subject_id", "params" => array(":subject_id" => $subject_id))))->findAll();
     //            $doc = Doc::model()->with(array("docs" => array(
     //                            "select" => "*",
     //                            "condition" => "subject_id = :subject_id and active = 1",
     //                            "params" => array(":subject_id" => $subject_id)
     //                )))->findAll(array("limit" => "3", "order" => "RAND()"));
     //
     //            $reference = Doc::model()->with(array("docs" => array(
     //                            "select" => "*",
     //                            "condition" => "subject_id = :subject_id and active = 0",
     //                            "params" => array(":subject_id" => $subject_id)
     //                )))->findAll(array("limit" => "3", "order" => "RAND()"));
     $lesson = Lesson::model()->findAll(array("select" => "*", "condition" => "lesson_subject = :lesson_subject", "params" => array(":lesson_subject" => $subject_id), "order" => "lesson_weeks ASC"));
     //            $doc_related = Doc::model()->with(array("docs" => array(
     //                            "condition" => "subject_id = :subject_id",
     //                            "params" => array(":subject_id" => $subject_id)
     //                )))->findAll();
     //   $sql = "SELECT * FROM tbl_doc JOIN tbl_subject_doc ON tbl_doc.doc_id = tbl_subject_doc.doc_id WHERE tbl_subject_doc.subject_id = " . $subject_id;
     // $doc_related = Yii::app()->db->createCommand($sql)->query();
     $criteria = new CDbCriteria();
     $criteria->select = 't.*';
     $criteria->join = 'JOIN tbl_subject_doc ON t.doc_id = tbl_subject_doc.doc_id';
     $criteria->condition = 'tbl_subject_doc.subject_id = :value';
     $criteria->params = array(":value" => $subject_id);
     $doc_related = Doc::model()->findAll($criteria);
     //            $doc_related = SubjectDoc::model()->findAll(array(
     //                'select' => '*',
     //                'condition' => 'subject_id = :subject_id',
     //                'params' => array(':subject_id' => $subject_id)));
     foreach ($subject as $subject_detail) {
         $title = $subject_detail->subject_name . " | Bluebee - UET";
         $des = $subject_detail->subject_target;
     }
     $this->pageTitle = $title;
     Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
     Yii::app()->clientScript->registerMetaTag(Yii::app()->createAbsoluteUrl('listOfSubject/subject?subject_id=') . $subject_id, null, null, array('property' => 'og:url'));
     Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
     $category_father = Faculty::model()->findAll();
     $subject_type = SubjectType::model()->findAll();
     $this->render('subject', array('subject' => $subject, 'category_father' => $category_father, 'subject_type' => $subject_type, 'teacher' => $teachers, 'lesson' => $lesson, 'doc_related' => $doc_related));
 }
Exemplo n.º 27
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     //
     $faker = Faker\Factory::create();
     $minimum = $this->option('minimum');
     for ($is = 1; $is <= $minimum; $is++) {
         $first_name = $faker->firstname;
         $last_name = $faker->lastname;
         $email = $faker->safeEmail;
         $password = "******";
         $usergroup = rand(1, 3);
         $subjects = self::createSubjects();
         $user = Sentry::getUserProvider()->create(array('email' => $email, 'password' => $password, 'activated' => '1', 'first_name' => $first_name, 'last_name' => $last_name, 'created_at' => self::randDate('10th January 2013', date('jS F o'))));
         // Find the group using the group id
         $adminGroup = Sentry::getGroupProvider()->findById($usergroup);
         $user->addGroup($adminGroup);
         if ($usergroup == 1) {
             $teacher = new Teacher();
             $teacher->user_id = $user->id;
             $teacher->email = $email;
             $teacher->extra = $subjects;
             $teacher->dob = self::randDate('10th January 1950', '10th January 1995');
             $teacher->created_at = self::randDate('10th January 2013', date('jS F o'));
             $teacher->save();
         }
         if ($usergroup == 2) {
             $teacher = new Teacher();
             $teacher->user_id = $user->id;
             $teacher->email = $email;
             $teacher->extra = $subjects;
             $teacher->dob = self::randDate('10th January 1950', '10th January 1995');
             $teacher->created_at = self::randDate('10th January 2013', date('jS F o'));
             $teacher->save();
         }
         if ($usergroup == 3) {
             $student = new Student();
             $student->user_id = $user->id;
             $student->email = $email;
             $student->extra = $subjects;
             $student->dob = self::randDate('10th January 1995', '10th January 2005');
             $student->created_at = self::randDate('10th January 2013', date('jS F o'));
             $student->save();
         }
     }
 }
Exemplo n.º 28
0
 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl();
     $model = new Teacher();
     $criteria = new CDbCriteria();
     $criteria->condition = $condition;
     $criteria->order = 't.id ASC';
     //$criteria->with = array ( 'catalog' );
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     //$pageParams = XUtils::buildCondition( $_GET, array ( 'title' , 'catalogId','titleAlias' ) );
     //$pages->params = is_array( $pageParams ) ? $pageParams : array ();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('teacher_index', array('datalist' => $result, 'pagebar' => $pages));
 }
Exemplo n.º 29
0
 public function showTeachers()
 {
     $teachers = Teacher::all();
     if (Auth::Admin()->check()) {
         return Response::json($teachers);
     } else {
         return Redirect::intended('/');
     }
 }
Exemplo n.º 30
0
 public function actionIndex()
 {
     $criteria = new CDbCriteria(array('condition' => 'status=1', 'order' => 'pos ASC', 'limit' => '0,1'));
     $teacher = Teacher::model()->find($criteria);
     $teacher->view += 1;
     $teacher->update(array('view'));
     $this->registerScripts();
     $this->render('view', array('teacher' => $teacher));
 }