Skip to content

Commit

Permalink
🔧 Fix course update bug with Roster API, #151
Browse files Browse the repository at this point in the history
- Don't sync course resource if there is no change in the column being synchronized
  • Loading branch information
kyoshizaki committed Nov 29, 2018
1 parent 034cb02 commit dcb016d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def edit

def update
@course = Course.find_enabled_by params[:id]
initial_hash = @course.to_roster_hash
course_form = course_params
# Remedy for both new file upload and delete_image are selected
course_form.delete(:remove_image) if course_form[:image] && course_form[:image].size.nonzero?
Expand All @@ -62,7 +63,7 @@ def update
raise unless @course.update_attributes course_form.merge(status: term.status)
raise t('controllers.courses.manager_creation_failed') unless register_course_managers
@course.update_lesson_notes
if SYSTEM_ROSTER_SYNC == :on
if (SYSTEM_ROSTER_SYNC == :on) && !initial_hash.eql?(@course.to_roster_hash)
payload = {class: @course.to_roster_hash}
response = request_roster_api("/classes/#{@course.sourced_id}", :put, payload)
end
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# Synchronization mode with IMS OneRoster API: select one from [:on, :suspended, :off]
# Check schedule.rb and run "bundle exec whenever -i" when SYSTEM_ROSTER_SYNC changes
SYSTEM_ROSTER_SYNC = :on.freeze
SYSTEM_ROSTER_SYNC = :off.freeze

# ===== Versatile constatns =====
# time delay for autocomplete
Expand Down

0 comments on commit dcb016d

Please sign in to comment.