Skip to content

Commit

Permalink
Configure subscriptions to discussions like in forum activity.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Jun 12, 2024
1 parent e2314a1 commit 4127266
Show file tree
Hide file tree
Showing 16 changed files with 1,357 additions and 48 deletions.
81 changes: 61 additions & 20 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:

services:
postgres:
image: postgres
image: postgres:14
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
image: mariadb
image: mariadb:10.6
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
Expand All @@ -28,51 +28,92 @@ jobs:
fail-fast: false
matrix:
include:
- php: 8.3
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.3
moodle-branch: MOODLE_404_STABLE
database: mariadb

- php: 8.2
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_404_STABLE
database: mariadb
- php: 8.2
moodle-branch: MOODLE_403_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_403_STABLE
database: mariadb
- php: 8.2
moodle-branch: MOODLE_402_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_402_STABLE
database: mariadb

- php: 8.1
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_404_STABLE
database: mariadb
- php: 8.1
moodle-branch: MOODLE_403_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_403_STABLE
database: mariadb
- php: 8.1
moodle-branch: MOODLE_402_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_402_STABLE
database: mariadb
- php: 8.1
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_401_STABLE
database: mariadb

- php: 8.0
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 8.0
moodle-branch: MOODLE_401_STABLE
database: mariadb

- php: 8.0
moodle-branch: MOODLE_400_STABLE
database: pgsql
- php: 8.0
moodle-branch: MOODLE_400_STABLE
database: mariadb

- php: 7.4
- php: 8.0
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 7.4
- php: 8.0
moodle-branch: MOODLE_401_STABLE
database: mariadb

- php: 7.4
- php: 8.0
moodle-branch: MOODLE_400_STABLE
database: pgsql
- php: 7.4
- php: 8.0
moodle-branch: MOODLE_400_STABLE
database: mariadb

- php: 7.4
moodle-branch: MOODLE_311_STABLE
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 7.4
moodle-branch: MOODLE_311_STABLE
database: mariadb

- php: 7.3
moodle-branch: MOODLE_311_STABLE
database: pgsql
- php: 7.3
moodle-branch: MOODLE_311_STABLE
moodle-branch: MOODLE_401_STABLE
database: mariadb

steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -86,7 +127,7 @@ jobs:

- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
Expand Down
17 changes: 13 additions & 4 deletions classes/output/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct($data, $cm, $context) {
$this->addeditbutton($comment, $editanypost);
$this->addhidebutton($comment, $seehiddencomments, $hidecomments);
$this->adddeletebutton($comment, $deleteown, $deleteany);
$this->addsubscribebutton($comment, $subscribe);
$this->addsubscribebutton($comment, $subscribe, $cm);
$this->addforwardbutton($comment, $forwardquestions, $cm);
$this->addmarksolvedbutton($comment, $solve);

Expand Down Expand Up @@ -270,9 +270,18 @@ private function adddeletebutton($comment, $deleteown, $deleteany) {
}
}

private function addsubscribebutton($comment, $subscribe) {
if (!isset($comment->type) && $comment->isquestion && $subscribe && $comment->visibility != 'private') {
// Only set for textbox and drawing.
/**
* Add a subscribe button
*
* @param object $comment
* @param bool $subscribe
* @param stdClass $cm course module object
* @throws \coding_exception
*/
private function addsubscribebutton($comment, $subscribe, $cm) {
// Only set for textbox and drawing, and only if subscription mode is not disabled or forced.
if ((pdfannotator_get_subscriptionmode($cm->instance) == PDFANNOTATOR_CHOOSESUBSCRIBE) ||
(pdfannotator_get_subscriptionmode($cm->instance) == PDFANNOTATOR_INITIALSUBSCRIBE)) {
if (!empty($comment->issubscribed)) {
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell-slash"],
"text" => get_string('unsubscribeQuestion', 'pdfannotator')];
Expand Down
Loading

0 comments on commit 4127266

Please sign in to comment.