예제 #1
0
 /**
  * Finds the UserPlay model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UserPlay the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserPlay::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
0
 public function actionQa()
 {
     $courseId = Yii::$app->request->get('cid');
     $model = $this->findModelByCoursId($courseId);
     // var_dump($model);die;
     $categoryModel = Category::findOneById($model->category);
     $isLearn = false;
     if (UserCourse::isLearn(Yii::$app->user->id, $courseId)) {
         $isLearn = true;
     }
     $learnPersent = UserPlay::getLearnPercent(Yii::$app->user->id, $courseId) * 100;
     $learnTimeToal = Common::transTime(UserCourse::findOneLearnModel(Yii::$app->user->id, $courseId)->learn_time_total);
     return $this->render('qa', ['course' => $model, 'categoryModel' => $categoryModel, 'isLearn' => $isLearn, 'learnPersent' => $learnPersent, 'learnTimeToal' => $learnTimeToal]);
 }
예제 #3
0
 public function actionPlay($id)
 {
     $model = $this->findModel($id);
     $course = Course::findOneById($model->course_id);
     $root = Course::findOneById($course->root);
     $userPlayModel = new UserPlay();
     if (!$userPlayModel->isLearn(Yii::$app->user->id, $model->course_id)) {
         $userPlayModel->addData(Yii::$app->user->id, $model->course_id);
     }
     $learnPoint = $userPlayModel->findOneLearnModel(Yii::$app->user->id, $model->course_id)->learn_point;
     $model->play_count += 1;
     if ($model->save()) {
         //获取附件
         $resourceModel = new Resource();
         $attachments = $resourceModel->getAttachments($model->course_id);
         return $this->render('play', ['url' => $model->url, 'course' => $course, 'root' => $root, 'learnPoint' => $learnPoint, 'id' => $model->id, 'attachments' => $attachments]);
     }
 }
예제 #4
0
            <li>
              <time class="cbp_tmtime" datetime="">
                <span><?php echo date('Y-m-d', strtotime($userCourse->create_time))?></span> <span><?php echo date('H:i', strtotime($userCourse->create_time))?></span></time>
              <div class="cbp_tmicon cbp_tmicon-learn">
                <?php if ($userCourse->type == UserCourse::TYPE_FOCUS): ?>
                  <abbr title="focus" class="initialism"><span class="fa fa-heart"></span></abbr>
                <?php else :?>
                  <abbr title="learn" class="initialism"><span class="fa fa-tasks"></span></abbr>
                <?php endif ?>
              	
              </div>
              <div class="cbp_tmlabel">
                <h2><?php echo Course::findOneById($userCourse->course_id)->name?></h2>
                <a href="/course/view?cid=<?php echo Course::findOneById($userCourse->course_id)->id?>"><img src="<?php echo Course::findOneById($userCourse->course_id)->icon?>" alt="" class="img-rounded"></a>
                <?php if ($userCourse->type == UserCourse::TYPE_LEARN): ?>
                  <span >已学<?php echo UserPlay::getLearnPercent(Yii::$app->user->id, $userCourse->course_id) * 100 . '%'?> 用时 <?php echo Common::transTime(UserCourse::findOneLearnModel(Yii::$app->user->id, $userCourse->course_id)->learn_time_total)?></span>
                <?php endif ?>

              </div>
            </li>
          <?php endforeach ?>
        </ul>
      <?php else: ?>
       <div class="alert alert-warning" role="alert" style="margin-top: 15px"><?php echo Yii::t('app', 'No more focus or learn courses.');?></div>
      <?php endif ?>
    </div>




<script type="text/javascript" src="/js/jquery.min.js"></script>