mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: add multiselect question
This commit is contained in:
1 parent
c01f8042ce
commit
e509bde41b
1 file changed
+36
-17
@@ -205,29 +205,48 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
|||||||
async function loadObjectiveNew() {
|
async function loadObjectiveNew() {
|
||||||
$('.outer-loader-container').show();
|
$('.outer-loader-container').show();
|
||||||
const ans = {};
|
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) => {
|
$('.problem-content .typo').children().each((i, e) => {
|
||||||
if (e.innerText.includes('{{ input }}')) {
|
if (e.tagName === 'PRE' && !e.children[0].className.includes('#input')) return;
|
||||||
objectiveNum++;
|
const objQuestions = [];
|
||||||
$(e).text($(e).text().replace(/{{ input }}/g, '?'));
|
let objQuestion = reg.exec(e.innerText);
|
||||||
$(e).after(`<div class="objective_${objectiveNum} medium-7">
|
while (objQuestion != null) {
|
||||||
<input type="text" placeholder="${objectiveNum}. ?" name="${objectiveNum}" class="textbox objective-input">
|
objQuestions.push(objQuestion);
|
||||||
</div>`);
|
objQuestion = reg.exec(e.innerText);
|
||||||
}
|
}
|
||||||
if (e.innerText.includes('{{ select }}')) {
|
objQuestions.forEach((obj) => {
|
||||||
objectiveNum++;
|
objNum++;
|
||||||
$(e).text($(e).text().replace(/{{ select }}/g, ''));
|
const [objData, objType] = obj;
|
||||||
$(e).next('ul').children().each((j, ele) => {
|
const objID = objData.replace(/{{ (input|select|multiselect)\(([a-zA-Z0-9]+)\) }}/, '$2');
|
||||||
$(ele).after(`<div class="objective_${objectiveNum} radiobox">
|
if (objType === 'input') {
|
||||||
|
$(e).html($(e).html().replace(objData, `<div class="objective_${objID} medium-3" style="display: inline-block;">
|
||||||
|
<input type="text" placeholder="Question${objNum} ${objID}" name="${objID}" class="textbox objective-input">
|
||||||
|
</div>`));
|
||||||
|
} else if (objType === 'select') {
|
||||||
|
$(e).html($(e).html().replace(objData, `Question${objNum}_${objID}:`));
|
||||||
|
$(e).next('ul').children().each((j, ele) => {
|
||||||
|
$(ele).after(`<div class="objective_${objID} radiobox">
|
||||||
|
${String.fromCharCode(65 + j)}.
|
||||||
|
<input type="radio" name="${objID}" class="objective-input" value="${String.fromCharCode(65 + j)}">
|
||||||
|
${ele.innerHTML}
|
||||||
|
</div>`);
|
||||||
|
$(ele).remove();
|
||||||
|
});
|
||||||
|
} else if (objType === 'multiselect') {
|
||||||
|
$(e).html($(e).html().replace(objData, `Question${objNum}_${objID}:`));
|
||||||
|
$(e).next('ul').children().each((j, ele) => {
|
||||||
|
$(ele).after(`<div class="objective_${objID} radiobox">
|
||||||
${String.fromCharCode(65 + j)}.
|
${String.fromCharCode(65 + j)}.
|
||||||
<input type="radio" name="${objectiveNum}" class="objective-input" value="${String.fromCharCode(65 + j)}">
|
<input type="checkbox" name="${objID}" class="objective-input" value="${String.fromCharCode(65 + j)}">
|
||||||
${ele.innerHTML}
|
${ele.innerHTML}
|
||||||
</div>`);
|
</div>`);
|
||||||
$(ele).remove();
|
$(ele).remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
if (objectiveNum) {
|
if (objNum) {
|
||||||
$('.problem-content .typo').append(document.getElementsByClassName('nav__item--round').length
|
$('.problem-content .typo').append(document.getElementsByClassName('nav__item--round').length
|
||||||
? '<input type="submit" disabled class="button rounded primary" value="登录后提交" />'
|
? '<input type="submit" disabled class="button rounded primary" value="登录后提交" />'
|
||||||
: '<input type="submit" class="button rounded primary" value="提交" />');
|
: '<input type="submit" class="button rounded primary" value="提交" />');
|
||||||
|
|||||||
Reference in new issue
Block a user