Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

courseware
cxt 5 years ago
commit a03f9ae79b

@ -1503,11 +1503,10 @@ class CoursesController < ApplicationController
@videos = CourseVideo.joins("
JOIN videos ON course_videos.course_id = #{@course.id} AND videos.id = course_videos.video_id
LEFT JOIN (
SELECT watch_course_videos.course_video_id, SUM(watch_course_videos.total_duration) AS time, COUNT(watch_video_histories.watch_course_video_id) AS num
SELECT watch_course_videos.course_video_id, SUM(watch_course_videos.total_duration) AS time, COUNT(watch_course_videos.course_video_id) AS num
FROM watch_course_videos
JOIN course_videos ON course_videos.id = watch_course_videos.course_video_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
JOIN watch_video_histories ON watch_course_videos.id = watch_video_histories.watch_course_video_id AND watch_video_histories.end_at IS NOT NULL
WHERE course_videos.course_id = #{@course.id}
GROUP BY watch_course_videos.course_video_id
) AS hisotries ON hisotries.course_video_id = course_videos.id").select("course_videos.id")

@ -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>
:
<div className="ws100s xaxisreverseorder">
<div className="jiezhis h40s color-reds xiaoshou" onClick={(e)=>{e.stopPropagation();this.props.thisdelete(item.id)}}>删除</div>
</div>
(
//是否有编辑权限
item.edit_auth === true ?
<div className="ws100s xaxisreverseorder">
<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" ?

@ -33,8 +33,10 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
course_groups:[],
type:false,
dateString:null,
start_time: "",
end_time:""
start_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,17 +128,21 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
})
return
}
let url=`/weapps/courses/${coursesId}/attendances.json`;
axios.post(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(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({
@ -107,10 +151,38 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
hideCreatesign()
settabsdata()
}
}).catch((error) => {
console.log(error)
})
}else{
let url=`/weapps/courses/${coursesId}/attendances.json`;
axios.post(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'),
})
.catch(function (error) {
console.log(error);
});
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification(`创建签到成功`);
this.setState({
type:false
})
hideCreatesign()
settabsdata()
}
})
.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