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; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $delete = UserCourse::where('id', $id)->delete(); if ($delete) { $data = Auth::User()->toArray(); $data['msg'] = 'User ' . $data['name'] . ' with email id ' . $data['email'] . ' has remove course from his/her to profile.'; if (Auth::User()->user_type == USER_TYPE_MEMBER) { Mail::send('emails.notification', $data, function ($message) use($data) { $message->to(ADMIN_EMAIL)->subject('Course remove by user'); }); } $message = 'Detele successfully'; return Response()->json(ResponseManager::getResult($delete, 10, $message)); } else { $message = 'Error while deleting'; return Response()->json(ResponseManager::getError('', 10, $message)); } }
<div class="col-lg-2 col-md-2 col-sm-2 user-head-pic"> <img src="<?php echo $model->head_picture?>" class="img-circle" id="user-head-pic" width="140px"> </div> <div class="col-lg-3 col-md-3 col-sm-3 zone-username"> <h2><?php echo $model->username;?></h2> <h4 class="signature"><?php echo $model->signature;?></h4> </div> <div class="col-lg-3 col-lg-offset-4 col-md-3 col-md-offset-4 col-sm-3 col-sm-offset-4 zone-nut"> <ul class="list-inline"> <li class="col-lg-6 col-md-6 col-sm-6 "> <?php if (Common::transTime(UserCourse::userTotalTime($model->id)) == 0): ?> <h4>0</h4> <?php else: ?> <h4><?php echo Common::transTime(UserCourse::userTotalTime($model->id))?></h4> <?php endif ?> <h5>学习时长</h5> </li> <li class="col-lg-6 col-md-6 col-sm-6 "> <h4><?php echo Nut::nutCount($model->id)?></h4> <h5>果果</h5> </li> </ul> </div> </div> <div class="col-lg-2 col-md-2 col-sm-2 zone-user-sex"> <?php if ($model->sex == $model::SEX_FEMALE) : ?> <span class="fa fa-venus"></span> <?php endif; ?>
<h4><dt><?php echo $levelList[$course->difficulty_level]?></dt></h4> <dd><?php echo Yii::t('app', 'Level');?></dd> </dl> <dl> </div> <div class="col-lg-3 col-md-3 col-xs-3 course-view-class"> <dl> <h4><dt><?php echo $course->learner_count?></dt></h4> <dd><?php echo Yii::t('app', 'Learner Count')?></dd> </dl> <dl> </div> <div class="col-lg-2 col-lg-offset-4 col-md-2 col-md-offset-4 course-view-share"> <?php if (UserCourse::isFocus(Yii::$app->user->id, $course->id)) : ?> <span class="fa fa-heart fa-large" onclick="dropFocus(<?php echo $course->id;?>)"><?php echo Yii::t('app', 'Focused');?></span> <?php else : ?> <span class="fa fa-heart-o fa-large" onclick="addFocus(<?php echo $course->id;?>)"><?php echo Yii::t('app', 'Focus');?></span> <?php endif;?> <span class="fa fa-share-alt fa-large" style="margin-left: 10px"><?php echo Yii::t('app', 'Share');?></span> <wb:share-button appkey="4209546553" addition="simple" type="icon" picture_search="false" ralateUid="2919453367" default_text="分享夏果的精彩课程----<?php echo $course->name?>。夏果,满满的都是干货!"></wb:share-button> </div> <!-- 弹出提示框--> <div class="modal fade" id="modal" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
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]); }
<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>
/** * @return \yii\db\ActiveQuery */ public function getUserMobiles() { return $this->hasMany(UserCourse::className(), ['mobile_id' => 'user_mobile_id'])->viaTable('course_has_user', ['course_id' => 'id']); }