Skip to content

Commit 23ff44b

Browse files
committed
chore: revert grading server
1 parent 19e4719 commit 23ff44b

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

grading_server/lib/grading_server/answer_store.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule GradingServer.AnswerStore do
2424
{:ok, state}
2525
end
2626

27-
defp key(module_id, question_id), do: "#{module_id}-#{question_id}"
27+
defp key(module_id, question_id), do: "module_#{module_id}-#{question_id}}"
2828

2929
@impl true
3030
def handle_call({:fetch, module_id, question_id}, _from, _) do
@@ -63,9 +63,12 @@ defmodule GradingServer.AnswerStore do
6363
end
6464

6565
defp map_module({module_name, answers}) do
66+
[_, module_id] = String.split(module_name, "module_")
67+
module_id = String.to_integer(module_id)
68+
6669
Enum.map(answers, fn data ->
6770
%Answer{
68-
module_id: module_name,
71+
module_id: module_id,
6972
answer: data["answer"],
7073
help_text: data["help_text"],
7174
question_id: data["question_id"]

grading_server/lib/grading_server/answers.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule GradingServer.Answers do
1616
{:incorrect, "Question not found"}
1717

1818
%{answer: correct_answer, help_text: help_text} ->
19-
if String.trim(inspect(answer)) == String.trim(correct_answer) do
19+
if String.trim(answer) == String.trim(correct_answer) do
2020
:correct
2121
else
2222
{:incorrect, help_text}

grading_server/priv/answers.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,42 @@
33
module_1:
44
- question_id: 1
55
help_text: "This is helpful text that can be used."
6-
answer: ":f"
6+
answer: "Not a real answer, but an example."
7+
8+
module_2:
9+
- question_id: 1
10+
help_text: ""
11+
answer: ""
12+
- question_id: 2
13+
help_text: ""
14+
answer: ""
15+
16+
module_3:
17+
- question_id: 1
18+
help_text: ""
19+
answer: ""
20+
21+
module_5:
22+
- question_id: 1
23+
help_text: ""
24+
answer: ""
25+
26+
module_6:
27+
- question_id: 1
28+
help_text: ""
29+
answer: ""
30+
31+
module_7:
32+
- question_id: 1
33+
help_text: ""
34+
answer: ""
35+
36+
module_8:
37+
- question_id: 1
38+
help_text: ""
39+
answer: ""
40+
41+
module_9:
42+
- question_id: 1
43+
help_text: ""
44+
answer: ""

0 commit comments

Comments
 (0)