Skip to content

Commit

Permalink
version upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ewallah committed Jul 25, 2021
1 parent 1d5b391 commit 46d06c9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 31 deletions.
25 changes: 9 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,23 @@ jobs:
strategy:
fail-fast: false
matrix:
moodle-branch: ['master', 'MOODLE_311_STABLE', 'MOODLE_310_STABLE', 'MOODLE_39_STABLE']
moodle-branch: ['MOODLE_311_STABLE', 'MOODLE_310_STABLE', 'MOODLE_39_STABLE']
php: ['7.4']
database: ['mysqli']
include:
- php: 8.0
moodle-branch: master
database: mysqli

steps:
- name: checkout plugin
uses: actions/checkout@v2
if: ${{ matrix.moodle-branch != 'master' }}
with:
path: this-plugin
ref: main

- name: checkout plugin
uses: actions/checkout@v2
if: ${{ matrix.moodle-branch == 'master' }}
with:
path: this-plugin
ref: dev

- name: setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, mysqli, gd, xmlrpc, zip
ini-values: max_input_vars=5000
tools: composer, behat, phpunit:8.5.14, phpmd, phpcbf, phpcpd, psalm, phpcs
coverage: xdebug2

- name: composer
run: |
Expand Down Expand Up @@ -84,7 +70,7 @@ jobs:
run: moodle-plugin-ci --ansi grunt

- name: phpunit
run: moodle-plugin-ci --ansi phpunit --coverage-text || true
run: moodle-plugin-ci --ansi phpunit --coverage-text --coverage-clover || true

- name: firefox
run: moodle-plugin-ci --ansi behat
Expand All @@ -105,3 +91,10 @@ jobs:
- name: privacy
run: vendor/bin/phpunit --colors --no-coverage --testsuite tool_dataprivacy_testsuite,tool_policy_testsuite,core_privacy_testsuite
working-directory: moodle

- name: coveralls
if: ${{ matrix.moodle-branch == 'MOODLE_311_STABLE' }}
env:
COVERALLS_RUN_LOCALLY: true
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: moodle-plugin-ci --ansi coveralls-upload
11 changes: 5 additions & 6 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot. '/course/format/topics/lib.php');
require_once($CFG->dirroot . '/course/format/topics/lib.php');

/**
* Main class for the masonry course format
Expand Down Expand Up @@ -203,12 +203,11 @@ public function get_config_for_external() {
* @return \core\output\inplace_editable
*/
function format_masonry_inplace_editable($itemtype, $itemid, $newvalue) {
global $DB, $CFG;
global $CFG, $DB;
require_once($CFG->dirroot . '/course/lib.php');
if ($itemtype === 'sectionname' || $itemtype === 'sectionnamenl') {
$section = $DB->get_record_sql(
'SELECT s.* FROM {course_sections} s JOIN {course} c ON s.course = c.id WHERE s.id = ? AND c.format = ?',
[$itemid, 'masonry'], MUST_EXIST);
if ($itemtype == 'sectionname' || $itemtype == 'sectionnamenl') {
$sql = 'SELECT s.* FROM {course_sections} s JOIN {course} c ON s.course = c.id WHERE s.id = ? AND c.format = ?';
$section = $DB->get_record_sql($sql, [$itemid, 'masonry'], MUST_EXIST);
return course_get_format($section->course)->inplace_editable_update_section_name($section, $itemtype, $newvalue);
}
}
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<directory suffix="_test.php">.</directory>
<directory>tests</directory>
<directory>lang</directory>
<file>db/upgrade.php</file>
<file>version.php</file>
<file>format.php</file>
<file>settings.php</file>
Expand Down
3 changes: 0 additions & 3 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ protected function section_summary($section, $course, $mods) {
$str = $this->section_header($section, $course, false, 0);
if ($section->uservisible) {
$str .= $this->courserenderer->course_section_cm_list($course, $section, 0);
if ($this->page->user_is_editing()) {
$str .= $this->courserenderer->course_section_add_cm_control($course, $section, 0);
}
}
$str .= $this->section_footer();
return $str;
Expand Down
15 changes: 10 additions & 5 deletions tests/format_masonry_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public function setUp(): void {
require_once($CFG->dirroot . '/course/format/masonry/renderer.php');
$this->resetAfterTest(true);
$generator = $this->getDataGenerator();
$params = ['format' => 'masonry', 'numsections' => 5, 'startdate' => 1445644800];
$params = ['format' => 'masonry', 'numsections' => 6, 'startdate' => 1445644800];
$this->course = $generator->create_course($params, ['createsections' => true]);
$generator->get_plugin_generator('mod_page')->create_instance(['course' => $this->course->id, 'section' => 0]);
$generator->get_plugin_generator('mod_page')->create_instance(['course' => $this->course->id, 'section' => 1]);
$generator->get_plugin_generator('mod_page')->create_instance(['course' => $this->course->id, 'section' => 2]);
$generator->get_plugin_generator('mod_page')->create_instance(['course' => $this->course->id, 'section' => 3]);
$generator->get_plugin_generator('mod_page')->create_instance(['course' => $this->course->id, 'section' => 4]);
$generator->get_plugin_generator('mod_forum')->create_instance(['course' => $this->course->id, 'section' => 5]);
$generator->get_plugin_generator('mod_page')->create_instance(['course' => $this->course->id, 'section' => 5]);
$generator->get_plugin_generator('mod_forum')->create_instance(['course' => $this->course->id, 'section' => 6]);
$generator->get_plugin_generator('mod_forum')->create_instance(['course' => $this->course->id, 'section' => 7]);
}

/**
Expand Down Expand Up @@ -218,6 +218,7 @@ public function test_renderer() {
'requires' => ['base', 'node', 'transition', 'event', 'io-base', 'moodle-core-io']]);
$renderer = new \format_masonry_renderer($page, null);
ob_start();
$renderer->print_single_section_page($this->course, null, null, null, null, 0);
$renderer->print_single_section_page($this->course, null, null, null, null, 1);
$out1 = ob_get_contents();
$renderer->print_multiple_section_page($this->course, null, null, null, null, null);
Expand Down Expand Up @@ -258,11 +259,12 @@ public function test_format() {
$this->setAdminUser();
$USER->editing = true;
$PAGE->set_course($this->course);
$PAGE->get_renderer('core', 'course');
$PAGE->get_renderer('format_masonry');
$course = $this->course;
ob_start();
include_once($CFG->dirroot . '/course/format/masonry/format.php');
ob_end_clean();
$this->assertEquals($course, $this->course);
}

/**
Expand All @@ -283,11 +285,13 @@ public function test_format_editing() {
ob_start();
include_once($CFG->dirroot . '/course/format/masonry/format.php');
ob_end_clean();
$this->assertEquals($course, $this->course);
}

/**
* Test other.
* @covers format_masonry
* @covers format_masonry_inplace_editable
*/
public function test_other() {
$this->setAdminUser();
Expand All @@ -300,6 +304,7 @@ public function test_other() {
$this->assertCount(6, $format->course_format_options());
$this->assertTrue($format->allow_stealth_module_visibility(null, null));
$this->assertCount(6, $format->get_config_for_external());
$this->assertNotEmpty(format_masonry_inplace_editable('sectionname', $sections[1]->id, 'newname'));
$this->assertInstanceOf('\core\output\inplace_editable',
format_masonry_inplace_editable('sectionname', $sections[1]->id, 'newname'));
}
}
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 = 2021051500;
$plugin->version = 2021072500;
$plugin->requires = 2020061500;
$plugin->component = 'format_masonry';
$plugin->release = '3.9+';
Expand Down

0 comments on commit 46d06c9

Please sign in to comment.