本文整理汇总了PHP中app\models\Course::findOneById方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::findOneById方法的具体用法?PHP Course::findOneById怎么用?PHP Course::findOneById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::findOneById方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuestionList
public static function getQuestionList($courseId)
{
$courseModel = Course::findOneById($courseId);
if (Course::isRoot($courseModel)) {
return static::find()->where(['root_id' => $courseId])->orderBy('create_time DESC')->all();
}
if (Course::isFile($courseModel)) {
return static::find()->where(['course_id' => $courseId])->orderBy('create_time DESC')->all();
}
}
示例2: 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);
}
示例3: actionAddPlayTime
public function actionAddPlayTime()
{
$chapterId = Yii::$app->request->post('courseId');
$duration = Yii::$app->request->post('duration');
$userId = Yii::$app->user->id;
$courseId = Course::findOneById(Course::findOneById($chapterId)->root)->id;
//写入play表
$userPlayModel = new UserPlay();
$userPlayModel = $userPlayModel->findOneLearnModel($userId, $chapterId);
$userPlayModel->learn_time_total += ceil($duration);
$userPlayModel->save();
//写入usercourse表
$model = UserCourse::findOneLearnModel($userId, $courseId);
$model->learn_time_total += ceil($duration);
if ($model->save()) {
echo Json::encode('true');
return;
} else {
echo Json::encode('false');
return;
}
}
示例4: function
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
[
'attribute' => 'user_id',
'label' => Yii::t('app', 'Username'),
'value' => function ($model) {
return User::findModel($model->user_id)->username;
}
],
[
'attribute' => 'course_id',
'label' => Yii::t('app', 'Course'),
'value' => function ($model) {
return Course::findOneById($model->course_id)->name;
}
],
'nut_count',
'create_time',
'update_time',
[
'class' => 'yii\grid\ActionColumn',
'template' => "{delete}"
],
],
]); ?>
</div>
示例5:
use app\models\Course;
use app\models\Category;
VideoPlay::register($this);
CommentEmoji::register($this);
/* @var $this yii\web\View */
/* @var $searchModel app\models\VideoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$categoryModel = Category::findOneById($course->category);
$this->title = Yii::t('app', 'Play');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Course'), 'url' => ['/course/list']];
// $this->params['breadcrumbs'][] = ['label' => $categoryModel->name, 'url' => ["/course/list?c=".$categoryModel->alias]];
$this->params['breadcrumbs'][] = ['label' => $course->name, 'url' => ["/course/learn?cid=".Course::findOneById($course->root)->id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="container">
<div class="row col-lg-10">
<video id="video-player" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="1120" height="550" poster="" data-setup="{}" autoplay='true'>
<source src="<?php echo $url?>" type='video/mp4'>
<!-- 如果浏览器不兼容HTML5则使用flash播放 -->
<object id="video-player-flash" class="vjs-flash-fallback" width="1120" height="550" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
<param name="movie"
value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
<param name="allowfullscreen" value="true" />
示例6: actionAddComment
public function actionAddComment()
{
$userId = Yii::$app->user->id;
$courseId = Yii::$app->request->post('courseId');
$content = Yii::$app->request->post('content');
$rootId = Course::findOneById($courseId)->root;
$model = new CourseComment();
if ($model->addData($userId, $courseId, $content, $model::SCORE_DEFAULT, $model::COMMENT_TYPE_COMMENT, $rootId)) {
echo Json::encode('true');
return;
} else {
echo Json::encode('false');
return;
}
}
示例7: actionPlay
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]);
}
}
示例8: actionQadetail
public function actionQadetail()
{
$questionModel = Question::findModel(Yii::$app->request->get('qid'));
$courseModel = Course::findOneById($questionModel->course_id);
$userModel = User::findModel($questionModel->user_id);
$questionModel->views += 1;
$questionModel->save();
return $this->render('qadetail', ['question' => $questionModel, 'course' => $courseModel, 'user' => $userModel]);
}
示例9: foreach
<ul class="cbp_tmtimeline">
<?php foreach (UserCourse::findModelsByUserId($user->id) as $userCourse): ?>
<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>