Skip to content

Commit 3629dd9

Browse files
committed
Add solution field to GradingController.show
1 parent 0d10313 commit 3629dd9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/cadet_web/controllers/grading_controller.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ defmodule CadetWeb.GradingController do
160160
GradingInfo:
161161
swagger_schema do
162162
description(
163-
"A list of questions with submitted answers and previous grading info if available"
163+
"A list of questions with submitted answers, solution and previous grading info " <>
164+
"if available"
164165
)
165166

166167
type(:array)
@@ -171,6 +172,12 @@ defmodule CadetWeb.GradingController do
171172
question(Schema.ref(:Question))
172173
grade(Schema.ref(:Grade))
173174

175+
solution(
176+
:string,
177+
"the marking scheme and model solution to this question. Only available for programming questions",
178+
required: true
179+
)
180+
174181
maxGrade(
175182
:integer,
176183
"the max grade that can be given to this question",

lib/cadet_web/views/grading_view.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ defmodule CadetWeb.GradingView do
3535
&1.answer["code"] || &1.answer["choice_id"]
3636
),
3737
maxGrade: & &1.question.max_grade,
38+
solution: &(&1.question.question["solution"] || ""),
3839
grade: &transform_map_for_view(&1, [:grade, :adjustment, :comment])
3940
})
4041
end

test/cadet_web/controllers/grading_controller_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ defmodule CadetWeb.GradingControllerTest do
144144
"content" => &1.question.question.content,
145145
"answer" => &1.answer.code
146146
},
147+
"solution" => &1.question.question.solution,
147148
"maxGrade" => &1.question.max_grade,
148149
"grade" => %{
149150
"grade" => &1.grade,
@@ -176,6 +177,7 @@ defmodule CadetWeb.GradingControllerTest do
176177
}
177178
end
178179
},
180+
"solution" => "",
179181
"maxGrade" => &1.question.max_grade,
180182
"grade" => %{
181183
"grade" => &1.grade,

0 commit comments

Comments
 (0)