Skip to content

Commit 5d1d97d

Browse files
nickygerritsenvmcj
authored andcommitted
Export custom (interactive) compare scripts when downloading problem ZIP.
Fixes #2327. (cherry picked from commit b67412e)
1 parent ab51b4e commit 5d1d97d

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
@@ -261,7 +261,10 @@ public function exportAction(int $problemId): StreamedResponse
261261
$yaml = ['name' => $problem->getName()];
262262
if (!empty($problem->getCompareExecutable())) {
263263
$yaml['validation'] = 'custom';
264+
} elseif ($problem->getCombinedRunCompare() && !empty($problem->getRunExecutable())) {
265+
$yaml['validation'] = 'custom interactive';
264266
}
267+
265268
if (!empty($problem->getSpecialCompareArgs())) {
266269
$yaml['validator_flags'] = $problem->getSpecialCompareArgs();
267270
}
@@ -291,6 +294,27 @@ public function exportAction(int $problemId): StreamedResponse
291294
stream_get_contents($problem->getProblemtext()));
292295
}
293296

297+
$compareExecutable = null;
298+
if ($problem->getCompareExecutable()) {
299+
$compareExecutable = $problem->getCompareExecutable();
300+
} elseif ($problem->getCombinedRunCompare()) {
301+
$compareExecutable = $problem->getRunExecutable();
302+
}
303+
if ($compareExecutable) {
304+
foreach ($compareExecutable->getImmutableExecutable()->getFiles() as $file) {
305+
$filename = sprintf('output_validators/%s/%s', $compareExecutable->getExecid(), $file->getFilename());
306+
$zip->addFromString($filename, $file->getFileContent());
307+
if ($file->isExecutable()) {
308+
// 100755 = regular file, executable
309+
$zip->setExternalAttributesName(
310+
$filename,
311+
ZipArchive::OPSYS_UNIX,
312+
octdec('100755') << 16
313+
);
314+
}
315+
}
316+
}
317+
294318
foreach ([true, false] as $isSample) {
295319
/** @var Testcase[] $testcases */
296320
$testcases = $this->em->createQueryBuilder()

0 commit comments

Comments
 (0)