Fix two bugs (OC-839) #52
Merged
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.
JIRA: OC-839
This fixes:
Bug 1
The LMS sequential ("subsection") displays tooltips in its accordion unit selector according to a strange criterion: If there are zero or one child blocks in the "Unit" (vertical block) and there is no title set on that child, then the Unit's title is used. Otherwise, the recursively combined titles of all child blocks are shown.
This caused an apparent regression when upgrading from mentoring to problem builder, in a course with no titles set on any of the mentoring/pb blocks: Since Problem Builder now declares a title ("Mentoring Questions") by default, that title was being used instead of the unit's title.
To fix this, I have changed the
get_content_titlesmethod to only return a title to the LMS if a title is set explicitly.Before:

After:

Bug 2
When a text answer is provided in the same subsection as an answer recap (or another text answer with the same answer id), submitted answers aren't updated. This is because the LMS loads a whole sub-section at once - when navigating the different units, the initial answers values remain the ones from the initial loading of the subsection.
I have fixed this by refreshing the answers with JavaScript/AJAX every time the unit is activated. The answer values of an editable answer field are only updated if the user hasn't modified them, to avoid losing edits.