Skip to content

Updates for 4.2 #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions .github/workflows/moodle_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Moodle plugin CI
on: [push, pull_request]

jobs:
test:
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
include:
- php: '8.0'
moodle-branch: 'MOODLE_402_STABLE'
database: 'mariadb'
- php: '8.1'
moodle-branch: 'master'
database: 'pgsql'

services:
postgres:
image: postgres
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 3
ports:
- 5432:5432

mariadb:
image: mariadb:10
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3

steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: plugin

- name: Install node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: zip, gd, mbstring, pgsql, mysqli
ini-values: max_input_vars=5000
coverage: none

- name: Deploy moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
# Add dirs to $PATH
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
# PHPUnit depends on en_AU.UTF-8 locale
sudo locale-gen en_AU.UTF-8
- name: Install Moodle
# Need explicit IP to stop mysql client fail on attempt to use unix socket.
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
IGNORE_PATHS: 'tool/printable/classes/bfpdf.php'

- name: phplint
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: phpcpd
if: ${{ always() }}
run: moodle-plugin-ci phpcpd || true

- name: phpmd
if: ${{ always() }}
run: moodle-plugin-ci phpmd

- name: codechecker
if: ${{ always() }}
run: moodle-plugin-ci codechecker

- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc

- name: validate
if: ${{ always() }}
run: moodle-plugin-ci validate

- name: savepoints
if: ${{ always() }}
run: moodle-plugin-ci savepoints

- name: mustache
if: ${{ always() }}
run: moodle-plugin-ci mustache

- name: grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt

- name: phpunit
if: ${{ always() }}
run: moodle-plugin-ci phpunit

- name: behat
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
4 changes: 2 additions & 2 deletions classes/controller/edit_controller.php
Original file line number Diff line number Diff line change
@@ -228,7 +228,7 @@ public function update_post_action() {
$timestart = $timestart === 0 ? $discussion->timestart : 0;
$timeend = $timeend === 0 ? $discussion->timeend : 0;

return $this->postservice->handle_update_post($course, $cm, $forum, $context, $discussion, $post, $files, array(
return $this->postservice->handle_update_post($course, $cm, $forum, $context, $discussion, $post, array(
'subject' => $subject,
'name' => $subject,
'groupid' => $groupid,
@@ -239,7 +239,7 @@ public function update_post_action() {
'privatereply' => $privatereply,
'timestart' => $timestart,
'timeend' => $timeend
));
), $files);
} catch (\Exception $e) {
return new json_response($e);
}
29 changes: 0 additions & 29 deletions classes/event/assessable_uploaded.php
Original file line number Diff line number Diff line change
@@ -54,35 +54,6 @@ public function get_description() {
"'$this->contextinstanceid'.";
}

/**
* Legacy event data if get_legacy_eventname() is not empty.
*
* @return \stdClass
*/
protected function get_legacy_eventdata() {
$eventdata = new \stdClass();
$eventdata->modulename = 'hsuforum';
$eventdata->name = $this->other['triggeredfrom'];
$eventdata->cmid = $this->contextinstanceid;
$eventdata->itemid = $this->objectid;
$eventdata->courseid = $this->courseid;
$eventdata->userid = $this->userid;
$eventdata->content = $this->other['content'];
if ($this->other['pathnamehashes']) {
$eventdata->pathnamehashes = $this->other['pathnamehashes'];
}
return $eventdata;
}

/**
* Return the legacy event name.
*
* @return string
*/
public static function get_legacy_eventname() {
return 'assessable_content_uploaded';
}

/**
* Return localised event name.
*
10 changes: 0 additions & 10 deletions classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
@@ -56,16 +56,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/view.php', array('f' => $this->objectid));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'hsuforum', 'view forum', 'view.php?f=' . $this->objectid,
$this->objectid, $this->contextinstanceid);
}

public static function get_objectid_mapping() {
return array('db' => 'hsuforum', 'restore' => 'hsuforum');
}
12 changes: 0 additions & 12 deletions classes/event/course_searched.php
Original file line number Diff line number Diff line change
@@ -82,18 +82,6 @@ public function get_url() {
array('id' => $this->courseid, 'search' => $this->other['searchterm']));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
// The legacy log table expects a relative path to /mod/hsuforum/.
$logurl = substr($this->get_url()->out_as_local_url(), strlen('/mod/hsuforum/'));

return array($this->courseid, 'hsuforum', 'search', $logurl, $this->other['searchterm']);
}

/**
* Custom validation.
*
13 changes: 0 additions & 13 deletions classes/event/discussion_created.php
Original file line number Diff line number Diff line change
@@ -80,19 +80,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/discuss.php', array('d' => $this->objectid));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {

// The legacy log table expects a relative path to /mod/hsuforum/.
$logurl = substr($this->get_url()->out_as_local_url(), strlen('/mod/hsuforum/'));

return array($this->courseid, 'hsuforum', 'add discussion', $logurl, $this->objectid, $this->contextinstanceid);
}

/**
* Custom validation.
*
10 changes: 0 additions & 10 deletions classes/event/discussion_deleted.php
Original file line number Diff line number Diff line change
@@ -81,16 +81,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/view.php', array('id' => $this->contextinstanceid));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'hsuforum', 'delete discussion', 'view.php?id=' . $this->contextinstanceid,
$this->other['forumid'], $this->contextinstanceid);
}

/**
* Custom validation.
*
10 changes: 0 additions & 10 deletions classes/event/discussion_moved.php
Original file line number Diff line number Diff line change
@@ -81,16 +81,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/discuss.php', array('d' => $this->objectid));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'hsuforum', 'move discussion', 'discuss.php?d=' . $this->objectid,
$this->objectid, $this->contextinstanceid);
}

/**
* Custom validation.
*
11 changes: 0 additions & 11 deletions classes/event/discussion_pinned.php
Original file line number Diff line number Diff line change
@@ -70,17 +70,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/discuss.php', array('d' => $this->objectid));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
// The legacy log table expects a relative path to /mod/hsuforum/.
$logurl = substr($this->get_url()->out_as_local_url(), strlen('/mod/hsuforum/'));
return array($this->courseid, 'hsuforum', 'pin discussion', $logurl, $this->objectid, $this->contextinstanceid);
}

/**
* Custom validation.
*
11 changes: 0 additions & 11 deletions classes/event/discussion_unpinned.php
Original file line number Diff line number Diff line change
@@ -70,17 +70,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/discuss.php', array('d' => $this->objectid));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
// The legacy log table expects a relative path to /mod/hsuforum/.
$logurl = substr($this->get_url()->out_as_local_url(), strlen('/mod/hsuforum/'));
return array($this->courseid, 'hsuforum', 'unpin discussion', $logurl, $this->objectid, $this->contextinstanceid);
}

/**
* Custom validation.
*
10 changes: 0 additions & 10 deletions classes/event/discussion_viewed.php
Original file line number Diff line number Diff line change
@@ -75,16 +75,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/discuss.php', array('d' => $this->objectid));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'hsuforum', 'view discussion', 'discuss.php?d=' . $this->objectid,
$this->objectid, $this->contextinstanceid);
}

/**
* Custom validation.
*
12 changes: 0 additions & 12 deletions classes/event/post_created.php
Original file line number Diff line number Diff line change
@@ -91,18 +91,6 @@ public function get_url() {
return $url;
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
// The legacy log table expects a relative path to /mod/hsuforum/.
$logurl = substr($this->get_url()->out_as_local_url(), strlen('/mod/hsuforum/'));

return array($this->courseid, 'hsuforum', 'add post', $logurl, $this->other['forumid'], $this->contextinstanceid);
}

/**
* Custom validation.
*
12 changes: 0 additions & 12 deletions classes/event/post_deleted.php
Original file line number Diff line number Diff line change
@@ -90,18 +90,6 @@ public function get_url() {
return $url;
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
// The legacy log table expects a relative path to /mod/hsuforum/.
$logurl = substr($this->get_url()->out_as_local_url(), strlen('/mod/hsuforum/'));

return array($this->courseid, 'hsuforum', 'delete post', $logurl, $this->objectid, $this->contextinstanceid);
}

/**
* Custom validation.
*
12 changes: 0 additions & 12 deletions classes/event/post_updated.php
Original file line number Diff line number Diff line change
@@ -91,18 +91,6 @@ public function get_url() {
return $url;
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
// The legacy log table expects a relative path to /mod/hsuforum/.
$logurl = substr($this->get_url()->out_as_local_url(), strlen('/mod/hsuforum/'));

return array($this->courseid, 'hsuforum', 'update post', $logurl, $this->objectid, $this->contextinstanceid);
}

/**
* Custom validation.
*
10 changes: 0 additions & 10 deletions classes/event/readtracking_disabled.php
Original file line number Diff line number Diff line change
@@ -79,16 +79,6 @@ public function get_url() {
return new \moodle_url('/mod/hsuforum/view.php', array('f' => $this->other['forumid']));
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'hsuforum', 'stop tracking', 'view.php?f=' . $this->other['forumid'],
$this->other['forumid'], $this->contextinstanceid);
}

/**
* Custom validation.
*
Loading