diff --git a/lib/cadet/assessments/assessments.ex b/lib/cadet/assessments/assessments.ex index f95cdfec2..d37b0c45c 100644 --- a/lib/cadet/assessments/assessments.ex +++ b/lib/cadet/assessments/assessments.ex @@ -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 diff --git a/test/cadet_web/controllers/assessments_controller_test.exs b/test/cadet_web/controllers/assessments_controller_test.exs index 1a27ec05c..709fa960e 100644 --- a/test/cadet_web/controllers/assessments_controller_test.exs +++ b/test/cadet_web/controllers/assessments_controller_test.exs @@ -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 @@ -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() @@ -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()