| 941 | } |
| 942 | |
| 943 | export class ProblemSolutionRawHandler extends ProblemDetailHandler { |
| 944 | @param('psid', Types.ObjectId) |
| 945 | @route('psrid', Types.ObjectId, true) |
| 946 | @param('tid', Types.ObjectId, true) |
| 947 | async get(domainId: string, psid: ObjectId, psrid?: ObjectId, tid?: ObjectId) { |
| 948 | if (tid) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_SOLUTION); |
| 949 | const accepted = this.psdoc?.status === STATUS.STATUS_ACCEPTED; |
| 950 | if (!accepted || !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION_ACCEPT)) { |
| 951 | this.checkPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION); |
| 952 | } |
| 953 | if (psrid) { |
| 954 | const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid); |
| 955 | if ((!psdoc) || psdoc.parentId !== this.pdoc.docId) throw new SolutionNotFoundError(psid, psrid); |
| 956 | this.response.body = psrdoc.content; |
| 957 | } else { |
| 958 | const psdoc = await solution.get(domainId, psid); |
| 959 | this.response.body = psdoc.content; |
| 960 | } |
| 961 | this.response.type = 'text/markdown'; |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | export class ProblemStatisticsHandler extends ProblemDetailHandler { |
| 966 | @param('sort', Types.Range(Object.keys(record.STAT_QUERY)), true) |