import React,{Component} from "React"; import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal, Table, Divider, Tag,DatePicker,Radio,Tooltip} from "antd"; import {Link} from 'react-router-dom'; import locale from 'antd/lib/date-picker/locale/zh_CN'; import { WordsBtn,getUrl ,handleDateString} from 'educoder'; import axios from 'axios'; import Modals from '../../../modals/Modals'; import DownloadMessageysl from "../../../modals/DownloadMessageysl"; import CoursesListType from '../../coursesPublic/CoursesListType'; import HomeworkModal from "../../coursesPublic/HomeworkModal"; import moment from 'moment'; const { Option} = Select; const RadioGroup = Radio.Group; function range(start, end) { const result = []; for (let i = start; i < end; i++) { result.push(i); } return result; } function disabledDateTime() { return { disabledMinutes: () => range(1, 30).concat(range(31, 60)), }; } function disabledDate(current) { return current && current < moment().endOf('day').subtract(1, 'days'); } class GraduationTaskssettingapp extends Component{ constructor(props){ super(props) this.state={ coursename:"", coursesearch:"", title_num:20, title_value:"", fileList: [], contents: [{val:"",id:1}], type:true, taskname:"", taskid:"", settingdata:undefined, baseonproject:false, minnum:2, maxnum:5, firstTimes:true, publish_time:null, end_time:null, allowlate:1, latepenalty:undefined, latetime:null, crosscomment:undefined, commentstatus:1, commentnum:0, opergrade:false, operworks:false, commenttime:undefined, graduationgroups:[], assigngroups:[], selecassigngroups:[], hasproject:false, hascommit:false, minnums:0, max_nums:0, minnumstype:false, maxnumstype:false, edittype:false, task_type:false, starttimetype:false, endtimetype:false, flagPageEdit:false, visible:false, starttime:undefined, DownloadType:false, DownloadMessageval:undefined } } reInit=()=>{ this.getsettings(); } getsettings=()=>{ let task_Id=this.props.match.params.task_Id; let url ="/graduation_tasks/"+task_Id+"/settings.json" axios.get(url).then((result)=> { if(result.status===200){ let assigngroups = [] for (var list of result.data.graduation_groups) { assigngroups.push({ assign_group_id: list.assign_group_id, select_name: list.select_name, }) } let starttype=false; let endtype=false; if(moment(result.data.publish_time){ console.log(error) }) } componentDidMount(){ let query=this.props.location.search const type = query.split('?tab='); let id=parseInt(type[1]) this.getsettings(); if(this.props.isAdmin()===true&&isNaN(id)){ this.editSetting() } let tab = this.props.tab; this.props.setTab && this.props.setTab(tab); try{ this.props.triggerRef(this) }catch(e){ } } baseprojectfun=(e)=>{ this.setState({ baseonproject:e.target.checked }) } setminnum=(e)=>{ if(isNaN(parseInt(e.target.value))){ this.setState({ minnum:"" }) }else if(parseInt(e.target.value)===0) { this.setState({ minnum:1 }) }else{ this.setState({ minnum:parseInt(e.target.value) }) } } setmaxnum=(e)=>{ let {minnum}=this.state; if(isNaN(parseInt(e.target.value))){ this.setState({ maxnum:"" }) }else if(parseInt(e.target.value)===0) { this.setState({ maxnum:parseInt(minnum)+1 }) }else{ if(parseInt(e.target.value)<=parseInt(minnum)){ this.setState({ maxnum:minnum+1 }) }else{ this.setState({ maxnum:parseInt(e.target.value) }) } } } onChangeTimepublish= (date, dateString) => { let endtime; if(date===null){ this.setState({ publish_time:null, end_time:null, latetime:null }) }else{ let { firstTimes } = this.state; // 判断是否是第一次设置 this.setState({ publish_time:moment(moment(handleDateString(dateString))).format("YYYY-MM-DD HH:mm"), publishTimetypes:false }) if(firstTimes){ endtime= moment(moment(handleDateString(dateString))).add(1, 'months').format("YYYY-MM-DD HH:mm") let {allowlate}=this.state; this.setState({ firstTimes:undefined }) if(allowlate===true||allowlate===1){ this.setState({ end_time:endtime, latetime:moment(moment(handleDateString(endtime))).add(1, 'months').format("YYYY-MM-DD HH:mm"), }) }else{ this.setState({ end_time:endtime }) } } } } onChangeTimeend= (date, dateString) => { if(date===null){ this.setState({ end_time:null, latetime:null }) }else{ let { firstTimes } = this.state; this.setState({ end_time:moment(moment(handleDateString(dateString))).format("YYYY-MM-DD HH:mm"), endTimetypes:false }) // 判断是否是第一次设置 if(firstTimes){ this.setState({ firstTimes:undefined }) let {allowlate}=this.state; if(allowlate===true||allowlate===1){ this.setState({ latetime:moment(moment(handleDateString(dateString))).add(1, 'months').format("YYYY-MM-DD HH:mm"), }) } } } } onChangeTimelatetime=(date, dateString)=>{ let {end_time}=this.state; if(moment(dateString)>moment(end_time)){ this.setState({ latetimetype:false }) } this.setState({ latetime:handleDateString(dateString) }) } onChangeTimecommenttime=(date, dateString)=>{ let{end_time}=this.state; if(moment(dateString)>moment(end_time)){ this.setState({ commenttimetype:false, }) } this.setState({ commenttime:handleDateString(dateString) }) } allowlatefun=(e)=>{ let {end_time}=this.state; if(e.target.value===true||e.target.value===1){ this.setState({ latepenalty:5, allowlate:e.target.value, latetime:end_time===null||end_time === ""?"":moment(moment(handleDateString(end_time))).add(1, 'months').format("YYYY-MM-DD HH:mm"), }) }else{ this.setState({ latepenalty:0, allowlate:e.target.value, latetime:"" }) } } funlatepenalty=(e)=>{ let value= parseInt(e.target.value); if(isNaN(value)){ value=0 } this.setState({ latepenalty:value }) } updatesfuncrosscomment=(types,newlatetime,newcommenttime)=>{ let {endtimetype}=this.state; if(types===1){ this.setState({ latetime:newlatetime, crosscomment:true, commenttime:newcommenttime }) }else{ if(endtimetype===true){ this.setState({ crosscomment:true, commenttime:newcommenttime }) }else{ this.setState({ end_time:newlatetime, crosscomment:true, commenttime:newcommenttime }) } } } funcrosscomment=(e)=>{ let {latetime,end_time,allowlate}=this.state; let newlatetimea=moment(new Date()).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttimea=moment(new Date()).format("YYYY-MM-DD HH:mm"); let newlatetimes=moment(latetime).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttimes=moment(latetime).format("YYYY-MM-DD HH:mm"); let newend_timeb=moment(new Date()).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttimeb=moment(new Date()).add(8, 'days').format("YYYY-MM-DD HH:mm"); let newend_timed=moment(end_time).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttimed=moment(end_time).add(8, 'days').format("YYYY-MM-DD HH:mm"); let newtime; if(e.target.checked===true){ if(allowlate===1||allowlate===true){ if(latetime===null||latetime===""){ this.updatesfuncrosscomment(1,newlatetimea,newcommenttimea) }else{ this.updatesfuncrosscomment(1,newlatetimes,newcommenttimes) } }else{ if(end_time===null||end_time===""){ this.updatesfuncrosscomment(2,newend_timeb,newcommenttimeb) }else{ this.updatesfuncrosscomment(2,newend_timed,newcommenttimed) } } }else{ this.setState({ crosscomment:e.target.checked, commenttime:undefined }) } } funcommentstatus=(e)=>{ this.setState({ commentstatus:parseInt(e.target.value) }) } funcoperworks=(e)=>{ this.setState({ operworks:e.target.checked }) } funcopergrade=(e)=>{ this.setState({ opergrade:e.target.checked }) } homepublish=(ids,endtime)=>{ let task_Id=this.props.match.params.task_Id; const cid = this.props.match.params.coursesId // let url = `/courses/${cid}/graduation_tasks/publish_task.json`; let url="/courses/"+cid+"/graduation_tasks/publish_task.json" axios.post(url,{ task_ids:[task_Id], group_ids: this.state.course_groupslist, end_time:endtime, }).then((response)=>{ if (response.data.status == 0) { this.getsettings(); this.cancelmodel(); this.setState({ // Modalstype:true, // Modalstopval:resulet.data.message, // ModalSave:this.cancelmodel, // Loadtype:true starttime:undefined, course_groupslist:[], }) this.props.showNotification(response.data.message); } }).catch((error)=>{ }) } // //跳转道描点的地方 // scrollToAnchor = (anchorName) => { // if (anchorName) { // // 找到锚点 // let anchorElement = document.getElementById(anchorName); // // 如果对应id的锚点存在,就跳转到锚点 // if(anchorElement) { anchorElement.scrollIntoView(); } // } // } saveTaskssetting=()=>{ let {latepenalty,hascommit,minnums,max_nums,publish_time,end_time,crosscomment,latetime,starttimetype}=this.state; if(isNaN(parseInt(this.state.minnum))){ this.setState({ numtype:true }) this.scrollToAnchor("publishtimestart"); return }else{ this.setState({ numtype:false }) } if(isNaN(parseInt(this.state.maxnum))){ this.setState({ numtype:true }) this.scrollToAnchor("publishtimestart"); return }else{ this.setState({ numtype:false }) } if(latepenalty===undefined){ this.setState({ latepenaltytype:true, latepenaltyvalue:"不能为空" }) return }else if(latepenalty===""){ this.setState({ latepenaltytype:true, latepenaltyvalue:"不能为空" }) return }else{ this.setState({ latepenaltytype:false }) } if(starttimetype===false) { if (moment(publish_time) <= moment()) { this.setState({ publishTimetypes: true, publishTimetypesval: "发布时间不能早于当前时间", }) return } else { this.setState({ publishTimetypes: false }) } } if(moment(end_time) parseInt(minnums)) { this.setState({ minnumstype: true }) return }else{ this.setState({ minnumstype:false }) } if (parseInt(this.state.maxnum) < parseInt(max_nums)) { this.setState({ maxnumstype: true }) return }else{ this.setState({ maxnumstype:false }) } } if (this.state.end_time === "" || this.state.end_time === null) { this.setState({ end_timetype: true }) return }else{ this.setState({ end_timetype:false }) } if(publish_time!=null){ this.sethomepublish(); } } } sethomepublish=()=>{ let {assigngroups,starttime}=this.state; let assigngroupslist=[]; for(var list of assigngroups){ assigngroupslist.push(list.assign_group_id) } let {allowlate,baseonproject,crosscomment,opergrade,operworks,commentstatus,latepenalty,end_time,latetime}=this.state; let task_Id=this.props.match.params.task_Id; let url="/graduation_tasks/"+task_Id+"/update_settings.json"; axios.post(url,{ min_num: this.state.minnum, max_num: this.state.maxnum, base_on_project:baseonproject===true?1:0, publish_time:this.state.publish_time===null||this.state.publish_time=== ""?"":this.state.publish_time, end_time: this.state.end_time===null||this.state.end_time=== ""?this.props.getNowFormatDates(2,1):this.state.end_time, allow_late:allowlate===true||allowlate===1?1:undefined, late_time: this.state.latetime===null||this.state.latetime=== ""?this.props.getNowFormatDates(3,1):this.state.latetime, late_penalty: latepenalty, cross_comment: crosscomment===true?1:undefined, comment_status: crosscomment===true?this.state.commentstatus===0?2:this.state.commentstatus===1?2:this.state.commentstatus:undefined, comment_num: commentstatus===4?this.state.commentnum:undefined, comment_time: crosscomment===true?this.state.commenttime:undefined, comment_group: commentstatus===4?assigngroupslist:undefined, open_work: opergrade===true?1:undefined, open_score: operworks===true?1:undefined, group_ids:this.state.course_groupslist }).then((resulet)=>{ if(resulet.status===200){ if(resulet.data.status===0){ this.getsettings(); this.cancelmodel(); this.isgoback() this.setState({ // Modalstype:true, // Modalstopval:resulet.data.message, // ModalSave:this.cancelmodel, // Loadtype:true starttime:undefined, course_groupslist:[], }) this.props.showNotification(resulet.data.message); //调用父组件方法,刷新按钮 this.props.getdatas(); } } }).catch((error)=>{ console.log(error) }) } selectassigngroups=(e,index)=>{ let {assigngroups}=this.state; let newassigngroups=assigngroups; for(var i=0; i{ this.getsettings(); this.setState({ flagPageEdit: false, }) } cancelmodel=()=>{ this.setState({ Modalstype:false, Loadtype:false, visible:false, visibles:false, Modalstopval:"", ModalCancel:"", ModalSave:"", starttime:undefined }) } coursetaskend=()=>{ const coursesId = this.props.match.params.coursesId; const task_Id = this.props.match.params.task_Id; let url = `/courses/${coursesId}/graduation_tasks/end_task.json`; axios.post(url,{ task_ids:[task_Id], group_ids:this.state.course_groupslist }).then((response)=>{ if (response.data.status == 0) { // this.setState({ // Modalstype:true, // Modalstopval:response.data.message, // ModalSave:this.cancelmodel, // Loadtype:true, // checkBoxValues:[], // checkAllValue:false // }) this.getsettings(); this.props.showNotification(response.data.message); this.cancelmodel(); this.setState({ course_groupslist:[], // Modalstopval:resulet.data.message, // ModalSave:this.cancelmodel, // Loadtype:true }) } }).catch((error)=>{ }) } setcommentnum=(e)=>{ this.setState({ commentnum:parseInt(e.target.value) }) } scrollToAnchor = (anchorName) => { if (anchorName) { // 找到锚点 let anchorElement = document.getElementById(anchorName); // 如果对应id的锚点存在,就跳转到锚点 if(anchorElement) { anchorElement.scrollIntoView({block: 'start', behavior: 'smooth'}); } } } skipTop=()=>{ this.scrollToAnchor("starttime") this.cancelmodel() } getcourse_groupslist=(id)=>{ this.setState({ course_groupslist:id }) } //编辑 editSetting = () => { if (this.state.settingdata&&this.state.settingdata.is_end === true) { // this.setState({ // modalsType: true, // modalsTopval: "课堂已结束不能再修改!", // loadtype: true, // modalSave: this.cancelBox // }) this.props.showNotification("课堂已结束不能再修改!"); } else { this.setState({ flagPageEdit: true, }) } } /// 确认是否下载 confirmysl(url){ debugger; console.log(3); axios.get(url + '?export=true' ).then((response) => { if(response === undefined){ return } if(response.data.status&&response.data.status===-1){ }else if(response.data.status&&response.data.status===-2){ if(response.data.message === "100"){ // 已超出文件导出的上限数量(100 ),建议: this.setState({ DownloadType:true, DownloadMessageval:100 }) }else { //因附件资料超过500M this.setState({ DownloadType:true, DownloadMessageval:500 }) } }else { this.props.showNotification(`正在下载中`); window.open("/api"+url, '_blank'); } }).catch((error) => { console.log(error) }); } Downloadcal=()=> { this.setState({ DownloadType: false, DownloadMessageval: undefined }) } render(){ const { getFieldDecorator } = this.props.form; const dateFormat = 'YYYY-MM-DD HH:mm'; let {coursename,taskname,settingdata,baseonproject,Modalstype,Modalstopval,operworks,opergrade,graduationgroups,Loadtype,task_type,end_timetype, ModalCancel,ModalSave,publish_time,end_time,allowlate,latepenalty,latetime,crosscomment,commentstatus,commentnum,commenttime,numtype, minnum,maxnum,modalname,task_status, visible, Topval, Topvalright, Botvalleft, Botval, starttime, endtime, Cancelname, Savesname, Cancel, Saves, course_groups,hasproject,hascommit,minnumstype,maxnumstype, latepenaltytype, latepenaltyvalue, latetimetype, starttimetype, endtimetype, commenttimetype, commenttimevalue, flagPageEdit } =this.state; let courseId=this.props.match.params.coursesId; let category_id=this.props.match.params.category_id; let task_Id=this.props.match.params.task_Id; const radioStyle = { display: 'block', height: '30px', lineHeight: '30px', }; // // console.log(moment(publish_time)) // console.log(this.props.isSuperAdmin()) return( { settingdata && settingdata ?
{/*提示*/} this.getcourse_groupslist(id)} />
{ !flagPageEdit && this.props.isAdmin() === true ? : "" } {/*内容*/} {task_type===2?
分组设置 (提交作品时需要关联同组成员,组内成员作品共享)
~ (学生提交作品时需要关联同组成员,组内成员作品共享)
{minnumstype===true?
已有提交作品,最小人数不能变大
:""} {maxnumstype===true?
已有提交作品,最大人数不能变小
:""} {numtype===true?
不能为空
:""}
基于项目实施 (选中,则必须在本平台创建项目,项目管理员可以提交作品;不选中,无需在平台创建项目,任意小组成员均可以提交作品)
:""}
发布设置
发布时间: (学生收到作业的时间)
{this.state.publishTimetypes===true?
{this.state.publishTimetypesval}
:""}
截止时间: (学生“按时”提交作品的时间截点)
{this.state.endTimetypes===true?
{this.state.endTimetypesval}
:""} {end_timetype===true?
不能为空
:""}
补交设置
开启补交(选中,则允许学生延时提交作品)
迟交扣分: (延时提交作品时,学生成绩将被扣减的分值) {latepenaltytype===true?
{latepenaltyvalue}
:""}
结束时间: (学生“延时”提交作品的时间截点) {latetimetype===true?
{this.state.latetimetypeval}
:""}
禁止补交
评分设置
最终成绩组成 (取各教师最终评分的平均分)
启用交叉评阅 (给老师分配其他指导老师的学生作品) {crosscomment===true?
开始时间: (交叉评阅开始时间之前提交的作品,参与交叉评阅) {crosscomment===true&&commenttimetype===true?
{commenttimevalue}
:""}
{/*
评阅方式: 指导老师手动分配 (由指导老师在作品列表中,手动选择每个作品被分配的评阅老师) 答辩组间老师互评 (由系统按照设置在答辩组之间自动分配: 答辩组设置
*/} {/*
评阅数: (单个作品将被分配互评的次数)
{graduationgroups.map((item,key)=>{ return(
{item.group_name}({item.member_count} 个教师)
) })}
*/}
:""}
{/*open_score: true*/} {/*open_work: true*/}
公开设置
公开作品 (选中,则在作业截止/补交结束时间之后,已提交作品的学生可以查看其它学生的作品,否则只能查看自己的作品)
公开成绩 (选中,则在作业截止/补交结束时间之后,已提交作品的学生可以查看其它学生的成绩,否则只能查看自己的成绩)
{this.props.isAdmin()===true?flagPageEdit===true?
{/*取消*/} 取消
:"":""}
:""}
) } } const GraduationTaskssetting = Form.create({ name: 'coursesNew' })(GraduationTaskssettingapp); export default GraduationTaskssetting;