mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core&ui: hello subjective
This commit is contained in:
1 parent
385b8f4fe6
commit
4c7e51631b
8 files changed
+30
-11
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.28.16",
|
"version": "2.28.17",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hydrooj/utils": "^1.0.19",
|
"@hydrooj/utils": "^1.0.20",
|
||||||
"adm-zip": "^0.5.5",
|
"adm-zip": "^0.5.5",
|
||||||
"ansi_up": "^5.0.1",
|
"ansi_up": "^5.0.1",
|
||||||
"cac": "^6.7.3",
|
"cac": "^6.7.3",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export async function parseConfig(config: string | ProblemConfigFile = {}) {
|
|||||||
result.timeMax = result.timeMin = 1000;
|
result.timeMax = result.timeMin = 1000;
|
||||||
}
|
}
|
||||||
if (cfg.langs) result.langs = cfg.langs;
|
if (cfg.langs) result.langs = cfg.langs;
|
||||||
|
console.log(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default class SubjectiveContainer extends React.PureComponent {
|
|||||||
Textbox(args, name) {
|
Textbox(args, name) {
|
||||||
return (
|
return (
|
||||||
<label htmlFor={`textbox${name}`}>
|
<label htmlFor={`textbox${name}`}>
|
||||||
{args.desc}
|
{name}. {args.desc}
|
||||||
<div name={`form_item_${name}`} className="textbox-container">
|
<div name={`form_item_${name}`} className="textbox-container">
|
||||||
<input type="text" name={name} id={`textbox${name}`} className="textbox" onChange={this.onChange}></input>
|
<input type="text" name={name} id={`textbox${name}`} className="textbox" onChange={this.onChange}></input>
|
||||||
</div>
|
</div>
|
||||||
@@ -47,7 +47,7 @@ export default class SubjectiveContainer extends React.PureComponent {
|
|||||||
Radio(args, name) {
|
Radio(args, name) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{args.desc}
|
{name}. {args.desc}
|
||||||
{args.choices.map((i) => (
|
{args.choices.map((i) => (
|
||||||
<label className="radiobox" htmlFor={`radio${name}${i}`} key={i}>
|
<label className="radiobox" htmlFor={`radio${name}${i}`} key={i}>
|
||||||
<input type="radio" name={name} id={`radio${name}${i}`} value={i} onChange={this.onChange} /> {i} <br />
|
<input type="radio" name={name} id={`radio${name}${i}`} value={i} onChange={this.onChange} /> {i} <br />
|
||||||
@@ -67,7 +67,9 @@ export default class SubjectiveContainer extends React.PureComponent {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<input type="submit" className="button rounded primary" value="提交" />
|
{document.getElementsByClassName('nav__item--round').length
|
||||||
|
? <input type="submit" disabled className="button rounded primary" value="登录后提交" />
|
||||||
|
: <input type="submit" className="button rounded primary" value="提交" />}
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.11.8",
|
"version": "4.11.9",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"@blueprintjs/core": "^3.45.0",
|
"@blueprintjs/core": "^3.45.0",
|
||||||
"@blueprintjs/icons": "^3.26.1",
|
"@blueprintjs/icons": "^3.26.1",
|
||||||
"@blueprintjs/select": "^3.16.4",
|
"@blueprintjs/select": "^3.16.4",
|
||||||
"@hydrooj/utils": "^1.0.15",
|
"@hydrooj/utils": "^1.0.20",
|
||||||
"@undefined-moe/monaco-yaml": "^2.5.0",
|
"@undefined-moe/monaco-yaml": "^2.5.0",
|
||||||
"ansi_up": "^5.0.1",
|
"ansi_up": "^5.0.1",
|
||||||
"autoprefixer": "^9.8.6",
|
"autoprefixer": "^9.8.6",
|
||||||
|
|||||||
@@ -177,7 +177,20 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
|||||||
async function loadSubjective() {
|
async function loadSubjective() {
|
||||||
try {
|
try {
|
||||||
if (UiContext.pdoc.config?.type !== 'subjective') return;
|
if (UiContext.pdoc.config?.type !== 'subjective') return;
|
||||||
const props = yaml.load(document.getElementsByClassName('section__body typo')[0].innerText);
|
let s = '';
|
||||||
|
try {
|
||||||
|
s = JSON.parse(UiContext.pdoc.content);
|
||||||
|
} catch {
|
||||||
|
s = UiContext.pdoc.content;
|
||||||
|
}
|
||||||
|
if (typeof s === 'object') {
|
||||||
|
const langs = Object.keys(s);
|
||||||
|
const f = langs.filter((i) => i.startsWith(UserContext.viewLang));
|
||||||
|
if (s[UserContext.viewLang]) s = s[UserContext.viewLang];
|
||||||
|
else if (f.length) s = s[f[0]];
|
||||||
|
else s = s[langs[0]];
|
||||||
|
}
|
||||||
|
const props = yaml.load(s);
|
||||||
if (!(props instanceof Array)) return;
|
if (!(props instanceof Array)) return;
|
||||||
$('.outer-loader-container').show();
|
$('.outer-loader-container').show();
|
||||||
const { default: Subjective } = await import('vj/components/subjective-question/index');
|
const { default: Subjective } = await import('vj/components/subjective-question/index');
|
||||||
|
|||||||
@@ -39,8 +39,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="section__body">
|
<div class="section__body">
|
||||||
<ul class="problem__tags">
|
<ul class="problem__tags">
|
||||||
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Type') }}: {{ pdoc.config.type }}</span>
|
||||||
|
{% if pdoc.config.type != 'subjective' and pdoc.config.type != 'submit_answer' %}
|
||||||
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Time') }}: {{ pdoc.config.timeMax if pdoc.config.timeMax == pdoc.config.timeMin else pdoc.config.timeMin+'~'+pdoc.config.timeMax }}ms</span>
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Time') }}: {{ pdoc.config.timeMax if pdoc.config.timeMax == pdoc.config.timeMin else pdoc.config.timeMin+'~'+pdoc.config.timeMax }}ms</span>
|
||||||
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Memory') }}: {{ pdoc.config.memoryMax if pdoc.config.memoryMax == pdoc.config.memoryMin else pdoc.config.memoryMin+'~'+pdoc.config.memoryMax }}MiB</span>
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Memory') }}: {{ pdoc.config.memoryMax if pdoc.config.memoryMax == pdoc.config.memoryMin else pdoc.config.memoryMin+'~'+pdoc.config.memoryMax }}MiB</span>
|
||||||
|
{% endif %}
|
||||||
<a class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item" href="{{ url('record_main', query={pid:pdoc.docId}) }}">{{ _('Submitted') }}: {{ pdoc.nSubmit }}</a>
|
<a class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item" href="{{ url('record_main', query={pid:pdoc.docId}) }}">{{ _('Submitted') }}: {{ pdoc.nSubmit }}</a>
|
||||||
<a class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item" href="{{ url('record_main', query={pid:pdoc.docId, status:1}) }}">{{ _('Accepted') }}: {{ pdoc.nAccept }}</a>
|
<a class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item" href="{{ url('record_main', query={pid:pdoc.docId, status:1}) }}">{{ _('Accepted') }}: {{ pdoc.nAccept }}</a>
|
||||||
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Accepted Ratio') }}: {% if pdoc.nSubmit > 0 %}{{ (100 * pdoc.nAccept / pdoc.nSubmit)|round|int }}%{% else %}{{ _('?') }}{% endif %}</span>
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Accepted Ratio') }}: {% if pdoc.nSubmit > 0 %}{{ (100 * pdoc.nAccept / pdoc.nSubmit)|round|int }}%{% else %}{{ _('?') }}{% endif %}</span>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default async function readYamlCases(cfg: Record<string, any> = {}, check
|
|||||||
} else throw new Error('Invalid user_extra_files config.');
|
} else throw new Error('Invalid user_extra_files config.');
|
||||||
}
|
}
|
||||||
if (cfg.outputs) {
|
if (cfg.outputs) {
|
||||||
config.type = 'subjective';
|
config.type = cfg.type || 'subjective';
|
||||||
} else if (cfg.cases?.length) {
|
} else if (cfg.cases?.length) {
|
||||||
config.subtasks = [{
|
config.subtasks = [{
|
||||||
score: +cfg.score || Math.floor(100 / cfg.cases.length),
|
score: +cfg.score || Math.floor(100 / cfg.cases.length),
|
||||||
@@ -70,7 +70,7 @@ export default async function readYamlCases(cfg: Record<string, any> = {}, check
|
|||||||
}
|
}
|
||||||
if (cfg.time) config.time = parseTimeMS(cfg.time);
|
if (cfg.time) config.time = parseTimeMS(cfg.time);
|
||||||
if (cfg.memory) config.memory = parseMemoryMB(cfg.memory);
|
if (cfg.memory) config.memory = parseMemoryMB(cfg.memory);
|
||||||
if (config.type === 'submit_answer' && !cfg.outputs?.length) throw new Error('outputs config not found');
|
if ((config.type === 'subjective' || cfg.type === 'submit_answer') && !cfg.outputs?.length) throw new Error('outputs config not found');
|
||||||
return Object.assign(cfg, config);
|
return Object.assign(cfg, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/utils",
|
"name": "@hydrooj/utils",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"description": "hydrooj utils",
|
"description": "hydrooj utils",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
Reference in new issue
Block a user