Skip to content

Commit 218b6b1

Browse files
committed
Configure subscriptions to discussions like in forum activity.
1 parent e2314a1 commit 218b6b1

17 files changed

+1388
-69
lines changed

.github/workflows/moodle-plugin-ci.yml

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ jobs:
88

99
services:
1010
postgres:
11-
image: postgres
11+
image: postgres:14
1212
env:
1313
POSTGRES_USER: 'postgres'
1414
POSTGRES_HOST_AUTH_METHOD: 'trust'
1515
ports:
1616
- 5432:5432
1717
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
1818
mariadb:
19-
image: mariadb
19+
image: mariadb:10.6
2020
env:
2121
MYSQL_USER: 'root'
2222
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
@@ -28,51 +28,86 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31-
- php: 8.0
32-
moodle-branch: MOODLE_401_STABLE
31+
- php: 8.3
32+
moodle-branch: MOODLE_404_STABLE
3333
database: pgsql
34-
- php: 8.0
35-
moodle-branch: MOODLE_401_STABLE
34+
- php: 8.3
35+
moodle-branch: MOODLE_404_STABLE
3636
database: mariadb
3737

38-
- php: 8.0
39-
moodle-branch: MOODLE_400_STABLE
38+
- php: 8.2
39+
moodle-branch: MOODLE_404_STABLE
4040
database: pgsql
41-
- php: 8.0
42-
moodle-branch: MOODLE_400_STABLE
41+
- php: 8.2
42+
moodle-branch: MOODLE_404_STABLE
43+
database: mariadb
44+
- php: 8.2
45+
moodle-branch: MOODLE_403_STABLE
46+
database: pgsql
47+
- php: 8.2
48+
moodle-branch: MOODLE_403_STABLE
49+
database: mariadb
50+
- php: 8.2
51+
moodle-branch: MOODLE_402_STABLE
52+
database: pgsql
53+
- php: 8.2
54+
moodle-branch: MOODLE_402_STABLE
4355
database: mariadb
4456

45-
- php: 7.4
57+
- php: 8.1
58+
moodle-branch: MOODLE_404_STABLE
59+
database: pgsql
60+
- php: 8.1
61+
moodle-branch: MOODLE_404_STABLE
62+
database: mariadb
63+
- php: 8.1
64+
moodle-branch: MOODLE_403_STABLE
65+
database: pgsql
66+
- php: 8.1
67+
moodle-branch: MOODLE_403_STABLE
68+
database: mariadb
69+
- php: 8.1
70+
moodle-branch: MOODLE_402_STABLE
71+
database: pgsql
72+
- php: 8.1
73+
moodle-branch: MOODLE_402_STABLE
74+
database: mariadb
75+
- php: 8.1
4676
moodle-branch: MOODLE_401_STABLE
4777
database: pgsql
48-
- php: 7.4
78+
- php: 8.1
4979
moodle-branch: MOODLE_401_STABLE
5080
database: mariadb
5181

52-
- php: 7.4
53-
moodle-branch: MOODLE_400_STABLE
82+
- php: 8.0
83+
moodle-branch: MOODLE_403_STABLE
5484
database: pgsql
55-
- php: 7.4
56-
moodle-branch: MOODLE_400_STABLE
85+
- php: 8.0
86+
moodle-branch: MOODLE_403_STABLE
5787
database: mariadb
58-
59-
- php: 7.4
60-
moodle-branch: MOODLE_311_STABLE
88+
- php: 8.0
89+
moodle-branch: MOODLE_402_STABLE
6190
database: pgsql
62-
- php: 7.4
63-
moodle-branch: MOODLE_311_STABLE
91+
- php: 8.0
92+
moodle-branch: MOODLE_402_STABLE
93+
database: mariadb
94+
- php: 8.0
95+
moodle-branch: MOODLE_401_STABLE
96+
database: pgsql
97+
- php: 8.0
98+
moodle-branch: MOODLE_401_STABLE
6499
database: mariadb
65100

66-
- php: 7.3
67-
moodle-branch: MOODLE_311_STABLE
101+
- php: 7.4
102+
moodle-branch: MOODLE_401_STABLE
68103
database: pgsql
69-
- php: 7.3
70-
moodle-branch: MOODLE_311_STABLE
104+
- php: 7.4
105+
moodle-branch: MOODLE_401_STABLE
71106
database: mariadb
72107

73108
steps:
74109
- name: Check out repository code
75-
uses: actions/checkout@v3
110+
uses: actions/checkout@v4
76111
with:
77112
path: plugin
78113

@@ -86,7 +121,7 @@ jobs:
86121

87122
- name: Initialise moodle-plugin-ci
88123
run: |
89-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
124+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
90125
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
91126
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
92127
sudo locale-gen en_AU.UTF-8
@@ -106,11 +141,6 @@ jobs:
106141
if: ${{ always() }}
107142
run: moodle-plugin-ci phplint
108143

109-
- name: PHP Copy/Paste Detector
110-
continue-on-error: true # This step will show errors but will not fail
111-
if: ${{ always() }}
112-
run: moodle-plugin-ci phpcpd
113-
114144
- name: PHP Mess Detector
115145
continue-on-error: true # This step will show errors but will not fail
116146
if: ${{ always() }}

backup/moodle2/backup_pdfannotator_stepslib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function define_structure() {
5555
// 2. Define each element separately.
5656
$pdfannotator = new backup_nested_element('pdfannotator', array('id'), array(
5757
'name', 'intro', 'introformat', 'usevotes', 'useprint', 'useprintcomments', 'use_studenttextbox', 'use_studentdrawing',
58-
'useprivatecomments', 'useprotectedcomments', 'timecreated', 'timemodified'));
58+
'useprivatecomments', 'useprotectedcomments', 'forcesubscribe', 'timecreated', 'timemodified'));
5959

6060
$annotations = new backup_nested_element('annotations');
6161
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid',

classes/output/comment.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function __construct($data, $cm, $context) {
8383
$this->addeditbutton($comment, $editanypost);
8484
$this->addhidebutton($comment, $seehiddencomments, $hidecomments);
8585
$this->adddeletebutton($comment, $deleteown, $deleteany);
86-
$this->addsubscribebutton($comment, $subscribe);
86+
$this->addsubscribebutton($comment, $subscribe, $cm);
8787
$this->addforwardbutton($comment, $forwardquestions, $cm);
8888
$this->addmarksolvedbutton($comment, $solve);
8989

@@ -270,15 +270,26 @@ private function adddeletebutton($comment, $deleteown, $deleteany) {
270270
}
271271
}
272272

273-
private function addsubscribebutton($comment, $subscribe) {
273+
/**
274+
* Add a subscribe button
275+
*
276+
* @param object $comment
277+
* @param bool $subscribe
278+
* @param stdClass $cm course module object
279+
* @throws \coding_exception
280+
*/
281+
private function addsubscribebutton($comment, $subscribe, $cm) {
274282
if (!isset($comment->type) && $comment->isquestion && $subscribe && $comment->visibility != 'private') {
275-
// Only set for textbox and drawing.
276-
if (!empty($comment->issubscribed)) {
277-
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell-slash"],
278-
"text" => get_string('unsubscribeQuestion', 'pdfannotator')];
279-
} else {
280-
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell"],
281-
"text" => get_string('subscribeQuestion', 'pdfannotator')];
283+
// Only set for textbox and drawing, and only if subscription mode is not disabled or forced.
284+
if ((pdfannotator_get_subscriptionmode($cm->instance) == PDFANNOTATOR_CHOOSESUBSCRIBE) ||
285+
(pdfannotator_get_subscriptionmode($cm->instance) == PDFANNOTATOR_INITIALSUBSCRIBE)) {
286+
if (!empty($comment->issubscribed)) {
287+
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell-slash"],
288+
"text" => get_string('unsubscribeQuestion', 'pdfannotator')];
289+
} else {
290+
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell"],
291+
"text" => get_string('subscribeQuestion', 'pdfannotator')];
292+
}
282293
}
283294
}
284295
}

0 commit comments

Comments
 (0)