Skip to content

Commit 36a3a69

Browse files
committed
Add endpoint
1 parent 0645990 commit 36a3a69

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib/cadet_web/admin_controllers/admin_grading_controller.ex

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ defmodule CadetWeb.AdminGradingController do
5858
index(conn, %{"group" => "false"})
5959
end
6060

61+
@doc """
62+
# Description
63+
Attains every assessment submission registered, regardless of grading or attempted status.
64+
This is a special call of the general `index` submission whereby pagination is bypassed.
65+
"""
66+
def index_all_submissions(conn, _) do
67+
# 100 billion page size here should cover all feasible table rows in 1 page
68+
# given that the hard limit of pages in a postgres database is ~4 billion.
69+
# (https://www.postgresql.org/docs/current/limits.html)
70+
index(
71+
conn,
72+
%{"group" => "false", "pageSize" => "100000000000", "offset" => "0"}
73+
)
74+
end
75+
6176
def show(conn, %{"submissionid" => submission_id}) when is_ecto_id(submission_id) do
6277
case Assessments.get_answers_in_submission(submission_id) do
6378
{:ok, {answers, assessment}} ->
@@ -367,7 +382,9 @@ defmodule CadetWeb.AdminGradingController do
367382
required: true
368383
)
369384

370-
student(Schema.ref(:StudentInfo), "Student who created the submission", required: true)
385+
student(Schema.ref(:StudentInfo), "Student who created the submission",
386+
required: true
387+
)
371388

372389
unsubmittedBy(Schema.ref(:GraderInfo))
373390
unsubmittedAt(:string, "Last unsubmitted at", format: "date-time", required: false)

lib/cadet_web/router.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ defmodule CadetWeb.Router do
144144
post("/assessments/:assessmentid", AdminAssessmentsController, :update)
145145
delete("/assessments/:assessmentid", AdminAssessmentsController, :delete)
146146

147+
get("/grading/all_submissions", AdminGradingController, :index_all_submissions)
148+
147149
post(
148150
"/grading/:assessmentid/publish_all_grades",
149151
AdminGradingController,

priv/repo/seeds.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ alias Cadet.Accounts.{
2626
# Cadet.Repo.insert!(%Cadet.Settings.Sublanguage{chapter: 1, variant: "default"})
2727

2828
if Cadet.Env.env() == :dev do
29-
number_of_students = 100_000
29+
number_of_students = 100
3030
number_of_assessments = 5
3131
number_of_questions = 13
3232

0 commit comments

Comments
 (0)