Skip to content

Conversation

@vmcj
Copy link
Member

@vmcj vmcj commented Nov 10, 2025

We already allow this over the API so use the same URL.

image

This doesn't check if there are actually samples as I think it will in 99% of the cases and in case there are none someone would just get a 404.

@nickygerritsen
Copy link
Member

I would prefer adding a check if it exists, I don't think it's very nice to add buttons that don't always work. Even if it is very rare.

vmcj added 3 commits November 11, 2025 18:42
We already allow this over the API so use the same URL.
…s.zip

We always try to exit early and skip the actual adding. As checking and
creation are more or less the same code we wrap the check inside the actual
creation to prevent duplication.
if (!($tempFilename = tempnam($this->getDomjudgeTmpDir(), "export-"))) {
throw new ServiceUnavailableHttpException(null, 'Could not create temporary file.');
}
$zip = null;
Copy link
Member

Choose a reason for hiding this comment

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

I get what you're doing, but I think just doing a simple query to count the number of sample testcases across all problems in the contest in checkIfSamplesZipForContest is cleaner than this (and more performant)

Copy link
Member Author

@vmcj vmcj Nov 11, 2025

Choose a reason for hiding this comment

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

Yes, but in case you have no samples but do have attachments you would not create the zip. But I wonder if this will ever return false, why would there be a contest with neither of:

  • samples,
  • problem statements
  • attachments

All of those are possible, but having neither of those files really feels strange.

Copy link
Member

Choose a reason for hiding this comment

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

The zip with all samples contains only samples or also attachment? In the latter case the button has a weird name maybe, not sure.

But still I would not mis-use a method like this.

Copy link
Member

Choose a reason for hiding this comment

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

All of those are possible, but having neither of those files really feels strange.

When everything is provided on the team machine and/or as hardcopy problem statements. I don't think that's a far-fetched case.

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.

3 participants