Fix button that marks all posts as read #232
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.
🔀 Purpose of this PR:
📝 Description:
The issue #230 described the problem that the "mark all posts as read" button did not perform its intended function. Instead of marking posts as read, the button had no effect.
What was the problem?
The function responsible for marking all posts in moodleoverflow as read (readtracking::moodleoverflow_mark_moodleoverflow_read() ) iterates through the unread discussions of a user. These unread discussions are stored in an associative array of the form:
$discussions = [discussionID => amount_of_unread_posts].However, the loop incorrectly iterated over the values (number of unread posts) instead of the keys (discussion IDs):
What is the solution?
Iterate the right way over the array, explicitly using the key:
📋 Checklist
Please confirm the following (check all that apply):
phpunitand/orbehattests that cover my changes or additions.var_dump()orvar_exportor any other debugging statements (or commented out code) thatshould not appear on the productive branch.
db/upgrade.phpandupdated the
version.php..minfiles with thegrunt amdcommand.version.phpand theCHANGES.md.I ran all tests thoroughly checking for errors. I checked if bootstrap had any changes/deprecations that require
changes in the plugins UI.
🔍 Related Issues