ui: problemconfig: bug fix

pull/541/head
undefined 2 years ago
parent 82d32f1f38
commit 6c6147d050
No known key found for this signature in database

@ -25,7 +25,7 @@ export default function reducer(state = {
return { ...state, __valid: false, __errors: validate.errors.map((i) => `${i.instancePath}: ${i.message}`) };
}
const subtasks = (data as any).subtasks;
for (const subtask of subtasks) {
for (const subtask of subtasks || []) {
if (typeof subtask.id !== 'number') {
for (let i = 1; ; i++) {
if (!subtasks.find((s) => s.id === i)) {

@ -126,7 +126,7 @@ export function SubtaskSettings(props: SubtaskSettingsProps) {
<span className="bp4-tree-node-caret-none bp4-icon-standard"></span>
<span className="bp4-tree-node-label">{i18n('Scoring method')}</span>
<span className="bp4-tree-node-secondary-label">
<select value={ctype} onChange={(e) => setType(e.target.value)}>
<select className="compact select" value={ctype} onChange={(e) => setType(e.target.value)}>
<option value="min">Min</option>
<option value="max">Max</option>
<option value="sum">Sum</option>

@ -104,7 +104,12 @@ const page = new NamedPage('problem_config', () => {
if (!state.config.__loaded) return;
if (state.config.cases) {
const score = state.config.score * state.config.cases.length;
state.config.subtasks = [{ type: 'sum' as SubtaskType, score: score && score < 100 ? score : 100, cases: state.config.cases }];
state.config.subtasks = [{
type: 'sum' as SubtaskType,
score: score && score < 100 ? score : 100,
cases: state.config.cases,
id: 1,
}];
delete state.config.cases;
delete state.config.score;
}

Loading…
Cancel
Save