| 43 | const tasks: Promise<any>[] = [ProblemModel.addTestdata(domainId, pid, 'config.yaml', Buffer.from(yaml.dump(config)))]; |
| 44 | if (!markdown) tasks.push(ProblemModel.edit(domainId, pid, { html: true })); |
| 45 | const addTestdata = (node: any, index: string, ext: string) => { |
| 46 | if (!node || !['object', 'string'].includes(typeof node)) return; // Ignore file not exist |
| 47 | const id = node.$?.name || `${index}`; |
| 48 | // `filename` attribute introduced by winterant/OnlineJudge |
| 49 | // PLEASE, respect the spec |
| 50 | const filename = node.$?.filename || `${id}.${ext}`; |
| 51 | const c = node._ || (typeof node === 'string' ? node : ''); |
| 52 | tasks.push(ProblemModel.addTestdata(domainId, pid, filename, Buffer.from(c))); |
| 53 | }; |
| 54 | if (p.test_output) { |
| 55 | for (let i = 0; i < p.test_input.length; i++) { |
| 56 | addTestdata(p.test_input[i], `${i + 1}`, 'in'); |