本文整理汇总了PHP中app\models\Course::fileCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::fileCount方法的具体用法?PHP Course::fileCount怎么用?PHP Course::fileCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::fileCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLearnPercent
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);
}
示例2: actionView
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]);
}
}