Skip to content

Commit b70f4ab

Browse files
authored
Merge branch 'master' into ISSUE-7711_group_assignment_test_result_api_route
2 parents 5409b7c + 3421ef3 commit b70f4ab

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- Check against mtime instead of atime for clean up of git repo directories in tmp folder (#7706)
2828
- Update Model: Fix level validation checks through use of a custom validator (#7696)
2929
- Fixed test group results table to display `extra_info` field from all test groups (#7710)
30+
- Fixed syncing grades with Canvas to not include inactive students (#7759)
3031

3132
### 🔧 Internal changes
3233
- Updated Github Actions CI to use cache-apt-pkgs to speed up workflow runs (#7645)

app/helpers/lti_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def get_assignment_marks(lti_deployment, assignment)
117117
released_results = assignment.released_marks
118118
.joins(grouping: [{ accepted_student_memberships: { role: { user: :lti_users } } }])
119119
.where('lti_users.lti_client': lti_deployment.lti_client)
120+
.where(roles: { hidden: false })
120121
.pluck('lti_users.lti_user_id', 'results.id')
121122
result_ids = released_results.pluck(1)
122123
grades = Result.get_total_marks(result_ids)

spec/helpers/lti_helper_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,49 @@
496496
expect(get_assignment_marks(lti_deployment, assessment)).not_to be_empty
497497
end
498498
end
499+
500+
context 'when some students are inactive (hidden)' do
501+
let(:student1) { create(:student, course: course) }
502+
let(:student2) { create(:student, course: course) }
503+
let(:assignment) { create(:assignment, course: course) }
504+
505+
let!(:grouping) do
506+
create(:grouping, assignment: assignment).tap do |g|
507+
create(:student_membership,
508+
grouping: g,
509+
role: student1,
510+
membership_status: StudentMembership::STATUSES[:accepted])
511+
512+
create(:student_membership,
513+
grouping: g,
514+
role: student2,
515+
membership_status: StudentMembership::STATUSES[:accepted])
516+
end
517+
end
518+
519+
before do
520+
create(:result,
521+
grouping: grouping,
522+
released_to_students: true,
523+
marking_state: Result::MARKING_STATES[:complete])
524+
525+
student2.update!(hidden: true)
526+
527+
[student1.user, student2.user].each do |usr|
528+
create(:lti_user, user: usr, lti_client: lti_deployment.lti_client)
529+
end
530+
end
531+
532+
it 'does not include hidden students in the marks hash' do
533+
marks = get_assignment_marks(lti_deployment, assignment)
534+
535+
id1 = student1.user.lti_users.first.lti_user_id
536+
id2 = student2.user.lti_users.first.lti_user_id
537+
538+
expect(marks.keys).to include(id1)
539+
expect(marks.keys).not_to include(id2)
540+
end
541+
end
499542
end
500543

501544
describe '#get_grade_entry_form_marks' do

0 commit comments

Comments
 (0)