Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta backup #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
92 changes: 33 additions & 59 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,55 @@
language: php

sudo: true

addons:
firefox: "47.0.1"
postgresql: "9.4"
mysql: "8.0.2"
apt:
packages:
- oracle-java9-installer
- oracle-java9-set-default
postgresql: "9.6"

services:
- mysql
- postgresql
- docker

cache:
directories:
- $HOME/.composer/cache
- $HOME/.npm

php:
- 5.6
- 7.1
- 7.2
- 7.1
- 7.2
- 7.3
- 7.4

env:
- MOODLE_BRANCH=MOODLE_36_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
matrix:
- MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_310_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_311_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_311_STABLE DB=mysqli

matrix:
exclude:
- php: 7.1
env: MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
- php: 7.1
env: MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql
- php: 7.2
env: MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
- php: 7.2
env: MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql
- php: 5.6
env: MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli
- php: 5.6
env: MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql
- php: 7.2
env: MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli
- php: 7.2
env: MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql
- php: 5.6
env: MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
- php: 5.6
env: MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql
- php: 7.2
env: MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
- php: 7.2
env: MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql
- php: 5.6
env: MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli
- php: 5.6
env: MOODLE_BRANCH=MOODLE_36_STABLE DB=pgsql
- php: 7.1
env: MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli
- php: 7.1
env: MOODLE_BRANCH=MOODLE_36_STABLE DB=pgsql
- php: 7.3
env: MOODLE_BRANCH=MOODLE_310_STABLE DB=mysqli
- php: 7.3
env: MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql
- php: 7.4
env: MOODLE_BRANCH=MOODLE_310_STABLE DB=mysqli
- php: 7.4
env: MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql
- php: 7.1
env: MOODLE_BRANCH=MOODLE_311_STABLE DB=mysqli
- php: 7.1
env: MOODLE_BRANCH=MOODLE_311_STABLE DB=pgsql
- php: 7.2
env: MOODLE_BRANCH=MOODLE_311_STABLE DB=mysqli
- php: 7.2
env: MOODLE_BRANCH=MOODLE_311_STABLE DB=pgsql

before_install:
- phpenv config-rm xdebug.ini
- nvm install node
- nvm install 8.9
- nvm use 8.9
- cd ../..
- composer selfupdate
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2
- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"


install:
- moodle-plugin-ci install

Expand All @@ -89,5 +62,6 @@ script:
- moodle-plugin-ci savepoints
- moodle-plugin-ci mustache
- moodle-plugin-ci grunt
# - moodle-plugin-ci phpdoc
- moodle-plugin-ci phpunit
- moodle-plugin-ci behat
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Release Notes

Release 3.11.0 (Build 2020111801)
Updated subplugin declaration file to new subplugins.json structure.

(see CHANGES.TXT in release 3.8 for earlier changes.)
11 changes: 0 additions & 11 deletions CHANGES.txt

This file was deleted.

51 changes: 51 additions & 0 deletions backup/moodle2/backup_local_metadata_plugin.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package local_metadata
* @version 1.0
* @copyright &copy; 2020 Kurvin Hendricks [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/


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


class backup_local_metadata_plugin extends backup_local_plugin {
/**
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
// No particular settings for this activity.
}
protected function define_course_plugin_structure() {

$plugin = $this->get_plugin_element(null, null, null);
$pluginwrapper = new backup_nested_element(
$this->get_recommended_name(),
array('id'),
array('instanceid', 'fieldid', 'data', 'dataformat')
);
// Connect the visible container ASAP.
$plugin->add_child($pluginwrapper);

// Set source to populate the data.
$pluginwrapper->set_source_sql("SELECT id, instanceid, fieldid, data, dataformat FROM {local_metadata}", array());

return $plugin;
}
}
76 changes: 76 additions & 0 deletions backup/moodle2/restore_local_metadata_plugin.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Grid Information
* @package local_metadata
* @version 1.0
* @copyright &copy; 2020 Kurvin Hendricks [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
defined('MOODLE_INTERNAL') || die();

/**
* Restore plugin class that provides the necessary information
* needed to restore metadata
*/

class restore_local_metadata_plugin extends restore_local_plugin {

/**
* Returns the paths to be handled by the plugin at course level.
*/
protected function define_course_plugin_structure() {

$paths = array();

$elename = 'plugin_local_metatdata_course'; // This defines the postfix of 'process_*' below.
$elepath = $this->get_pathfor('/');
$paths[] = new restore_path_element($elename, $elepath);
return $paths; // And we return the interesting paths.
}


/**
* Process the metadata element.
*/
public function process_plugin_local_metatdata_course($data) {
global $DB, $COURSE;

$data = (object)$data;
$oldid = $data->id;
unset($data->id);

$data->instanceid = $this->task->get_courseid();

if ($data->instanceid) {
$sql = 'SELECT * FROM {local_metadata} WHERE instanceid = ?';
$params = array('instanceid' => $data->instanceid);
try {
if (!$DB->record_exists_sql($sql, $params)) {
try {
$DB->insert_record('local_metadata', $data);
} catch (Exception $e){
error_log($e->getMessage(), 0);
}
}
} catch(Exception $e) {
error_log($e->getMessage(), 0);
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class metadatacontext_category_event_testcase extends advanced_testcase {
/**
* Setup tasks.
*/
public function setUp() {
public function setUp(): void {
$this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata');
$this->category = [];
$this->category[] = $this->getDataGenerator()->create_category();
Expand Down
2 changes: 1 addition & 1 deletion context/cohort/tests/metadatacontext_cohort_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class metadatacontext_cohort_event_testcase extends advanced_testcase {
/**
* Setup tasks.
*/
public function setUp() {
public function setUp(): void {
$this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata');
$this->cohort = [];
$this->cohort[] = $this->getDataGenerator()->create_cohort();
Expand Down
4 changes: 2 additions & 2 deletions context/course/classes/context_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function get_redirect() {
*/
public function require_access() {
require_login($this->instance);
require_capability('moodle/course:create', $this->context);
require_capability('moodle/course:update', $this->context);
return true;
}

Expand Down Expand Up @@ -138,4 +138,4 @@ public function extend_navigation_course($parentnode, $course, $context) {
$parentnode->add_node($metadatanode);
}
}
}
}
2 changes: 1 addition & 1 deletion context/course/tests/metadatacontext_course_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class metadatacontext_course_event_testcase extends advanced_testcase {
/**
* Setup tasks.
*/
public function setUp() {
public function setUp(): void {
$this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata');
$this->course = [];
$this->course[] = $this->getDataGenerator()->create_course();
Expand Down
2 changes: 1 addition & 1 deletion context/group/tests/metadatacontext_group_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class metadatacontext_group_event_testcase extends advanced_testcase {
/**
* Setup tasks.
*/
public function setUp() {
public function setUp(): void {
$this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata');
$this->course = [];
$this->course[] = $this->getDataGenerator()->create_course();
Expand Down
2 changes: 1 addition & 1 deletion context/module/tests/metadatacontext_module_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class metadatacontext_module_event_testcase extends advanced_testcase {
/**
* Setup tasks.
*/
public function setUp() {
public function setUp(): void {
$this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata');
$this->course = [];
$this->course[] = $this->getDataGenerator()->create_course();
Expand Down
2 changes: 1 addition & 1 deletion context/user/tests/metadatacontext_user_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class metadatacontext_user_event_testcase extends advanced_testcase {
/**
* Setup tasks.
*/
public function setUp() {
public function setUp(): void {
$this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata');
$this->user = [];
$this->user[] = $this->getDataGenerator()->create_user();
Expand Down
6 changes: 6 additions & 0 deletions db/subplugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugintypes": {
"metadatafieldtype": "local\/metadata\/fieldtype",
"metadatacontext": "local\/metadata\/context"
}
}
31 changes: 0 additions & 31 deletions db/subplugins.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/metadata_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class local_metadata_testcase extends advanced_testcase {
/**
* Sets up the test cases.
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->metadata = new local_metadata\fieldtype\metadata();
}
Expand Down
Loading