Skip to content

Commit

Permalink
Fix to NVM for ci purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Aug 31, 2024
1 parent a7299d9 commit fe6faba
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 144 deletions.
43 changes: 20 additions & 23 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]
jobs:
test:
runs-on: 'ubuntu-latest'

services:
postgres:
image: postgres:13
Expand All @@ -29,43 +30,43 @@ jobs:
fail-fast: false
matrix:
include:
# - php: '8.1'
# moodle-branch: 'MOODLE_401_STABLE'
# database: 'mariadb'
- php: '8.1'
moodle-branch: 'master'
database: 'pgsql'
moodle-branch: 'MOODLE_404_STABLE'
database: 'mariadb'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check out repository code
uses: actions/checkout@v2
with:
path: plugin

- name: Setup PHP
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: max_input_vars=5000
# none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead.
coverage: none

- name: Deploy moodle-plugin-ci
- name: Install NVM and Node
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 20
nvm use 20
- name: Initialise 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
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
- 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
- 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 }}
IGNORE_PATHS: 'templates/local/mobile'

- name: PHP Lint
if: ${{ always() }}
Expand Down Expand Up @@ -97,13 +98,9 @@ jobs:
if: ${{ always() }}
run: moodle-plugin-ci savepoints

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

- name: Grunt
if: ${{ matrix.moodle-branch == 'master' }}
run: moodle-plugin-ci grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ always() }}
Expand Down
241 changes: 120 additions & 121 deletions tests/behat/basic_test.feature
Original file line number Diff line number Diff line change
@@ -1,165 +1,164 @@
@tool @tool_driprelease @tool_driprelease_basic
Feature: Drip release modifies activity availability
In order to set a course activities for drip/sequential availabiliy
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
| Empty course | C2 | topics | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| teacher1 | C2 | editingteacher |
| student1 | C1 | student |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext | answer 1 | grade |
| Test questions | shortanswer | Short answer 1 | Where is the capital city of France? | Paris | 100% |
| Test questions | shortanswer | Short answer 2 | Where is the capital city of Australia? | Canberra | 100% |
| Test questions | shortanswer | Short answer 3 | Where is the capital city of Germany? | Berlin | 100% |

And the following "activities" exist:
| activity | name | course | intro | completionusegrade |
| quiz | Quiz1 | C1 | quiz1description | 1 |
| quiz | Quiz2 | C1 | 1 | |
| quiz | Quiz3 | C1 | 1 | |
| quiz | Quiz4 | C1 | 1 | |
| quiz | Quiz5 | C1 | 1 | |
| quiz | Quiz6 | C1 | 1 | |
| quiz | Quiz7 | C1 | 1 | |
| quiz | Quiz8 | C1 | 1 | |

And quiz "Quiz1" contains the following questions:
| question | page |
| Short answer 1 | 1 |
| Short answer 2 | 1 |
| Short answer 3 | 1 |

@javascript
Scenario: Select/deselect activities to set their availability
Given I log in as "teacher1"

And I am on "Empty course" course homepage with editing mode on
And I navigate to "Drip release" in current page administration
Then I should see "No modules in course"
And I am on "Course 1" course homepage with editing mode on
And I navigate to "Drip release" in current page administration
In order to set a course activities for drip/sequential availabiliy
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
| Empty course | C2 | topics | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| teacher1 | C2 | editingteacher |
| student1 | C1 | student |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext | answer 1 | grade |
| Test questions | shortanswer | Short answer 1 | Where is the capital city of France? | Paris | 100% |
| Test questions | shortanswer | Short answer 2 | Where is the capital city of Australia? | Canberra | 100% |
| Test questions | shortanswer | Short answer 3 | Where is the capital city of Germany? | Berlin | 100% |

And the following "activities" exist:
| activity | name | course | intro | completionusegrade |
| quiz | Quiz1 | C1 | quiz1description | 1 |
| quiz | Quiz2 | C1 | 1 | |
| quiz | Quiz3 | C1 | 1 | |
| quiz | Quiz4 | C1 | 1 | |
| quiz | Quiz5 | C1 | 1 | |
| quiz | Quiz6 | C1 | 1 | |
| quiz | Quiz7 | C1 | 1 | |
| quiz | Quiz8 | C1 | 1 | |

And quiz "Quiz1" contains the following questions:
| question | page |
| Short answer 1 | 1 |
| Short answer 2 | 1 |
| Short answer 3 | 1 |
@javascript
Scenario: Select/deselect activities to set their availability
Given I log in as "teacher1"

And I am on "Empty course" course homepage with editing mode on
And I navigate to "Drip release" in current page administration
Then I should see "No modules in course"
And I am on "Course 1" course homepage with editing mode on
And I navigate to "Drip release" in current page administration
# Can I follow the link to view the settings of the quiz
And I click on "Quiz1" "link" in the "Quiz1" "table_row"
And I should see "Preview quiz"
And I am on "Course 1" course homepage with editing mode on
When I open "Quiz1" actions menu
And I click on "Edit settings" "link" in the "Quiz1" activity
And I expand all fieldsets
And I click on "Quiz1" "link" in the "Quiz1" "table_row"
And I should see "Preview quiz"
And I am on "Course 1" course homepage with editing mode on
When I open "Quiz1" actions menu
And I click on "Edit settings" "link" in the "Quiz1" activity
And I expand all fieldsets

# Need to set a grade for the first quiz so the second can be set to
# depend on it in restrictions
And I set the field "Add requirements" to "1"
And I set the field "Add requirements" to "1"

And I press "Save and return to course"
And I press "Save and return to course"

When I open "Quiz2" actions menu
And I click on "Edit settings" "link" in the "Quiz2" activity
And I expand all fieldsets
When I open "Quiz2" actions menu
And I click on "Edit settings" "link" in the "Quiz2" activity
And I expand all fieldsets

And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"

And I click on ".availability-item .availability-eye img" "css_element"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save and return to course"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save and return to course"

And I navigate to "Drip release" in current page administration
And I navigate to "Drip release" in current page administration
# To confirm the question count column is showing the count of questions in a quiz
Then I should see "3" in the "Quiz1" "table_row"
Then I should see "3" in the "Quiz1" "table_row"
# Confirm that module discriptions wrap and are not truncated
And I should see "quiz1description"
And I should see "quiz1description"
# Confirm that a common "off by 1 error has not crept in"
And I should not see "Session 0"
And I should not see "Session 0"

# Check the validation checks for empty fields works
And I set the field "sessionlength" to ""
And I should see "You must supply a value here"
And I set the field "sessionlength" to "1"
And I set the field "activitiespersession" to ""
And I should see "You must supply a value here"
And I set the field "activitiespersession" to "100"
And I press "Save and return to course"
Then I should see "Activities per session is 100 but the course only has 8 activities"

And I press "Cancel"
And I set the field "sessionlength" to ""
And I should see "You must supply a value here"
And I set the field "sessionlength" to "1"
And I set the field "activitiespersession" to ""
And I should see "You must supply a value here"
And I set the field "activitiespersession" to "100"
And I press "Save and return to course"
Then I should see "Activities per session is 100 but the course only has 8 activities"

And I press "Cancel"
# Confirm I am back on the course page
And I should see "Participants"
And I navigate to "Drip release" in current page administration
And I set the field "schedulestart[day]" to "1"
And I set the field "schedulestart[month]" to "January"
And I set the field "schedulestart[year]" to "2017"
And I should see "Participants"
And I navigate to "Drip release" in current page administration
And I set the field "schedulestart[day]" to "1"
And I set the field "schedulestart[month]" to "January"
And I set the field "schedulestart[year]" to "2017"

And I click on "select" "checkbox" in the "Quiz1" "table_row"
And I click on "select" "checkbox" in the "Quiz1" "table_row"

# Typically you would press Save and display, but this is to confirm this button works
And I press "Save and return to course"
And I navigate to "Drip release" in current page administration
And I press "Save and return to course"
And I navigate to "Drip release" in current page administration
# Check the table and modules availability has been updated
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"
# Confirm only the row with a selected checkbox have been updated
Then I should not see "1 Jan 2017" in the "Quiz2" "table_row"
Then I should see "7 Jan 2017" in the "Quiz1" "table_row"
Then I should not see "1 Jan 2017" in the "Quiz2" "table_row"
Then I should see "7 Jan 2017" in the "Quiz1" "table_row"

And I am on "Course 1" course homepage with editing mode on
And I am on "Course 1" course homepage with editing mode on
# Confirming that Moodle is saving/displaying the updated availability
# On the course page
Then I should see "It is after 1 January 2017"
Then I should see "It is after 1 January 2017"
# Confirm that non date availability restrictions have not been cleared
Then I should see "Not available unless"
Then I should see "Not available unless"

And I navigate to "Drip release" in current page administration
And I follow "Show more..."
And I navigate to "Drip release" in current page administration
And I follow "Show more..."

# Check the dates have been saved
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"
# Confirm only the row with a selected checkbox have been updated
Then I should not see "7 Jan 2017" in the "Quiz2" "table_row"
Then I should see "7 Jan 2017" in the "Quiz1" "table_row"
Then I should not see "7 Jan 2017" in the "Quiz2" "table_row"
Then I should see "7 Jan 2017" in the "Quiz1" "table_row"
# Now select the second module/quiz
And I click on "select" "checkbox" in the "Quiz2" "table_row"
And I press "Save and display"
And I click on "select" "checkbox" in the "Quiz2" "table_row"
And I press "Save and display"
# Check the table and modules availability has been updated
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"
Then I should see "7 Jan 2017" in the "Quiz2" "table_row"
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"
Then I should see "7 Jan 2017" in the "Quiz2" "table_row"
# Deselect rows for Quiz1 and 2
And I click on "select" "checkbox" in the "Quiz1" "table_row"
And I click on "select" "checkbox" in the "Quiz2" "table_row"
And I click on "select" "checkbox" in the "Quiz1" "table_row"
And I click on "select" "checkbox" in the "Quiz2" "table_row"

# Select quiz 3
And I click on "select" "checkbox" in the "Quiz3" "table_row"
And I set the field "schedulestart[day]" to "1"
And I set the field "schedulestart[month]" to "February"
And I click on "select" "checkbox" in the "Quiz3" "table_row"
And I set the field "schedulestart[day]" to "1"
And I set the field "schedulestart[month]" to "February"

And I press "Save and display"
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"
And I press "Save and display"
Then I should see "1 Jan 2017" in the "Quiz1" "table_row"

# This doesn't work as it should and so is commented out.
# Then I should see "1 Feb 2017" in the "Quiz3" "table_row"
# This will toggle all rows to checked
And I click on "selectall" "checkbox"
And I press "Save and display"
Then I should see "1 Feb 2017" in the "Quiz5" "table_row"
And I click on "selectall" "checkbox"
And I press "Save and display"
Then I should see "1 Feb 2017" in the "Quiz5" "table_row"
# The next session
Then I should see "8 Feb 2017" in the "Quiz6" "table_row"
And I click on "select" "checkbox" in the "Quiz1" "table_row"
And I click on "select" "checkbox" in the "Quiz2" "table_row"
And I click on "select" "checkbox" in the "Quiz3" "table_row"
And I click on "select" "checkbox" in the "Quiz4" "table_row"
And I click on "select" "checkbox" in the "Quiz5" "table_row"
Then I should see "8 Feb 2017" in the "Quiz6" "table_row"
And I click on "select" "checkbox" in the "Quiz1" "table_row"
And I click on "select" "checkbox" in the "Quiz2" "table_row"
And I click on "select" "checkbox" in the "Quiz3" "table_row"
And I click on "select" "checkbox" in the "Quiz4" "table_row"
And I click on "select" "checkbox" in the "Quiz5" "table_row"
# Skip date count over the unselected items.
And I press "Save and display"
Then I should see "1 Feb 2017" in the "Quiz6" "table_row"
And I press "Save and display"
Then I should see "1 Feb 2017" in the "Quiz6" "table_row"
#There may still be some inconsistancies in the start from checked code.

0 comments on commit fe6faba

Please sign in to comment.