Skip to content

Commit

Permalink
Adding Moodle Plugins CI checks, resolves #54.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed May 3, 2024
1 parent 9550d0f commit 0988ea6
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 134 deletions.
169 changes: 169 additions & 0 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
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.6
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:
include:
- php: 7.4
moodle-branch: MOODLE_401_STABLE
database: mariadb
- php: 7.4
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 8.0
moodle-branch: MOODLE_401_STABLE
database: mariadb
- php: 8.0
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_401_STABLE
database: mariadb
- php: 8.1
moodle-branch: MOODLE_401_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_402_STABLE
database: mariadb
- php: 8.1
moodle-branch: MOODLE_402_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_403_STABLE
database: mariadb
- php: 8.1
moodle-branch: MOODLE_403_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_404_STABLE
database: mariadb
- php: 8.1
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_402_STABLE
database: mariadb
- php: 8.2
moodle-branch: MOODLE_402_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_403_STABLE
database: mariadb
- php: 8.2
moodle-branch: MOODLE_403_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_404_STABLE
database: mariadb
- php: 8.2
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.3
moodle-branch: MOODLE_404_STABLE
database: mariadb
- php: 8.3
moodle-branch: MOODLE_404_STABLE
database: pgsql

steps:
- name: Check out repository code
uses: actions/checkout@v4
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 ^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
moodle-plugin-ci add-config '$CFG->behat_increasetimeout = 10;'
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
IGNORE_PATHS: 'moodle/tests/fixtures,moodle/Sniffs,classes/vendor'
PHPCS_IGNORE_PATHS: /^classes\/vendor/
PHPDOCCHECKER_IGNORE_PATHS: /^classes\/vendor/
MUSTACHE_IGNORE_NAMES: 'report.mustache,questionnaire.mustache'

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

- 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 phpcs --max-warnings 0

- 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
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci mustache

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

- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit --coverage-text || true

- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
4 changes: 2 additions & 2 deletions classes/event/update_vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has just voted for a question in the hotquestion activity with the course module id
'$this->contextinstanceid'.";
return "The user with id '$this->userid' has just voted for a question in the hotquestion activity with the course module ".
" id '$this->contextinstanceid'.";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class provider implements \core_privacy\local\metadata\provider,
* @param collection $collection The initialised collection to add items to.
* @return collection The updated collection of metadata items.
*/
public static function get_metadata(collection $collection) : collection {
public static function get_metadata(collection $collection): collection {
$collection->add_database_table(
'hotquestion_questions',
[
Expand Down Expand Up @@ -107,7 +107,7 @@ private static function get_modid() {
* @param int $userid The user to search.
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
public static function get_contexts_for_userid(int $userid): contextlist {
$contextlist = new contextlist();
$modid = self::get_modid();
if (!$modid) {
Expand Down
84 changes: 43 additions & 41 deletions lang/en/hotquestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,37 @@

$string['ago'] = '{$a} ago';
$string['allowanonymouspost'] = 'Allow post question as anonymous';
$string['allowanonymouspost_help'] = 'If enabled, questions can be posted anonomously, and if approved for viewing heat votes can be made by everyone.';
$string['allowanonymouspost_descr'] = 'If enabled, questions can be posted anonomously, and if approved for viewing heat votes can be made by everyone.';
$string['allowanonymouspost_help'] = 'If enabled, questions can be posted anonomously, and if approved for viewing heat votes can be made by everyone.';
$string['allowauthorinfohide'] = 'Allow authors name to be hidden';
$string['allowauthorinfohide_help'] = 'If enabled, the name of the questions author can be visible to teachers but hidden from students.';
$string['allowauthorinfohide_descr'] = 'If enabled, the name of the questions author can be visible to teachers but hidden from students.';
$string['allowauthorinfohide_help'] = 'If enabled, the name of the questions author can be visible to teachers but hidden from students.';
$string['allowcomments'] = 'Allow comments on entries';
$string['allowcomments_help'] = 'If enabled, all participants with permission to create comments will be able to add comments to hot question entries.';
$string['alwaysshowdescription'] = 'Always show description';
$string['alwaysshowdescription_help'] = 'If disabled, the Hot Question Description will not be visible to students.';
$string['anonymous'] = 'Anonymous';
$string['approvallabel'] = 'Approval required column label';
$string['approvallabel_descr'] = 'Enter a default label for the Approved column.';
$string['approvedyes'] = 'Approved';
$string['approvedno'] = 'Not approved';
$string['approvedyes'] = 'Approved';
$string['authorinfo'] = 'Posted by {$a->user} at {$a->time}';
$string['authorinfohide'] = 'Posted {$a->time}';
$string['calendarend'] = '{$a} closes';
$string['calendarstart'] = '{$a} opens';
$string['cnfallowcomments'] = 'Define if a hot question will accept comments on entries by default';
$string['completiondetail:pass'] = 'Passing grade: {$a}';
$string['completiondetail:post'] = 'Post questions: {$a}';
$string['completiondetail:vote'] = 'Give heat: {$a}';
$string['completiondetail:pass'] = 'Passing grade: {$a}';
$string['completionpostdesc'] = 'Student must create at least {$a} questions(s)';
$string['completionvotedesc'] = 'Student must vote/give heat to {$a} question(s) or post(s)';
$string['completionpass'] = 'Student must pass:';
$string['completionpassdesc'] = 'Student must receive passing grade of {$a}';
$string['completionpostgroup'] = 'Require questions';
$string['completionvotegroup'] = 'Require heat:';
$string['completionpassgroup'] = 'Require pass:';
$string['completionpost'] = 'Student must add questions:';
$string['completionpostdesc'] = 'Student must create at least {$a} questions(s)';
$string['completionpostgroup'] = 'Require questions';
$string['completionvote'] = 'Student must add heat:';
$string['completionpass'] = 'Student must pass:';
$string['completionvotedesc'] = 'Student must vote/give heat to {$a} question(s) or post(s)';
$string['completionvotegroup'] = 'Require heat:';
$string['connectionerror'] = 'Connection error';
$string['content'] = 'Content';
$string['csvexport'] = 'Export to .csv';
Expand Down Expand Up @@ -115,15 +115,9 @@
$string['heatlimit_help'] = 'Enter a default for the number of times you can apply heat/vote, per round. Zero hides the heat column.';
$string['heatreceived'] = 'Heat received';
$string['heatvisibility'] = 'Heat column visibility';
$string['heatvisibility_help'] = 'If enabled, the Heat column is visible.';
$string['heatvisibility_descr'] = 'If enabled, the Heat column is visible, otherwise it is hidden.';
$string['heatvisibility_help'] = 'If enabled, the Heat column is visible.';
$string['hotquestion'] = 'Hotquestion';
$string['hotquestionclosed'] = 'This activity closed on {$a}.';
$string['hotquestionclosetime'] = 'Close time';
$string['hotquestionintro'] = 'Topic';
$string['hotquestionname'] = 'Activity Name';
$string['hotquestionopentime'] = 'Open time';
$string['hotquestionopen'] = 'This activity will be open on {$a}.';
$string['hotquestion:addinstance'] = 'Can add new Hot Question';
$string['hotquestion:ask'] = 'Ask questions';
$string['hotquestion:comment'] = 'Write comments';
Expand All @@ -132,88 +126,96 @@
$string['hotquestion:rate'] = 'Rate questions';
$string['hotquestion:view'] = 'View questions';
$string['hotquestion:vote'] = 'Vote on questions';
$string['hotquestionclosed'] = 'This activity closed on {$a}.';
$string['hotquestionclosetime'] = 'Close time';
$string['hotquestionintro'] = 'Topic';
$string['hotquestionname'] = 'Activity Name';
$string['hotquestionopen'] = 'This activity will be open on {$a}.';
$string['hotquestionopentime'] = 'Open time';
$string['id'] = 'ID';
$string['improperuseviewgradesclass'] = 'Improper use of the viewgrades class. Cannot load the grade item.';
$string['incorrectmodule'] = 'Course Module ID was incorrect';
$string['id'] = 'ID';
$string['inputapprovallabel'] = 'Approved';
$string['inputapprovallabel_descr'] = 'Change the Approved column name to what you want it to be.';
$string['inputapprovallabel_help'] = 'Change the Approved column name to better fit the use of this activity.';
$string['inputheatlabel'] = 'Heat';
$string['inputheatlabel_descr'] = 'Change the Heat column name to what you want it to be.';
$string['inputheatlabel_help'] = 'Change the Heat column name to better fit the use of this activity.';
$string['inputquestion'] = 'Submit your question here:';
$string['inputquestion_descr'] = 'Change submit directions to what you want them to be.';
$string['inputquestion_help'] = 'Change the submit directions to what you want them to be.';
$string['inputquestionlabel'] = 'Questions';
$string['inputquestionlabel_descr'] = 'Change the Questions column name to what you want it to be.';
$string['inputquestionlabel_help'] = 'Change the Questions column name to better fit the use of this activity.';
$string['inputteacherprioritylabel'] = 'Priority';
$string['inputteacherprioritylabel_descr'] = 'Change the Priority column name to what you want it to be.';
$string['inputteacherprioritylabel_help'] = 'Change the Priority column name to better fit the use of this activity.';
$string['inputheatlabel'] = 'Heat';
$string['inputheatlabel_descr'] = 'Change the Heat column name to what you want it to be.';
$string['inputheatlabel_help'] = 'Change the Heat column name to better fit the use of this activity.';
$string['inputremovelabel'] = 'Remove';
$string['inputremovelabel_descr'] = 'Change the Remove column name to what you want it to be.';
$string['inputremovelabel_help'] = 'Change the remove column name to better fit the use of this activity.';
$string['inputapprovallabel'] = 'Approved';
$string['inputapprovallabel_descr'] = 'Change the Approved column name to what you want it to be.';
$string['inputapprovallabel_help'] = 'Change the Approved column name to better fit the use of this activity.';
$string['inputteacherprioritylabel'] = 'Priority';
$string['inputteacherprioritylabel_descr'] = 'Change the Priority column name to what you want it to be.';
$string['inputteacherprioritylabel_help'] = 'Change the Priority column name to better fit the use of this activity.';
$string['invalidquestion'] = 'Empty questions are ignored.';
$string['modulename'] = 'Hot Question';
$string['modulename_help'] = 'A Hot Question activity enables students to post and vote on posts, in response to questions asked by course teachers.';
$string['modulename_link'] = 'mod/hotquestion/view';
$string['modulenameplural'] = 'Hot Questions';
$string['newround'] = 'Open a new round';
$string['newroundsuccess'] = 'You have successfully opened a new round.';
$string['newroundconfirm'] = 'Confirm you want to start a new round? (Existing questions and votes will be archived and can not be added to!)';
$string['newroundsuccess'] = 'You have successfully opened a new round.';
$string['nextround'] = 'Next round';
$string['noquestions'] = 'No entries yet.';
$string['notavailable'] = '<b>Not currently available!<br></b>';
$string['notapproved'] = '<b>This entry is not currently approved for viewing.<br></b>';
$string['notavailable'] = '<b>Not currently available!<br></b>';
$string['pluginadministration'] = 'Hot question administration';
$string['pluginname'] = 'Hot Question';
$string['previousround'] = 'Previous round';
$string['postbutton'] = 'Click to post';
$string['postmaxgrade'] = 'Questions for max grading';
$string['postmaxgrade_help'] = 'The number of questions required to obtain the maximum score.
This is nominally a count of questions, but the value attained by a user may be improved by heat factor (questions with greater heat count more)
and by voting on other questions (a user may improve the grade by participating in voting for questions by other students).';
$string['previousround'] = 'Previous round';
$string['prioritydown'] = 'Priority down';
$string['priorityup'] = 'Priority up';
$string['privacy:metadata:hotquestion_questions'] = "Information about the user's entries for a given Hot Question activity. ";
$string['privacy:metadata:hotquestion_questions:userid'] = 'The ID of the user that posted this entry.';
$string['privacy:metadata:hotquestion_questions:hotquestion'] = 'The ID of the Hot Question activity in which the content was posted.';
$string['privacy:metadata:hotquestion_questions:content'] = 'The content of the question.';
$string['privacy:metadata:hotquestion_questions:time'] = 'Time the question was posted.';
$string['privacy:metadata:hotquestion_questions:id'] = 'ID of the entry.';
$string['privacy:metadata:hotquestion_questions:anonymous'] = 'Is the entry posted as anonymous?';
$string['privacy:metadata:hotquestion_questions:approved'] = 'Is the question approved for general viewing?';
$string['privacy:metadata:hotquestion_questions:content'] = 'The content of the question.';
$string['privacy:metadata:hotquestion_questions:hotquestion'] = 'The ID of the Hot Question activity in which the content was posted.';
$string['privacy:metadata:hotquestion_questions:id'] = 'ID of the entry.';
$string['privacy:metadata:hotquestion_questions:time'] = 'Time the question was posted.';
$string['privacy:metadata:hotquestion_questions:tpriority'] = 'Has the teacher given a priority for this entry?';
$string['privacy:metadata:hotquestion_questions:userid'] = 'The ID of the user that posted this entry.';
$string['privacy:metadata:hotquestion_votes'] = 'Information about votes on questions.';
$string['privacy:metadata:hotquestion_votes:id'] = 'ID of the entry.';
$string['privacy:metadata:hotquestion_votes:question'] = 'The ID of the entry for this vote';
$string['privacy:metadata:hotquestion_votes:voter'] = 'User ID who voted.';
$string['teacherprioritylabel'] = 'Priority column label';
$string['teacherprioritylabel_descr'] = 'Enter a default label for the Priority column.';
$string['question'] = 'Question';
$string['questions'] = 'Questions';
$string['questionlabel'] = 'Questions column label';
$string['questionlabel_descr'] = 'Enter a default label for the Questions column.';
$string['questionsubmitted'] = 'Your post has been submitted successfully.';
$string['questionremove'] = 'Remove';
$string['questionremovesuccess'] = 'You have successfully removed that question.';
$string['questions'] = 'Questions';
$string['questionsubmitted'] = 'Your post has been submitted successfully.';
$string['rawgrade'] = 'Raw grade {$a->rawgrade} / {$a->max}';
$string['removedround'] = 'You have successfully removed this round.';
$string['removelabel'] = 'Remove column label';
$string['removelabel_descr'] = 'Enter a default label for the Remove column.';
$string['removeround'] = 'Remove this round';
$string['removedround'] = 'You have successfully removed this round.';
$string['removevote'] = 'Remove my vote';
$string['requireapproval'] = 'Approval required';
$string['requireapproval_help'] = 'If enabled, questions require approval by a teacher before they are viewable by everyone.';
$string['requireapproval_descr'] = 'If enabled, questions require approval by a teacher before they are viewable by everyone.';
$string['requireapproval_help'] = 'If enabled, questions require approval by a teacher before they are viewable by everyone.';
$string['resethotquestion'] = 'Delete all questions and votes';
$string['returnto'] = 'Return to {$a}';
$string['round'] = 'Round {$a}';
$string['showrecentactivity'] = 'Show recent activity';
$string['showrecentactivityconfig'] = 'Everyone can see notifications in recent activity reports.';
$string['teacherpriority'] = 'Priority';
$string['teacherprioritylabel'] = 'Priority column label';
$string['teacherprioritylabel_descr'] = 'Enter a default label for the Priority column.';
$string['teacherpriorityvisibility'] = 'Teacher priority column visibility';
$string['teacherpriorityvisibility_help'] = 'If enabled, the Teacher priority column is visible.';
$string['teacherpriorityvisibility_descr'] = 'If enabled, the Teacher priority column is visible, otherwise it is hidden.';
$string['teacherpriorityvisibility_help'] = 'If enabled, the Teacher priority column is visible.';
$string['time'] = 'Time';
$string['totalcomments'] = 'Total comments';
$string['unapprovedquestionhide'] = 'Hide unapproved questions';
Expand Down
Loading

0 comments on commit 0988ea6

Please sign in to comment.