fix: multiple non-numeric problems of the same type should also route to the advanced editor. TNL-10401.

This commit is contained in:
Ken Clary
2023-01-26 12:28:55 -05:00
parent 83acc741f5
commit 3b9681618c
3 changed files with 24 additions and 4 deletions

View File

@@ -330,8 +330,8 @@ export class OLXParser {
getProblemType() {
const problemKeys = Object.keys(this.problem);
const intersectedProblems = _.intersection(Object.values(ProblemTypeKeys), problemKeys);
if (intersectedProblems.length === 0) {
const problemTypeKeys = problemKeys.filter(key => Object.values(ProblemTypeKeys).indexOf(key) !== -1);
if (problemTypeKeys.length === 0) {
// a blank problem is a problem which contains only `<problem></problem>` as it's olx.
// blank problems are not given types, so that a type may be selected.
if (problemKeys.length === 1 && problemKeys[0] === '#text' && this.problem[problemKeys[0]] === '') {
@@ -341,10 +341,14 @@ export class OLXParser {
return ProblemTypeKeys.ADVANCED;
}
// make sure compound problems are treated as advanced
if (intersectedProblems.length > 1) {
// TODO: Find a way to add answers using additional_answers v/s numericalresponse
if ((problemTypeKeys.length > 1)
|| (problemTypeKeys[0] !== ProblemTypeKeys.NUMERIC // multiple numeric problems are really just multiple answers
&& _.isArray(this.problem[problemTypeKeys[0]])
&& this.problem[problemTypeKeys[0]].length > 1)) {
return ProblemTypeKeys.ADVANCED;
}
const problemType = intersectedProblems[0];
const problemType = problemTypeKeys[0];
return problemType;
}