Skip to content

Commit

Permalink
cherry-pick: Add option to hide nonloggedin/nonsubmitted teams on the…
Browse files Browse the repository at this point in the history
… scoreboard (DOMjudge#2134)

* Add option to hide nonloggedin/nonsubmitted teams on the scoreboard

Done as a config option for the following 2 cases:
- Normally you want a team which has logged on on the scoreboard
- In case of the autologin tool of GEHACK/Nicky the user would also
login without interaction of the actual team

* Allow API logon as the submit client uses it

Alternative would be to UNION over teams which submitted and teams which
did a GUI logon but that is more expensive.
  • Loading branch information
vmcj authored and tom93 committed Aug 5, 2024
1 parent 1e2219a commit fa26671
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 9 additions & 0 deletions etc/db-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@
default_value: true
public: true
description: Show submission and problem statistics on the team and public pages.
- name: show_teams_on_scoreboard
type: int
default_value: 0
public: true
description: Show teams on the scoreboard?
options:
0: Always
1: After login
2: After first submission
- category: Authentication
description: Options related to authentication.
items:
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/Service/ScoreboardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
*/
class ScoreboardService
{
final public const SHOW_TEAM_ALWAYS = 0;
final public const SHOW_TEAM_AFTER_LOGIN = 1;
final public const SHOW_TEAM_AFTER_SUBMIT = 2;

protected EntityManagerInterface $em;
protected DOMJudgeService $dj;
protected ConfigurationService $config;
Expand Down Expand Up @@ -932,8 +936,17 @@ protected function getTeams(Contest $contest, bool $jury = false, Filter $filter
->setParameter('cid', $contest->getCid());
}

$show_filter = $this->config->get('show_teams_on_scoreboard');
if (!$jury) {
$queryBuilder->andWhere('tc.visible = 1');
if ($show_filter === self::SHOW_TEAM_AFTER_LOGIN) {
$queryBuilder
->join('t.users', 'u', Join::WITH, 'u.last_login IS NOT NULL OR u.last_api_login IS NOT NULL');
} elseif ($show_filter === self::SHOW_TEAM_AFTER_SUBMIT) {
$queryBuilder
->join('t.submissions', 's', Join::WITH, 's.contest = :cid')
->setParameter('cid', $contest->getCid());
}
}

if ($filter) {
Expand Down
11 changes: 6 additions & 5 deletions webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ protected function setUp(): void

// Default configuration values:
$this->configValues = [
'verification_required' => false,
'compile_penalty' => false,
'penalty_time' => 20,
'score_in_seconds' => false,
'data_source' => 0,
'verification_required' => false,
'compile_penalty' => false,
'penalty_time' => 20,
'score_in_seconds' => false,
'data_source' => 0,
'show_teams_on_scoreboard' => 0,
];

$this->config = $this->createMock(ConfigurationService::class);
Expand Down

0 comments on commit fa26671

Please sign in to comment.