<li class="active"><a href="#comment" data-toggle="tab">评论</a></li> <li><a href="#qa" data-toggle="tab">问答</a></li> <li><a href="#attachment" data-toggle="tab">附件</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="comment"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-input"> <textarea class="form-control" placeholder="扯淡、吐槽、表扬、鼓励……想说啥就说啥!" id="comment-input" rows="3"></textarea> <button class="btn btn-info emotion" type="button"><span class="icon-smile icon-large"> 添加表情</span></button> <button class="btn btn-success comment-send" type="button" id="addCommentSubmit"><span class="icon-mail-forward icon-large"> 发表评论</span></button> </div> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-detail"> <?php if (CourseComment::commentList($course->id)): ?> <?php $i = 1; foreach (CourseComment::commentList($course->id) as $comment): ?> <div class="media col-lg-12 evaluation-con"> <div class="media-left media-middle"> <a href="#"> <img class="media-object img-circle" src="<?php echo User::findModel($comment->user_id)->head_picture?>" alt="" width="60px"> </a> </div> <div class="media-body"> <span class="evaluation-name"><?php echo User::findModel($comment->user_id)->username?></span> <h5 class="media-heading evaluation-content" id="comment-content-<?php echo $i?>"><?php echo $comment->content?></h5> <?php if ($comment->course_id == $comment->root_id): ?> <span class="evaluation-time">时间:<?php echo Common::getAwayTime($comment->comment_time)?></span> <?php else: ?> <span class="evaluation-time">时间:<?php echo Common::getAwayTime($comment->comment_time)?> <a href="/resource/play?id=<?php echo Resource::getVideo($comment->course_id)->url?>">源自:<?php Course::findModel($comment->course_id)->name?></a></span> <?php endif ?> <span class="fa fa-thumbs-o-down comment-down" onclick="commentDown(<?php echo $comment->id?>)"><?php echo $comment->down_count?></span>
<h6 class="col-lg-11 col-md-11 col-sm-11"><?php echo $chapter['chapterIntro'];?></h6> <?php endif; ?> </li> <?php endforeach; ?> </ul> </div> <div class="col-lg-12 col-md-12 col-sm-12 course-comment"> <span class="comment-title"><?php echo Yii::t('app', 'Course Judgement')?></span> <?php if (!CourseComment::isCommented(Yii::$app->user->id, $course->id) && !empty(Yii::$app->user->id)): ?> <span class="fa fa-comment addComment" onclick="alertAddCommentMoal();"><?php echo Yii::t('app', 'Add Course Judgement')?></span> <?php endif ?> <div class="evaluation-info col-lg-12 col-md-12 col-sm-12"> <span><?php echo Yii::t('app', 'satisfaction score')?>:<?php $arr = CourseComment::courseAvgScore($course->id);$score = ceil($arr[0]['avgScore']);echo $score;?></span> <?php for ($i = 1; $i <=5; $i++): ?> <?php if ($i <= $score) : ?> <span class="fa fa-star"></span> <?php else : ?> <span class="fa fa-star-o"></span> <?php endif;?> <?php endfor;?> <span class="comment-total"><?php echo $judgmentCount;?><?php echo Yii::t('app', 'students comment')?></span> </div> <?php foreach ($judgments as $judgment): ?> <div class="media col-lg-12 col-md-12 col-sm-12 evaluation-con"> <div class="media-left media-middle"> <a href="#">
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; } }