Skip to content

Commit b67412e

Browse files
Export custom (interactive) compare scripts when downloading problem ZIP.
Fixes #2327.
1 parent 2c82b95 commit b67412e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

webapp/src/Controller/Jury/ProblemController.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ public function exportAction(int $problemId): StreamedResponse
270270
$yaml = ['name' => $problem->getName()];
271271
if (!empty($problem->getCompareExecutable())) {
272272
$yaml['validation'] = 'custom';
273+
} elseif ($problem->getCombinedRunCompare() && !empty($problem->getRunExecutable())) {
274+
$yaml['validation'] = 'custom interactive';
273275
}
276+
274277
if (!empty($problem->getSpecialCompareArgs())) {
275278
$yaml['validator_flags'] = $problem->getSpecialCompareArgs();
276279
}
@@ -300,6 +303,27 @@ public function exportAction(int $problemId): StreamedResponse
300303
$problem->getProblemtext());
301304
}
302305

306+
$compareExecutable = null;
307+
if ($problem->getCompareExecutable()) {
308+
$compareExecutable = $problem->getCompareExecutable();
309+
} elseif ($problem->getCombinedRunCompare()) {
310+
$compareExecutable = $problem->getRunExecutable();
311+
}
312+
if ($compareExecutable) {
313+
foreach ($compareExecutable->getImmutableExecutable()->getFiles() as $file) {
314+
$filename = sprintf('output_validators/%s/%s', $compareExecutable->getExecid(), $file->getFilename());
315+
$zip->addFromString($filename, $file->getFileContent());
316+
if ($file->isExecutable()) {
317+
// 100755 = regular file, executable
318+
$zip->setExternalAttributesName(
319+
$filename,
320+
ZipArchive::OPSYS_UNIX,
321+
octdec('100755') << 16
322+
);
323+
}
324+
}
325+
}
326+
303327
foreach ([true, false] as $isSample) {
304328
/** @var Testcase[] $testcases */
305329
$testcases = $this->em->createQueryBuilder()

0 commit comments

Comments
 (0)