diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index 372a79ae6..8b0956ba4 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -995,6 +995,37 @@ class PollNew extends Component { } + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } var questiontwo = {}; var other = []; var option = []; @@ -1196,6 +1227,40 @@ class PollNew extends Component { } } } + + + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + // if (object.question.max_choices < object.question.min_choices) { // this.props.showNotification('可选的最大限制不能小于最小限制!'); // @@ -1482,11 +1547,44 @@ class PollNew extends Component { if(object.question.max_choices>0){ if (object.question.max_choices < object.question.min_choices) { this.props.showNotification(`可选的最大限制不能小于最小限制`); + return; + } + } + } + + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); return; + } } + } + + // if (object.question.max_choices < object.question.min_choices) { // this.props.showNotification(`可选的最大限制不能小于最小限制`); // @@ -1665,11 +1763,38 @@ class PollNew extends Component { } } } - // if (object.question.max_choices < object.question.min_choices) { - // this.props.showNotification(`可选的最大限制不能小于最小限制`); - // - // return; - // } + + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } var questiontwo = {}; var other = []; var option = []; @@ -2240,34 +2365,34 @@ class PollNew extends Component { var minbool = false; var maxbool = false; let arr = this.state.adddom; - if (parseInt(value) === 0 || parseInt(value) === "0" || parseInt(value) === null || parseInt(value) === undefined || parseInt(value) < 1) { - minbool = true; - } - if (max === 0 || max === "0" || max === null || max === undefined) { - maxbool = true; - } - - if (minbool === true && maxbool === true) { - for (var i = 0; i < arr.length; i++) { - if (index === i) { - arr[i].question.min_choices = parseInt(value); - } - } - this.setState({ - adddom: arr - }) - } else { + // if (parseInt(value) === 0 || parseInt(value) === "0" || parseInt(value) === null || parseInt(value) === undefined || parseInt(value) < 1) { + // minbool = true; + // } + // if (max === 0 || max === "0" || max === null || max === undefined) { + // maxbool = true; + // } + // + // if (minbool === true && maxbool === true) { + // for (var i = 0; i < arr.length; i++) { + // if (index === i) { + // arr[i].question.min_choices = parseInt(value); + // } + // } + // this.setState({ + // adddom: arr + // }) + // } else { for (var i = 0; i < arr.length; i++) { if (index === i) { arr[i].question.min_choices = parseInt(value); - arr[i].question.max_choices = length; + // arr[i].question.max_choices = length; break; } } this.setState({ adddom: arr }) - } + // } } @@ -2284,21 +2409,21 @@ class PollNew extends Component { let arr = this.state.adddom; for (var i = 0; i < arr.length; i++) { if (index === i) { - if(parseInt(value)===0&&parseInt(minchoices)===0){ - arr[i].question.min_choices= parseInt(0); - arr[i].question.max_choices = parseInt(0); - }else if(parseInt(minchoices)===0){ - arr[i].question.min_choices= parseInt(2); - arr[i].question.max_choices = parseInt(value); - } - else if(parseInt(value)===0&&parseInt(minchoices)>0){ - arr[i].question.min_choices= parseInt(minchoices); - arr[i].question.max_choices = parseInt(value); - } - else { - arr[i].question.min_choices= minchoices===null?2:minchoices===undefined?2:minchoices===0?2:parseInt(minchoices); + // if(parseInt(value)===0&&parseInt(minchoices)===0){ + // arr[i].question.min_choices= parseInt(0); + // arr[i].question.max_choices = parseInt(0); + // }else if(parseInt(minchoices)===0){ + // arr[i].question.min_choices= parseInt(2); + // arr[i].question.max_choices = parseInt(value); + // } + // else if(parseInt(value)===0&&parseInt(minchoices)>0){ + // arr[i].question.min_choices= parseInt(minchoices); + // arr[i].question.max_choices = parseInt(value); + // } + // else { + // arr[i].question.min_choices= minchoices===null?2:minchoices===undefined?2:minchoices===0?2:parseInt(minchoices); arr[i].question.max_choices = parseInt(value); - } + // } } } // console.log(2119); @@ -2777,7 +2902,7 @@ class PollNew extends Component { { item.question.question_type === 2? {(item.question.min_choices === undefined && item.question.max_choices === undefined ? "不限制" : item.question.min_choices === null && item.question.max_choices === null ? "不限制" : item.question.min_choices === 0 && item.question.max_choices === 0 ? "": item.question.min_choices === "null" && item.question.max_choices === "null" ? "不限制" : "可选" +(item.question.min_choices===undefined||item.question.min_choices===null||item.question.min_choices===""||item.question.min_choices==="null"?2:item.question.min_choices) + "-" + (item.question.max_choices===undefined||item.question.max_choices===null||item.question.max_choices===""||item.question.max_choices==="null"?item.question.answers.length:item.question.max_choices) + "项")} + className="font-16 mt10 ml10">{(item.question.min_choices === undefined && item.question.max_choices === undefined ? "不限制" : item.question.min_choices === null && item.question.max_choices === null ? "不限制" : item.question.min_choices === 0 && item.question.max_choices === 0 ? "": item.question.min_choices === "null" && item.question.max_choices === "null" ? "不限制" : item.question.min_choices === item.question.max_choices && item.question.max_choices === item.question.min_choices ? "可选"+(item.question.max_choices)+"项" : "可选" +(item.question.min_choices===undefined||item.question.min_choices===null||item.question.min_choices===""||item.question.min_choices==="null"?2:item.question.min_choices) + "-" + (item.question.max_choices===undefined||item.question.max_choices===null||item.question.max_choices===""||item.question.max_choices==="null"?item.question.answers.length:item.question.max_choices) + "项")} : "" }