Skip to content

Commit

Permalink
Fix: Fix limit function for grading table fetch function (#1190)
Browse files Browse the repository at this point in the history
* fix: Fix limit functionality not working

* feat: Implement test for pagination
  • Loading branch information
GabrielCWT authored Sep 23, 2024
1 parent b02b43c commit e33b6c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cadet/assessments/assessments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,7 @@ defmodule Cadet.Assessments do
where: s.assessment_id in subquery(build_assessment_config_filter(params)),
where: ^build_submission_filter(params),
where: ^build_course_registration_filter(params, grader),
limit: ^params[:limit],
limit: ^params[:page_size],
offset: ^params[:offset],
select: %{
id: s.id,
Expand Down
23 changes: 23 additions & 0 deletions test/cadet/assessments/assessments_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2210,6 +2210,29 @@ defmodule Cadet.AssessmentsTest do
Map.put(seed, :total_submissions, total_submissions)
end

test "limit submissions", %{
course_regs: %{avenger1_cr: avenger}
} do
{_, res} =
Assessments.submissions_by_grader_for_index(avenger, %{
:page_size => 1
})

assert length(res[:data][:submissions]) == 1
end

test "limit submisssions 2", %{
course_regs: %{avenger1_cr: avenger},
assessments: assessments

Check warning on line 2226 in test/cadet/assessments/assessments_test.exs

View workflow job for this annotation

GitHub Actions / Run CI

variable "assessments" is unused (if the variable is not meant to be used, prefix it with an underscore)
} do
{_, res} =
Assessments.submissions_by_grader_for_index(avenger, %{
:page_size => 2
})

assert length(res[:data][:submissions]) == 2
end

test "filter by assessment title", %{
course_regs: %{avenger1_cr: avenger},
assessments: assessments,
Expand Down

0 comments on commit e33b6c0

Please sign in to comment.