Skip to content

Conversation

@TamaroWalter
Copy link
Contributor

@TamaroWalter TamaroWalter commented Nov 2, 2025

🔀 Purpose of this PR:

  • Fixes a bug
  • Updates for a new Moodle version
  • Adds a new feature of functionality
  • Improves or enhances existing features
  • Refactoring: restructures code for better performance or maintainability
  • Testing: add missing or improve existing tests
  • Miscellaneous: code cleaning (without functional changes), documentation, configuration, ...

📝 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):

foreach ($discussions as $discussionid) {...}

What is the solution?
Iterate the right way over the array, explicitly using the key:

foreach ($discussions as $discussionid => $unread) {...}

📋 Checklist

Please confirm the following (check all that apply):

  • I have phpunit and/or behat tests that cover my changes or additions.
  • Code passes the code checker without errors and warnings.
  • Code passes the moodle-ci/cd pipeline on all supported Moodle versions or the ones the plugin supports.
  • Code does not have var_dump() or var_export or any other debugging statements (or commented out code) that
    should not appear on the productive branch.
  • Code only uses language strings instead of hard-coded strings.
  • If there are changes in the database: I updated/created the necessary upgrade steps in db/upgrade.php and
    updated the version.php.
  • If there are changes in javascript: I build new .min files with the grunt amd command.
  • If it is a Moodle update PR: I read the release notes, updated the version.php and the CHANGES.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

@TamaroWalter TamaroWalter self-assigned this Nov 2, 2025
@TamaroWalter TamaroWalter linked an issue Nov 2, 2025 that may be closed by this pull request
@TamaroWalter TamaroWalter merged commit 810524a into main Nov 2, 2025
52 checks passed
@TamaroWalter TamaroWalter deleted the fix/markunreadposts branch November 2, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problems with marking/notification

2 participants