Skip to content

[TestcaseGroup problems] Extend testcases UI page & exporting of problems - #3623

Open
vmcj wants to merge 20 commits into
DOMjudge:mainfrom
vmcj:output_validator_args
Open

[TestcaseGroup problems] Extend testcases UI page & exporting of problems#3623
vmcj wants to merge 20 commits into
DOMjudge:mainfrom
vmcj:output_validator_args

Conversation

@vmcj

@vmcj vmcj commented May 4, 2026

Copy link
Copy Markdown
Member

Code might not be great/performant but it fixes a couple of (real) issues, so I propose to be lenient and fix performance issues when they show up.

Will squash after approval & take the commit named testing out.

@meisterT I had to change the scores, I think it makes sense as the samples should be a testgroup but maybe you did this by design and I interpret the spec wrong?

image

vmcj added 5 commits May 3, 2026 10:40
When a new testcase was added we would also update the description with the empty string
as it was `null` before.
Since the additions of the testcase groups we would switch for every tr,
not for only the testcase rows. This changes the selector to do the right
thing again.
…rectory

This can be checked with the addone problem where we would put the sample testcases
not in it's own group in the interface but only the secret data. Verified that this
works by checking both addone (where sample should now be under the root) and hello
where we don't want to display anything.
@vmcj
vmcj requested a review from meisterT May 4, 2026 11:14
vmcj added 15 commits May 4, 2026 18:13
This can be tested with having 1.desc, the description for testcase 1.
We all use unix line endings, but the http spec wants \r\n endings.
So when you save the testcases we would update testcase 1 but nothing (really) changed.
Alternative is to always fill the description with the empty string and make
it non-nullable.
There are some issues with floats/integer conversions but these seem to work on a quick glance.
This reverts commit 161fafd.
This reverts commit 1611a47.
@vmcj
vmcj force-pushed the output_validator_args branch from b95f9bf to 5bb28b3 Compare May 4, 2026 16:13

@meisterT meisterT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some phpcs nits as well

$testdataConfig['output_validator_flags'] = $testcaseGroup->getOutputValidatorFlags();
}
if ($testcaseGroup->getRangeLowerBound()) {
$testdataConfig['range'] = sprintf("range: %d %d", $testcaseGroup->getRangeLowerBound(), $testcaseGroup->getRangeUpperBound());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need the extra 'range: ? Isn't that already given by the key? I think it currently serializes as range: range: 0 100 (or similar)

// TODO: This is slow but prevents us from doing a transaction
$this->em->flush();
}
$newTestcase->setRank($last->getRank() + 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$last can be null here, or am I missing something?

$testdataConfig['accept_score'] = $testcaseGroup->getAcceptScore();
}
if ($testcaseGroup->getAggregationType() !== TestcaseAggregationType::SUM) {
$testdataConfig['grader_flags'] = $testcaseGroup->getAggregationType()->name;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be ->value?

if ($testcaseGroup->isOnRejectContinue()) {
$testdataConfig['on_reject'] = 'continue';
}
$zip->addFromString($testcaseDirectory . '/testdata.yaml', Yaml::dump($testdataConfig));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's only add it if $testdataConfig is non-empty?


$formatString = sprintf('data/%%s/%%0%dd', ceil(log10(count($testcases) + 1)));
$formatString = sprintf('%%s/%%0%dd', ceil(log10(count($testcases) + 1)));
$rankInGroup = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already the case before your change, but it looks like $rankInGroup is actually calculating a global rank not a per group rank?

<label class="col-sm-2 col-form-label" for="add_testgroup">Testgroup</label>
<div class="col-sm-4">
<select class="form-select" name="add_testgroup" id="add_testgroup">
{% for testgroup in testcaseGroups %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add some default for no group here as well?

}
}
if ($testCaseGroups !== []) {
foreach (['data/sample', 'data/secret'] as $default_dir) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that was the missing spec piece I missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants