Skip to content
Snippets Groups Projects
Commit 06db8cbd authored by Jenny Zhang's avatar Jenny Zhang
Browse files

fixed the problem in translating the standardAnswer from ast to string, so now validator works well

parent 67737df2
No related branches found
No related tags found
No related merge requests found
......@@ -77,7 +77,7 @@ export default {
localVisible: this.visible,
ruleFunction: null,
selectedRule: '',
standardAnswer: null,
standardAnswer: '',
expressions: [], // parsed expressions
currentExpression: '',
answers: [], // original user input string
......@@ -108,16 +108,21 @@ export default {
this.localVisible = newVal;
},
closeDialog() {
console.log("cancel clicked");
console.log(this.statement);
console.log(this.ruleFunction);
console.log(this.conclusionString);
console.log(this.expressions);
console.log(this.answers);
this.selectedRule = '';
clean() {
this.ruleFunction = null;
this.selectedRule = '';
this.standardAnswer = '';
this.expressions = [];
this.currentExpression = '';
this.answers = [];
this.currentAnswer = '';
this.errorMsg = '';
this.msg = '';
},
closeDialog() {
this.localVisible = false;
this.clean();
},
// 新增的方法
......@@ -132,7 +137,6 @@ export default {
if (this.currentAnswer) {
this.answers.push(this.currentAnswer);
this.currentAnswer = '';
this.errorMsg = '';
}
},
......@@ -177,20 +181,36 @@ export default {
}
// list of strings
this.standardAnswer.forEach(answer => { ast.astsToString(answer); });
this.standardAnswer = this.standardAnswer.map(answer => ast.astsToString(answer));
this.standardAnswer.sort();
this.answers.sort();
console.log(this.statement);
console.log(this.ruleFunction);
console.log(this.conclusionString);
console.log(this.expressions);
console.log(this.answers);
console.log("standard answer result:", JSON.stringify(this.standardAnswer, null, 2));
for (let i = 0; i < this.standardAnswer.length; i++) {
console.log(this.answers[i]);
console.log(this.standardAnswer[i]);
const output = validator(this.standardAnswer[i], this.answers[i]);
if (!output[0]) {
this.errorMsg = output[1];
this.errorMsg = "Incorrect answer in statement " + this.answers[i] + output[1];
return;
}
}
this.msg = 'Correct answer';
this.selectedRule = '';
this.ruleFunction = null;
this.expressions = [];
this.answers = [];
this.standardAnswer = null;
return;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment