From bf1af80b41108a935d15fa1294bd765091eed9fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Tue, 3 Sep 2019 13:57:39 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../modules/courses/poll/PollNewQuestbank.js | 242 ++++++++++++++----
1 file changed, 192 insertions(+), 50 deletions(-)
diff --git a/public/react/src/modules/courses/poll/PollNewQuestbank.js b/public/react/src/modules/courses/poll/PollNewQuestbank.js
index 81aa4d9fc..331478cab 100644
--- a/public/react/src/modules/courses/poll/PollNewQuestbank.js
+++ b/public/react/src/modules/courses/poll/PollNewQuestbank.js
@@ -1014,7 +1014,37 @@ class PollNewQuestbank extends Component {
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 = [];
@@ -1214,6 +1244,37 @@ class PollNewQuestbank extends Component {
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 = [];
@@ -1502,7 +1563,37 @@ class PollNewQuestbank extends Component {
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 = [];
@@ -1673,6 +1764,37 @@ class PollNewQuestbank extends Component {
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,60 +2362,76 @@ class PollNewQuestbank extends Component {
}
//最小值
HandleGradationGroupChangee = (value, index, max, length) => {
+ // console.log("最小值");
+ // console.log(value);
+ // console.log(index);
+ // console.log(max);
+ // console.log(length);
+
+ // debugger
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 {
- for (var i = 0; i < arr.length; i++) {
- if (index === i) {
- arr[i].question.min_choices = parseInt(value);
- arr[i].question.max_choices = length;
- break;
- }
+ // 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;
+ break;
}
- this.setState({
- adddom: arr
- })
}
+ this.setState({
+ adddom: arr
+ })
+ // }
+
}
//最大值
HandleGradationGroupChangeee = (value, index, minchoices, length) => {
+ // console.log("2112");
+ // console.log(value);
+ // console.log(minchoices);
+ // console.log("最大值");
+ // console.log(value);
+ // console.log(index);
+ // console.log(minchoices);
+ // console.log(length);
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);
- arr[i].question.max_choices = parseInt(value);
- }
+ // 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);
@@ -2830,8 +2968,13 @@ class PollNewQuestbank extends Component {
className="color-grey-9 fl">{item.question.question_type === 1 ? "单选题" : item.question.question_type === 2 ? "多选题" : "主观题"}
{item.question.is_necessary === 1 ? "(必答)" : 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 + "-" + item.question.max_choices + "项")}
+ {
+ 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 === 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) + "项")}
+ : ""
+ }
+
{
polls_status === undefined || polls_status === 1 ?
@@ -3106,7 +3249,7 @@ class PollNewQuestbank extends Component {
{item.question.is_necessary === 1 ? "(必答)" : 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 === 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) + "项")}
+ {
+ 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 === 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) + "项")}
+ : ""
+ }
+
{
polls_status === undefined || polls_status === 1 ?