mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: pretest support for remote_judge
This commit is contained in:
1 parent
3762bb31f5
commit
af994325b5
7 files changed
+16
-7
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.4.26",
|
"version": "3.4.27",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -328,7 +328,9 @@ export class ContestCodeHandler extends Handler {
|
|||||||
const rnames = {};
|
const rnames = {};
|
||||||
for (const tsdoc of tsdocs) {
|
for (const tsdoc of tsdocs) {
|
||||||
for (const pid in tsdoc.detail || {}) {
|
for (const pid in tsdoc.detail || {}) {
|
||||||
rnames[tsdoc.detail[pid].rid] = `U${tsdoc.uid}_P${pid}_R${tsdoc.detail[pid].rid}`;
|
let name = `U${tsdoc.uid}_P${pid}_R${tsdoc.detail[pid].rid}`;
|
||||||
|
if (typeof tsdoc.detail[pid].score === 'number') name += `_S${tsdoc.detail[pid].status}@${tsdoc.detail[pid].score}`;
|
||||||
|
rnames[tsdoc.detail[pid].rid] = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const zip = new AdmZip();
|
const zip = new AdmZip();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import domain from '../model/domain';
|
|||||||
import * as oplog from '../model/oplog';
|
import * as oplog from '../model/oplog';
|
||||||
import problem from '../model/problem';
|
import problem from '../model/problem';
|
||||||
import record from '../model/record';
|
import record from '../model/record';
|
||||||
|
import * as setting from '../model/setting';
|
||||||
import solution from '../model/solution';
|
import solution from '../model/solution';
|
||||||
import storage from '../model/storage';
|
import storage from '../model/storage';
|
||||||
import * as system from '../model/system';
|
import * as system from '../model/system';
|
||||||
@@ -436,7 +437,10 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
|||||||
if (this.response.body.pdoc.config?.langs && !this.response.body.pdoc.config.langs.includes(lang)) {
|
if (this.response.body.pdoc.config?.langs && !this.response.body.pdoc.config.langs.includes(lang)) {
|
||||||
throw new BadRequestError('Language not allowed.');
|
throw new BadRequestError('Language not allowed.');
|
||||||
}
|
}
|
||||||
if (pretest && !['default', 'fileio'].includes(this.response.body.pdoc.config?.type)) throw new BadRequestError('unable to run pretest');
|
if (pretest && setting.langs[lang]?.pretest) lang = setting.langs[lang].pretest;
|
||||||
|
if (pretest && !['default', 'fileio', 'remote_judge'].includes(this.response.body.pdoc.config?.type)) {
|
||||||
|
throw new BadRequestError('unable to run pretest');
|
||||||
|
}
|
||||||
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
||||||
const rid = await record.add(domainId, this.pdoc.docId, this.user._id, lang, code, true, pretest ? input : tid, tid && !pretest);
|
const rid = await record.add(domainId, this.pdoc.docId, this.user._id, lang, code, true, pretest ? input : tid, tid && !pretest);
|
||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class RecordModel {
|
|||||||
source = `${pdoc.domainId}/${pdoc.docId}`;
|
source = `${pdoc.domainId}/${pdoc.docId}`;
|
||||||
data = pdoc.data;
|
data = pdoc.data;
|
||||||
if (typeof pdoc.config === 'string') throw new Error(pdoc.config);
|
if (typeof pdoc.config === 'string') throw new Error(pdoc.config);
|
||||||
if (pdoc.config.type === 'remote_judge') {
|
if (pdoc.config.type === 'remote_judge' && rdoc.contest.toHexString() !== '0'.repeat(24)) {
|
||||||
return await task.add({
|
return await task.add({
|
||||||
...omit(rdoc, ['_id']),
|
...omit(rdoc, ['_id']),
|
||||||
priority,
|
priority,
|
||||||
|
|||||||
@@ -87,7 +87,10 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
|||||||
}
|
}
|
||||||
const keys = Object.keys(LANGS);
|
const keys = Object.keys(LANGS);
|
||||||
if (!keys.includes(this.props.editorLang)) this.props.setEditorLanguage(keys[0]);
|
if (!keys.includes(this.props.editorLang)) this.props.setEditorLanguage(keys[0]);
|
||||||
const canUsePretest = ['default', 'fileio'].includes(UiContext.pdoc.config?.type);
|
let canUsePretest = ['default', 'fileio'].includes(UiContext.pdoc.config?.type);
|
||||||
|
if (UiContext.pdoc.config?.type === 'remote_judge') {
|
||||||
|
if (window.LANGS[this.props.editorLang].pretest) canUsePretest = true;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
{canUsePretest && (
|
{canUsePretest && (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.31.16",
|
"version": "4.31.17",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
{% if pdoc.domainId !== handler.domainId %}{{ set(_linkArgs, 'domainId', pdoc.domainId) }}{% endif %}
|
{% if pdoc.domainId !== handler.domainId %}{{ set(_linkArgs, 'domainId', pdoc.domainId) }}{% endif %}
|
||||||
<a href="{{ url('problem_detail', _linkArgs) }}"{% if small %} data-tooltip="{{ pdoc.title }}"{% endif %}>
|
<a href="{{ url('problem_detail', _linkArgs) }}"{% if small %} data-tooltip="{{ pdoc.title }}"{% endif %}>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if pdoc.domainId !== handler.domainId -%}{{ pdoc.domainId }}#{%- endif -%}
|
{%- if pdoc.domainId !== handler.domainId -%}<b>{{ pdoc.domainId }}#</b>{%- endif -%}
|
||||||
<b>{{ pdoc.pid or 'P'+pdoc.docId if pdoc.domainId === handler.domainId else pdoc.docId }}</b>
|
<b>{{ pdoc.pid or 'P'+pdoc.docId if pdoc.domainId === handler.domainId else pdoc.docId }}</b>
|
||||||
{%- if not small -%} {{ pdoc.title }}{%- endif -%}
|
{%- if not small -%} {{ pdoc.title }}{%- endif -%}
|
||||||
{%- if not invalid -%}
|
{%- if not invalid -%}
|
||||||
|
|||||||
Reference in new issue
Block a user