judge&ui: fix bugs

This commit is contained in:
panda committed 2022-06-28 16:17:05 +08:00
1 parent 061698a548
commit d7f72617c8
2 files changed
+5 -4

No files matched your search

+2 -2
View File
@@ -15,7 +15,7 @@ export async function judge({
: ''; : '';
let answers: { [x: string]: string | string[] } = {}; let answers: { [x: string]: string | string[] } = {};
try { try {
answers = yaml.load(answer) as { [x: string]: string | string[] }; answers = yaml.load(answer) as any;
assert(typeof answers === 'object'); assert(typeof answers === 'object');
} catch (e) { } catch (e) {
return end({ return end({
@@ -39,7 +39,7 @@ export async function judge({
memory: 0, memory: 0,
}; };
if (typeof ansInfo[0] === 'string') { if (typeof ansInfo[0] === 'string') {
if (ansInfo[0].trim() === (answers[key] as string).trim()) { if (ansInfo[0].trim() === (answers[key] as any).trim()) {
totalScore += score; totalScore += score;
totalStatus = Math.max(totalStatus, STATUS.STATUS_ACCEPTED); totalStatus = Math.max(totalStatus, STATUS.STATUS_ACCEPTED);
next({ next({
@@ -8,6 +8,7 @@ import loadReactRedux from 'vj/utils/loadReactRedux';
import delay from 'vj/utils/delay'; import delay from 'vj/utils/delay';
import pjax from 'vj/utils/pjax'; import pjax from 'vj/utils/pjax';
import request from 'vj/utils/request'; import request from 'vj/utils/request';
import tpl from 'vj/utils/tpl';
class ProblemPageExtender { class ProblemPageExtender {
constructor() { constructor() {
@@ -187,7 +188,7 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
cnt++; cnt++;
const id = info.replace(/{{ (input|select|multiselect)\((\d+(-\d+)?)\) }}/, '$2'); const id = info.replace(/{{ (input|select|multiselect)\((\d+(-\d+)?)\) }}/, '$2');
if (type === 'input') { if (type === 'input') {
$(e).html($(e).html().replace(info, ` $(e).html($(e).html().replace(info, tpl`
<div class="objective_${id} medium-3" style="display: inline-block;"> <div class="objective_${id} medium-3" style="display: inline-block;">
<input type="text" name="${id}" class="textbox objective-input"> <input type="text" name="${id}" class="textbox objective-input">
</div> </div>
@@ -199,7 +200,7 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
} }
$(e).html($(e).html().replace(info, '')); $(e).html($(e).html().replace(info, ''));
$(e).next('ul').children().each((j, ele) => { $(e).next('ul').children().each((j, ele) => {
$(ele).after(` $(ele).after(tpl`
<div class="objective_${id} radiobox"> <div class="objective_${id} radiobox">
<input type="${type === 'select' ? 'radio' : 'checkbox'}" name="${id}" class="objective-input" value="${String.fromCharCode(65 + j)}"> <input type="${type === 'select' ? 'radio' : 'checkbox'}" name="${id}" class="objective-input" value="${String.fromCharCode(65 + j)}">
${String.fromCharCode(65 + j)}. ${ele.innerHTML} ${String.fromCharCode(65 + j)}. ${ele.innerHTML}