diff --git a/packages/ui-default/pages/problem_detail.page.jsx b/packages/ui-default/pages/problem_detail.page.jsx index 977922785..b3cca2cf3 100644 --- a/packages/ui-default/pages/problem_detail.page.jsx +++ b/packages/ui-default/pages/problem_detail.page.jsx @@ -205,29 +205,48 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor async function loadObjectiveNew() { $('.outer-loader-container').show(); const ans = {}; - let objectiveNum = 0; + let objNum = 0; + const reg = /{{ (input|select|multiselect)\([a-zA-Z0-9]+\) }}/g; $('.problem-content .typo').children().each((i, e) => { - if (e.innerText.includes('{{ input }}')) { - objectiveNum++; - $(e).text($(e).text().replace(/{{ input }}/g, '?')); - $(e).after(`
- -
`); + if (e.tagName === 'PRE' && !e.children[0].className.includes('#input')) return; + const objQuestions = []; + let objQuestion = reg.exec(e.innerText); + while (objQuestion != null) { + objQuestions.push(objQuestion); + objQuestion = reg.exec(e.innerText); } - if (e.innerText.includes('{{ select }}')) { - objectiveNum++; - $(e).text($(e).text().replace(/{{ select }}/g, '')); - $(e).next('ul').children().each((j, ele) => { - $(ele).after(`
+ objQuestions.forEach((obj) => { + objNum++; + const [objData, objType] = obj; + const objID = objData.replace(/{{ (input|select|multiselect)\(([a-zA-Z0-9]+)\) }}/, '$2'); + if (objType === 'input') { + $(e).html($(e).html().replace(objData, `
+ +
`)); + } else if (objType === 'select') { + $(e).html($(e).html().replace(objData, `Question${objNum}_${objID}:`)); + $(e).next('ul').children().each((j, ele) => { + $(ele).after(`
+ ${String.fromCharCode(65 + j)}. + + ${ele.innerHTML} +
`); + $(ele).remove(); + }); + } else if (objType === 'multiselect') { + $(e).html($(e).html().replace(objData, `Question${objNum}_${objID}:`)); + $(e).next('ul').children().each((j, ele) => { + $(ele).after(`
${String.fromCharCode(65 + j)}. - + ${ele.innerHTML}
`); - $(ele).remove(); - }); - } + $(ele).remove(); + }); + } + }); }); - if (objectiveNum) { + if (objNum) { $('.problem-content .typo').append(document.getElementsByClassName('nav__item--round').length ? '' : '');