Commit 3f0e8b5e authored by 黄奎's avatar 黄奎

页面修改

parent 1ec9e74c
......@@ -250,6 +250,7 @@ export function judgeValidate(gName, detailsList) {
}
return message;
}
/**
* 【简答题、名词解释、论述题、计算题、其它题】验证
*/
......@@ -440,3 +441,249 @@ export function sharingchooseValidate(gName, detailsList) {
}
return message;
}
/**
*【题库使用--单题目验证】 (单选题、多选题、数字选择题 验证)
*/
export function questionBankChooseValidate(gName, AnswerList, qObj) {
var message = "";
if (qObj && qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
if (AnswerList && AnswerList.length > 0) {
var Num = 0;
for (let j = 0; j < AnswerList.length; j++) {
if (AnswerList[j].Content == '') {
message = `请填写【${gName}】,选项 ${AnswerList[j].Name} 内容!`;
return message;
}
if (AnswerList[j].IsAnswer) {
Num++
}
}
if (Num == 0) {
message = `请设置【${gName}】正确答案!`;
return message;
}
}
return message;
}
/**
* 【题库使用--单题目验证】 (填空题、分录题、资料题 验证)
*/
export function questionBankFillInValidate(gName, AnswerList, qObj) {
var message = "";
if (qObj && qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
if (AnswerList && AnswerList.length > 0) {
for (let j = 0; j < AnswerList.length; j++) {
if (AnswerList[j].Content == '') {
message = `请填写【${gName}】,第 ${j+1} 空 答案!`;
return message;
}
}
}
return message;
}
/**
* 【题库使用--单题目验证】 (判断题 验证)
*/
export function questionBankJudgeValidate(gName, qObj) {
var message = "";
if (qObj && qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
return message;
}
/**
* 【题库使用--单题目验证】 (简答题、名词解释、论述题、计算题、其它题 验证)
*/
export function questionBankShortanswerValidate(gName, qObj) {
var message = "";
if (qObj) {
if (qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
if (qObj.Answer == '') {
message = `请填写【${gName}】问题答案!`;
return message;
}
}
return message;
}
/**
* 【题库使用--单题目验证】 (连线题 验证)
*/
export function questionBankMatchingValidate(gName, AnswerList, qObj) {
var message = "";
if (qObj && qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
if (AnswerList) {
if (AnswerList.length > 0) {
for (let p = 0; p < AnswerList[0].length; p++) {
if (AnswerList[0][p].Content == '') {
message = `请填写【${gName}】 第一组 选项 ${AnswerList[0][p].Name} 内容!`
return message;
}
}
}
if (AnswerList.length > 1) {
for (let p = 0; p < AnswerList[1].length; p++) {
if (AnswerList[1][p].Content == '') {
message = `请填写【${gName}】 第二组 选项 ${AnswerList[1][p].Name} 内容!`
return message;
}
}
}
}
return message;
}
/**
* 【题库使用--单题目验证】 (排序题 验证)
*/
export function questionBankSortingproblemValidate(gName, AnswerList, qObj) {
var message = "";
if (qObj && qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
if (AnswerList && AnswerList.length > 0) {
for (let j = 0; j < AnswerList[0].length; j++) {
if (AnswerList[0][j].Content == '') {
message = `请填写【${gName}】 选项 ${AnswerList[0][j].Name} 内容!`
return message;
}
}
}
return message;
}
/**
*【题库使用--单题目验证】 (完型填空 验证)
*/
export function questionBankClozeValidate(gName, AnswerList, qObj) {
var message = "";
if (qObj && qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
if (AnswerList && AnswerList.length > 0) {
for (let j = 0; j < AnswerList.length; j++) {
var Num = 0;
for (var k = 0; k < AnswerList[j].length; k++) {
if (AnswerList[j][k].Content == '') {
message =
`请填写【${gName}】第 ${j+1} 小题 选项 ${AnswerList[j][k].Name} 内容!`;
return message;
}
if (AnswerList[j][k].IsAnswer) {
Num++
}
}
if (Num == 0) {
message = `请设置【${gName}】,第 ${j+1} 小题 正确答案!`;
return message;
}
}
}
return message;
}
/**
* 【题库使用--单题目验证】 (阅读理解、听力题 验证)
*/
export function questionBankReadingcomprehensioValidate(gName, AnswerList, qObj) {
var message = "";
if (qObj && qObj.Title == '') {
message = `请填写【${gName}】问题内容!`;
return message;
}
if (AnswerList && AnswerList.length > 0) {
for (let i = 0; i < AnswerList.length; i++) {
var subQuestion = AnswerList[i];
if (subQuestion) {
if (subQuestion.SubTitle == '') {
message = `请填写【${gName}】,第 ${i+1} 小题 问题内容!`;
return message;
}
//单选题、多选题
if (subQuestion.QuestionKey == 'single' || subQuestion.QuestionKey == "multiple") {
var singleNum = 0;
for (var k = 0; k < subQuestion.SubAnwser.length; k++) {
if (subQuestion.SubAnwser[k].Content == '') {
message = `请填写【${gName}】,第 ${i+1} 小题 选项 ${subQuestion.SubAnwser[k].Name} 内容!`;
return message;
}
if (subQuestion.SubAnwser[k].IsAnswer) {
singleNum++
}
}
if (singleNum == 0) {
message = `请设置【${gName}】,第 ${i+1} 小题 正确答案!`;
return message;
}
}
//填空题
if (subQuestion.QuestionKey == "fill-in") {
for (var k = 0; k < subQuestion.SubAnwser.length; k++) {
if (subQuestion.SubAnwser[k].Content == '') {
message = `请填写【${gName}】,第 ${i+1} 小题 第 ${k+1} 空答案!`;
return message;
}
}
}
//简答题
if (subQuestion.QuestionKey == "short-answer") {
for (var k = 0; k < subQuestion.SubAnwser.length; k++) {
if (subQuestion.SubAnwser[k].Content == '') {
message = `请填写【${gName}】,第 ${i+1} 小题答案!`;
return message;
}
}
}
}
}
}
return message;
}
/**
* 【题库使用--单题目验证】 (公用选项题 验证)
*/
export function questionBankSharingchooseValidate(gName, AnswerList) {
var message = "";
if (AnswerList && AnswerList.length > 0) {
for (var j = 0; j < AnswerList[0].length; j++) {
if (AnswerList[0][j].Content == '') {
message = `请填写【${gName}】,第一组 选项 ${AnswerList[0][j].Name} 内容!`;
return message;
}
}
for (var j = 0; j < AnswerList[1].length; j++) {
if (AnswerList[1][j].Content == '') {
message = `请填写【${gName}】,第二组 题干 ${j+1} 内容!`;
return message;
}
if (AnswerList[1][j].Name == '') {
message = `请选择【${gName}】, 第二组 题干 ${j+1} 答案!`;
return message;
}
}
return message;
}
}
......@@ -246,6 +246,15 @@
} from '../../api/question/question'
import {
CreateQuestion, //生成问题
questionBankChooseValidate, //【单选题、多选题、数字选择题】验证
questionBankFillInValidate, //【填空题、分录题、资料题】验证
questionBankJudgeValidate, //【判断题】验证
questionBankShortanswerValidate, //【简答题、名词解释、论述题、计算题、其它题】验证
questionBankMatchingValidate, //【连线题】验证
questionBankSortingproblemValidate, //【排序题】验证
questionBankClozeValidate, //【完型填空】验证
questionBankReadingcomprehensioValidate, //【阅读理解、听力题】验证
questionBankSharingchooseValidate, //【公用选项题】验证
} from '../../api/question/questionconfig'
import UeEditor from '../editor/UeEditor'
//知识点列表
......@@ -511,315 +520,102 @@
})
}
},
//验证
validateType() {
//连线题
var result = true;
if (this.objOption.QuestionTypeKey == 'matching') {
if (this.objOption.QuestionContent) {
var myArr = JSON.parse(this.objOption.QuestionContent);
for (var i = 0; i < myArr[0].length; i++) {
if (myArr[0][i].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `第一组第${i+1}行数据内容为空!`
})
result = false;
return;
}
}
if (this.isRepeat(myArr[0], 1)) {
result = this.isRepeat(myArr[0], 1);
} else {
return;
}
for (var i = 0; i < myArr[1].length; i++) {
if (myArr[1][i].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `第二组第${i+1}行数据内容为空!`
})
result = false;
return;
}
}
if (this.isRepeat(myArr[1], 2)) {
result = this.isRepeat(myArr[1], 2);
} else {
return;
}
}
}
//公用选择题
if (this.objOption.QuestionTypeKey == 'sharing-choose') {
if (this.objOption.QuestionContent) {
var myArr = JSON.parse(this.objOption.QuestionContent);
for (var i = 0; i < myArr[0].length; i++) {
if (myArr[0][i].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `选项内容不能为空!`
})
result = false;
return;
}
}
if (this.isRepeat(myArr[0], 3)) {
result = this.isRepeat(myArr[0], 3);
} else {
return;
}
for (var i = 0; i < myArr[1].length; i++) {
if (myArr[1][i].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `题干内容不能为空!`
})
result = false;
return;
}
}
if (this.isRepeat(myArr[1], 4)) {
result = this.isRepeat(myArr[1], 4);
} else {
return;
}
}
}
//其他何口语题
if (this.objOption.QuestionTypeKey == 'other' || this.objOption.QuestionTypeKey == 'spoken') {
if (this.objOption.Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入试题的题干`
})
result = false;
return;
}
}
//听力题 阅读理解
if (this.objOption.QuestionTypeKey == 'listening' || this.objOption.QuestionTypeKey == 'reading-comprehensio') {
if (this.objOption.QuestionContent) {
var myArr = JSON.parse(this.objOption.QuestionContent);
for (var i = 0; i < myArr.length; i++) {
if (myArr[i].SubTitle == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入第${i+1}小题题干!`
})
result = false;
return;
}
for (var j = 0; j < myArr[i].SubAnwser.length; j++) {
if (myArr[i].SubAnwser[j].Content === '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入第${i+1}小题选项`
})
result = false;
return;
}
}
if (this.isRepeat(myArr[i].SubAnwser, 3)) {
result = this.isRepeat(myArr[i].SubAnwser, 3);
} else {
return;
}
}
}
}
//口语题
if (this.objOption.QuestionTypeKey == 'spoken') {
if (this.objOption.Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入试题的题干`
})
result = false;
return;
}
}
//阅读理解
if (this.objOption.QuestionTypeKey == 'cloze') {
if (this.objOption.Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入试题的题干`
})
result = false;
return;
}
if (this.objOption.QuestionContent) {
var myArr = JSON.parse(this.objOption.QuestionContent);
for (var i = 0; i < myArr.length; i++) {
for (var j = 0; j < myArr[i].length; j++)
if (myArr[i][j].Content === '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入第${i+1}小题选项`
})
result = false;
return;
}
if (this.isRepeat(myArr[i], 3)) {
result = this.isRepeat(myArr[i], 3);
} else {
return;
}
}
}
}
//排序题
if (this.objOption.QuestionTypeKey == 'sorting-problem') {
if (this.objOption.Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入试题的题干`
})
result = false;
return;
}
if (this.objOption.QuestionContent) {
var myArr = JSON.parse(this.objOption.QuestionContent);
for (var i = 0; i < myArr[0].length; i++) {
if (myArr[0].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入试题选项`
})
result = false;
return;
}
if (this.isRepeat(myArr[0], 3)) {
result = this.isRepeat(myArr[0], 3);
} else {
return;
}
}
}
}
//资料提 分录题 多选题
if (this.objOption.QuestionTypeKey == 'data-question' || this.objOption.QuestionTypeKey == 'entry-problem' ||
this.objOption.QuestionTypeKey == 'multiple' ||
this.objOption.QuestionTypeKey == 'single') {
if (this.objOption.Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入题干!`
})
result = false;
return;
}
if (this.objOption.QuestionContent) {
var myArr = JSON.parse(this.objOption.QuestionContent);
for (var i = 0; i < myArr.length; i++) {
if (myArr[i].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入第${i+1}的选项!`
})
result = false;
return;
}
if (this.isRepeat(myArr, 3)) {
result = this.isRepeat(myArr, 3);
} else {
return;
}
}
}
}
//计算题
if (this.objOption.QuestionTypeKey == 'calculation' || this.objOption.QuestionTypeKey == 'essay-question' ||
this.objOption.QuestionTypeKey == 'noun-explanation') {
if (this.objOption.Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入题干!`
})
result = false;
return;
}
if (this.objOption.Answer == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入回答!`
})
result = false;
return;
}
}
//判断题
if (this.objOption.QuestionTypeKey == 'judge') {
if (this.objOption.Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请输入题干!`
})
result = false;
return;
}
}
return result;
},
//js 判断重复
isRepeat(Arr, type) {
var result = true;
var msg = '';
switch (type) {
case 1:
msg = '第1组数据选项不能相同'
var newKey = this.objOption.QuestionTypeKey;
var gName = this.questionName;
var detailsList = this.AnswerList;
var retMessage = "";
switch (newKey) {
//单选题
case "single":
retMessage = questionBankChooseValidate(gName, detailsList, this.objOption);
break;
case 2:
msg = '第2组数据选项不能相同'
//多选题
case 'multiple':
retMessage = questionBankChooseValidate(gName, detailsList, this.objOption);
break;
case 3:
msg = '选项内容不能相同'
//填空题
case "fill-in":
retMessage = questionBankFillInValidate(gName, detailsList, this.objOption);
break;
case 4:
msg = '题干内容不能相同!';
//判断题
case "judge":
retMessage = questionBankJudgeValidate(gName, this.objOption);
break;
//简答题
case "short-answer":
retMessage = questionBankShortanswerValidate(gName, this.objOption);
break;
//名词解释
case "noun-explanation":
retMessage = questionBankShortanswerValidate(gName, this.objOption);
break;
//论述题
case "essay-question":
retMessage = questionBankShortanswerValidate(gName, this.objOption);
break;
//计算题
case "calculation":
retMessage = questionBankShortanswerValidate(gName, this.objOption);
break;
//分录题
case "entry-problem":
retMessage = questionBankFillInValidate(gName, detailsList, this.objOption);
break;
//资料题
case "data-question":
retMessage = questionBankFillInValidate(gName, detailsList, this.objOption);
break;
//连线题
case "matching":
retMessage = questionBankMatchingValidate(gName, detailsList, this.objOption);
break;
//排序题
case "sorting-problem":
retMessage = questionBankSortingproblemValidate(gName, detailsList,this.objOption);
break;
//完型填空
case "cloze":
retMessage = questionBankClozeValidate(gName, detailsList,this.objOption);
break;
//阅读理解
case "reading-comprehensio":
retMessage = questionBankReadingcomprehensioValidate(gName, detailsList,this.objOption);
break;
//口语题
case "spoken":
retMessage = questionBankShortanswerValidate(gName, this.objOption);
break;
//听力题
case "listening":
retMessage = questionBankReadingcomprehensioValidate(gName, detailsList,this.objOption);
break;
//公用选项题
case "sharing-choose":
retMessage = questionBankSharingchooseValidate(gName, detailsList);
break;
//其它题
case "other":
retMessage = questionBankShortanswerValidate(gName, this.objOption);
break;
//单选题-数字
case "single-number":
retMessage = questionBankChooseValidate(gName, detailsList,this.objOption);
break;
default:
}
let num = 0;
for (var i = 0; i < Arr.length - 1; i++) {
for (var j = i + 1; j < Arr.length; j++) {
if (Arr[i].Content === Arr[j].Content) {
this.$q.notify({
type: 'negative',
position: "top",
message: msg
})
num++;
}
}
}
if (num > 0) {
if (retMessage != '') {
this.$q.notify({
type: 'negative',
position: "top",
message: retMessage
});
result = false;
} else {
result = true;
return;
}
return result;
}
},
},
}
......
......@@ -650,7 +650,6 @@
sItem.Score = avgScore;
})
}
},
//上移下移(IsUp:0上移,1下移)
MoveFatherItem(subIndex, IsUp) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment