Skip to content

Commit 2dbe45c

Browse files
committed
fix: merge tutorials for duplicate student rows
1 parent 559eb8c commit 2dbe45c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/models/unit.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,17 @@ def sync_enrolment_with(enrolment_data, import_settings, result)
763763
if changes.key? username
764764
if row_data[:enrolled] # they should be enrolled - record that... overriding anything else
765765
# record previous row as ignored
766-
ignored << { row: changes[username][:row], message: "Skipping duplicate role - ensuring enrolled" }
766+
ignored_entry = { row: changes[username][:row], message: 'Skipping duplicate role - ensuring enrolled.' }
767+
768+
# Allocate+ csv data may have duplicate student rows for each tutorial enrolment
769+
# We need to combine the tutorials from both rows so that the student is enrolled into each tutorial
770+
if import_settings[:merge_tutorials_for_duplicate_students] && changes[username][:tutorials]&.any?
771+
row_data[:tutorials] ||= []
772+
row_data[:tutorials].concat(changes[username][:tutorials])
773+
ignored_entry[:message] += ' Merged tutorial enrolments.'
774+
end
775+
776+
ignored << ignored_entry
767777
changes[username] = row_data
768778
else
769779
# record this row as skipped

0 commit comments

Comments
 (0)