Skip to content

Commit

Permalink
Fixed the Moodle Plug-in CI issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace committed Nov 15, 2024
1 parent ed1f8ea commit 27d303d
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 45 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,17 @@ jobs:
matrix:
include:
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
database: 'mariadb'
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
moodle-branch: 'MOODLE_405_STABLE'
database: 'pgsql'
- php: '8.1'
moodle-branch: 'MOODLE_403_STABLE'
moodle-branch: 'MOODLE_404_STABLE'
database: 'mariadb'
- php: '8.1'
- php: '8.0'
moodle-branch: 'MOODLE_403_STABLE'
database: 'pgsql'
- php: '8.0'
moodle-branch: 'MOODLE_402_STABLE'
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'mariadb'
- php: '8.0'
moodle-branch: 'MOODLE_402_STABLE'
database: 'pgsql'

steps:
- name: Check out repository code
Expand Down
3 changes: 3 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

require_once($CFG->dirroot. '/course/format/lib.php');


use format_kickstart\output\course_template_list;

/**
* Main class for the Kickstart course format
*
Expand Down
122 changes: 122 additions & 0 deletions tests/behat/behat_format_kickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,112 @@
*/
class behat_format_kickstart extends behat_base {

/**
* @Given /^I click on disable link single activity$/
* @param string $format The course data
*/
public function i_click_on_disable_link_single_activity() {
global $CFG;
if ($CFG->branch <= '403') {
$this->execute('behat_general::i_click_on_in_the', ["Disable", "link", "Single activity format", "table_row"]);
} else {
$this->execute('behat_general::i_click_on_in_the', ["Disable", "link", "Single activity", "table_row"]);
}
}

/**
* @Given /^I click on enable link custom sections$/
* @param string $format The course data
*/
public function i_click_on_edit_link_custom_sections() {
global $CFG;
if ($CFG->branch <= '403') {
$this->execute('behat_general::i_click_on_in_the', ["Edit", "button", "Topics format", "table_row"]);
} else {
$this->execute('behat_general::i_click_on_in_the', ["Edit", "button", "Custom sections", "table_row"]);
}
}

/**
* @Given /^I click on enable link single activity$/
* @param string $format The course data
*/
public function i_click_on_edit_link_single_activity() {
global $CFG;
if ($CFG->branch <= '403') {
$this->execute('behat_general::i_click_on_in_the', ["Edit", "button", "Single activity format", "table_row"]);
} else {
$this->execute('behat_general::i_click_on_in_the', ["Edit", "button", "Single activity", "table_row"]);
}
}

/**
* @Given /^I check single activity condition kickstart:$/
* @param string $format The course data
*/
public function i_check_single_activity_condition_kickstart(TableNode $table) {
global $CFG;
//if ($CFG->branch <= '403') {
$this->execute('behat_forms::i_set_the_following_fields_to_these_values', $table);
$this->execute('behat_forms::press_button', "Save and display");
$this->execute('behat_general::assert_page_contains_text', "There are no discussion topics yet in this forum");
//}
/* else {
$this->execute('behat_general::assert_element_contains_text', ["There are no discussion topics yet in this forum", ".alert-warning","css_element"]);
} */
}

/**
* @Given /^I should see course format "(?P<element_string>(?:[^"]|\\")*)"$/
* @param string $format The course data
*/
public function i_should_see_define_course_format($format) {
global $CFG;
if ($CFG->branch <= '403') {
switch($format) {
case 'Single activity':
$format = 'Single activity format';
break;
case 'Social':
$format = 'Social format';
break;
case 'Custom sections':
$format = 'Topics format';
break;
case 'Weekly sections':
$format = 'Weekly format';
break;
}
}
$this->execute('behat_general::assert_page_contains_text', [$format]);
}


/**
* @Given /^I should not see course format "(?P<element_string>(?:[^"]|\\")*)"$/
* @param string $format The course data
*/
public function i_should_not_see_define_course_format($format) {
global $CFG;
if ($CFG->branch <= '403') {
switch($format) {
case 'Single activity':
$format = 'Single activity format';
break;
case 'Social':
$format = 'Social format';
break;
case 'Custom sections':
$format = 'Topics format';
break;
case 'Weekly sections':
$format = 'Weekly format';
break;
}
}
$this->execute('behat_general::assert_page_not_contains_text', [$format]);
}

/**
* Creates a new template with the provided table data matching template settings names with the desired values.
*
Expand Down Expand Up @@ -84,4 +190,20 @@ public function i_click_kickstart_template($selector) {
throw new ExpectationException("Doesn't working correct", $this->getSession());
}
}


/**
* Set the kickstart course format plugins settings.
*
* @Given /^I click kickstart single activity format template$/
* @param string $selector Selector
*/
public function i_click_kickstart_single_activity_format_template() {
global $CFG;
if ($CFG->branch <= '403') {
$this->i_click_kickstart_template(".use-template[data-templatename=\"Single activity format\"]");
} else {
$this->i_click_kickstart_template(".use-template[data-templatename=\"Single activity\"]");
}
}
}
52 changes: 19 additions & 33 deletions tests/behat/format_kickstart_visibility.feature
Original file line number Diff line number Diff line change
Expand Up @@ -121,61 +121,47 @@ Feature: Check the kickstart course format features.
Scenario: Check the format plugin template access.
Given I log in as "admin"
Then I navigate to "Plugins > Course formats > Manage templates" in site administration
And I should see "Kickstart format"
And I should see "Single activity"
And I should see "Social"
And I should see "Custom sections"
And I should see "Weekly sections"
And I should see course format "Kickstart format"
And I should see course format "Single activity"
And I should see course format "Social"
And I should see course format "Custom sections"
And I should see course format "Weekly sections"
And I navigate to "Plugins > Course formats > Manage course formats" in site administration
And I click on "Disable" "link" in the "Single activity" "table_row"
Then I click on disable link single activity
Then I navigate to "Plugins > Course formats > Manage templates" in site administration
And I should not see "Single activity"
And I should not see course format "Single activity"
Then I am on "Course 1" course homepage
Then I should see "Course templates"
And I should not see "Single activity"
Then I should see "Custom sections"
And I click kickstart template ".use-template[data-templatename=\"Custom sections\"]"
And I should not see course format "Single activity"
Then I should see course format "Custom sections"
Then I click on ".template-list .card-deck .card:nth-child(2) .card-footer a" "css_element"
And I click on "Import" "button" in the ".modal" "css_element"
And I start watching to see if a new page loads
Then I should see "Course 1"
Then ".course-content .topics" "css_element" should exist
Then ".course-content" "css_element" should exist
And I navigate to "Plugins > Course formats > Manage templates" in site administration
Then I click on "Edit" "button" in the "Custom sections" "table_row"
Then I click on enable link custom sections
And I should see "Edit template"
And I set the following fields to these values:
| Course layout | Show one section per page |
Then I press "Save changes"
Then I am on "Course 2" course homepage
And I click kickstart template ".use-template[data-templatename=\"Custom sections\"]"
And I click on "Import" "button" in the ".modal" "css_element"
#And I start watching to see if a new page loads
Then I should see "Course 2"
Then ".course-content .topics" "css_element" should exist
Then I click on ".template-list .card-deck .card:nth-child(2) .card-footer a" "css_element"

Scenario: Check the visible course templates in different roles
Given I log in as "user1"
Then I am on "Course 1" course homepage
Then I should see "Course templates"
And I click kickstart template ".use-template[data-templatename=\"Custom sections\"]"
And I click on "Import" "button" in the ".modal" "css_element"
And I start watching to see if a new page loads
Then I should see "Course 1"
Then ".course-content .topics" "css_element" should exist
Then I should see "Course 2"
Then ".course-content" "css_element" should exist

Scenario: Check the single activity format template
Given I log in as "admin"
And I am on "Course 3" course homepage with editing mode on
Then I should see "Course templates"
And I should see "Single activity"
And I click kickstart template ".use-template[data-templatename=\"Single activity\"]"
And I should see course format "Single activity"
And I click kickstart single activity format template
And I click on "Import" "button" in the ".modal" "css_element"
And I start watching to see if a new page loads
And I set the following fields to these values:
And I check single activity condition kickstart:
| Forum name | Test Forum |
Then I press "Save and display"
Then I should see "There are no discussion topics yet in this forum"
And I navigate to "Plugins > Course formats > Manage templates" in site administration
Then I click on "Edit" "button" in the "Single activity" "table_row"
Then I click on enable link single activity
And I should see "Edit template"
And I set the following fields to these values:
| Type of activity | Page |
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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

$plugin->version = 2024111101; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024111500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2022041900; // Requires this Moodle version.
$plugin->release = 'Version 1.4';
$plugin->component = 'format_kickstart'; // Full name of the plugin (used for diagnostics).
Expand Down

0 comments on commit 27d303d

Please sign in to comment.