diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 03cb07833..18255fb2b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -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") diff --git a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js index 8834df1af..454b11c6f 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js @@ -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 {
总体评价
{ - 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( 查看学员实训 diff --git a/public/react/src/modules/courses/signin/component/Teacherentry.js b/public/react/src/modules/courses/signin/component/Teacherentry.js index ff08fe126..070fa6bb7 100644 --- a/public/react/src/modules/courses/signin/component/Teacherentry.js +++ b/public/react/src/modules/courses/signin/component/Teacherentry.js @@ -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 (
+ {/*修改实训*/} + {this.state.editvisible===true?this.hideCreatesign()} + settabsdata={()=>this.props.getsetdatas()} + type={"edit"} + />:""}
{e.stopPropagation();this.props.qiandaoxiangq(true,item.id)}:""}>

{ @@ -97,17 +132,21 @@ class Teacherentry extends Component {

{e.stopPropagation();this.props.thisEnd(item.id)}}>截止
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
+
{e.stopPropagation();this.getdatalist(item.id)}}>编辑
: - item.edit_auth === true ? -
-
{e.stopPropagation();this.props.Signinnamestypes(item.id,true,item.name)}}>编辑
-
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
-
- : -
-
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
-
+ ( + //是否有编辑权限 + item.edit_auth === true ? +
+
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
+
{e.stopPropagation();this.getdatalist(item.id,true,item.name)}}>编辑
+
+ : +
+
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
+
+ ) : ( this.props.defaultActiveKey === "1" ? diff --git a/public/react/src/modules/courses/signin/model/Createsignmodel.js b/public/react/src/modules/courses/signin/model/Createsignmodel.js index 117531750..99f616204 100644 --- a/public/react/src/modules/courses/signin/model/Createsignmodel.js +++ b/public/react/src/modules/courses/signin/model/Createsignmodel.js @@ -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') { + + 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 ( {getFieldDecorator('group_ids')( - 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' })( 二维码签到 , )} - {Radiolist==="QUICK"?
学生点击签到按钮即可完成签到
:""} - {Radiolist==="NUMBER"?
学生需要输入签到码才能完成签到
:""} - {Radiolist==="QRCODE"?
{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: '请选择签到日期',}], })( trigger.parentNode} disabledTime={disabledDateTime} disabledDate={disabledDate} onChange={this.onChange} + // value={moment('2015-01-01', 'YYYY-MM-DD')} />)}