Skip to content

Commit

Permalink
Contest leaderboard hiding (#826)
Browse files Browse the repository at this point in the history
* Add contest leaderboard hiding

* fix open leaderboard wrong condition
  • Loading branch information
YaleChen299 authored Sep 24, 2021
1 parent 02557b7 commit c447552
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/cadet/assessments/assessments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,8 @@ defmodule Cadet.Assessments do

defp leaderboard_open?(assessment, voting_question) do
Timex.before?(
Timex.now(),
Timex.shift(assessment.close_at, hours: voting_question.question["reveal_hours"])
Timex.shift(assessment.close_at, hours: voting_question.question["reveal_hours"]),
Timex.now()
)
end

Expand Down
15 changes: 11 additions & 4 deletions test/cadet_web/controllers/assessments_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,15 @@ defmodule CadetWeb.AssessmentsControllerTest do
role_crs: role_crs,
assessments: assessments
} do
voting_assessment = assessments["practical"].assessment

voting_assessment
|> Assessment.changeset(%{
open_at: Timex.shift(Timex.now(), days: -30),
close_at: Timex.shift(Timex.now(), days: -20)
})
|> Repo.update()

voting_question = assessments["practical"].voting_questions |> List.first()
contest_assessment_number = voting_question.question.contest_number

Expand Down Expand Up @@ -548,8 +557,7 @@ defmodule CadetWeb.AssessmentsControllerTest do

voting_assessment
|> Assessment.changeset(%{
open_at: Timex.shift(Timex.now(), days: -30),
close_at: Timex.shift(Timex.now(), days: -20)
close_at: Timex.shift(Timex.now(), days: 20)
})
|> Repo.update()

Expand Down Expand Up @@ -621,8 +629,7 @@ defmodule CadetWeb.AssessmentsControllerTest do

voting_assessment
|> Assessment.changeset(%{
open_at: Timex.shift(Timex.now(), days: -30),
close_at: Timex.shift(Timex.now(), days: -20)
close_at: Timex.shift(Timex.now(), days: 20)
})
|> Repo.update()

Expand Down

0 comments on commit c447552

Please sign in to comment.