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 @@