MCPcopy Index your code
hub / github.com/hydro-dev/Hydro / ProblemEditHandler

Class ProblemEditHandler

packages/hydrooj/src/handler/problem.ts:615–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615export class ProblemEditHandler extends ProblemManageHandler {
616 async get() {
617 this.response.body.additional_file = sortFiles(this.pdoc.additional_file || []);
618 this.response.body.statementLangs = this.ctx.i18n.langs(false);
619 this.response.template = 'problem_edit.html';
620 }
621
622 @route('pid', Types.ProblemId)
623 @post('title', Types.Title)
624 @post('content', Types.Content)
625 @post('pid', Types.ProblemId, true, (i) => /^(?:[a-z0-9]{1,10}-)?[a-z][a-z0-9]*$/i.test(i))
626 @post('hidden', Types.Boolean)
627 @post('tag', Types.Content, true, null, parseCategory)
628 @post('difficulty', Types.PositiveInt, (i) => +i <= 10, true)
629 async post(
630 domainId: string, pid: string | number, title: string, content: string,
631 newPid: string | number = '', hidden = false, tag: string[] = [], difficulty = 0,
632 ) {
633 if (typeof newPid !== 'string') newPid = `P${newPid}`;
634 if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new ProblemAlreadyExistError(newPid);
635 const $update: Partial<ProblemDoc> = {
636 title, content, pid: newPid, hidden, tag: tag ?? [], difficulty, html: false,
637 };
638 const pdoc = await problem.edit(domainId, this.pdoc.docId, $update);
639 this.response.redirect = this.url('problem_detail', { pid: newPid || pdoc.docId });
640 }
641}
642
643export class ProblemConfigHandler extends ProblemManageHandler {
644 async get() {

Callers

nothing calls this directly

Calls 2

routeFunction · 0.85
postFunction · 0.50

Tested by

no test coverage detected