コード例 #1
0
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $course_id = Yii::$app->request->get('course_id');
     $model = new Task();
     if ($model->load(Yii::$app->request->post())) {
         $model = $model->validateAttr($model);
         if (empty($model->errors)) {
             $resourceModel = new Resource();
             $model = $resourceModel->uploadImg($model, 'image');
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     }
     $model->course_id = $course_id;
     if (!json_decode($model->answer_json)) {
         $model->answer_json = '';
     }
     $chapterName = $courseName = null;
     if (!empty($course_id)) {
         $chapterName = Course::findModel($course_id)->name;
         $courseName = Course::findRoot($course_id)->name;
     }
     return $this->render('create', ['model' => $model, 'courseId' => $course_id, 'chapterName' => $chapterName, 'courseName' => $courseName]);
 }
コード例 #2
0
ファイル: CourseComment.php プロジェクト: songwanfu/SummerNut
 public static function commentList($courseId)
 {
     $courseModel = Course::findModel($courseId);
     if (Course::isFile($courseModel)) {
         return static::find()->where(['course_id' => $courseId, 'comment_type' => self::COMMENT_TYPE_COMMENT])->orderBy('comment_time DESC')->all();
     }
     if (Course::isRoot($courseModel)) {
         return static::find()->where(['root_id' => $courseId, 'comment_type' => self::COMMENT_TYPE_COMMENT])->orderBy('comment_time DESC')->all();
     }
 }
コード例 #3
0
ファイル: view.php プロジェクト: songwanfu/SummerNut
            'extension',
            'url:url',
            'size',
            'duration',
            [
                'attribute' => 'status',
                'value' => $statusList[$model->status],
            ],
            [
                'attribute' => 'resource_type',
                'value' => $typeList[$model->resource_type],
            ],
            [
                'attribute' => 'course_id',
                'label' => Yii::t('app', 'Chapter'),
                'value' => Course::findModel($model->course_id)->name,
            ],
            [
                'attribute' => 'course_id',
                'label' => Yii::t('app', 'Course'),
                'value' => Course::findRoot($model->course_id)->name,
            ],
            'play_count',
            'download_count',
            'create_time',
            'update_time',
        ],
    ]) ?>

    <p>
        <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
コード例 #4
0
ファイル: play.php プロジェクト: songwanfu/SummerNut
        <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)?>&nbsp;<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>
							    <span class="fa fa-thumbs-o-up comment-up" onclick="commentUp(<?php echo $comment->id?>)"><?php echo $comment->up_count?></span>
							  </div>
							</div>
						<?php $i++;endforeach ?>
					<?php else: ?>
					  <div class="alert alert-warning" role="alert" style="margin-top: 15px"><?php echo Yii::t('app', 'No more comments.');?></div>
					<?php endif ?>

				</div>



コード例 #5
0
ファイル: index.php プロジェクト: songwanfu/SummerNut
            'extension',
            [
                'attribute' => 'url',
                'format' => 'raw',
                'value' => function ($model) {
                    return Html::a($model->name . '.' . $model->extension, ["play?id=$model->id"]);
                }
            ],
            'size',
            // 'duration',
            
            
            [
                'label' => Yii::t('app', 'Chapter'),
                'value' => function ($model) {
                    return Course::findModel($model->course_id)->name;
                }   
            ],

            [
                'label' => Yii::t('app', 'Course'),
                'attribute' => 'course_id',
                'value' => function ($model) {
                    return Course::findRoot($model->course_id)->name;
                }   
            ],
            'play_count',
            'download_count',

            ['class' => 'yii\grid\ActionColumn'],
        ],