Ejemplo n.º 1
0
 public static function getLearnPercent($userId, $courseId)
 {
     $fileCount = Course::fileCount($courseId);
     $userPlayModels = static::findAll(['user_id' => $userId, 'learn_status' => self::LEARN_STATUS_FINISH]);
     $count = 0;
     foreach ($userPlayModels as $userPlayModel) {
         if (Course::findOneById($userPlayModel->chapter_id)->root == $courseId) {
             $count++;
         }
     }
     return round($count / $fileCount, 2);
 }
Ejemplo n.º 2
0
 public function actionView()
 {
     $courseId = Yii::$app->request->get('cid');
     $isLearn = false;
     $model = $this->findModelByCoursId($courseId);
     $categoryModel = Category::findOneById($model->category);
     if (empty($model)) {
         $this->goBack(Yii::$app->request->headers['Referer']);
         return;
     } else {
         $videoCount = Course::fileCount($model->id);
         if (UserCourse::isLearn(Yii::$app->user->id, $courseId)) {
             $isLearn = true;
         }
         return $this->render('view', ['course' => $model, 'isLearn' => $isLearn, 'categoryModel' => $categoryModel, 'videoCount' => $videoCount]);
     }
 }