Merge branches 'courseware' and 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into courseware

courseware
杨树明 5 years ago
commit 1635b7aba5

@ -103,25 +103,37 @@ class CoursesController < ApplicationController
end
def course_videos
videos = @course.course_videos
course_videos = @course.course_videos
course_videos = course_videos.joins("
JOIN videos ON course_videos.video_id = videos.id
LEFT JOIN (
SELECT watch_course_videos.course_video_id,
SUM(watch_course_videos.total_duration) AS total_duration,
count(watch_course_videos.course_video_id) AS count
FROM watch_course_videos
JOIN course_videos ON watch_course_videos.course_video_id = course_videos.id AND watch_course_videos.end_at IS NOT NULL
JOIN course_members ON course_members.user_id = watch_course_videos.user_id AND course_members.course_id = #{@course.id} AND role = 4
WHERE course_videos.course_id = #{@course.id}
GROUP BY watch_course_videos.course_video_id
) AS watch_courses ON watch_courses.course_video_id = course_videos.id
").where("((videos.transcoded = TRUE OR videos.user_id = #{current_user.id}) OR course_videos.is_link = TRUE)")
@video_module = @course.course_modules.find_by(module_type: "video")
if params[:category_id].present? && params[:category_id].to_i != 0
@category = @video_module&.course_second_categories.find_by(id: params[:category_id])
tip_exception("子目录id有误") if !@category.present?
videos = videos.where(course_second_category_id: params[:category_id].to_i)
course_videos = course_videos.where(course_second_category_id: params[:category_id].to_i)
end
videos = custom_sort(videos, params[:sort_by], params[:sort_direction])
course_videos = custom_sort(course_videos, params[:sort_by], params[:sort_direction])
course_videos = course_videos.includes(video: [user: :user_extension], user: :user_extension)
#sql = "left join videos on videos.id=course_videos.video_id AND (videos.transcoded=1 OR videos.user_id = #{current_user.id})"
#@videos = paginate videos.joins(sql).includes(video: [user: :user_extension], user: :user_extension)
videos = videos.includes(video: [user: :user_extension],user: :user_extension).select("course_videos.id, course_videos.title, course_videos.link, course_videos.user_id")
videos = videos.where(videos: {transcoded: true})
.or(videos.where(videos: {user_id: current_user.id}))
.or(videos.where(course_videos: {is_link: true}))
@count = videos.count("course_videos.id")
@count = course_videos.count("course_videos.id")
logger.info("#######count:#{@count}")
@videos = paginate videos
course_videos = course_videos.select("IFNULL(watch_courses.total_duration, 0) AS total_duration, IFNULL(watch_courses.count,0) AS count, course_videos.video_id, course_videos.title, course_videos.is_link, course_videos.user_id")
@videos = paginate course_videos
end
def delete_course_video

@ -10,8 +10,8 @@ json.videos @videos do |video|
json.user_login user&.login
else
json.partial! 'users/videos/video', locals: { video: video.video }
json.total_time video.watch_course_videos.sum(:total_duration).round(0)
json.people_num video.watch_course_videos.count(:user_id)
json.total_time video['total_duration'].round(0)
json.people_num video['count']
end
end

@ -17,7 +17,7 @@ json.data do
end
# json.partial! "files/course_groups", attachment_group_settings: attachment.attachment_group_settings
json.category_id attachment.course_second_category_id
if (@parent_category_id.blank? || @parent_category_id != 0) && attachment.course_second_category&.parent_id.to_i != 0
if (@course_second_category_id.to_i == 0 && attachment.course_second_category.present?) || (@parent_category_id == 0 && attachment.course_second_category&.parent_id.to_i != 0)
json.category_name attachment.course_second_category&.name
end
end

@ -38,7 +38,8 @@ class ShixunWorkReport extends Component {
work_comment_hidden:undefined,
work_comment:undefined,
has_commit: false,
shixun_detail:[]
shixun_detail:[],
view_tpi:false
}
}
@ -115,7 +116,8 @@ class ShixunWorkReport extends Component {
work_comment:result.data.work_comment,
spinning: false,
has_commit: result.data.has_commit,
shixun_detail:result.data.shixun_detail
shixun_detail:result.data.shixun_detail,
view_tpi:result.data.view_tpi
})
}
@ -307,7 +309,7 @@ class ShixunWorkReport extends Component {
}
render() {
let {data, showAppraiseModaltype, work_comment_hidden, work_comment, has_commit,shixun_detail} = this.state;
let {data, showAppraiseModaltype, work_comment_hidden, work_comment, has_commit,shixun_detail,view_tpi} = this.state;
let category_id=data===undefined?"":data.category===null?"":data.category.category_id;
let homework_common_id=data===undefined?"":data.homework_common_id;
@ -461,7 +463,7 @@ class ShixunWorkReport extends Component {
<div className={"fl"}>总体评价</div>
<div className={"fr"}>
{
this.props&&this.props.isAdmin()===true?shixun_detail&&shixun_detail.map((item,key)=>{
view_tpi&&view_tpi===true?shixun_detail&&shixun_detail.map((item,key)=>{
if(key===0){
return(
<a className={"color-blue font-16"} href={/tasks/+item.game_identifier} target="_blank" >查看学员实训</a>

@ -2,14 +2,17 @@ import React, {Component} from "react";
import '../css/signincdi.css';
import {Progress} from 'antd';
import axios from 'axios';
import Createsignmodel from '../model/Createsignmodel';
//条目
class Teacherentry extends Component {
//条目组件
constructor(props) {
super(props);
this.state = {}
this.state = {
editvisible:false,
attendancesid:null
}
}
componentDidMount() {
@ -21,7 +24,30 @@ class Teacherentry extends Component {
}
getdatalist=(id)=>{
let urls = `/attendances/${id}/edit.json`;
axios.get(urls).then((response) => {
//console.log(response);
if(response){
if(response.data){
this.setState({
editvisible:true,
attendancesdata:response.data,
attendancesid:id
})
}
}
}).catch((error) => {
console.log(error);
})
}
hideCreatesign=()=>{
this.setState({
editvisible:false
})
}
render() {
let isAdmin = this.props.isAdmin();
let item = this.props.item;
@ -32,9 +58,18 @@ class Teacherentry extends Component {
} catch (e) {
jdt = 100;
}
return (
<React.Fragment>
<div className={index===0?"ws100s edu-back-white xiaoshou": "ws100s edu-back-white mt20 xiaoshou"}>
{/*修改实训*/}
{this.state.editvisible===true?<Createsignmodel
{...this.state}
{...this.props}
hideCreatesign={()=>this.hideCreatesign()}
settabsdata={()=>this.props.getsetdatas()}
type={"edit"}
/>:""}
<div className="ws100s teacherentrydiv" onClick={isAdmin?(e)=>{e.stopPropagation();this.props.qiandaoxiangq(true,item.id)}:""}>
<p className={isAdmin?"ws100s teachedivp ymaxnamewidthdivp xiaoshou color-blue":"ws100s teachedivp ymaxnamewidthdivp"} >
{
@ -97,17 +132,21 @@ class Teacherentry extends Component {
<div className="ws100s xaxisreverseorder">
<div className="jiezhis h40s xiaoshou" onClick={(e)=>{e.stopPropagation();this.props.thisEnd(item.id)}}>截止</div>
<div className="shanchu h40s xiaoshou" onClick={(e)=>{e.stopPropagation();this.props.thisdelete(item.id)}}>删除</div>
<div className="shanchu h40s color-blue" onClick={(e)=>{e.stopPropagation();this.getdatalist(item.id)}}>编辑</div>
</div>
:
(
//是否有编辑权限
item.edit_auth === true ?
<div className="ws100s xaxisreverseorder">
<div className="jiezhis h40s xiaoshou" onClick={(e)=>{e.stopPropagation();this.props.Signinnamestypes(item.id,true,item.name)}}>编辑</div>
<div className="shanchu h40s xiaoshou" onClick={(e)=>{e.stopPropagation();this.props.thisdelete(item.id)}}>删除</div>
<div className="shanchu h40s color-blue" onClick={(e)=>{e.stopPropagation();this.getdatalist(item.id,true,item.name)}}>编辑</div>
</div>
:
<div className="ws100s xaxisreverseorder">
<div className="jiezhis h40s color-reds xiaoshou" onClick={(e)=>{e.stopPropagation();this.props.thisdelete(item.id)}}>删除</div>
</div>
)
:
(
this.props.defaultActiveKey === "1" ?

@ -34,7 +34,9 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
type:false,
dateString:null,
start_time:"",
end_time:""
end_time:"",
attendance_date:"",
newmode:null
}
}
@ -53,6 +55,43 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
});
}
componentDidMount() {
if(this.props.type==="edit"){
let newlist=[]
if(this.props.attendancesdata.groups.length>0){
this.props.attendancesdata.groups.map((item,key)=>{
newlist.push(item.id)
})
}
console.log(this.props.attendancesdata.start_time)
// console.log()
this.setState({
attendance_date: this.props.attendancesdata.attendance_date,
start_time:new Date(this.props.attendancesdata.start_time),
end_time:new Date(this.props.attendancesdata.end_time),
newmode:this.props.attendancesdata.mode,
})
this.props.form.setFieldsValue({
name: this.props.attendancesdata.name,
group_ids:newlist,
mode:this.props.attendancesdata.mode,
start_time:new Date(this.props.attendancesdata.start_time),
end_time:new Date(this.props.attendancesdata.end_time),
});
}else{
this.setState({
start_time: new Date("2000-01-01T09:00:00.000+08:00"),
})
this.props.form.setFieldsValue({
start_time:new Date("2000-01-01T09:00:00.000+08:00"),
});
}
const coursesId=this.props.match.params.coursesId;
let newurl=`/courses/${coursesId}/all_course_groups.json`;
axios.get(newurl).then((response) => {
@ -73,6 +112,7 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
type:true
})
this.props.form.validateFields((err, values) => {
if (!err) {
if(moment(values.end_time).format('HH:mm')<moment(values.start_time).format('HH:mm')){
this.props.showNotification(`结束时间不能小于起始时间`);
@ -88,6 +128,34 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
})
return
}
if(this.props.type==="edit"){
const attendancesid=this.props.attendancesid;
let url=`/attendances/${attendancesid}.json`
axios.put(url,{
attendance_date:moment(values.attendance_date).format('YYYY-MM-DD'),
end_time: moment(values.end_time).format('HH:mm'),
group_ids:values.group_ids,
mode: values.mode,
name: values.name,
start_time:moment(values.start_time).format('HH:mm'),
}
).then((response) => {
if (response.data.status == 0) {
this.props.showNotification(`创建签到成功`);
this.setState({
type:false
})
hideCreatesign()
settabsdata()
}
}).catch((error) => {
console.log(error)
})
}else{
let url=`/weapps/courses/${coursesId}/attendances.json`;
axios.post(url, {
@ -111,6 +179,10 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
.catch(function (error) {
console.log(error);
});
}
}else{
this.setState({
type:false
@ -153,8 +225,8 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
})
}
render() {
const { visible, form ,setRadio,Radiolist,hideCreatesign} = this.props;
let {course_groups}=this.state;
const { visible,form ,setRadio,Radiolist,hideCreatesign,editvisible} = this.props;
let {course_groups,newmode}=this.state;
const { getFieldDecorator } = form;
const { Option } = Select;
const formItemLayout = {
@ -175,12 +247,12 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
"background":"#4CACFF",
"borderRadius":"4px",
}
const format = 'HH:mm';
return (
<Modal
visible={visible}
title="创建签到"
visible={editvisible?editvisible:visible}
title={this.props&&this.props.type==="edit"?"编辑签到":"创建签到"}
closable={false}
footer={null}
width={600}
@ -196,7 +268,9 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
<Form.Item label="签到班级:">
{getFieldDecorator('group_ids')(
<Select mode="multiple" placeholder={course_groups.length>0?"不选择分班时默认选择全部学生":'暂无分班,将默认选择课堂全部学生'} getPopupContainer={trigger => trigger.parentNode}>
<Select mode="multiple" placeholder={course_groups.length>0?"不选择分班时默认选择全部学生":'暂无分班,将默认选择课堂全部学生'} getPopupContainer={trigger => trigger.parentNode}
disabled={this.props&&this.props.type==="edit"?true:false}
>
{course_groups.map((item,key)=>{
return(
@ -218,18 +292,18 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
<Radio value="QRCODE">二维码签到</Radio>
</Radio.Group>,
)}
{Radiolist==="QUICK"?<div
{Radiolist==="QUICK"||!Radiolist&&newmode==="QUICK"?<div
style={{color:"#E6A23C",
height:"15px",
lineHeight: "15px"}}>学生点击签到按钮即可完成签到</div>:""}
{Radiolist==="NUMBER"?<div
{Radiolist==="NUMBER"||!Radiolist&&newmode==="NUMBER"?<div
style={{color:"#E6A23C",
height:"15px",
lineHeight: "15px"}}
>学生需要输入签到码才能完成签到</div>:""}
{Radiolist==="QRCODE"?<div
{Radiolist==="QRCODE"||!Radiolist&&newmode==="QRCODE"?<div
style={{color:"#E6A23C",
height:"15px",
lineHeight: "15px"}}
@ -238,11 +312,13 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
<Form.Item label="签到日期:">
{getFieldDecorator('attendance_date', {
rules: [{ type: 'object', required: true, message: '请选择签到日期',}],
initialValue:this.props.type==="edit"?moment(this.state.attendance_date,'YYYY-MM-DD'):"",
rules: [{required: true, message: '请选择签到日期',}],
})(<DatePicker style={{width:"413px"}} getPopupContainer={trigger => trigger.parentNode}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
onChange={this.onChange}
// value={moment('2015-01-01', 'YYYY-MM-DD')}
/>)}
</Form.Item>
<style>
@ -332,7 +408,7 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
class Createsignmodel extends React.Component {
state = {
Radiolist: "",
Radiolist: null,
};
setRadio=(e)=>{
@ -341,6 +417,7 @@ class Createsignmodel extends React.Component {
})
}
render() {
return (
<React.Fragment>
<CollectionCreateForm

Loading…
Cancel
Save