Skip to content

Commit 8424c63

Browse files
committed
Restore correctness check for win condition
1 parent 1ceacb8 commit 8424c63

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

registrations/lib/registrations/waydowntown.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,10 @@ defmodule Registrations.Waydowntown do
604604

605605
concept when concept in ["bluetooth_collector", "code_collector", "string_collector", "food_court_frenzy"] ->
606606
run_answer_count = length(run.specification.answers)
607-
submissions_by_user = Enum.group_by(run.submissions, & &1.creator_id)
607+
correct_submissions = Enum.filter(run.submissions, & &1.correct)
608+
correct_submissions_by_user = Enum.group_by(correct_submissions, & &1.creator_id)
608609

609-
Enum.any?(Map.values(submissions_by_user), &(length(&1) == run_answer_count))
610+
Enum.any?(Map.values(correct_submissions_by_user), &(length(&1) == run_answer_count))
610611

611612
# FIXME these all need fixing, and order is missing
612613
"orientation_memory" ->

registrations/test/registrations_web/controllers/submission_controller_test.exs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ defmodule RegistrationsWeb.SubmissionControllerTest do
795795
assert included_run["attributes"]["total_answers"] == 3
796796
end
797797

798-
test "win check is user-scoped", %{conn: conn, run: run, user: user} do
798+
test "win check is user- and correctness-scoped", %{conn: conn, run: run, user: user} do
799799
other_user = insert(:user)
800800

801801
Repo.insert!(%Submission{
@@ -812,6 +812,20 @@ defmodule RegistrationsWeb.SubmissionControllerTest do
812812
creator: other_user
813813
})
814814

815+
Repo.insert!(%Submission{
816+
submission: "first string",
817+
run_id: run.id,
818+
correct: true,
819+
creator: user
820+
})
821+
822+
Repo.insert!(%Submission{
823+
submission: "non string",
824+
run_id: run.id,
825+
correct: false,
826+
creator: user
827+
})
828+
815829
conn =
816830
conn
817831
|> setup_conn(user)

0 commit comments

Comments
 (0)