Skip to content
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

CI and 3.3 #29

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
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
119 changes: 0 additions & 119 deletions .github/workflows/master.yml

This file was deleted.

116 changes: 116 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Moodle Plugin CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:13
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"
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
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']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_403_STABLE']
database: [pgsql, 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
# If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
# If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
coverage: none

- name: Initialise moodle-plugin-ci
run: |
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
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: ${{ !cancelled() }}
run: moodle-plugin-ci phplint

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

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpmd

- name: Moodle Code Checker
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpcs --max-warnings 0

# - name: Moodle PHPDoc Checker
# if: ${{ !cancelled() }}
# run: moodle-plugin-ci phpdoc --max-warnings 0

- name: Validating
if: ${{ !cancelled() }}
run: moodle-plugin-ci validate

- name: Check upgrade savepoints
if: ${{ !cancelled() }}
run: moodle-plugin-ci savepoints

- name: Mustache Lint
if: ${{ !cancelled() }}
run: moodle-plugin-ci mustache

- name: Grunt
if: ${{ !cancelled() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpunit --fail-on-warning

- name: Behat features
if: ${{ !cancelled() }}
run: moodle-plugin-ci behat --profile chrome

- name: Mark cancelled jobs as failed.
if: ${{ cancelled() }}
run: exit 1
2 changes: 1 addition & 1 deletion aspiredu.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
echo html_writer::tag('iframe', '', [
'src' => new moodle_url('/local/aspiredu/lti.php', ['id' => $id, 'product' => $product]),
'id' => 'contentframe',
'class' => 'local_aspiredu_lti_wrapper'
'class' => 'local_aspiredu_lti_wrapper',
]);

echo $OUTPUT->footer();
29 changes: 16 additions & 13 deletions classes/external/core_course_get_courses_paginated.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@
* @author Open Source Learning <[email protected]>
* @link https://opensourcelearning.co.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2023 AspirEDU
*/

namespace local_aspiredu\external;

defined('MOODLE_INTERNAL') || die();

global $CFG;

require_once("$CFG->dirroot/course/externallib.php");
require_once("$CFG->dirroot/lib/externallib.php");

use context_course;
use core_course\customfield\course_handler;
use external_api;
Expand All @@ -38,12 +46,6 @@
use external_warnings;
use invalid_parameter_exception;

global $CFG;

defined('MOODLE_INTERNAL') || die();

require_once("$CFG->dirroot/course/externallib.php");

class core_course_get_courses_paginated extends external_api {
public static function execute_parameters() {
return new external_function_parameters (
Expand Down Expand Up @@ -78,7 +80,7 @@ public static function execute($sortby = 'id', $sortdirection = 'DESC', $page =
'sortby' => $sortby,
'sortdirection' => $sortdirection,
'page' => $page,
'perpage' => $perpage
'perpage' => $perpage,
]
);

Expand Down Expand Up @@ -110,7 +112,8 @@ public static function execute($sortby = 'id', $sortdirection = 'DESC', $page =
$sort = $sortby . ' ' . $sortdirection;

$courses = enrol_get_my_courses(
['format', 'summary', 'summaryformat', 'enddate', 'showgrades', 'showreports', 'newsitems', 'maxbytes', 'defaultgroupingid', 'lang', 'timecreated', 'timemodified', 'theme', 'enablecompletion', 'completionnotify'],
['format', 'summary', 'summaryformat', 'enddate', 'showgrades', 'showreports', 'newsitems', 'maxbytes',
'defaultgroupingid', 'lang', 'timecreated', 'timemodified', 'theme', 'enablecompletion', 'completionnotify', ],
$sort, $limitnum, [], true, $limitfrom);

$coursesinfo = [];
Expand Down Expand Up @@ -143,7 +146,7 @@ public static function execute($sortby = 'id', $sortdirection = 'DESC', $page =
'value' => $data->get_value(),
'valueraw' => $data->get_data_controller()->get_value(),
'name' => $data->get_name(),
'shortname' => $data->get_shortname()
'shortname' => $data->get_shortname(),
];
}
}
Expand Down Expand Up @@ -174,7 +177,7 @@ public static function execute($sortby = 'id', $sortdirection = 'DESC', $page =
foreach ($courseformatoptions as $key => $value) {
$courseinfo['courseformatoptions'][] = [
'name' => $key,
'value' => $value
'value' => $value,
];
}
}
Expand Down Expand Up @@ -252,7 +255,7 @@ public static function execute_returns() {
'courseformatoptions' => new external_multiple_structure(
new external_single_structure(
['name' => new external_value(PARAM_ALPHANUMEXT, 'course format option name'),
'value' => new external_value(PARAM_RAW, 'course format option value')
'value' => new external_value(PARAM_RAW, 'course format option value'),
]), 'additional options for particular course format', VALUE_OPTIONAL
),
'showactivitydates' => new external_value(
Expand All @@ -266,12 +269,12 @@ public static function execute_returns() {
'type' => new external_value(PARAM_COMPONENT,
'The type of the custom field - text, checkbox...'),
'valueraw' => new external_value(PARAM_RAW, 'The raw value of the custom field'),
'value' => new external_value(PARAM_RAW, 'The value of the custom field')]
'value' => new external_value(PARAM_RAW, 'The value of the custom field'), ]
), 'Custom fields and associated values', VALUE_OPTIONAL),
], 'course'
)
),
'warnings' => new external_warnings()
'warnings' => new external_warnings(),
]
);
}
Expand Down
21 changes: 10 additions & 11 deletions classes/external/core_grades_get_course_grades.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@
* @author Open Source Learning <[email protected]>
* @link https://opensourcelearning.co.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2023 AspirEDU
*/

namespace local_aspiredu\external;

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once("$CFG->dirroot/lib/externallib.php");
require_once("$CFG->dirroot/course/externallib.php");
require_once("$CFG->libdir/gradelib.php");
require_once($CFG->dirroot . '/grade/querylib.php');

use context_course;
use external_api;
use external_function_parameters;
Expand All @@ -35,12 +44,6 @@
use external_value;
use stdClass;

global $CFG;

defined('MOODLE_INTERNAL') || die();

require_once("$CFG->dirroot/course/externallib.php");

class core_grades_get_course_grades extends external_api {
public static function execute_returns() {
return new external_single_structure(
Expand Down Expand Up @@ -97,7 +100,7 @@ public static function execute_parameters() {
'userids' => new external_multiple_structure(
new external_value(PARAM_INT, 'user ID'),
'An array of user IDs, leave empty to just retrieve grade item information', VALUE_DEFAULT, []
)
),
]
);
}
Expand All @@ -110,10 +113,6 @@ public static function execute_parameters() {
* @return stdClass Array of grades
*/
public static function execute($courseid, $userids = []) {
global $CFG;
require_once("$CFG->libdir/gradelib.php");
require_once($CFG->dirroot . '/grade/querylib.php');

$params = self::validate_parameters(self::execute_parameters(),
['courseid' => $courseid, 'userids' => $userids]);

Expand Down
Loading