Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cae19ab
added full test coverage for the MarksGraderController#randomly_assig…
danielrafailov1 May 12, 2026
68e16a0
added my name to the contributors file
danielrafailov1 May 12, 2026
4b10fc9
Added relevant changes to the changelog
danielrafailov1 May 12, 2026
349a73d
Included due date in LTI assessment sync (#7872)
Naragod May 14, 2026
7e60231
Added rake task to backfill start and end course dates (#7925)
Naragod May 14, 2026
6943752
Fixed remark request display of original result's total mark (#7945)
donny-wong May 15, 2026
78119c6
Fixed flaky git-hooks tests (#7950)
david-yz-liu May 15, 2026
e4ab049
Moved my changes in the Changelog file from the New features and impr…
danielrafailov1 May 17, 2026
c8bb827
Merged upstream/master and resolved conflicts in Changelog.md
danielrafailov1 May 17, 2026
74e030c
Merge branch 'MarkUsProject:master' into marks_graders_controller_ran…
danielrafailov1 May 18, 2026
60109a4
fixed merge conflcits in Changelog.md
danielrafailov1 May 19, 2026
033e92e
changed find_or_create_by to find_by
danielrafailov1 May 19, 2026
63313d0
Merge branch 'MarkUsProject:master' into marks_graders_controller_ran…
danielrafailov1 May 20, 2026
81b645a
Merge remote-tracking branch 'upstream' into marks_graders_controller…
danielrafailov1 May 20, 2026
119cf63
added new test and did some refactoring
danielrafailov1 May 21, 2026
530ccce
Merge remote-tracking branch 'origin/marks_graders_controller_randoml…
danielrafailov1 May 21, 2026
017498b
chore: trigger github actions retry
danielrafailov1 May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Fix: include original total mark in JSON response for remark requests (#7945)

### 🔧 Internal changes
- Added tests for `MarksGradersController` to achieve full test coverage for `randomly_assign` (#7947)
- Fixed flaky test `can bulk assign duplicated TAs to grade entry students` in `/spec/models/grade_entry_student_spec.rb` (#7958)
- Added tests for `GroupsController` to fully cover `global_actions` (#7955)
- Added tests for `graders_controller` to fully cover `grader_criteria_mapping` function (#7949)
Expand Down
1 change: 1 addition & 0 deletions doc/markus-contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Clément Delafargue
Clément Schiano
Danesh Dadachanji
Daniel Dervishi
Daniel Rafailov
Daniel St. Jules
Daniyal Liaqat
Daryn Lam
Expand Down
111 changes: 111 additions & 0 deletions spec/controllers/marks_graders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,115 @@
end
end
end

describe '#randomly_assign' do
context 'does not require initial setup' do
context 'when students and graders are selected' do
it 'calls GradeEntryStudent `randomly_assign_tas` and ensures that every student gets a TA assigned to them' do
tas = create_list(:ta, 3)
ta_ids = tas.map(&:id)

students = create_list(:student, 10, course: course)
student_ids = students.map(&:id)

post_as instructor, :randomly_assign, params: {
course_id: course.id,
grade_entry_form_id: grade_entry_form.id,
students: student_ids,
graders: ta_ids
}

expect(response).to have_http_status(:ok)

students.each do |student|
ges = grade_entry_form.grade_entry_students.find_by!(role: student.id)
expect(ges.tas.count).to eq(1)
end
end
end
end

context 'requires initial setup' do
before do
allow(GradeEntryStudent).to receive(:randomly_assign_tas)
end

context 'when students and graders are selected' do
it 'calls GradeEntryStudent `randomly_assign_tas` and returns a success response' do
student = create(:student)
grade_entry_student = grade_entry_form.grade_entry_students.find_by(role: student)
grade_entry_student_ta = create(:grade_entry_student_ta, grade_entry_student: grade_entry_student)

expect(GradeEntryStudent).to receive(:randomly_assign_tas).with(
[grade_entry_student.id.to_s],
[grade_entry_student_ta.id.to_s],
grade_entry_form
)

post_as instructor, :randomly_assign, params: {
course_id: course.id,
grade_entry_form_id: grade_entry_form.id,
students: [grade_entry_student.id],
graders: [grade_entry_student_ta.id]
}

expect(response).to have_http_status(:ok)
end
end

context 'when students are not selected' do
it 'returns bad request and sets a flash error' do
post_as instructor, :randomly_assign, params: {
course_id: course.id,
grade_entry_form_id: grade_entry_form.id,
students: [],
graders: [1]
}

expect(response).to have_http_status(:bad_request)
expect(flash[:error]).to have_message(I18n.t('groups.select_a_student'))
end
end

context 'when graders are not selected' do
it 'returns bad request and sets flash error' do
post_as instructor, :randomly_assign, params: {
course_id: course.id,
grade_entry_form_id: grade_entry_form.id,
students: [1],
graders: []
}

expect(response).to have_http_status(:bad_request)
expect(flash[:error]).to have_message(I18n.t('graders.select_a_grader'))
end
end

context 'when students parameter is missing' do
it 'returns bad request and sets flash error' do
post_as instructor, :randomly_assign, params: {
course_id: course.id,
grade_entry_form_id: grade_entry_form.id,
graders: [1]
}

expect(response).to have_http_status(:bad_request)
expect(flash[:error]).to have_message(I18n.t('groups.select_a_student'))
end
end

context 'when graders parameter is missing' do
it 'returns bad request and sets flash error' do
post_as instructor, :randomly_assign, params: {
course_id: course.id,
grade_entry_form_id: grade_entry_form.id,
students: [1]
}

expect(response).to have_http_status(:bad_request)
expect(flash[:error]).to have_message(I18n.t('graders.select_a_grader'))
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/models/grade_entry_student_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
GradeEntryStudent.assign_all_tas(student_ids, ta_ids.first, form)

# First grade entry student gets all the TAs.
grade_entry_student = form.grade_entry_students.find_by!(role_id: student_ids.first)
grade_entry_student = form.grade_entry_students.first
grade_entry_student.reload
form.grade_entry_students.delete(grade_entry_student)
expect(grade_entry_student.tas).to match_array(tas)
Expand Down
Loading