Skip to content

Commit

Permalink
Acceptation pull request grp-attestoodle#172
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadiou committed Oct 17, 2024
2 parents 957e974 + 3a86d9b commit a5e116c
Show file tree
Hide file tree
Showing 44 changed files with 648 additions and 630 deletions.
75 changes: 45 additions & 30 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,39 @@ on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:10
image: postgres:13
env:
POSTGRES_USER: "postgres"
POSTGRES_HOST_AUTH_METHOD: "trust"
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.5
image: mariadb:10
env:
MYSQL_USER: "root"
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: ["7.3", "7.4", "8.0"]
moodle-branch: ["MOODLE_311_STABLE"]
php: ['7.4', '8.0', '8.1']
moodle-branch: ['MOODLE_401_STABLE']
database: [pgsql, mariadb]

steps:
- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -43,65 +46,77 @@ jobs:
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 ^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
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
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
# Uncomment this to run Behat tests using the Moodle App.
# MOODLE_APP: 'true'

- name: PHP Lint
if: ${{ always() }}
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: ${{ 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() }}
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpmd

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

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

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

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

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

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

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

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

- name: Upload Behat Faildump
if: ${{ failure() && steps.behat.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: Behat Faildump (${{ join(matrix.*, ', ') }})
path: ${{ github.workspace }}/moodledata/behat_dump
retention-days: 7
if-no-files-found: ignore

- name: Mark cancelled jobs as failed.
if: ${{ cancelled() }}
run: exit 1
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Release notes
## v1.10.4

- Issue #168 fix,
- and improved compliance with Moodle coding rules (CI configuration updated)

## v1.10.3

Expand Down
8 changes: 4 additions & 4 deletions classes/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class activity {
/** @var integer Id of the activity */
/** @var int Id of the activity */
private $id;

/** @var integer Id of the activity from its specific module type */
/** @var int Id of the activity from its specific module type */
private $idmodule;

/** @var string Name of the activity */
Expand All @@ -50,14 +50,14 @@ class activity {
/** @var string Type of the activity */
private $type;

/** @var integer Milestone time (in minutes) of the activity */
/** @var int Milestone time (in minutes) of the activity */
private $milestone;

/**
* @var course The course corresponding to the activity
* @todo Replace by the ID of the course to avoid bijective relation
*/
private $course;
// To be done ? Replace by the id of the course to avoid bijective relation.

/** @var bool The visibility of the activity.*/
private $visible;
Expand Down
2 changes: 1 addition & 1 deletion classes/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class category {
/** @var integer Id of the category */
/** @var int Id of the category */
private $id;

/** @var string Name of the category */
Expand Down
8 changes: 4 additions & 4 deletions classes/certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public function get_file_infos() {
$usercontext = \context_user::instance($this->learner->get_id());

// Prepare file record object.
$fileinfos = array(
$fileinfos = [
'contextid' => $usercontext->id,
'component' => 'tool_attestoodle',
'filearea' => 'certificates',
'filepath' => '/',
'itemid' => 0,
'filename' => $this->get_file_name()
);
'filename' => $this->get_file_name(),
];

return $fileinfos;
}
Expand Down Expand Up @@ -118,7 +118,7 @@ public function get_pdf_informations() {
$filteredmilestones = $this->get_filtered_milestones();

// Retrieve activities informations in an array structure.
$activitiesstructured = array();
$activitiesstructured = [];
$index = 0;
foreach ($filteredmilestones as $fva) {
// Retrieve activity.
Expand Down
6 changes: 3 additions & 3 deletions classes/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course {
/** @var integer Id of the course */
/** @var int Id of the course */
private $id;

/** @var string Name of the course */
Expand All @@ -42,9 +42,9 @@ class course {

/**
* @var training Training corresponding to the course.
* @todo Replace by the ID of the training to avoid bijective relation
*/
private $training;
// To be done ? replace by the ID of the training to avoid bijective relation.

/**
* Constructor of the course class
Expand All @@ -55,7 +55,7 @@ class course {
public function __construct($id, $name) {
$this->id = $id;
$this->name = $name;
$this->activities = array();
$this->activities = [];
$this->training = null;
}

Expand Down
4 changes: 2 additions & 2 deletions classes/factories/activities_factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class activities_factory extends singleton {
*/
protected function __construct() {
parent::__construct();
$this->modulenames = array();
$this->modulenames = [];
}

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ private function get_module_table_name($moduleid) {
*/
public function retrieve_activities_by_course($id, $trainingid) {
$dbcoursemodules = db_accessor::get_instance()->get_course_modules_by_course($id);
$activities = array();
$activities = [];
foreach ($dbcoursemodules as $coursemodule) {
$activityid = $coursemodule->id;

Expand Down
4 changes: 2 additions & 2 deletions classes/factories/courses_factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function create($dbcourse, $trainingid) {
public function retrieve_courses_childof_category($id, $trainingid = 0) {
$dbcourses = db_accessor::get_instance()->get_courses_childof_category($id);

$courses = array();
$courses = [];
foreach ($dbcourses as $course) {
$courses[$course->id] = $this->create($course, $trainingid);
}
Expand All @@ -95,7 +95,7 @@ public function retrieve_courses_childof_category($id, $trainingid = 0) {
*/
public function retrieve_courses_of_training($trainingid) {
$dbcourses = db_accessor::get_instance()->get_courses_of_training($trainingid);
$courses = array();
$courses = [];
foreach ($dbcourses as $course) {
$courses[] = $this->create($course, $trainingid);
}
Expand Down
9 changes: 4 additions & 5 deletions classes/factories/learners_factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class learners_factory extends singleton {
*/
protected function __construct() {
parent::__construct();
$this->learners = array();
$this->learners = [];
}

/**
Expand All @@ -71,13 +71,12 @@ private function create($dblearner) {
/**
* Method that retrieves the activities validated by a learner in DB and
* stores them in the learner.
*
* @todo The passing by reference may be useless
* Comment : the passing by reference may be useless.
*
* @param learner $learner The learner to search activities for
*/
public function retrieve_validated_activities(&$learner) {
$learner->set_validated_activities(array());
$learner->set_validated_activities([]);
$dbactivities = db_accessor::get_instance()->get_activities_validated_by_learner($learner);

foreach ($dbactivities as $dbactivity) {
Expand Down Expand Up @@ -124,7 +123,7 @@ public function retrieve_learner($id) {
* @param Training $training where we search learner.
*/
public function retrieve_learners_by_training($training) {
$learners = array();
$learners = [];

$dblearners = db_accessor::get_instance()->get_learners_by_training($training->get_id());

Expand Down
8 changes: 4 additions & 4 deletions classes/factories/trainings_factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class trainings_factory extends singleton {
*/
protected function __construct() {
parent::__construct();
$this->trainings = array();
$this->trainings = [];
}

/**
Expand All @@ -60,7 +60,7 @@ protected function __construct() {
* @param int $numpage the page number searched.
*/
public function create_trainings($numpage = 0) {
$this->trainings = array();
$this->trainings = [];
// Must call categories_factory before find trainings.
$dbtrainings = db_accessor::get_instance()->get_page_trainings($numpage * 10, 10);

Expand Down Expand Up @@ -99,7 +99,7 @@ public function get_count_training_by_categ($categoryid) {
* @param int $categoryid the identifier of the category where we search training.
*/
public function create_trainings_4_categ($categoryid) {
$this->trainings = array();
$this->trainings = [];
// Must call categories_factory before find trainings.
$dbtrainings = db_accessor::get_instance()->get_page_trainings_categ(0, 10, $categoryid);

Expand Down Expand Up @@ -292,7 +292,7 @@ public function get_trainings() {
* @return integer[] The category IDs in an array
*/
public function get_training_category_ids() {
$categoryids = array();
$categoryids = [];
foreach ($this->trainings as $tr) {
$categoryids[] = $tr->get_categoryid();
}
Expand Down
6 changes: 3 additions & 3 deletions classes/forms/add_course_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class add_course_form extends \moodleform {
*/
public function definition() {
$mform = $this->_form;
$group = array();
$group[] =& $mform->createElement('text', 'coursename', '', array("size" => 35));
$group = [];
$group[] =& $mform->createElement('text', 'coursename', '', ["size" => 35]);
$mform->setType('coursename', PARAM_NOTAGS);
$group[] =& $mform->createElement('submit', 'action',
'Ajouter', array('class' => 'send-button'));
'Ajouter', ['class' => 'send-button']);
$mform->addGroup($group, 'period', 'Cours à ajouter' , '', false);
}
}
Loading

0 comments on commit a5e116c

Please sign in to comment.