import React, {Component} from "react"; import CoursesListType from '../coursesPublic/CoursesListType'; import HomeworkModal from "../coursesPublic/HomeworkModal"; import {WordsBtn, ActionBtn, handleDateString,getImageUrl} from 'educoder'; import PollDetailTabForthRules from '../poll/PollDetailTabForthRules'; import ShixunWorkModal from './Shixunworkdetails/ShixunWorkModal'; import { Button, Checkbox, message, InputNumber, DatePicker, Radio, Tooltip, notification, } from "antd"; import {Link} from 'react-router-dom'; import locale from 'antd/lib/date-picker/locale/zh_CN'; import axios from 'axios'; import moment from 'moment'; import 'moment/locale/zh-cn'; import Modals from "../../modals/Modals"; import DownloadMessageysl from "../../modals/DownloadMessageysl"; import OneSelfOrderModal from "../coursesPublic/OneSelfOrderModal"; import '../css/members.css'; import "../common/formCommon.css"; import '../css/Courses.css'; import './style.css'; import '../css/busyWork.css' import '../poll/pollStyle.css' import Startshixuntask from "../coursesPublic/Startshixuntask"; const RadioGroup = Radio.Group; //GraduationTaskssetting.js //课堂作业设置 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)), // disabledSeconds: () => range(0,60) } } function disabledDate(current) { return current && current < moment().endOf('day').subtract(1, 'days'); } class Trainingjobsetting extends Component { //unifiedsetting 统一设置 //allowreplenishment 允许补交 //completionefficiencyscore 完成效率评分占比 //level级别 //proportion 比例 //releasetime 发布时间 //deadline 截至时间 constructor(props) { super(props); // this.props.form.setFieldsValue({ // radiogroup:1, // // }); this.state = { flagPageEdit: true, flagPageEdits: false, flagPageEditstwo:false, flagPageEditsthrees:false, flagPageEditsfor:false, props: props, flagPageEditsbox:false, handclass:undefined, rulest:undefined, rules:undefined, starttimetype: false, endtimetype: false, latetimetype: false, allowlate: 1, unit_p_tip: "", unit_e_tip: "", latepenaltytype: false, unifiedsetting: true, allowreplenishment: undefined, completionefficiencyscore: false, whethertopay: false, proportion: undefined, level: undefined, ealuation: false, latededuction: undefined, latedeductiontwo: "0", database: false, datasheet: false, databasetwo: undefined, datasheettwo: undefined, publicwork: undefined, publish_time: undefined, publish_timebool:false, end_time: undefined, late_time: undefined, endOpen: false, borreds:undefined, borredss:undefined, releasetime: undefined, deadline: undefined, late_times: undefined, mystyle: {"display": "block"}, mystyles: {"display": "none"}, challenge_settings: undefined, boolUnite: true, boolUnitetwo: true, boolUnitetwoname:undefined, score_open: false, group_settings:undefined, rulesdata:[], showmodel:false, code_review:false, testscripttiptype:false, starttimesend:undefined, end_timebool:false, late_timesbool:false, work_efficiencys:false, } // console.log("获取到的值") // console.log("Trainingjobsetting") // // console.log("设置页面调用的老师学生权限") // console.log(JSON.stringify(props)) // console.log(this.props.isAdmin()) //判断是否是老师 // console.log(this.props.isStudent()) //判断是否是学生 // console.log(this.props.isNotMember()) //判断是否有登入权限 } componentDidMount() { console.log("Trainingjobsetting"); console.log("componentDidMount"); this.getTrainingjobsetting(true); let query = this.props.location.pathname; const type = query.split('/'); this.setState({ shixuntypes:type[3] }) this.props.triggerRef(this); if(this.props.isAdmin() === false){ this.cancelEdit() } } // componentWillReceiveProps(nextProps) { // // console.log("+++++++++916"); // // console.log(nextProps); // // console.log(this.props) // // console.log(this.props.isAdmin()); // if (nextProps.code_review != this.props.code_review) { // if (nextProps.code_review !== undefined) { // console.log("diaoyonglwangluo4"); // this.getTrainingjobsetting() // // } // } // // } // 获取数据地方 getTrainingjobsetting = (bool) => { // console.log("getTrainingjobsetting") var homeworkid = this.props.match.params.homeworkid; // console.log(homeworkid) let url = `/homework_commons/${homeworkid}/settings.json`; axios.get(url).then((result) => { // console.log(url); // console.log(result); if (result!=undefined) { // console.log(result.data.code_review) // console.log("设置页") // console.log(JSON.stringify(result)) let array=[]; let arrays=[]; var rulesdatas=[]; if(result.data.group_settings !== undefined){ if(result.data.group_settings.length === 0){ array.push({ course_group_id:[], course_group_name:[], publish_time:undefined, end_time:undefined, publish_flag:"", end_flag:"", class_flag:"", course_search:"", open:false }) }else { for(var i=0;i { if (anchorName) { // 找到锚点 let anchorElement = document.getElementById(anchorName); // 如果对应id的锚点存在,就跳转到锚点 if(anchorElement) { anchorElement.scrollIntoView(); } } } //提交数据 pustdate = () => { var thiss=this; // console.log("pustdate"); var homeworkid = this.props.match.params.homeworkid var array = []; var datas = this.state.challenge_settings; var challenge_scoredata = []; for (var i = 0; i < datas.length; i++) { if (datas[i].checked === true) { var object = { challenge_id: datas[i].challenge_id, challenge_score: datas[i].challenge_score, }; challenge_scoredata.push(datas[i].challenge_score); array.push(object) console.log("datas[i].challenge_score"); console.log(i); console.log(datas[i].challenge_score); } } console.log("提交的数据"+"pustdate"); console.log("提交的数据"+"pustdate"); if (this.state.jobsettingsdata.data.unified_setting === true) { if (this.state.unifiedsetting === true) { if (this.state.releasetime === undefined || this.state.releasetime === null || this.state.releasetime === "") { // this.props.showNotification(`请选择发布时间`); //立即发布 // this.homeworkstart(); this.scrollToAnchor("publishtimeid"); this.setState({ unit_p_tip: "请选择发布时间", p_flag: true, borreds:"bor-reds", }) return; }else{ if (this.state.publish_time=== undefined || this.state.publish_time=== null || this.state.publish_time=== "") { if ( moment(this.state.publish_time, 'YYYY-MM-DD HH:mm') <= moment()) { //发布时间小于 当前时间 this.scrollToAnchor("publishtimeid"); this.setState({ unit_p_tip: "发布时间不能早于当前时间", p_flag: true, borreds:"bor-reds", }) return; } } } if (this.state.deadline === undefined || this.state.deadline === null || this.state.deadline === "") { // this.props.showNotification(`请选择截止时间`); this.scrollToAnchor("publishtimeid"); this.setState({ unit_e_tip: "请选择截止时间", p_flag: true, borredss:"bor-reds", }) return }else { if(!this.state.flagPageEditsthrees === false){ if (moment(this.state.end_time, "YYYY-MM-DD HH:mm") <= moment()) { //截止时间小于当前时间 this.scrollToAnchor("publishtimeid"); this.setState({ unit_e_tip: "截止时间不能早于当前时间", p_flag: true, borredss:"bor-reds", }) return; } if (moment(this.state.end_time, "YYYY-MM-DD HH:mm") <= moment(this.state.publish_time, "YYYY-MM-DD HH:mm")) { //截止时间小于发布时间 this.scrollToAnchor("publishtimeid"); this.setState({ unit_e_tip: "截止时间不能早于发布时间", p_flag: true, borredss:"bor-reds", }) return } } } if (this.state.allowreplenishment === true) { if (this.state.late_times === undefined || this.state.late_times === null || this.state.late_times === "") { // this.props.showNotification(`请选择结束时间`); this.scrollToAnchor("end_timeid") this.setState({ hand__e_tip: "请选择结束时间", hand_flags: true, handclass: "bor-reds", }) return; } else { // 补交结束时间不能早于截止时间 if(!this.state.flagPageEditsfor ===false){ if (moment(this.state.late_time, "YYYY-MM-DD HH:mm") <= moment()) { //结束时间小于当前时间 this.scrollToAnchor("end_timeid"); this.setState({ hand__e_tip: "结束时间不能早于当前时间", hand_flags: true, handclass: "bor-reds", }) return; } if (moment(this.state.late_time, "YYYY-MM-DD HH:mm") <= moment(this.state.publish_time, "YYYY-MM-DD HH:mm")) { //结束时间小于发布时间 this.scrollToAnchor("end_timeid"); this.setState({ hand__e_tip: "结束时间不能早于发布时间", hand_flags: true, handclass: "bor-reds", }) return; } if (moment(this.state.late_time, "YYYY-MM-DD HH:mm") <= moment(this.state.end_time, "YYYY-MM-DD HH:mm")) { //结束时间小于发布时间 this.scrollToAnchor("end_timeid"); this.setState({ hand__e_tip: "补交结束时间不能早于截止时间", hand_flags: true, handclass: "bor-reds", }) return; } } } } } else { let rulesdata=this.state.rulesdata; console.log("pustdate123131312321321321"); console.log(rulesdata); if( rulesdata.length === 0){ this.props.showNotification(`分班发布设置不能为空`); return; } // } } if (this.state.allowreplenishment === true) { if (this.state.latededuction === undefined) { this.props.showNotification(`请输入迟交扣分数`); return; } if (this.state.latededuction === null) { this.props.showNotification(`请输入迟交扣分数`); return; } if (this.state.latededuction === "") { this.props.showNotification(`请输入迟交扣分数`); return; } if (this.state.latededuction <0) { this.props.showNotification(`迟交扣分数不能小于零`); return; } if (this.state.level === undefined || this.state.level === "") { this.props.showNotification(`请选择扣分项`); return; } } if (this.state.completionefficiencyscore === true) { if (this.state.latedeductiontwo === undefined) { this.props.showNotification(`请输入占比分数`); return; } if (this.state.latedeductiontwo === null) { this.props.showNotification(`请输入占比分数`); return; } if (this.state.latedeductiontwo === "") { this.props.showNotification(`请输入占比分数`); return; } if (this.state.latedeductiontwo <= 0) { this.props.showNotification(`占比分数不能小于等于零`); return; } // if(this.state.latedeductiontwo >100){ // message.error("占比分不能大于100",1); // return; // } if (this.state.proportion === undefined) { this.props.showNotification(`请选择比列`); return; } if (this.state.proportion !== undefined) { if (this.state.proportion === "均分比例") { //关卡分值平分 } if (this.state.proportion === "经验值比例") { this.setState({ boolUnitetwo: false, }) } if (this.state.proportion === "自定义分值") { this.setState({ boolUnitetwo: false, }) } } } var latedeductiontwos = 0; if (this.state.completionefficiencyscore === true) { latedeductiontwos = this.state.latedeductiontwo; } if(challenge_scoredata.length>0){ var len = 0; for (var k = 0; k < challenge_scoredata.length; k++) { len = len + parseFloat(challenge_scoredata[k]); console.log(len); console.log(challenge_scoredata[k]); console.log(len); } var max = latedeductiontwos + len; if (max > 100) { console.log("max>100"); this.props.showNotification(`总分值+效率占比分之和要等于100,现在分值为` + max); return; } if(max<100){ console.log("max<100"); this.props.showNotification(`总分值+效率占比分之和要等于100,现在分值为` + max); return; } } var url = `/homework_commons/${homeworkid}/update_settings.json`; var data = undefined; // console.log("this.state.unified_setting") // console.log(this.state.unifiedsetting) if(array === "[]" || array.length === 0){ this.props.showNotification(`没有关卡不能更新设置`); return; } if(this.state.unifiedsetting === true){ console.log("统一设置"); data = { unified_setting: this.state.unifiedsetting, //统一配置 publish_time: moment(this.state.publish_time).format('YYYY-MM-DD HH:mm'), //发布时间 end_time: moment(this.state.end_time).format('YYYY-MM-DD HH:mm'), //截止时间 allow_late: this.state.allowreplenishment, //补交 late_penalty: parseInt(this.state.latededuction), //迟交扣分 late_time: moment(this.state.late_time).format('YYYY-MM-DD HH:mm'), //结束时间 answer_open_evaluation: this.state.level === "满分" ? true : false, //扣分项 work_efficiency: this.state.completionefficiencyscore, //完成效率评分占比 eff_score: this.state.completionefficiencyscore === true ? this.state.latedeductiontwo : undefined,//占比分 shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, } }else{ // //非统一配置 // console.log("非统一设置"); let rulesdata=this.state.rulesdata; let newlist=[] rulesdata.map((item,key)=>{ if(item.publish_time==="Invalid date"||item.end_time==="Invalid date"||item.publiend_timesh_time==="Invalid date"){ }else{ newlist.push(item) } }) data = { unified_setting: this.state.unifiedsetting, //非统一配置 group_settings: newlist, allow_late: this.state.allowreplenishment, //补交 late_penalty: parseInt(this.state.latededuction), //迟交扣分 late_time: moment(this.state.late_time).format('YYYY-MM-DD HH:mm'), //结束时间 answer_open_evaluation: this.state.level === "满分" ? true : false, //扣分项 work_efficiency: this.state.work_efficiencys, //完成效率评分占比 eff_score: this.state.completionefficiencyscore === true ? this.state.latedeductiontwo : undefined,//占比分 shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, } } // console.log("pustdate"); // console.log(data); // console.log(JSON.stringify(data)); axios.post(url, data) .then((result) => { if (result.data.status == 0) { // console.log(JSON.stringify(result)); this.props.showNotification(`更新成功`); this.setState({ flagPageEditsbox:false, flagPageEdit: false, flagPageEditstwo:false, flagPageEditsthrees:false, flagPageEditsfor:false, whethertopay:false, completionefficiencyscore:false, }) this.refs.targetElementTrainingjobsetting.scrollIntoView() } }).catch((error) => { console.log(error); }) } //数据库 onChangedatabase = (e) => { this.setState({ database: e.target.checked, }) // console.log(e.target.checked); } //公开设置 onChangepublicwork = (e) => { this.setState({ publicwork: e.target.checked, }) // console.log(e.target.checked); } //数据表创建 onChangedatasheet = (e, index) => { var challenge_settings = this.state.challenge_settings; var bool= false; for (var i = 0; i < challenge_settings.length; i++) { if (i === index) { if (challenge_settings[i].checked === true) { challenge_settings[i].checked = false bool=false; } else { challenge_settings[i].checked = true bool=true; } } } for (var i = 0; i < challenge_settings.length; i++) { if(bool=== true){ if (i < index) { challenge_settings[i].checked = true } }else{ if (i > index) { challenge_settings[i].checked = false } } } // console.log(e.target.checked) // console.log(index) this.setState({ datasheet: e.target.checked, challenge_settings: challenge_settings }) this.onChangeslevelproportiontwo(this.state.proportion); } //统一设置 onChange = (e) => { if((moment(this.state.publish_time,"YYYY-MM-DD HH:mm")<=moment())){ this.props.showNotification(`已发布,不能再修改统一设置`); return } this.setState({ unifiedsetting: e.target.checked, }) // console.log(e.target.checked); } //允许补交 onChanges = (e) => { // console.log(this.state.end_time); if(e.target.checked ===true){ if(this.state.end_time !== null && this.state.end_time!== undefined){ // console.log(this.state.end_time); // var times = this.state.deadline.format('YYYY-MM-DD HH:mm'); this.setState({ late_time:moment(handleDateString(this.state.deadline)).add(1, 'months'), late_times:moment(handleDateString(this.state.deadline)).add(1, 'months').format('YYYY-MM-DD HH:mm'), }) } this.setState({ allowreplenishment: e.target.checked, latededuction:5, whethertopay:true, }) }else { this.setState({ allowreplenishment: e.target.checked, latededuction:0, whethertopay:false, hand__e_tip: "", hand_flags: false, handclass:"", }) } // console.log('radio checked', e.target.value); } //级别 onChangeslevel = (e) => { this.setState({ level: e.target.value }) // console.log('radio checked', e.target.value); } //比例 onChangeslevelproportion = (e) => { this.state.proportion=e.target.value if (e.target.value === "均分比例") { this.Equalproportion(this.state.latedeductiontwo); } if (e.target.value === "经验值比例") { this.Empiricalvalueratio(this.state.latedeductiontwo); } if (e.target.value === "自定义分值") { this.state.boolUnitetwoname="自定义分值"; this.setState({ boolUnitetwoname:"自定义分值", boolUnitetwo: false, flagPageEdits:true, }) } this.setState({ proportion: e.target.value }) // console.log('radio checked', e.target.value); } onChangeslevelproportiontwo=(value)=>{ if (value === "均分比例") { this.Equalproportion(this.state.latedeductiontwo); } if (value === "经验值比例") { this.Empiricalvalueratio(this.state.latedeductiontwo); } if (value=== "自定义分值") { this.state.boolUnitetwoname="自定义分值"; this.setState({ boolUnitetwoname:"自定义分值", boolUnitetwo: false, flagPageEdits:true, }) } this.setState({ proportion: value }) } //均分比例 Equalproportion = (latedeductiontwo) => { var challenge_settingsdata=this.state.challenge_settings; var latedeductiontwos=latedeductiontwo; if(latedeductiontwos === undefined || latedeductiontwos===null || latedeductiontwos===""){ latedeductiontwos=0; } //占比分 if(challenge_settingsdata.length>0){ var Proportion=100; var oushution=0; //获取占用分后的值 Proportion=Proportion-latedeductiontwos; oushution=Proportion; var srorelength=0; //计算选中用户 for (var k=0;k{ var shixun_exp = this.state.shixun_exp; var challenge_settingsdata=this.state.challenge_settings; var latedeductiontwos=latedeductiontwo; if(latedeductiontwos === undefined || latedeductiontwos===null || latedeductiontwos===""){ latedeductiontwos=0; } // //占比分 if(shixun_exp!==undefined){ if(shixun_exp>0){ if(challenge_settingsdata.length>0){ var ionsp=100; //获取占比分之后的值 ionsp=ionsp-latedeductiontwos; //获取道总分值 var Proportion=shixun_exp; //获取改变后的总分值 for (var k=0;k0){ expzsy=parseFloat(ionsp.toFixed(1)) - parseFloat(expzs.toFixed(1)); expzsy=Math.abs(expzsy); bool=true; }else{ expzsy= parseFloat(ionsp.toFixed(1)) - parseFloat(expzs.toFixed(1)); expzsy= Math.abs(expzsy); bool=false; } var macts=0; for (var i=0;i { if( e.target.checked === true){ this.setState({ completionefficiencyscore: e.target.checked, work_efficiencys:e.target.checked, latedeductiontwo: 20, }) //均分比例 if(this.state.proportion==="均分比例"){ this.Equalproportion(20); }else if(this.state.proportion==="经验值比例"){ this.Empiricalvalueratio(20); } } else { this.state.latedeductiontwo=0; this.setState({ completionefficiencyscore: e.target.checked, work_efficiencys:e.target.checked, latedeductiontwo: 0, }) //均分比例 if(this.state.proportion==="均分比例"){ this.Equalproportion(0); }else if(this.state.proportion==="经验值比例"){ this.Empiricalvalueratio(0); } } // console.log(e.target.checked); } //迟交扣分 changeTopicName = (value) => { // console.log("1e.target.value", value) if (value === "" || value === undefined) { return } var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/ var nubmer = value; if (!re.test(nubmer)) { this.props.showNotification(`请输入数字`); this.setState({ latededuction: 0 }) return false; } if (nubmer > 100) { this.props.showNotification(`请输入小于100的数`); this.setState({ latededuction: 0 }) return } this.setState({ latededuction: value, }) } // //占比分 changeTopicNametwo = (value) => { // console.log("TrainingjobsettingTrainingjobsetting", value) if (value === "" || value === undefined) { return } var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/ var nubmer = value; if (!re.test(nubmer)) { this.props.showNotification(`请输入数字`); this.setState({ latedeductiontwo: 0 }) return false; } if (nubmer > 100) { this.props.showNotification(`请输入小于100的数`); this.setState({ latedeductiontwo: 0 }) return } this.setState({ latedeductiontwo: value, }) //均分比例 if(this.state.proportion==="均分比例"){ this.Equalproportion(value); }else if(this.state.proportion==="经验值比例"){ this.Empiricalvalueratio(value); } } hangeTopicNametwodatasheet = (value, index) => { // console.log("2e.target.value", value) if (value === "" || value === undefined) { return } var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/ var nubmer = value; if (!re.test(nubmer)) { this.props.showNotification(`请输入数字`); // this.setState({ // datasheet: 0 // }) var challenge_settings = this.state.challenge_settings; for (var i = 0; i < challenge_settings.length; i++) { if (i === index) { challenge_settings[i].challenge_score = ""; } } this.setState({ challenge_settings: challenge_settings }) return false; } var challenge_settings = this.state.challenge_settings; for (var i = 0; i < challenge_settings.length; i++) { if (i === index) { challenge_settings[i].challenge_score = value; } } this.setState({ challenge_settings: challenge_settings }) // if (nubmer > 100) { // message.error("请输入小于100的数"); // this.setState({ // datasheet: 0 // }) // return // } // this.setState({ // datasheet: value, // }) } // disabledEndDate = (end_time) => { // const publish_time = this.state.publish_time; // if (!end_time || !publish_time) { // return false; // } // return end_time.valueOf() <= publish_time.valueOf(); // // } // disabledEndDates = (end_time) => { // const publish_time = this.state.end_time // if (!end_time || !publish_time) { // return false; // } // console.log("end_time.valueOf()") // // console.log(end_time.valueOf()); // // console.log(publish_time.valueOf()); // return end_time.valueOf() <= publish_time.valueOf(); // // // } disabledStartDatestart= (startValue) => { const endValue = this.state.end_time if (!startValue || !endValue) { return false; } var endValues= moment(endValue).subtract(1, 'days'); return startValue.valueOf() > endValues.valueOf(); }; disabledEndDateend = (endValue) => { const startValue = this.state.publish_time; if (!endValue || !startValue) { return false; } var endValuesys= moment(startValue).subtract(1, 'days'); return endValue.valueOf() <= endValuesys.valueOf(); }; disabledEndDateendd = (endsValue) => { const endValues = this.state.end_time if (!endsValue|| !endValues) { return false; } var endValuesyss= moment(endValues).subtract(1, 'days'); return endsValue.valueOf() <= endValuesyss.valueOf(); }; onChangedata = (field, value, dateString) => { this.setState({ [field]: handleDateString(dateString), }); } ontimeonok=(value)=>{ console.log("ontimeonok点击了2"); if(value === undefined){ return; } if (moment(value, "YYYY-MM-DD HH:mm") <= moment()) { } else { try { this.setState({ unit_p_tip: "", p_flag: false, borreds:undefined, releasetime: value.format('YYYY-MM-DD HH:mm'), }) } catch (e) { } } } ontimeonoktwo =(value)=>{ if(value === undefined){ return; } if (moment(value, "YYYY-MM-DD HH:mm") <= moment()) { } else { if (moment(value, "YYYY-MM-DD HH:mm") <= moment(this.state.publish_time, "YYYY-MM-DD HH:mm")) { return } try { this.setState({ unit_e_tip: "", p_flag: false, deadline: value.format('YYYY-MM-DD HH:mm'), borredss:undefined, }) } catch (e) { } } } ontimeonokthree=(value)=>{ if(value === undefined){ return; } let{publish_time,unifiedsetting,rulesdata}=this.state; if(unifiedsetting===true){ if (moment(value, "YYYY-MM-DD HH:mm") <= moment(publish_time)) { } else { } }else{ rulesdata.map((item,key)=>{ if(item.publish_time!="Invalid date"){ if (moment(value, "YYYY-MM-DD HH:mm") <= moment(item.publish_time, "YYYY-MM-DD HH:mm")) { }else{ this.setState({ late_times: value.format('YYYY-MM-DD HH:mm'), hand__e_tip: "", hand_flags: false, handclass:"", }) } } }) } } onStartChange = (value, dateString) => { console.log("onStartChange点击了1"); if(value==null){ this.setState({ releasetime:undefined, publish_time:undefined, }) return; } // if (moment(value, "YYYY-MM-DD HH:mm") <= moment()) { // this.setState({ // unit_p_tip: "发布时间不能早于当前时间", // p_flag: true, // borreds:"bor-reds", // releasetime:undefined, // publish_time:undefined, // }) // } else { try { this.setState({ unit_p_tip: "", p_flag: false, borreds:undefined, releasetime: value.format('YYYY-MM-DD HH:mm'), }) } catch (e) { } // console.log(value); console.log(dateString); // console.log(handleDateString(dateString)); // this.onChangedata('publish_time', value, dateString); this.setState({ publish_time:moment(moment(handleDateString(dateString))).format("YYYY-MM-DD HH:mm"), }); if(this.state.allowreplenishment === true) { if(this.state.end_time=== undefined || this.state.end_time===""){ this.setState({ end_time:moment(handleDateString(dateString)).add(1, 'months'), deadline:moment(handleDateString(dateString)).add(1, 'months').format('YYYY-MM-DD HH:mm'), }) }else { } if(this.state.late_time===undefined || this.state.late_time===""){ this.setState({ late_time:moment(handleDateString(dateString)).add(2, 'months'), late_times:moment(handleDateString(dateString)).add(2, 'months').format('YYYY-MM-DD HH:mm'), }); }else{ } try { this.setState({ unit_e_tip: "", p_flag: false, borredss:undefined, }) } catch (e) { } }else{ if(this.state.end_time=== undefined || this.state.end_time===""){ this.setState({ end_time:moment(handleDateString(dateString)).add(1, 'months'), deadline:moment(handleDateString(dateString)).add(1, 'months').format('YYYY-MM-DD HH:mm'), }) }else { } } // } } onEndChange = (value, dateString) => { // console.log("onEndChange") // console.log(value) // console.log(dateString) if(value==null){ this.setState({ end_time:undefined, deadline:undefined, }) return; } // if (moment(value, "YYYY-MM-DD HH:mm") <= moment()) { // this.setState({ // unit_e_tip: "截止时间不能早于当前时间", // p_flag: true, // borredss:"bor-reds", // end_time:undefined, // deadline:undefined, // }) // } else { // console.log(moment(value, "YYYY-MM-DD HH:mm")); // console.log(moment(this.state.publish_time, "YYYY-MM-DD HH:mm")); if (moment(value, "YYYY-MM-DD HH:mm") <= moment(this.state.publish_time, "YYYY-MM-DD HH:mm")) { this.setState({ unit_e_tip: "截止时间不能早于发布时间", p_flag: true, borredss:"bor-reds", end_time:value.format('YYYY-MM-DD HH:mm'), deadline:value.format('YYYY-MM-DD HH:mm'), }) return } try { this.setState({ unit_e_tip: "", p_flag: false, borredss:undefined, deadline: value.format('YYYY-MM-DD HH:mm'), }) } catch (e) { } this.setState({ end_time:moment(moment(handleDateString(dateString))).format("YYYY-MM-DD HH:mm"), }) // this.onChangedata('end_time', value, dateString); if(this.state.allowreplenishment === true){ this.setState({ deadline:moment(handleDateString(dateString)).format('YYYY-MM-DD HH:mm'), late_time:moment(handleDateString(dateString)).add(2, 'months'), late_times:moment(handleDateString(dateString)).add(2, 'months').format('YYYY-MM-DD HH:mm'), }) } // } } onEndChangeys = (value, dateString) => { if(value==null){ this.setState({ late_times:undefined, late_time:undefined, }) return; } let{publish_time,end_time,unifiedsetting,rulesdata}=this.state; if(unifiedsetting===true){ if (moment(value, "YYYY-MM-DD HH:mm") <= moment(publish_time)) { this.setState({ hand__e_tip: "补交时间不能早于发布时间", hand_flags: true, handclass:"bor-reds", late_times:value.format('YYYY-MM-DD HH:mm'), late_time:value.format('YYYY-MM-DD HH:mm'), }) } else if (moment(value, "YYYY-MM-DD HH:mm") <= moment(end_time)) { this.setState({ hand__e_tip: "补交时间不能早于截止时间", hand_flags: true, handclass:"bor-reds", late_times: value.format('YYYY-MM-DD HH:mm'), late_time:value.format('YYYY-MM-DD HH:mm'), }) } else { try { this.setState({ late_times: value.format('YYYY-MM-DD HH:mm'), late_time:value.format('YYYY-MM-DD HH:mm'), hand__e_tip: "", hand_flags: false, handclass:"", }) }catch (e) { } } }else{ rulesdata.map((item,key)=>{ if(item.publish_time!="Invalid date"){ if (moment(value, "YYYY-MM-DD HH:mm") <= moment(item.publish_time)) { console.log(moment(item.publish_time, "YYYY-MM-DD HH:mm") <= moment(publish_time)) let kes=key+1; this.setState({ hand__e_tip: "补交时间不能早于发布规则"+kes+"的发布时间", hand_flags: true, handclass:"bor-reds", }) return }else{ this.setState({ late_times: value.format('YYYY-MM-DD HH:mm'), late_time:value.format('YYYY-MM-DD HH:mm'), hand__e_tip: "", hand_flags: false, handclass:undefined, }) } } }) } } //立即发布 homeworkstart = () => { let homeworkid=this.props.match.params.homeworkid; let url="/homework_commons/"+homeworkid+"/publish_groups.json"; axios.get(url).then((response) => { if (response.status === 200) { const dataformat = 'YYYY-MM-DD HH:mm'; let starttime = this.props.getNowFormatDates(1); let endtime = this.props.getNowFormatDates(2); this.setState({ modalname: "立即发布", modaltype: response.data.course_groups === null || response.data.course_groups.length === 0 ? 2 : 1, OneSelftype: true, Topval:"学生将立即收到作业", // Botvalleft:"暂不发布", Botval:`本操作只对"未发布"的分班有效`, starttime: "发布时间:" + moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), starttimes:starttime, starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time, typs:"start", endtime: "截止时间:" + endtime, Cancelname: "暂不发布", Savesname: "立即发布", Cancel: this.homeworkhide, Saves: this.homeworkstartend, course_groups: response.data.course_groups, }) } }).catch((error) => { console.log(error) }); } //立即截止 homeworkends = () => { let homeworkid=this.props.match.params.homeworkid; let url="/homework_commons/"+homeworkid+"/end_groups.json"; axios.get(url).then((response) => { if (response.status === 200) { this.setState({}) this.setState({ modalname: "立即截止", modaltype: response.data.course_groups === null || response.data.course_groups.length === 0 ? 2 : 1, visible: true, Topval:"学生将不能再提交作业", // Botvalleft:"暂不截止", Botval:`本操作只对"提交中"的分班有效`, Cancelname: "暂不截止", Savesname: "立即截止", Cancel: this.homeworkhide, Saves: this.coursetaskend, starttime: undefined, endtime: undefined, typs:"end", course_groups: response.data.course_groups, }) } }).catch((error) => { console.log(error) }); } // 立即发布 homeworkstartend = (ds,endtime) => { var homeworkid = this.props.match.params.homeworkid; let data={} if(ds.length===0){ if(this.props.teacherdatapage.category.main===1){ data = { homework_ids: [homeworkid], end_time: endtime, } }else { data = { homework_ids: [homeworkid], end_time: endtime, category_id:this.props.teacherdatapage.category.category_id, } } }else{ if(this.props.teacherdatapage.category.main===1){ data={ homework_ids: [homeworkid], group_ids: ds, group_end_times:endtime, detail:true } }else{ data={ homework_ids: [homeworkid], group_ids: ds, group_end_times:endtime, category_id:this.props.teacherdatapage.category.category_id, detail:true } } } let coursesId = this.props.match.params.coursesId; let url = "/courses/" + coursesId + "/homework_commons/publish_homework.json"; axios.post(url,data).then((result) => { if (result.status === 200) { if (result.data.status === 0) { notification.open({ message:"提示", description:result.data.message }); this.homeworkhide(); this.getTrainingjobsetting(false); } } }).catch((error) => { console.log(error); }) } //立即截止确定按钮 coursetaskend = () => { var homeworkid = this.props.match.params.homeworkid; let {course_groupslist} = this.state; const cid = this.props.match.params.coursesId; let url = "/courses/" + cid + "/homework_commons/end_homework.json"; axios.post(url, { group_ids: course_groupslist, homework_ids: [homeworkid], }) .then((response) => { if (response.data.status == 0) { notification.open({ message:"提示", description:response.data.message }); // notification['success']({ // message:"提示", // description:response.data.message // }); this.getTrainingjobsetting(false); this.homeworkhide() } }) .catch(function (error) { console.log(error); }); } getcourse_groupslist = (id) => { this.setState({ course_groupslist: id }) } homeworkhide = () => { this.setState({ modalname: undefined, modaltype: undefined, visible: false, OneSelftype:false, Topval: undefined, Topvalright: undefined, Botvalleft: undefined, Botval: undefined, starttime: undefined, endtime: undefined, Cancelname: undefined, Savesname: undefined, Cancel: undefined, Saves: undefined, StudentList_value: undefined, addname: undefined, addnametype: false, addnametab: undefined, typs:undefined, starttimes:undefined, starttimesend:undefined, }) } cancelBox=()=>{ this.setState({ modalsType: false, modalsTopval: "", loadtype: false, }) } //编辑 editSetting = () => { try { if (this.state.jobsettingsdata.data.is_end === true) { this.setState({ modalsType: true, modalsTopval: "课堂已结束不能再修改!", loadtype: true, modalSave: this.cancelBox }) } else { var releasetime =true; var deadline = true; var endtime =true; var whethertopays =true; //发布时间 if(moment(this.state.publish_time,"YYYY-MM-DD HH:mm")<=moment()){ releasetime=false; } //截止时间 if(moment(this.state.end_time,"YYYY-MM-DD HH:mm")<=moment()){ deadline=false; } //结束时间 if(moment(this.state.late_time,"YYYY-MM-DD HH:mm")<=moment()){ endtime=false; } if(this.state.allowreplenishment === false){ whethertopays=false; } if(this.state.jobsettingsdata!==undefined){ } try { if(this.state.jobsettingsdata&& this.state.jobsettingsdata.data.homework_status[0]==="未发布"){ this.setState({ flagPageEditsbox:true, flagPageEdit: true, whethertopay:whethertopays, flagPageEditstwo:releasetime, flagPageEditsthrees:deadline, flagPageEditsfor:endtime, completionefficiencyscore:false, work_efficiencys:this.state.work_efficiencys, unifiedsetting:this.state.unifiedsetting, latedeductiontwo:this.state.latedeductiontwo, }); //均分比例 try { if(this.state.proportion==="均分比例"){ this.Equalproportion(this.state.latedeductiontwo); }else if(this.state.proportion==="经验值比例"){ this.Empiricalvalueratio(this.state.latedeductiontwo); } }catch (e) { } }else { this.setState({ flagPageEditsbox:true, flagPageEdit: true, whethertopay:whethertopays, flagPageEditstwo:releasetime, flagPageEditsthrees:deadline, flagPageEditsfor:endtime, unifiedsetting:this.state.unifiedsetting, }); if(this.state.work_efficiencys===true){ this.setState({ completionefficiencyscore:true, }) }else{ this.setState({ completionefficiencyscore:false, }) } } }catch (e) { this.setState({ flagPageEditsbox:true, flagPageEdit: true, whethertopay:whethertopays, flagPageEditstwo:releasetime, flagPageEditsthrees:deadline, flagPageEditsfor:endtime, unifiedsetting:this.state.unifiedsetting, }); if(this.state.work_efficiencys===true){ this.setState({ completionefficiencyscore:true, }) }else{ this.setState({ completionefficiencyscore:false, }) } } if(this.state.proportion === "自定义分值"){ this.setState({ boolUnitetwoname:"自定义分值", boolUnitetwo: false, flagPageEdits:true, }) } } } catch (e) { } }; //一进来就是老师要用的编辑页面 editSettings=(datas)=>{ // console.log("编辑页面"); // console.log(datas); try { if (datas.data.is_end === true) { this.setState({ modalsType: true, modalsTopval: "课堂已结束不能再修改!", loadtype: true, modalSave: this.cancelBox }) } else { // debugger var releasetime =true; var deadline = true; var endtime =true; var whethertopays =true; //发布时间 if(moment(datas.data.publish_time,"YYYY-MM-DD HH:mm")<=moment()){ releasetime=false; } //截止时间 if(moment(datas.data.end_time,"YYYY-MM-DD HH:mm")<=moment()){ deadline=false; } //结束时间 if(moment(datas.data.late_time,"YYYY-MM-DD HH:mm")<=moment()){ endtime=false; } if(datas.data.allow_late === false){ whethertopays=false; } try { if(datas.data&& datas.data.homework_status[0]==="未发布"){ this.setState({ flagPageEditsbox:true, flagPageEdit: true, whethertopay:whethertopays, flagPageEditstwo:releasetime, flagPageEditsthrees:deadline, flagPageEditsfor:endtime, completionefficiencyscore:datas.data.work_efficiency===true?true:false, work_efficiencys:datas.data.work_efficiency, unifiedsetting:datas.data.unified_setting, latedeductiontwo:datas.data.eff_score, }); //均分比例 // result.data.shixun_evaluation === 0 ? "均分比例" : result.data.shixun_evaluation === 1 ? "经验值比例" : result.data.shixun_evaluation === 2 ? try { if(datas.data.shixun_evaluation === 0){ this.Equalproportion(datas.data.eff_score); }else if(datas.data.shixun_evaluation === 1){ this.Empiricalvalueratio(datas.data.eff_score); } }catch (e) { console.log(1); console.log(e); } }else { this.setState({ flagPageEditsbox:true, flagPageEdit: true, whethertopay:whethertopays, flagPageEditstwo:releasetime, flagPageEditsthrees:deadline, flagPageEditsfor:endtime, unifiedsetting:datas.data.unified_setting, }); if(datas.data.work_efficiency===true){ this.setState({ completionefficiencyscore:true, }) }else{ this.setState({ completionefficiencyscore:false, }) } } }catch (e) { console.log(2); console.log(e); this.setState({ flagPageEditsbox:true, flagPageEdit: true, whethertopay:whethertopays, flagPageEditstwo:releasetime, flagPageEditsthrees:deadline, flagPageEditsfor:endtime, unifiedsetting:datas.data.unified_setting, }); if(datas.data.work_efficiency===true){ this.setState({ completionefficiencyscore:true, }) }else{ this.setState({ completionefficiencyscore:false, }) } } if(datas.data.shixun_evaluation === 2){ this.setState({ boolUnitetwoname:"自定义分值", boolUnitetwo: false, flagPageEdits:true, }) } } } catch (e) { console.log(3); console.log(e); } }; //取消编辑 cancelEdit = () => { this.setState({ flagPageEditsbox:false, flagPageEdit: false, flagPageEditstwo:false, flagPageEditsthrees:false, flagPageEditsfor:false, whethertopay:false, unit_p_tip: "", p_flag: false, borreds:undefined, borredss:undefined, hand__e_tip: "", hand_flags: false, handclass: undefined, completionefficiencyscore:false, latedeductiontwo:0, unit_e_tip: "", }) this.refs.targetElementTrainingjobsetting.scrollIntoView(); this.getTrainingjobsetting(false); } rulesCheckInfo=(rules)=>{ var datas=[]; for (var i=0;i{ this.setState({ showmodel:true }) } hideshowmodel=()=>{ this.setState({ showmodel:false }) } testscripttip =(e)=>{ if(e === 0){ this.setState({ testscripttiptype:true, }) }else { this.setState({ testscripttiptype:false, }) } } ChangeTab=(e)=>{ this.props.ChangeTab(e); } daochushixunbaogao=()=>{ let url =`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`; this.confirmysl(url, url + '&export=true'); } daochuzuoye =() =>{ let url = `/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`; this.confirmysl(url, url + '?export=true'); } confirmysl(url, urlWithExport){ axios.get(urlWithExport).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 dataformat = 'YYYY-MM-DD HH:mm'; let {flagPageEdit,testscripttiptype,publish_timebool,end_timebool,late_timesbool,work_efficiencys,flagPageEdits,flagPageEditstwo,flagPageEditsbox,whethertopay,handclass,flagPageEditsthrees, flagPageEditsfor,rules,rulest,unifiedsetting,group_settings, course_group,unit_e_tip, borreds,borredss,unit_p_tip, end_time, late_time, score_open, publish_time, starttimetype, modalsType, modalsTopval, loadtype, modalSave, endtimetype, latetimetype, allowlate, latepenaltytype, jobsettingsdata, endOpen, mystyle, mystyles} = this.state; // console.log(publish_timebool); // console.log(!flagPageEditstwo); const radioStyle = { display: 'block', height: '30px', lineHeight: '30px', color:"#666666" }; const radioStyles = { display: 'block', height: '30px', lineHeight: '30px', color:"#666666", marginLeft:'38px', }; // const startDate=moment(this.state.publish_time).format('YYYY-MM-DD HH:mm'); // const endDate =moment(this.state.publish_time).add('months',1).format('YYYY-MM-DD HH:mm'); // console.log("Trainingjobsetting"); // console.log(startDate); // console.log(endDate); // if( this.props.isAdmin() === true){ // this.editSetting(); // } // console.log(this.props.isAdmin()) // console.log(this.state.code_review===false) // console.log("引入的分值"); // console.log(this.state.work_efficiencys); return (
{this.state.showmodel===true?this.hideshowmodel()} />:""} {/**/} {/*立即发布*/} this.getcourse_groupslist(id)} starttimes={this.state.starttimes} starttimesend={this.state.starttimesend} typs={this.state.typs} /> {/*立即发布*/} {this.state.OneSelftype===true? this.getcourse_groupslist(id)} starttimes={this.state.starttimes} starttimesend={this.state.starttimesend} typs={this.state.typs} />:""}
{ !flagPageEdit && this.props.isAdmin() === true ? "" : }
{/*发布设置*/}

发布设置 { !flagPageEdit && this.props.isAdmin() === true ? 编辑设置 {/**/} : "" }

{ group_settings&&group_settings.length>0?
统一设置(选中则所有分班使用相同的发布设置,否则各个分班单独设置)
:
} { unifiedsetting === undefined ? "" : unifiedsetting=== true ?
发布时间:
(学生收到作业的时间)

{ unit_p_tip && unit_p_tip != "" ? { unit_p_tip } : "" }

截止时间:
(学生“按时”提交作品的时间截点)

{ unit_e_tip && unit_e_tip != "" ? { unit_e_tip } :"" }

:
this.rulesCheckInfo(info)} >
}
{/*补交设置*/}
补交设置
{/*value={this.state.allowreplenishment}*/}
开启补交 (选中,则允许学生延时提交作品)
迟交扣分: (延时提交作品时,学生成绩将被扣减的分值) {/*{latepenaltytype===true?
:""}*/}
{ whethertopay&& whethertopay === true ? :"" }
结束时间: (学生“延时”提交作品的时间截点) {/*{latetimetype===true?
结束时间不能小于截止时间
:""}*/}

{ this.state.hand__e_tip && this.state.hand__e_tip != "" ? { this.state.hand__e_tip }:"" }

{/*禁止补交*/}
{/*评分设置*/}
评分设置
关卡任务的选择和分值设置 (成绩 = 效率分+ 关卡任务总分)
效率分(选中,则学生最终成绩包含效率分)
分值

(学生工作效率= log(实训总得分/实训总耗时)
(学生效率分 = 学生工作效率 / 课堂学生最高工作效率 * 分值)

关卡任务分值设置规则 均分比例 难易度 自定义分值 {testscripttiptype===true?

若完成效率分值 = 10分, 则
均分比例: 根据任务数平均分配
例: 实训任务3关, 每关分值: 1/3*(100-10)=30分

难易度: 根据关卡经验值的高低确定关卡分值
例: 实训总经验值1200, 某关经验值200,
则其分值:200/1200*(100-10)=15分

自定义分值: 手动设置关卡分值

this.testscripttip(1)}>知道了

:""}
this.testscripttip(0)}>

关卡名称(需要学生完成的任务请选中,暂不支持跳关选择)

{this.state.challenge_settings === undefined ? "" : this.state.challenge_settings.map((object, index) => { return (
  • this.onChangedatasheet(value, index)} >{object.challenge_name} this.hangeTopicNametwodatasheet(value, index)} value={object.challenge_score} />
  • ) })}

    查看参考答案才通过评测的关卡扣分规则(学生通过评测后再查看参考答案,不对成绩产生影响)

    按查看答案级别扣分(根据学员选择查看的实训答案级别(解题思路、完整答案),扣减相应的分值) 不扣分
    {/*公开设置*/}
    公开设置
    公开成绩 (选中,则在作业截止/补交结束时间之后,已提交作品的学生可以查看其它学生的成绩,否则只能查看自己的成绩)
    { flagPageEdit && this.props.isAdmin() === true ?
    {/*提交*/} this.cancelEdit()}>取消
    : "" }
    ) } } export default Trainingjobsetting; //
    //
    // this.ChangeTab(0)}>作品列表 // this.ChangeTab(1)}>作业问答 // {this.props.isAdmin()?this.state.code_review===true||jobsettingsdata === undefined ? [""] : jobsettingsdata.data.homework_status[0]==="未发布"?"": this.ChangeTab(2)}>代码查重 : ""} // // this.ChangeTab(3)} // >设置 // // {this.props.isAdmin() ?
  • // 导出 // //
  • : ""} // {this.props.isAdmin() ?jobsettingsdata&&jobsettingsdata.data.end_immediately===true? // 立即截止 // : "": ""} // {this.props.isAdmin() ?jobsettingsdata&&jobsettingsdata.data.publish_immediately===true? // 立即发布: "" : ""} // {this.props.isAdmin()? // jobsettingsdata&&jobsettingsdata.data.code_review===true? // 代码查重: "":""} // { // jobsettingsdata&& jobsettingsdata&&jobsettingsdata.data === undefined ? "" // : jobsettingsdata&& jobsettingsdata.data.commit_des === null || jobsettingsdata&& jobsettingsdata.data.commit_des === undefined ? "" : // { jobsettingsdata&& jobsettingsdata.data.commit_des} // } // { jobsettingsdata&&jobsettingsdata.data === undefined ? "" : } {/*
    */} {/*
    */}