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 13, 2024
1 parent e2314a1 commit 218b6b1
Show file tree
Hide file tree
Showing 17 changed files with 1,388 additions and 69 deletions.
94 changes: 62 additions & 32 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,86 @@ jobs:
fail-fast: false
matrix:
include:
- php: 8.0
moodle-branch: MOODLE_401_STABLE
- php: 8.3
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.0
moodle-branch: MOODLE_401_STABLE
- php: 8.3
moodle-branch: MOODLE_404_STABLE
database: mariadb

- php: 8.0
moodle-branch: MOODLE_400_STABLE
- php: 8.2
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.0
moodle-branch: MOODLE_400_STABLE
- 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: 7.4
- 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: 7.4
- php: 8.1
moodle-branch: MOODLE_401_STABLE
database: mariadb

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

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

- php: 7.3
moodle-branch: MOODLE_311_STABLE
- php: 7.4
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 7.3
moodle-branch: MOODLE_311_STABLE
- php: 7.4
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 +121,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 All @@ -106,11 +141,6 @@ jobs:
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpcpd

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/backup_pdfannotator_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function define_structure() {
// 2. Define each element separately.
$pdfannotator = new backup_nested_element('pdfannotator', array('id'), array(
'name', 'intro', 'introformat', 'usevotes', 'useprint', 'useprintcomments', 'use_studenttextbox', 'use_studentdrawing',
'useprivatecomments', 'useprotectedcomments', 'timecreated', 'timemodified'));
'useprivatecomments', 'useprotectedcomments', 'forcesubscribe', 'timecreated', 'timemodified'));

$annotations = new backup_nested_element('annotations');
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid',
Expand Down
29 changes: 20 additions & 9 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,15 +270,26 @@ private function adddeletebutton($comment, $deleteown, $deleteany) {
}
}

private function addsubscribebutton($comment, $subscribe) {
/**
* 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) {
if (!isset($comment->type) && $comment->isquestion && $subscribe && $comment->visibility != 'private') {
// Only set for textbox and drawing.
if (!empty($comment->issubscribed)) {
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell-slash"],
"text" => get_string('unsubscribeQuestion', 'pdfannotator')];
} else {
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell"],
"text" => get_string('subscribeQuestion', 'pdfannotator')];
// 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')];
} else {
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell"],
"text" => get_string('subscribeQuestion', 'pdfannotator')];
}
}
}
}
Expand Down
Loading

0 comments on commit 218b6b1

Please sign in to comment.