[BUG FIX] [MER-4231] LTI course sections are incorrectly automatically created #5410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eliterate.atlassian.net/browse/MER-4231
Fixes an issue related to the LTI launch issue where the system was using the wrong LTIParams for a user, resulting in a previous/incorrect section being loaded.
The underlying issue here is that the relationship for user LTI params was specified as a
has_one
, however a user can have multiple associated params records. It seems that by preloading the LTI params, we had no control over which record is loaded (I assume it is the first one returned ordered by the database id, which would result in the first/oldest section a user ever launched into).The fix here updates the relationship to be more accurately specified as a
has_many
and adds a function to load the latest LTI launch params ordered by theupdated_at
field, which are then used to locate the section.