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 CoursesListType from '../../coursesPublic/CoursesListType'; import PublishModals from "../../coursesPublic/PublishModals"; import HomeworkModal from "../../coursesPublic/HomeworkModal"; import moment from 'moment'; const { Option} = Select; const CheckboxGroup = Checkbox.Group; const confirm = Modal.confirm; let GraduationTasksnewtype=true; // const $ = window.$; const Search = Input.Search; 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)), }; } 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, 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 } } 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() } } 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{ endtime= moment(moment(handleDateString(dateString))).add(1, 'months').format("YYYY-MM-DD HH:mm") let {allowlate}=this.state; if(allowlate===true||allowlate===1){ this.setState({ publish_time:moment(moment(handleDateString(dateString))).format("YYYY-MM-DD HH:mm"), end_time:endtime, latetime:moment(moment(handleDateString(endtime))).add(1, 'months').format("YYYY-MM-DD HH:mm"), }) }else{ this.setState({ publish_time:moment(moment(handleDateString(dateString))).format("YYYY-MM-DD HH:mm"), end_time:endtime }) } } } onChangeTimeend= (date, dateString) => { if(date===null){ this.setState({ end_time:null, latetime:null }) }else{ let {allowlate}=this.state; if(allowlate===true||allowlate===1){ this.setState({ end_time:moment(moment(handleDateString(dateString))).format("YYYY-MM-DD HH:mm"), latetime:moment(moment(handleDateString(dateString))).add(1, 'months').format("YYYY-MM-DD HH:mm"), }) }else{ this.setState({ end_time:moment(moment(handleDateString(dateString))).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?"":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 }) } funcrosscomment=(e)=>{ let {latetime,end_time,allowlate}=this.state; let newtime; if(e.target.checked===true){ if(allowlate===1||allowlate===true){ if(latetime===null||latetime===""){ let newlatetime=moment(new Date()).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttime=moment(new Date()).format("YYYY-MM-DD HH:mm"); this.setState({ latetime:newlatetime, crosscomment:e.target.checked, commenttime:newcommenttime }) }else{ let newlatetime=moment(latetime).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttime=moment(latetime).format("YYYY-MM-DD HH:mm"); this.setState({ latetime:newlatetime, crosscomment:e.target.checked, commenttime:newcommenttime }) } }else{ if(end_time===null||end_time===""){ let newend_time=moment(new Date()).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttime=moment(new Date()).add(8, 'days').format("YYYY-MM-DD HH:mm"); this.setState({ end_time:newend_time, crosscomment:e.target.checked, commenttime:newcommenttime }) }else{ let newend_time=moment(end_time).add(7, 'days').format("YYYY-MM-DD HH:mm"); let newcommenttime=moment(end_time).add(8, 'days').format("YYYY-MM-DD HH:mm"); this.setState({ end_time:newend_time, crosscomment:e.target.checked, commenttime:newcommenttime }) } } }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 }) } //立即发布 publish=()=>{ let starttime= this.props.getNowFormatDates(1,1); let endtime=this.props.getNowFormatDates(2,1); // this.homeworkstart() this.setState({ modalname:"立即发布", visibles:true, Topval:"学生将立即收到毕设任务", // Botvalleft:"点击修改", Botval:`本操作只对"未发布"的分班有效`, starttime:moment(moment(new Date())).format("YYYY-MM-DD HH:mm") , starttimes:this.props.getNowFormatDates(1), typs:"start", endtime:endtime, Cancelname:"暂不发布", Savesname:"立即发布", Cancel:this.cancelmodel, Saves:this.homepublish, }) } //立即发布 homeworkstart=()=>{ let coursesId=this.props.match.params.coursesId; let url="/courses/"+coursesId+"/all_course_groups.json"; axios.get(url).then((response) => { if(response.status===200){ this.setState({ modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, course_groups:response.data.course_groups, }) } }).catch((error) => { console.log(error) }); } 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, end_time: this.state.end_time===null?this.props.getNowFormatDates(2,1):this.state.end_time, allow_late:allowlate===true||allowlate===1?1:undefined, late_time: this.state.latetime===null?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); } } }).catch((error)=>{ console.log(error) }) } selectassigngroups=(e,index)=>{ let {assigngroups}=this.state; let newassigngroups=assigngroups; for(var i=0; i{ let courseId=this.props.match.params.coursesId; let category_id=this.props.match.params.category_id; window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; } isgoback=()=>{ this.setState({ flagPageEdit: false, }) } end=()=>{ this.setState({ modalname:"立即截止", visibles:true, Topval:"学生将不能再提交作品", // Botvalleft:"暂不截止", Botval:`本操作只对"提交中"的分班有效`, Cancelname:"暂不截止", Savesname:"立即截止", Cancel:this.cancelmodel, Saves:this.coursetaskend, typs:"end", }) // this.homeworkstart() } 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, }) } } 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)} />

{coursename} > 毕设任务 > {/*{taskname===""?"":*/} {/**/} {/*{taskname}*/} {/*>*/} {/**/} {/*}*/} 任务详情

{taskname}

返回
任务列表 任务问答 设置 {/*导出*/} {this.props.isAdmin()?
  • 导出
  • :""} {/*{this.props.isAdmin()?导出成绩:""}*/} {/*{this.props.isAdmin()?导出作品附件:""}*/} {/*项目在线质量检测*/} {this.props.isAdmin()?settingdata.status===1? { this.end()} }>立即截止:"":""} {this.props.isAdmin()?settingdata.status===0? { this.publish()} }>立即发布:"":""} {this.props.isAdmin()?编辑任务:""}
    { !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;