Skip to content

Commit

Permalink
WIP: change button string if posts are marked
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Apr 17, 2023
1 parent b98a9de commit 5b04f0e
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 54 deletions.
2 changes: 1 addition & 1 deletion amd/build/rating.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions amd/src/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ export function init(userid, allowmultiplemark) {
postElement.classList.remove(htmlclass);
actionElement.textContent = await getString(`mark${action}`, 'mod_moodleoverflow');
}
// Iterate trough all posts in the discussion and check if there are other marked posts.
var othermarkedposts = 0;
for (const el of root.querySelectorAll('.moodleoverflowpost')) {
if (el.classList.contains(htmlclass)) {
othermarkedposts = 1;
break;
}
}
// If there are other marked posts, iterate trough each post and update the string to 'also mark as ...' .
// Else: do nothing, because if there is no marked post, the string doesn't change.
if (othermarkedposts == 1) {
for (const el of root.querySelectorAll('.moodleoverflowpost')) {
if (!el.classList.contains(htmlclass)) {
el.querySelector(`[data-moodleoverflow-action="${action}"]`).textContent =
await getString(`alsomark${action}`, 'mod_moodleoverflow');
}
}
}
}
// If the post is being marked, mark it.
if (!shouldRemove) {
Expand Down
Loading

0 comments on commit 5b04f0e

Please sign in to comment.