Example #1
0
 public function actionExchange()
 {
     //$model = new StudentTeacher;
     $student_id = $this->_user['studentId'];
     $teacher_id = StudentTeacher::model()->findAllByAttributes(array('student_id' => $student_id));
     $this->render('exchange', array('teacher_id' => $teacher_id));
 }
Example #2
0
 public function actionDelete($id)
 {
     $student_id = $this->_user['studentId'];
     $model = StudentTeacher::model()->findByAttributes(array('student_id' => $student_id, 'teacher_id' => $id));
     $model->delete();
     $this->redirect($this->createUrl('/student/teacher/'));
 }
Example #3
0
 public function actionReview()
 {
     $message = false;
     $lesson = Lesson::model()->findByPk($_GET['id']);
     $model = StudentTeacher::model()->findByAttributes(array('student_id' => $this->_user['studentId'], 'teacher_id' => $lesson['teacher_id']));
     if (!count($model)) {
         $model = new StudentTeacher();
     }
     if (isset($_POST['StudentTeacher'])) {
         $model->attributes = $_POST['StudentTeacher'];
         $model->student_id = $this->_user['studentId'];
         $model->teacher_id = $lesson['teacher_id'];
         if ($model->save()) {
             $message = true;
         }
     }
     $this->render('review', array('lesson' => $lesson, 'message' => $message, 'model' => $model));
 }
Example #4
0
 public function actionView($id)
 {
     $teacher = $this->loadModel($id);
     $this->_seoTitle = '名师 - ' . $teacher->name;
     $userId = $this->_cookiesGet('userId');
     $userType = $this->_cookiesGet('userType');
     $reviewModel = new Review();
     if ($userType === 'student' and isset($_POST['Review'])) {
         $reviewModel->attributes = $_POST['Review'];
         $reviewModel->teacher_id = $id;
         $reviewModel->student_id = $userId;
         $reviewModel->ctime = time();
         if ($reviewModel->validate() and $reviewModel->save()) {
             Yii::app()->user->setFlash('success', '保存成功');
         }
     }
     $criteria = new CDbCriteria();
     $books = Book::model()->findAllByAttributes(array('teacher_id' => $id));
     $lessons = array();
     $reviews = array();
     $list = yii::app()->request->getParam('list');
     if ($list === null or $list === 'lesson') {
         $model = Lesson::model();
         $count = $model->count($criteria->addCondition("teacher_id = {$id}"));
         $pager = new CPagination($count);
         $pager->pageSize = 4;
         $pager->applyLimit($criteria);
         $lessons = $model->findAll($criteria);
     } else {
         $model = Review::model();
         $count = $model->count($criteria->addCondition("teacher_id = {$id}"));
         $pager = new CPagination($count);
         $pager->pageSize = 4;
         $pager->applyLimit($criteria);
         $reviews = Yii::app()->db->createCommand()->select('s.*, r.contents, r.ctime')->from('seed_review r')->leftjoin('seed_student s', 's.id=r.student_id')->where('r.teacher_id=:teacher_id', array(':teacher_id' => $id))->order('ctime desc')->limit(4, $pager->currentPage * $pager->pageSize)->queryAll();
     }
     //判断学员已关注老师
     if ($userType === 'student') {
         $is_focus = StudentTeacher::model()->findByAttributes(array('student_id' => $userId, 'teacher_id' => $id));
     }
     $this->render('view', array('is_focus' => $is_focus, 'teacher' => $teacher, 'lessons' => $lessons, 'reviews' => $reviews, 'books' => $books, 'userType' => $userType, 'reviewModel' => $reviewModel, 'count' => $count, 'pager' => $pager, 'list' => $_GET['list']));
 }