Skip to content

Commit ed907e5

Browse files
authored
Merge branch 'master' into gabriel/pagination
2 parents 4d2f3b2 + dd89ec9 commit ed907e5

File tree

5 files changed

+355
-310
lines changed

5 files changed

+355
-310
lines changed

lib/cadet/assessments/assessments.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,8 @@ defmodule Cadet.Assessments do
14821482
end
14831483

14841484
@spec get_answers_in_submission(integer() | String.t()) ::
1485-
{:ok, [Answer.t()]} | {:error, {:bad_request, String.t()}}
1485+
{:ok, {[Answer.t()], Assessment.t()}}
1486+
| {:error, {:bad_request, String.t()}}
14861487
def get_answers_in_submission(id) when is_ecto_id(id) do
14871488
answer_query =
14881489
Answer
@@ -1519,7 +1520,9 @@ defmodule Cadet.Assessments do
15191520
if answers == [] do
15201521
{:error, {:bad_request, "Submission is not found."}}
15211522
else
1522-
{:ok, answers}
1523+
assessment_id = Submission |> where(id: ^id) |> select([s], s.assessment_id) |> Repo.one()
1524+
assessment = Assessment |> where(id: ^assessment_id) |> Repo.one()
1525+
{:ok, {answers, assessment}}
15231526
end
15241527
end
15251528

lib/cadet_web/admin_controllers/admin_grading_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ defmodule CadetWeb.AdminGradingController do
2323

2424
def show(conn, %{"submissionid" => submission_id}) when is_ecto_id(submission_id) do
2525
case Assessments.get_answers_in_submission(submission_id) do
26-
{:ok, answers} ->
27-
render(conn, "show.json", answers: answers)
26+
{:ok, {answers, assessment}} ->
27+
render(conn, "show.json", answers: answers, assessment: assessment)
2828

2929
{:error, {status, message}} ->
3030
conn

lib/cadet_web/admin_views/admin_grading_view.ex

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,25 @@ defmodule CadetWeb.AdminGradingView do
33

44
import CadetWeb.AssessmentsHelpers
55

6-
def render("show.json", %{answers: answers}) do
7-
render_many(answers, CadetWeb.AdminGradingView, "grading_info.json", as: :answer)
6+
def render("show.json", %{answers: answers, assessment: assessment}) do
7+
%{
8+
assessment:
9+
render_one(assessment, CadetWeb.AdminGradingView, "assessment.json", as: :assessment),
10+
answers: render_many(answers, CadetWeb.AdminGradingView, "grading_info.json", as: :answer)
11+
}
12+
end
13+
14+
def render("assessment.json", %{assessment: assessment}) do
15+
%{
16+
id: assessment.id,
17+
title: assessment.title,
18+
summaryShort: assessment.summary_short,
19+
summaryLong: assessment.summary_long,
20+
coverPicture: assessment.cover_picture,
21+
number: assessment.number,
22+
story: assessment.story,
23+
reading: assessment.reading
24+
}
825
end
926

1027
def render("gradingsummaries.json", %{

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
6565
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
6666
"mock": {:hex, :mock, "0.3.8", "7046a306b71db2488ef54395eeb74df0a7f335a7caca4a3d3875d1fc81c884dd", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "7fa82364c97617d79bb7d15571193fc0c4fe5afd0c932cef09426b3ee6fe2022"},
67-
"oban": {:hex, :oban, "2.17.3", "ddfd5710aadcd550d2e174c8d73ce5f1865601418cf54a91775f20443fb832b7", [:mix], [{:ecto_sql, "~> 3.6", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "452eada8bfe0d0fefd0740ab5fa8cf3ef6c375df0b4a3c3805d179022a04738a"},
67+
"oban": {:hex, :oban, "2.17.4", "3ebe79dc0cad16f23e5feea418f9bc5b07d453b8fb7caf376d812be96157a5c5", [:mix], [{:ecto_sql, "~> 3.6", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "71a804abea3bb7e104782a5b5337cbab76c1a56b9689a6d5159a3873c93898b6"},
6868
"openid_connect": {:hex, :openid_connect, "0.2.2", "c05055363330deab39ffd89e609db6b37752f255a93802006d83b45596189c0b", [:mix], [{:httpoison, "~> 1.2", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm", "735769b6d592124b58edd0582554ce638524c0214cd783d8903d33357d74cc13"},
6969
"parallel_stream": {:hex, :parallel_stream, "1.1.0", "f52f73eb344bc22de335992377413138405796e0d0ad99d995d9977ac29f1ca9", [:mix], [], "hexpm", "684fd19191aedfaf387bbabbeb8ff3c752f0220c8112eb907d797f4592d6e871"},
7070
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},

0 commit comments

Comments
 (0)