core&ui: pretest support for remote_judge

This commit is contained in:
undefined committed 2022-02-13 18:07:56 +08:00
1 parent 3762bb31f5
commit af994325b5
7 files changed
+16 -7

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.4.26",
"version": "3.4.27",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+3 -1
View File
@@ -328,7 +328,9 @@ export class ContestCodeHandler extends Handler {
const rnames = {};
for (const tsdoc of tsdocs) {
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();
+5 -1
View File
@@ -23,6 +23,7 @@ import domain from '../model/domain';
import * as oplog from '../model/oplog';
import problem from '../model/problem';
import record from '../model/record';
import * as setting from '../model/setting';
import solution from '../model/solution';
import storage from '../model/storage';
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)) {
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'));
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);
+1 -1
View File
@@ -75,7 +75,7 @@ class RecordModel {
source = `${pdoc.domainId}/${pdoc.docId}`;
data = pdoc.data;
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({
...omit(rdoc, ['_id']),
priority,
@@ -87,7 +87,10 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
}
const keys = Object.keys(LANGS);
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 (
<Toolbar>
{canUsePretest && (
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.31.16",
"version": "4.31.17",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -5,7 +5,7 @@
{% if pdoc.domainId !== handler.domainId %}{{ set(_linkArgs, 'domainId', pdoc.domainId) }}{% endif %}
<a href="{{ url('problem_detail', _linkArgs) }}"{% if small %} data-tooltip="{{ pdoc.title }}"{% 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>
{%- if not small -%}&nbsp;&nbsp;{{ pdoc.title }}{%- endif -%}
{%- if not invalid -%}