diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 8f9f3dd2f..1bad852ea 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -6,7 +6,7 @@ import { SolutionNotFoundError, ProblemNotFoundError, BadRequestError, } from '../error'; import { - Pdoc, User, Rdoc, PathComponent, + Pdoc, User, Rdoc, PathComponent, ProblemStatusDoc, } from '../interface'; import paginate from '../lib/paginate'; import { isPid } from '../lib/validator'; @@ -157,8 +157,12 @@ export class ProblemRandomHandler extends ProblemHandler { } } +export interface PdocWithPsdoc extends Pdoc { + psdoc?: ProblemStatusDoc +} + export class ProblemDetailHandler extends ProblemHandler { - pdoc: Pdoc; + pdoc: PdocWithPsdoc; udoc: User; @route('pid', Types.Name, true, null, parsePid) @@ -196,6 +200,9 @@ export class ProblemDetailHandler extends ProblemHandler { } catch (e) { this.response.body.pdoc.config = `Cannot parse: ${e.message}`; } + if (this.pdoc.psdoc) { + this.response.body.rdoc = await record.get(this.domainId, this.pdoc.psdoc.rid); + } } @param('pid', Types.UnsignedInt) diff --git a/packages/ui-default/backendlib/template.js b/packages/ui-default/backendlib/template.js index 5bbc511e2..ac2159461 100644 --- a/packages/ui-default/backendlib/template.js +++ b/packages/ui-default/backendlib/template.js @@ -88,7 +88,7 @@ class Loader extends nunjucks.Loader { }; } let fullpath = null; - if (typeof argv.template !== 'string') argv.template = path.resolve(__dirname, '..', 'template'); + if (typeof argv.template !== 'string') argv.template = path.resolve(__dirname, '..', 'templates'); const p = path.resolve(process.cwd(), argv.template, name); if (fs.existsSync(p)) fullpath = p; if (!fullpath) { diff --git a/packages/ui-default/templates/partials/problem_sidebar_normal.html b/packages/ui-default/templates/partials/problem_sidebar_normal.html index a8c21f984..81bb96ec3 100644 --- a/packages/ui-default/templates/partials/problem_sidebar_normal.html +++ b/packages/ui-default/templates/partials/problem_sidebar_normal.html @@ -114,6 +114,10 @@
{{ _('ID') }}
{{ pdoc.docId }}
+
{{ _('Time') }}
+
{{ pdoc.config.timeMax if pdoc.config.timeMax == pdoc.config.timeMin else pdoc.config.timeMin+'~'+pdoc.config.timeMax }}ms
+
{{ _('Memory') }}
+
{{ pdoc.config.memoryMax if pdoc.config.memoryMax == pdoc.config.memoryMin else pdoc.config.memoryMin+'~'+pdoc.config.memoryMax }}MiB
{% if page_name != 'discussion_node' and page_name != 'discussion_detail' %} {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
{{ _('Submission') }}
diff --git a/packages/ui-default/templates/problem_detail.html b/packages/ui-default/templates/problem_detail.html index 7130a9538..114271b51 100644 --- a/packages/ui-default/templates/problem_detail.html +++ b/packages/ui-default/templates/problem_detail.html @@ -24,28 +24,18 @@
-
-

- {%- if rdoc -%} - - - {{ rdoc.score }} - - {%- endif %} - {{ pdoc.title }} -

-
-
+
{% if rdoc %} -

+

- {{ rdoc.score }} + {{ 'Accepted' if rdoc.status == model.builtin.STATUS.STATUS_ACCEPTED else rdoc.score }}

{% endif %} - {{ _('Time Limit') }}: {{ pdoc.config.timeMax if pdoc.config.timeMax == pdoc.config.timeMin else pdoc.config.timeMin+'~'+pdoc.config.timeMax }}ms - {{ _('Memory Limit') }}: {{ pdoc.config.memoryMax if pdoc.config.memoryMax == pdoc.config.memoryMin else pdoc.config.memoryMin+'~'+pdoc.config.memoryMax }}MiB +

+ {{ pdoc.title }} +

{% if tdoc %}