-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ada0f82
Showing
6 changed files
with
370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
name: Moodle Plugin CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
schedule: | ||
- cron: '0 8 * * 4' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
|
||
services: | ||
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: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 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['8.0', '8.1', '8.2', '8.3'] | ||
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE', 'MOODLE_405_STABLE', 'main'] | ||
database: [pgsql, mariadb] | ||
include: | ||
- {moodle-branch: 'MOODLE_401_STABLE', php: '7.4', database: 'pgsql'} | ||
exclude: | ||
- {moodle-branch: 'MOODLE_401_STABLE', php: '8.2', database: 'pgsql'} | ||
- {moodle-branch: 'MOODLE_401_STABLE', php: '8.2', database: 'mariadb'} | ||
- {moodle-branch: 'MOODLE_401_STABLE', php: '8.3', database: 'pgsql'} | ||
- {moodle-branch: 'MOODLE_401_STABLE', php: '8.3', database: 'mariadb'} | ||
- {moodle-branch: 'MOODLE_402_STABLE', php: '8.3', database: 'pgsql'} | ||
- {moodle-branch: 'MOODLE_402_STABLE', php: '8.3', database: 'mariadb'} | ||
- {moodle-branch: 'MOODLE_403_STABLE', php: '8.3', database: 'pgsql'} | ||
- {moodle-branch: 'MOODLE_403_STABLE', php: '8.3', database: 'mariadb'} | ||
- {moodle-branch: 'MOODLE_404_STABLE', php: '8.0', database: 'pgsql'} | ||
- {moodle-branch: 'MOODLE_404_STABLE', php: '8.0', database: 'mariadb'} | ||
- {moodle-branch: 'MOODLE_405_STABLE', php: '8.0', database: 'pgsql'} | ||
- {moodle-branch: 'MOODLE_405_STABLE', php: '8.0', database: 'mariadb'} | ||
- {moodle-branch: 'main', php: '8.0', database: 'pgsql'} | ||
- {moodle-branch: 'main', php: '8.0', database: 'mariadb'} | ||
- {moodle-branch: 'main', php: '8.1', database: 'pgsql'} | ||
- {moodle-branch: 'main', php: '8.1', database: 'mariadb'} | ||
|
||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
with: | ||
path: plugin | ||
|
||
- name: Setup PHP ${{ matrix.php }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: ${{ matrix.extensions }} | ||
ini-values: max_input_vars=5000 | ||
coverage: none | ||
|
||
- name: Initialise moodle-plugin-ci | ||
run: | | ||
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 | ||
echo $(cd ci/bin; pwd) >> $GITHUB_PATH | ||
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH | ||
sudo locale-gen en_AU.UTF-8 | ||
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV | ||
- name: Install moodle-plugin-ci | ||
run: | | ||
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 | ||
env: | ||
DB: ${{ matrix.database }} | ||
MOODLE_BRANCH: ${{ matrix.moodle-branch }} | ||
|
||
- name: PHP Lint | ||
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() }} | ||
run: moodle-plugin-ci phpmd | ||
|
||
- name: Moodle Code Checker | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci codechecker | ||
|
||
- name: Moodle PHPDoc Checker | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci phpdoc | ||
|
||
- name: Validating | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci validate | ||
|
||
- name: Check upgrade savepoints | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci savepoints | ||
|
||
- name: Mustache Lint | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci mustache | ||
|
||
- name: Grunt | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci grunt --max-lint-warnings 0 | ||
|
||
- name: PHPUnit tests | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci phpunit | ||
|
||
- name: Behat features | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci behat --profile chrome% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Manage enrol_manual instances. | ||
* | ||
* @package local_ws_enrol_manual | ||
* @copyright 2024 Lafayette College ITS | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace local_ws_enrol_manual; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->dirroot . '/enrol/manual/lib.php'); | ||
|
||
/** | ||
* Manage enrol_manual instances. | ||
* | ||
* @package local_ws_enrol_manual | ||
* @copyright 2024 Lafayette College ITS | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class manage { | ||
/** | ||
* Add an enrol_manual instance to a course. | ||
* | ||
* @param array $params the parameters for the instance | ||
* | ||
* @return int the id of the new instance | ||
*/ | ||
public static function add_instance($params) { | ||
global $DB; | ||
|
||
// Normalize. | ||
$fields = $params['params']; | ||
|
||
// Verify the course. | ||
$course = $DB->get_record('course', array('id'=>$fields['courseid']), '*', MUST_EXIST); | ||
|
||
$plugin = enrol_get_plugin('manual'); | ||
|
||
// Check for existing instance. | ||
if ($DB->record_exists('enrol', ['courseid' => $course->id, 'enrol' => 'manual'])) { | ||
throw new \invalid_parameter_exception('enrol_manual instance exists for course ID '. $course->id); | ||
} | ||
|
||
$enrolid = $plugin->add_instance($course, $fields); | ||
return $enrolid; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Web service definition for enrol_manual. | ||
* | ||
* @package local_ws_enrol_manual | ||
* @copyright 2024 Lafayette College ITS | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
$functions = [ | ||
'local_ws_enrol_manual_add_instance' => [ | ||
'classname' => 'local_ws_enrol_manual_external', | ||
'methodname' => 'add_instance', | ||
'classpath' => 'local/ws_enrol_manual/externallib.php', | ||
'description' => 'Add manual enrolment instance', | ||
'type' => 'write', | ||
'capabilities' => 'enrol/manual:config' | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* External functions for managing enrol_manual. | ||
* | ||
* @package local_ws_enrol_manual | ||
* @copyright 2024 Lafayette College ITS | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
use core_external\external_api; | ||
use core_external\external_function_parameters; | ||
use core_external\external_single_structure; | ||
use core_external\external_multiple_structure; | ||
use core_external\external_value; | ||
|
||
/** | ||
* External functions for managing enrol_manual. | ||
* | ||
* @package local_ws_enrol_manual | ||
* @copyright 2024 Lafayette College ITS | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class local_ws_enrol_manual_external extends external_api { | ||
|
||
/** | ||
* Returns description of method parameters | ||
* | ||
* @return external_function_parameters | ||
*/ | ||
public static function add_instance_parameters() { | ||
return new external_function_parameters([ | ||
'params' => new external_single_structure([ | ||
'courseid' => new external_value(PARAM_INT, 'The course id', VALUE_REQUIRED), | ||
'status' => new external_value(PARAM_INT, 'Enable manual enrolments', VALUE_DEFAULT, 0), | ||
'roleid' => new external_value(PARAM_INT, 'Default role', VALUE_REQUIRED), | ||
'enrolperiod' => new external_value(PARAM_INT, 'Default enrolment duration', VALUE_DEFAULT, 0), | ||
'expirynotify' => new external_value(PARAM_INT, 'Notify before enrolment expires', VALUE_DEFAULT, 0), | ||
'expirythreshold' => new external_value(PARAM_INT, 'Notification threshold', VALUE_DEFAULT, 86400), | ||
'customint1' => new external_value(PARAM_INT, 'Send course welcome message', VALUE_DEFAULT, 1), | ||
'customtext1' => new external_value(PARAM_RAW, 'Custom welcome message', VALUE_DEFAULT, null), | ||
]) | ||
]); | ||
} | ||
|
||
/** | ||
* Add a manual enrol instance to a course. | ||
* | ||
* @param array $params the parameters. | ||
*/ | ||
public static function add_instance($params) { | ||
$params = self::validate_parameters(self::add_instance_parameters(), ['params' => $params]); | ||
return [ | ||
'id' => local_ws_enrol_manual\manage::add_instance($params), | ||
]; | ||
} | ||
|
||
public static function add_instance_returns() { | ||
return new external_single_structure( | ||
[ | ||
'id' => new external_value(PARAM_INT, 'id of the created instance') | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Strings for component 'local_ws_enrol_manual', language 'en', branch 'main' | ||
* | ||
* @package local_ws_enrol_manual | ||
* @copyright 2024 onwards Lafayette College ITS | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
$string['pluginname'] = 'Manual enrolment web service function'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Version information for local_ws_enrol_manual. | ||
* | ||
* @package local_ws_enrol_manual | ||
* @copyright 2024 onwards Lafayette College ITS | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
$plugin->version = 2024120601; // The current plugin version (Date: YYYYMMDDXX). | ||
$plugin->requires = 2023100400; // Requires this Moodle version. | ||
$plugin->component = 'local_ws_enrol_manual'; // Full name of the plugin (used for diagnostics). |