Merging
This commit is contained in:
commit
024aae2ba1
8 changed files with 311 additions and 11 deletions
70
backup/moodle2/backup_expcontent_activity_task.class.php
Normal file
70
backup/moodle2/backup_expcontent_activity_task.class.php
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of the expcontent module for 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/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file contains the backup tasks that provides all the settings and steps to perform a backup of the activity.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||||
|
|
||||||
|
require_once($CFG->dirroot . '/mod/expcontent/backup/moodle2/backup_expcontent_stepslib.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles creating tasks to peform in order to create the backup.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
class backup_expcontent_activity_task extends backup_activity_task {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define particular settings this activity can have.
|
||||||
|
*/
|
||||||
|
protected function define_my_settings() {
|
||||||
|
// No particular settings for this activity.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define particular steps this activity can have.
|
||||||
|
*/
|
||||||
|
protected function define_my_steps() {
|
||||||
|
// The expcontent only has one structure step.
|
||||||
|
$this->add_step(new backup_expcontent_activity_structure_step('expcontent_structure', 'expcontent.xml'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code the transformations to perform in the activity in order to get transportable (encoded) links.
|
||||||
|
*
|
||||||
|
* @param string $content
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
|
public static function encode_content_links($content) {
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
|
$base = preg_quote($CFG->wwwroot, "/");
|
||||||
|
|
||||||
|
// Link to expcontent view by moduleid.
|
||||||
|
$search = "/(".$base."\/mod\/expcontent\/view.php\?id\=)([0-9]+)/";
|
||||||
|
$content = preg_replace($search, '$@EXPCONTENTVIEWBYID*$2@$', $content);
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
}
|
53
backup/moodle2/backup_expcontent_stepslib.php
Normal file
53
backup/moodle2/backup_expcontent_stepslib.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of the expcontent module for 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/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define all the backup steps that will be used by the backup_expcontent_activity_task.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the complete expcontent structure for backup, with file and id annotations.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
class backup_expcontent_activity_structure_step extends backup_activity_structure_step {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the structure of the backup file.
|
||||||
|
*
|
||||||
|
* @return backup_nested_element
|
||||||
|
*/
|
||||||
|
protected function define_structure() {
|
||||||
|
|
||||||
|
// The instance.
|
||||||
|
$expcontent = new backup_nested_element('expcontent', array('id'), array(
|
||||||
|
'name', 'contentid', 'intro', 'introformat', 'timecreated', 'timemodified'));
|
||||||
|
|
||||||
|
// Define sources.
|
||||||
|
$expcontent->set_source_table('expcontent', array('id' => backup::VAR_ACTIVITYID));
|
||||||
|
|
||||||
|
// Return the root element (expcontent), wrapped into standard activity structure.
|
||||||
|
return $this->prepare_activity_structure($expcontent);
|
||||||
|
}
|
||||||
|
}
|
101
backup/moodle2/restore_expcontent_activity_task.class.php
Normal file
101
backup/moodle2/restore_expcontent_activity_task.class.php
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of the expcontent module for 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/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define all the restore steps that will be used by the restore_expcontent_activity_task.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||||
|
|
||||||
|
require_once($CFG->dirroot . '/mod/expcontent/backup/moodle2/restore_expcontent_stepslib.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class definition for assigning tasks that provide the settings and steps to perform a restore of the activity.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
class restore_expcontent_activity_task extends restore_activity_task {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define particular settings this activity can have.
|
||||||
|
*/
|
||||||
|
protected function define_my_settings() {
|
||||||
|
// No particular settings for this activity.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define particular steps this activity can have.
|
||||||
|
*/
|
||||||
|
protected function define_my_steps() {
|
||||||
|
// The expcontent only has one structure step.
|
||||||
|
$this->add_step(new restore_expcontent_activity_structure_step('expcontent_structure', 'expcontent.xml'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the contents in the activity that must be processed by the link decoder.
|
||||||
|
*/
|
||||||
|
public static function define_decode_contents() {
|
||||||
|
$contents = array();
|
||||||
|
|
||||||
|
$contents[] = new restore_decode_content('expcontent', array('intro'), 'expcontent');
|
||||||
|
|
||||||
|
return $contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the decoding rules for links belonging to the activity to be executed by the link decoder.
|
||||||
|
*/
|
||||||
|
public static function define_decode_rules() {
|
||||||
|
$rules = array();
|
||||||
|
|
||||||
|
$rules[] = new restore_decode_rule('EXPCONTENTVIEWBYID', '/mod/expcontent/view.php?id=$1', 'course_module');
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the restore log rules that will be applied by the {@see restore_logs_processor} when restoring
|
||||||
|
* expcontent logs. It must return one array of {@see restore_log_rule} objects.
|
||||||
|
*
|
||||||
|
* @return array the restore log rules
|
||||||
|
*/
|
||||||
|
public static function define_restore_log_rules() {
|
||||||
|
$rules = array();
|
||||||
|
|
||||||
|
$rules[] = new restore_log_rule('expcontent', 'add', 'view.php?id={course_module}', '{expcontent}');
|
||||||
|
$rules[] = new restore_log_rule('expcontent', 'update', 'view.php?id={course_module}', '{expcontent}');
|
||||||
|
$rules[] = new restore_log_rule('expcontent', 'view', 'view.php?id={course_module}', '{expcontent}');
|
||||||
|
$rules[] = new restore_log_rule('expcontent', 'view report', 'view.php?id={course_module}', '{expcontent}');
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called after all the activities in the backup have been restored. This allows us to get
|
||||||
|
* the new course module ids, as they may have been restored after the expcontent module, meaning no id
|
||||||
|
* was available at the time.
|
||||||
|
*/
|
||||||
|
public function after_restore() {
|
||||||
|
global $DB;
|
||||||
|
}
|
||||||
|
}
|
73
backup/moodle2/restore_expcontent_stepslib.php
Normal file
73
backup/moodle2/restore_expcontent_stepslib.php
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of the expcontent module for 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/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define all the restore steps that will be used by the restore_expcontent_activity_task.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the complete expcontent structure for restore, with file and id annotations.
|
||||||
|
*
|
||||||
|
* @package mod_expcontent
|
||||||
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
class restore_expcontent_activity_structure_step extends restore_activity_structure_step {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the different items to restore.
|
||||||
|
*
|
||||||
|
* @return array the restore paths
|
||||||
|
*/
|
||||||
|
protected function define_structure() {
|
||||||
|
// The array used to store the path to the items we want to restore.
|
||||||
|
$paths = array();
|
||||||
|
|
||||||
|
// The expcontent instance.
|
||||||
|
$paths[] = new restore_path_element('expcontent', '/activity/expcontent');
|
||||||
|
|
||||||
|
// Return the paths wrapped into standard activity structure.
|
||||||
|
return $this->prepare_activity_structure($paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles restoring the expcontent activity.
|
||||||
|
*
|
||||||
|
* @param stdClass $data the expcontent data
|
||||||
|
*/
|
||||||
|
protected function process_expcontent($data) {
|
||||||
|
global $DB, $USER;
|
||||||
|
|
||||||
|
$data = (object) $data;
|
||||||
|
$data->course = $this->get_courseid();
|
||||||
|
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||||
|
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||||
|
$data->usermodified = $USER->id;
|
||||||
|
|
||||||
|
// Insert the expcontent record.
|
||||||
|
$newitemid = $DB->insert_record('expcontent', $data);
|
||||||
|
|
||||||
|
// Immediately after inserting record call this.
|
||||||
|
$this->apply_activity_instance($newitemid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$string['modulename'] = 'EXP360 Content';
|
$string['modulename'] = '360° Content';
|
||||||
$string['modulenameplural'] = 'EXP360 Contents';
|
$string['modulenameplural'] = $string['modulename'];
|
||||||
|
$string['pluginname'] = $string['modulename'];
|
||||||
|
|
||||||
$string['settings'] = 'Settings';
|
$string['settings'] = 'Settings';
|
||||||
|
|
||||||
|
@ -11,4 +12,4 @@ $string['baseurl'] = 'Base URL';
|
||||||
$string['baseurl_help'] = 'Base URL of the EXP360 Content Server';
|
$string['baseurl_help'] = 'Base URL of the EXP360 Content Server';
|
||||||
|
|
||||||
$string['name'] = 'Name';
|
$string['name'] = 'Name';
|
||||||
$string['contentid'] = 'Content ID';
|
$string['contentid'] = 'Content ID';
|
||||||
|
|
10
lib.php
10
lib.php
|
@ -18,7 +18,6 @@ function expcontent_update_instance($expcontent) {
|
||||||
|
|
||||||
$expcontent->timemodified = time();
|
$expcontent->timemodified = time();
|
||||||
$expcontent->id = $expcontent->instance;
|
$expcontent->id = $expcontent->instance;
|
||||||
$expcontent->introformat = FORMAT_MOODLE;
|
|
||||||
|
|
||||||
if (! $DB->update_record('expcontent', $expcontent)) {
|
if (! $DB->update_record('expcontent', $expcontent)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -41,8 +40,9 @@ function expcontent_delete_instance($id) {
|
||||||
|
|
||||||
function expcontent_supports($feature) {
|
function expcontent_supports($feature) {
|
||||||
switch($feature) {
|
switch($feature) {
|
||||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||||
case FEATURE_SHOW_DESCRIPTION: return true;
|
case FEATURE_SHOW_COMPLETION: return true;
|
||||||
default: return null;
|
case FEATURE_BACKUP_MOODLE2: return true;
|
||||||
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ class mod_expcontent_mod_form extends moodleform_mod {
|
||||||
$mform->addElement('text', 'contentid', get_string('contentid', 'expcontent'), array('size'=>'64'));
|
$mform->addElement('text', 'contentid', get_string('contentid', 'expcontent'), array('size'=>'64'));
|
||||||
$mform->setType('contentid', PARAM_TEXT);
|
$mform->setType('contentid', PARAM_TEXT);
|
||||||
$mform->addRule('contentid', null, 'required', null, 'client');
|
$mform->addRule('contentid', null, 'required', null, 'client');
|
||||||
|
|
||||||
|
$this->standard_intro_elements();
|
||||||
|
|
||||||
$this->standard_intro_elements();
|
$this->standard_intro_elements();
|
||||||
|
|
||||||
|
@ -27,4 +29,4 @@ class mod_expcontent_mod_form extends moodleform_mod {
|
||||||
$this->add_action_buttons();
|
$this->add_action_buttons();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$plugin->version = "2021111500";
|
$plugin->version = "2021113003";
|
||||||
$plugin->component = 'mod_expcontent';
|
$plugin->component = 'mod_expcontent';
|
||||||
$plugin->maturity = MATURITY_ALPHA;
|
$plugin->maturity = MATURITY_ALPHA;
|
||||||
$plugin->release = 'v0.0.1';
|
$plugin->release = 'v0.0.1';
|
||||||
$plugin->requires = '2019111800';
|
$plugin->requires = '2019111800';
|
||||||
|
|
Loading…
Reference in a new issue