-
Notifications
You must be signed in to change notification settings - Fork 284
Display all languages in the contest in teaminterface #3178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vmcj
wants to merge
6
commits into
DOMjudge:main
Choose a base branch
from
vmcj:language_contest_teaminterface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
903bff3
Display all languages in the contest in teaminterface
vmcj 2ee2712
Implement Nicky his suggestion
vmcj 2787bb9
Re-order to make it look better
vmcj e77eec3
Fix indentation
vmcj 0f94434
Handle case for the online judge
vmcj e91868c
Keep PHPStan happy
vmcj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| use App\Controller\BaseController; | ||
| use App\Entity\Language; | ||
| use App\Entity\ContestProblem; | ||
| use App\Service\ConfigurationService; | ||
| use App\Service\DOMJudgeService; | ||
| use App\Service\EventLogService; | ||
|
|
@@ -33,16 +34,73 @@ | |
| parent::__construct($em, $eventLogService, $dj, $kernel); | ||
| } | ||
|
|
||
| /** | ||
| * @param Language[] $languages | ||
| * @return Language[] | ||
| */ | ||
| private function addLanguage(array $languages, Language $language, ContestProblem $problem, bool $inverted = false): array | ||
| { | ||
| $langId = $language->getName(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it intentional here to use |
||
| if (!isset($languages[$langId])) { | ||
| $languages[$langId] = ['problems' => [], 'limitedProblems' => [], 'language' => $language]; | ||
| } | ||
| if ($inverted) { | ||
| $languages[$langId]['limitedProblems'][] = $problem; | ||
| } else { | ||
| $languages[$langId]['problems'][] = $problem; | ||
| } | ||
| return $languages; | ||
| } | ||
|
|
||
| /** | ||
| * @param Language[] $languages | ||
| * @return Language[] | ||
| */ | ||
| private function removeLanguage(array $languages, Language $language): array | ||
| { | ||
| $langId = $language->getLangid(); | ||
| if (isset($languages[$langId])) { | ||
| unset($languages[$langId]); | ||
| } | ||
| return $languages; | ||
| } | ||
|
|
||
| #[Route(path: '', name: 'team_languages')] | ||
| public function languagesAction(): Response | ||
| { | ||
| $languagesEnabled = $this->config->get('show_language_versions'); | ||
| if (!$languagesEnabled) { | ||
| throw new BadRequestHttpException("You are not allowed to view this page."); | ||
| } | ||
| $languages = []; | ||
| $currentContest = $this->dj->getCurrentContest(); | ||
| /** @var Language[] $languages */ | ||
| $languages = $this->dj->getAllowedLanguagesForContest($currentContest); | ||
| return $this->render('team/languages.html.twig', ['languages' => $languages]); | ||
| $limited = false; | ||
| $allLanguages = []; | ||
| foreach($this->dj->getAllowedLanguagesForContest($currentContest) as $language) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: phpcs error |
||
| $allLanguages[$language->getLangid()] = $language; | ||
| } | ||
| foreach ($this->dj->getCurrentContest()->getProblems() as $problem) { | ||
| foreach ($problem->getProblem()->getLanguages() as $language) { | ||
| $allLanguages[$language->getLangid()] = $language; | ||
| } | ||
| } | ||
| foreach ($this->dj->getCurrentContest()->getProblems() as $problem) { | ||
| $missingLanguages = $allLanguages; | ||
| foreach ($problem->getProblem()->getLanguages() as $language) { | ||
| $languages = $this->addLanguage($languages, $language, $problem); | ||
| $missingLanguages = $this->removeLanguage($missingLanguages, $language); | ||
| $limited = true; | ||
| } | ||
| if (count($problem->getProblem()->getLanguages()) == 0) { | ||
| foreach ($this->dj->getAllowedLanguagesForContest($currentContest) as $language) { | ||
| $languages = $this->addLanguage($languages, $language, $problem); | ||
| $missingLanguages = $this->removeLanguage($missingLanguages, $language); | ||
| } | ||
| } | ||
| foreach ($missingLanguages as $lang) { | ||
| $languages = $this->addLanguage($languages, $lang, $problem, true); | ||
| } | ||
| } | ||
| return $this->render('team/languages.html.twig', ['languages' => $languages, 'limited' => $limited]); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the return type that we actually return, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it is something complex like