/**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     //		$lesson = $this->loadModel($id);
     $lesson = Lesson::model()->with('course', 'comments.user')->findByPk($id);
     if (!Yii::app()->user->isGuest && !CourseLearn::model()->hasLearn(Yii::app()->user->id, $lesson->courseId)) {
         $lesson->course->addLearn(array('userId' => Yii::app()->user->id, 'status' => 'learning'));
     }
     $privateNote = PrivateLessonNote::model()->findByAttributes(array('lessonid' => $id, 'userId' => Yii::app()->user->id));
     $commentDataProvider = new CArrayDataProvider($lesson->comments, array('keyField' => 'commentId', 'pagination' => array('pageSize' => 20)));
     $this->render('view', array('lesson' => $lesson, 'commentDataProvider' => $commentDataProvider, 'privateNote' => $privateNote));
 }
Example #2
0
 public function addLearn($params)
 {
     $courseLearn = new CourseLearn();
     $courseLearn->courseId = $this->id;
     $courseLearn->userId = $params['userId'];
     $courseLearn->addTime = time();
     $courseLearn->status = $params['status'];
     if ($courseLearn->save()) {
         $this->memberNum = $this->studentCount;
         $this->save();
         return $courseLearn;
     }
 }
Example #3
0
 /**
  * 设为中止
  * Enter description here ...
  * @param unknown_type $courseId
  */
 public function actionSetStoped($courseId)
 {
     //$user = UserInfo::model()->findByPk($userId);
     $learn = CourseLearn::model()->findByAttributes(array('courseId' => $courseId, 'userId' => Yii::app()->user->id));
     $learn->status = "stoped";
     if ($learn->save()) {
         echo true;
         Yii::app()->end();
     }
 }