From 47b7866053751de6f5f9892e510541bcedfcb785 Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 29 Jul 2021 00:26:32 +0800 Subject: [PATCH] core: objective --- packages/hydrojudge/package.json | 2 +- packages/hydrojudge/src/judge/index.ts | 2 +- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/interface.ts | 2 +- packages/hydrooj/src/upgrade.ts | 13 +++++++++++++ packages/ui-default/components/monaco/index.js | 2 +- .../index.jsx | 2 +- packages/ui-default/locales/en.yaml | 2 +- packages/ui-default/locales/zh.yaml | 2 +- packages/ui-default/package.json | 2 +- packages/ui-default/pages/problem_detail.page.jsx | 10 +++++----- packages/ui-default/templates/problem_detail.html | 2 +- packages/utils/lib/cases.ts | 4 ++-- packages/utils/package.json | 2 +- 14 files changed, 31 insertions(+), 18 deletions(-) rename packages/ui-default/components/{subjective-question => objective-question}/index.jsx (97%) diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index d6ea35abb..e49e22fc0 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.8.18", + "version": "2.8.19", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/judge/index.ts b/packages/hydrojudge/src/judge/index.ts index b35c4b473..19f88cc48 100644 --- a/packages/hydrojudge/src/judge/index.ts +++ b/packages/hydrojudge/src/judge/index.ts @@ -5,5 +5,5 @@ import * as submit_answer from './submit_answer'; import * as hack from './hack'; export = { - default: def, interactive, run, submit_answer, hack, subjective: submit_answer, + default: def, interactive, run, submit_answer, hack, objective: submit_answer, }; diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index f440acf3c..00d01cdfc 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.29.45", + "version": "2.29.46", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/interface.ts b/packages/hydrooj/src/interface.ts index 45f481770..6264f89fd 100644 --- a/packages/hydrooj/src/interface.ts +++ b/packages/hydrooj/src/interface.ts @@ -126,7 +126,7 @@ export enum ProblemType { Default = 'default', SubmitAnswer = 'submit_answer', Interactive = 'interactive', - Subjective = 'subjective', + Objective = 'objective', } export enum SubtaskType { diff --git a/packages/hydrooj/src/upgrade.ts b/packages/hydrooj/src/upgrade.ts index 18f9edf75..3764ce49f 100644 --- a/packages/hydrooj/src/upgrade.ts +++ b/packages/hydrooj/src/upgrade.ts @@ -414,6 +414,19 @@ const scripts: UpgradeScript[] = [ } return true; }, + async function _37_38() { + const _FRESH_INSTALL_IGNORE = 1; + await iterateAllProblem(['docId', 'domainId', 'config'], async (pdoc) => { + logger.info('%s/%s', pdoc.domainId, pdoc.docId); + if (typeof pdoc.config !== 'string') return; + if (!pdoc.config?.includes('type: subjective')) return; + await problem.addTestdata( + pdoc.domainId, pdoc.docId, 'config.yaml', + Buffer.from(pdoc.config.replace('type: subjective', 'type: objective')), + ); + }); + return true; + }, ]; export default scripts; diff --git a/packages/ui-default/components/monaco/index.js b/packages/ui-default/components/monaco/index.js index a3505e4a1..426707a82 100644 --- a/packages/ui-default/components/monaco/index.js +++ b/packages/ui-default/components/monaco/index.js @@ -54,7 +54,7 @@ const problemConfigSchema = { def: problemConfigSchemaDef, properties: { key: { type: 'string', pattern: '[0-9a-f]{32}' }, - type: { enum: ['default', 'interactive', 'submit_answer', 'subjective', 'remote_judge'] }, + type: { enum: ['default', 'interactive', 'submit_answer', 'objective', 'remote_judge'] }, subType: { type: 'string' }, langs: { type: 'array', items: { type: 'string' } }, target: { type: 'string' }, diff --git a/packages/ui-default/components/subjective-question/index.jsx b/packages/ui-default/components/objective-question/index.jsx similarity index 97% rename from packages/ui-default/components/subjective-question/index.jsx rename to packages/ui-default/components/objective-question/index.jsx index e780f1a78..ac1c6586a 100644 --- a/packages/ui-default/components/subjective-question/index.jsx +++ b/packages/ui-default/components/objective-question/index.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { sortBy } from 'lodash'; import request from 'vj/utils/request'; -export default class SubjectiveContainer extends React.PureComponent { +export default class ObjectiveContainer extends React.PureComponent { constructor(args) { super(args); this.state = {}; diff --git a/packages/ui-default/locales/en.yaml b/packages/ui-default/locales/en.yaml index babb14e35..b832cbe6e 100644 --- a/packages/ui-default/locales/en.yaml +++ b/packages/ui-default/locales/en.yaml @@ -28,7 +28,7 @@ problem_type.default: 'Type: Default' problem_type.fileio: 'Type: FileIO ({0})' problem_type.interactive: 'Type: Interactive' problem_type.remote_judge: 'Type: RemoteJudge' -problem_type.subjective: 'Type: Subjective' +problem_type.objective: 'Type: Objective' problem_type.submit_answer: 'Type: SubmitAnswer' problem-category-delim: '|' problem-subcategory-delim: ', ' diff --git a/packages/ui-default/locales/zh.yaml b/packages/ui-default/locales/zh.yaml index 08e1195c7..9a335753d 100644 --- a/packages/ui-default/locales/zh.yaml +++ b/packages/ui-default/locales/zh.yaml @@ -558,7 +558,7 @@ problem_type.default: 传统题 problem_type.fileio: '文件IO ({0})' problem_type.interactive: 交互题 problem_type.remote_judge: 远端评测题 -problem_type.subjective: 客观题 +problem_type.objective: 客观题 problem_type.submit_answer: 提交答案题 problem-category-delim: '|' problem-subcategory-delim: 、 diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 090e37e44..0696aa628 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.13.12", + "version": "4.13.13", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", diff --git a/packages/ui-default/pages/problem_detail.page.jsx b/packages/ui-default/pages/problem_detail.page.jsx index 12613ea97..c47af80e6 100644 --- a/packages/ui-default/pages/problem_detail.page.jsx +++ b/packages/ui-default/pages/problem_detail.page.jsx @@ -171,7 +171,7 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor unmountReact(); } - async function loadSubjective() { + async function loadObjective() { try { let s = ''; try { @@ -189,15 +189,15 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor const props = yaml.load(s); if (!(props instanceof Array)) return; $('.outer-loader-container').show(); - const [{ default: Subjective }, React, ReactDOM] = await Promise.all([ - import('vj/components/subjective-question/index'), + const [{ default: Objective }, React, ReactDOM] = await Promise.all([ + import('vj/components/objective-question/index'), import('react'), import('react-dom'), ]); ReactDOM.render(
- +
, $('.problem-content').get(0), ); @@ -265,7 +265,7 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor $('span.tags').show(); }); $('[name="problem-sidebar__download').on('click', handleClickDownloadProblem); - if (UiContext.pdoc.config?.type === 'subjective') loadSubjective(); + if (UiContext.pdoc.config?.type === 'objective') loadObjective(); if (pagename !== 'contest_detail_problem') initChart(); }); diff --git a/packages/ui-default/templates/problem_detail.html b/packages/ui-default/templates/problem_detail.html index 78d999927..9c04c32a1 100644 --- a/packages/ui-default/templates/problem_detail.html +++ b/packages/ui-default/templates/problem_detail.html @@ -41,7 +41,7 @@
    {{ _('ID') }}: {{ pdoc.docId }} {{ _('problem_type.' + pdoc.config.type).format(pdoc.config.subType) }} - {% if pdoc.config.type != 'subjective' and pdoc.config.type != 'submit_answer' %} + {% if pdoc.config.type != 'objective' and pdoc.config.type != 'submit_answer' %} {{ pdoc.config.timeMax if pdoc.config.timeMax == pdoc.config.timeMin else pdoc.config.timeMin+'~'+pdoc.config.timeMax }}ms {{ pdoc.config.memoryMax if pdoc.config.memoryMax == pdoc.config.memoryMin else pdoc.config.memoryMin+'~'+pdoc.config.memoryMax }}MiB {% endif %} diff --git a/packages/utils/lib/cases.ts b/packages/utils/lib/cases.ts index 510b98151..68e83434f 100644 --- a/packages/utils/lib/cases.ts +++ b/packages/utils/lib/cases.ts @@ -31,7 +31,7 @@ export default async function readYamlCases(cfg: Record = {}, check } else throw new Error('Invalid user_extra_files config.'); } if (cfg.outputs) { - config.type = cfg.type || 'subjective'; + config.type = cfg.type || 'objective'; } else if (cfg.cases?.length) { config.subtasks = [{ score: +cfg.score || Math.floor(100 / cfg.cases.length), @@ -71,7 +71,7 @@ export default async function readYamlCases(cfg: Record = {}, check } if (cfg.time) config.time = parseTimeMS(cfg.time); if (cfg.memory) config.memory = parseMemoryMB(cfg.memory); - if ((config.type === 'subjective' || cfg.type === 'submit_answer') && !cfg.outputs?.length) throw new Error('outputs config not found'); + if ((config.type === 'objective' || cfg.type === 'submit_answer') && !cfg.outputs?.length) throw new Error('outputs config not found'); return Object.assign(cfg, config); } diff --git a/packages/utils/package.json b/packages/utils/package.json index 10ea1eb0a..16538bdbd 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/utils", - "version": "1.0.24", + "version": "1.0.26", "description": "hydrooj utils", "main": "package.json", "repository": "https://github.com/hydro-dev/Hydro.git",