Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 42 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ jobs:
fail-fast: false
matrix:
include:
- php: '7.4'
moodle-branch: 'master'
- php: '8.3'
moodle-branch: 'main'
database: 'pgsql'
- php: '7.4'
moodle-branch: 'MOODLE_311_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_500_STABLE'
database: 'mariadb'
- php: '8.2'
moodle-branch: 'MOODLE_405_STABLE'
database: 'pgsql'
- php: '8.2'
moodle-branch: 'MOODLE_404_STABLE'
database: 'mariadb'

services:
postgres:
image: postgres
image: postgres:14
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
Expand All @@ -30,77 +36,85 @@ jobs:
- 5432:5432

mariadb:
image: mariadb
image: mariadb:10
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

steps:
- name: Checkout
- name: Checkout 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: mbstring, pgsql, mysqli
extensions: ${{ matrix.extensions }}
ini-values: max_input_vars=5000
coverage: none

- name: Deploy moodle-plugin-ci
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
# Add dirs to $PATH
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
# 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
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

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

- name: phpcpd
- 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 || true
run: moodle-plugin-ci phpcpd

- name: phpmd
- name: PHP Mess Detector
if: ${{ always() }}
run: moodle-plugin-ci phpmd

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

- name: validate
- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc

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

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

- name: mustache
- name: Mustache Lint
continue-on-error: true # We are getting a false positive due to MDLSITE-6744 so ignore.
if: ${{ always() }}
run: moodle-plugin-ci mustache

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

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

- name: behat
- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
21 changes: 11 additions & 10 deletions blocks/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;


/**
* Example {@link report_editdates_block_date_extractor} subclass.
* Example {@see report_editdates_block_date_extractor} subclass.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -45,20 +42,24 @@ public function __construct($course) {
parent::load_data();
}

#[\Override]
public function get_settings(block_base $block) {
// Check if title text is a valid date then return the array.
$title = $block->title;
if ((string) (int) $title === $title) {
return array('title' => new report_editdates_date_setting
(get_string('availabledate', 'assignment'),
$block->title,
self::DATETIME, false, 5)
);
return [
'title' => new report_editdates_date_setting(
get_string('availabledate', 'assignment'),
$block->title,
self::DATETIME, false, 5
),
];
}
}

#[\Override]
public function validate_dates(block_base $block, array $dates) {
$errors = array();
$errors = [];
if ($dates['title'] == 0 ) {
$errors['title'] = get_string('datemustnotzero', 'report_editdates');
}
Expand Down
8 changes: 8 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change log for the Edit dates report

## Changes in 3.1

* This version is compatible with Moodle 5.0.
* Updated automated tests to support newer Moodle versions.
* Fixed coding style issues.
* Log events: removed legacy logging methods for compatibility with Moodle 4.2.
* Removed references to mod_assignment, which was deprecated and removed from core in Moodle 4.2.

## Changes in 3.0

* This version works with Moodle 4.0.
Expand Down
24 changes: 1 addition & 23 deletions classes/event/report_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

namespace report_editdates\event;

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

/**
*
* @package report_editdates
Expand Down Expand Up @@ -72,30 +70,10 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
$params = array('id' => $this->courseid);
$params = ['id' => $this->courseid];
if ($this->other['activitytype']) {
$params['activitytype'] = $this->other['activitytype'];
}
return new \moodle_url('/report/editdates/index.php', $params);
}

public static function get_legacy_eventname() {
return 'report edit dates';
}

/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array(
$this->courseid,
"course",
"report edit dates",
"report/editdates/index.php?id={$this->courseid}",
$this->contextinstanceid
);
}

}
7 changes: 4 additions & 3 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Privacy Subsystem implementation for report_editdates.
*
Expand All @@ -21,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_editdates\privacy;
defined('MOODLE_INTERNAL') || die();

/**
* Privacy Subsystem for report_editdates implementing null_provider.
*
Expand All @@ -33,9 +34,9 @@ class provider implements \core_privacy\local\metadata\null_provider {
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
14 changes: 7 additions & 7 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

defined('MOODLE_INTERNAL') || die;

$capabilities = array(
'report/editdates:view' => array(
$capabilities = [
'report/editdates:view' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/site:viewreports',
)
);
],
];
11 changes: 4 additions & 7 deletions db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

function xmldb_report_editdates_install() {
global $DB;

Expand All @@ -32,10 +29,10 @@ function xmldb_report_editdates_install() {
// and clone the permissions from moodle/site:viewreports, but if we are upgrading
// a Moodle that had the old course report plugin installed, then we get rid of the
// new cloned capabilities, and transfer the old permissions.
if ($DB->record_exists('role_capabilities', array('capability' => 'coursereport/editdates:view'))) {
$DB->delete_records('role_capabilities', array('capability' => 'report/editdates:view'));
if ($DB->record_exists('role_capabilities', ['capability' => 'coursereport/editdates:view'])) {
$DB->delete_records('role_capabilities', ['capability' => 'report/editdates:view']);
$DB->set_field('role_capabilities', 'capability', 'report/editdates:view',
array('capability' => 'coursereport/editdates:view'));
['capability' => 'coursereport/editdates:view']);
}

// This is a hack which is needed for cleanup of original coursereport_completion stuff.
Expand All @@ -44,6 +41,6 @@ function xmldb_report_editdates_install() {

// Update existing block page patterns.
$DB->set_field('block_instances', 'pagetypepattern', 'report-editdates-index',
array('pagetypepattern' => 'course-report-editdates-index'));
['pagetypepattern' => 'course-report-editdates-index']);
}

Loading
Loading