Skip to content

Commit

Permalink
Merge pull request #482 from sul-dlss/updateInstructorLogic
Browse files Browse the repository at this point in the history
Removing duplicate instructors across meetings for same section
  • Loading branch information
cbeer authored May 22, 2023
2 parents f0e35fb + 9f0fe45 commit 099895c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/services/course_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,14 @@ def parse_sections(response_xml, request_class_id)
# The same course request can return cross listed courses, so we will need to get a specific id
course_response.xpath("//class[@id='#{request_class_id}']//section[.//instructor]").each do |section|
section_id = section[:id]
instructors = []
# We do not want to duplicate instructor names even if multiple meetings have same instructor
instructor_sunets = {}
section.xpath(".//instructor/person").each do |person|
sunetid = person[:sunetid]
name = person.text
instructors << { sunet: sunetid, name: name }
instructor_sunets[sunetid] = name unless instructor_sunets.key?(sunetid)
end
sections << { sid: section_id, instructors: instructors }
sections << { sid: section_id, instructors: instructor_sunets.map { |k, v| { sunet: k, name: v } } }
end
sections
end
Expand Down

0 comments on commit 099895c

Please sign in to comment.