Commit 95b928f6 authored by 杨培's avatar 杨培

删除讲师功能,课堂锁定提示

parent 0339317e
......@@ -150,8 +150,15 @@ class QiniuTranscode
$fopsMain .= '/r/'.$target['fps'];
}
//print_r($avInfo);
//opcache_invalidate(__FILE__);
//exit;
//视频采样率对比,七牛文档指出如果给出的码率大于原码率,则会使用原码率转换,但某些视频仍然会出现码率变大,所以此处加上判断
$fopsAddon .= '/vb/'.($video['bit_rate'] > $target['vb'] ? $target['vb'] : $video['bit_rate']);
$bitRate = isset($video['bit_rate']) ? $video['bit_rate'] : (isset($avInfo['format']['bit_rate']) ? $avInfo['format']['bit_rate'] : 0);
if ($bitRate) {
$fopsAddon .= '/vb/' . ($bitRate > $target['vb'] ? $target['vb'] : $bitRate);
}
//编码对比
if ($video['codec_name'] != 'h264') {
......
......@@ -85,6 +85,20 @@ class Teacher extends ActiveRecord
];
}
/**
* 删除当前讲师所有数据
*/
public function deleteMe()
{
//删除头像
if ($this->avatar) {
UploadPools::deleteFile('public:'.$this->avatar);
}
CourseTeacher::deleteAll(['teacher_id'=>$this->id]);
self::deleteAll(['id'=>$this->id]);
}
/**
* 获取指定课堂下所有讲师的简单列表
*
......@@ -149,4 +163,18 @@ class Teacher extends ActiveRecord
return $data;
}
/**
* 删除指定讲师所有数据
*
* @param int $teacherId
*/
public static function deleteTeacher($teacherId)
{
$teacher = self::findOne(['id'=>$teacherId]);
if ($teacher) {
$teacher->deleteMe();
}
}
}
......@@ -54,7 +54,7 @@ class ClassesFilter extends ActionFilter
if ($this->_checkStatus && $class['status'] != Classes::STATUS_OK) {
switch ($class['status']) {
case Classes::STATUS_LOCKED:
Utils::showWarn('您的课堂已被锁定,暂无法访问!');
Utils::showWarn('课堂被锁定无法访问!');
break;
default:
Utils::showWarn('您提交的课堂资料尚未通过审核,无法访问此页面!');
......
......@@ -39,12 +39,10 @@ class MyCourseController extends \yii\web\Controller
'roles' => ['@']
]
]
],
'classes' => [
], [
'class' => ClassesFilter::className(),
'checkStatus' => true
],
'mobile' => [
], [
'class' => MobileFilter::className(),
'only' => ['publish', 'edit'],
'message' => '移动端暂不支持发布课程'
......
......@@ -4,6 +4,7 @@ namespace frontend\controllers;
use common\components\Qiniu;
use common\libs\Utils;
use common\models\CourseTeacher;
use common\models\Teacher;
use common\models\UploadPools;
use common\models\User;
......@@ -145,6 +146,30 @@ class TeacherManagerController extends \yii\web\Controller
return Teacher::fetchTeacherNames($classId);
}
/**
* 讲师管理
*
* @throws \yii\base\ExitException
*/
public function actionDelete()
{
$teacherId = Yii::$app->request->post('id', 0);
if (!$teacherId) {
Utils::ajaxResponse(false, '参数错误');
}
$teacher = Teacher::findOne(['id'=>$teacherId, 'class_id'=>$this->classStatus['id']]);
if (!$teacher) {
Utils::ajaxResponse(false, '该讲师不存在或无权操作!');
}
//删除讲师与课程的关系
$teacher->deleteMe();
Utils::ajaxResponse(true);
}
}
<?php
/* @var $this yii\web\View */
use frontend\assets\AppAsset;
$this->title = '讲师管理';
AppAsset::addScript($this, '@web/assets/teacher_manager.js');
?>
<div class="teacher-list">
<?php foreach($data as $row) { ?>
<div class="col-md-3">
<div class="col-md-3 TEACHER_ROW" data-teacher-id="<?=$row['id']?>">
<div class="teacher-box">
<img src="<?=\common\models\User::getAvatarUrl($row['avatar'])?>">
<h3><?=$row['name']?></h3>
<p><?=$row['intro']?></p>
<a class="edit" href="<?=\yii\helpers\Url::to(['teacher-manager/edit', 'id'=>$row['id']])?>"><i class="icon-mode_edit"></i></a>
<a href="#" class="delete"><i class="icon-trash"></i></a>
<a href="javascript:;" class="delete"><i class="icon-trash"></i></a>
</div>
</div>
<?php } ?>
......
/**
* Created by pader on 2016/10/27.
*/
var layer = require("layer-js");
$(".TEACHER_ROW a.delete").click(function() {
var teacherId = $(this).closest(".TEACHER_ROW").data("teacherId");
layer.confirm("确定删除该讲师吗?", {
title: "删除讲师",
btn: ['确定','取消']
}, function() {
var idx = layer.msg("正在提交..", {icon:16, shade: [0.2,'#000'], time:0});
$.post("/teacher-manager/delete", {id:teacherId}, function(t) {
layer.close(idx);
if (t.status) {
layer.msg("已删除指定讲师!", {
time: 1500,
icon: 1,
end: function() {
location.reload();
},
shade: [0.2,'#000']
});
} else {
layer.alert(t.message, {icon:5, title:"提示"});
}
}, "json");
});
});
\ No newline at end of file
......@@ -25,6 +25,7 @@ var entry = {
home_video: [js_dir + '/home/video.js'],
course_publish: [js_dir + '/my-course/publish.js'],
course_edit: [js_dir + '/my-course/edit.js'],
teacher_manager: [js_dir + '/teacher-manager/index.js'],
teacher_form: [js_dir + '/teacher-manager/form.js'],
my_income: [js_dir + '/my-income/index.js']
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment