mirror of
https://github.com/PlagiarismCheck/moodle-plagiarism_pchkorg.git
synced 2024-12-22 04:10:07 +00:00
Add Backup API and Restore API implementation.
This commit is contained in:
parent
74a67bce5f
commit
c0a0533b10
88
backup/moodle2/backup_plagiarism_pchkorg_plugin.class.php
Normal file
88
backup/moodle2/backup_plagiarism_pchkorg_plugin.class.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class backup_plagiarism_pchkorg_plugin extends backup_plagiarism_plugin {
|
||||
/**
|
||||
* define_module_plugin_structure
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function define_module_plugin_structure() {
|
||||
// Define the virtual plugin element without conditions as the global class checks already.
|
||||
$plugin = $this->get_plugin_element();
|
||||
|
||||
// Create one standard named plugin element (the visible container).
|
||||
$pluginwrapper = new backup_nested_element($this->get_recommended_name());
|
||||
|
||||
// Connect the visible container ASAP.
|
||||
$plugin->add_child($pluginwrapper);
|
||||
|
||||
$configs = new backup_nested_element('pchkorg_configs');
|
||||
$config = new backup_nested_element('pchkorg_config', ['id'], ['name', 'value']);
|
||||
$pluginwrapper->add_child($configs);
|
||||
$configs->add_child($config);
|
||||
$config->set_source_table('plagiarism_pchkorg_config', ['cm' => backup::VAR_PARENTID]);
|
||||
|
||||
// Now information about files to module.
|
||||
$ufiles = new backup_nested_element('pchkorg_files');
|
||||
$ufile = new backup_nested_element('pchkorg_file', ['id'], [
|
||||
'cm', 'fileid', 'userid',
|
||||
'state', 'score', 'created_at',
|
||||
'textid', 'reportid', 'signature',
|
||||
'attempt', 'itemid'
|
||||
]);
|
||||
|
||||
$pluginwrapper->add_child($ufiles);
|
||||
$ufiles->add_child($ufile);
|
||||
|
||||
// To know if we are including userinfo.
|
||||
$userinfo = $this->get_setting_value('userinfo');
|
||||
if ($userinfo) {
|
||||
$ufile->set_source_table('plagiarism_pchkorg_files', ['cm' => backup::VAR_PARENTID]);
|
||||
}
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* define_course_plugin_structure
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function define_course_plugin_structure() {
|
||||
// Define the virtual plugin element without conditions as the global class checks already.
|
||||
$plugin = $this->get_plugin_element();
|
||||
|
||||
// Create one standard named plugin element (the visible container).
|
||||
$pluginwrapper = new backup_nested_element($this->get_recommended_name());
|
||||
|
||||
// Connect the visible container ASAP.
|
||||
$plugin->add_child($pluginwrapper);
|
||||
// Save id from pchkorg course.
|
||||
$unconfigs = new backup_nested_element('pchkorg_configs');
|
||||
$unconfig = new backup_nested_element('pchkorg_config', ['id'], ['plugin', 'name', 'value']);
|
||||
$pluginwrapper->add_child($unconfigs);
|
||||
$unconfigs->add_child($unconfig);
|
||||
$unconfig->set_source_table('config_plugins', [
|
||||
'name' => backup::VAR_PARENTID, 'plugin' => 'plagiarism',
|
||||
]);
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
}
|
74
backup/moodle2/restore_plagiarism_pchkorg_plugin.class.php
Normal file
74
backup/moodle2/restore_plagiarism_pchkorg_plugin.class.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class restore_plagiarism_pchkorg_plugin extends restore_plagiarism_plugin {
|
||||
|
||||
public function process_pchkorgconfig($data) {
|
||||
$data = (object) $data;
|
||||
|
||||
set_config($this->task->get_courseid(), $data->value, $data->plugin);
|
||||
}
|
||||
|
||||
|
||||
public function process_pchkorgconfigmod($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object) $data;
|
||||
$data->cm = $this->task->get_moduleid();
|
||||
|
||||
$DB->insert_record('plagiarism_pchkorg_config', $data);
|
||||
}
|
||||
|
||||
public function process_pchkorgfiles($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object) $data;
|
||||
$data->cm = $this->task->get_moduleid();
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
|
||||
$DB->insert_record('plagiarism_pchkorg_files', $data);
|
||||
}
|
||||
|
||||
|
||||
protected function define_course_plugin_structure() {
|
||||
$paths = [];
|
||||
|
||||
// Add own format stuff.
|
||||
$elename = 'pchkorg_config';
|
||||
$elepath = $this->get_pathfor('pchkorg_configs/pchkorg_config'); // We used get_recommended_name() so this works.
|
||||
$paths[] = new restore_path_element($elename, $elepath);
|
||||
|
||||
return $paths; // And we return the interesting paths.
|
||||
}
|
||||
|
||||
|
||||
protected function define_module_plugin_structure() {
|
||||
$paths = [];
|
||||
|
||||
$elename = 'pchkorgconfigmod';
|
||||
$elepath = $this->get_pathfor('pchkorg_configs/pchkorg_config');
|
||||
$paths[] = new restore_path_element($elename, $elepath);
|
||||
|
||||
$elename = 'pchkorgfiles';
|
||||
$elepath = $this->get_pathfor('/pchkorg_file/pchkorg_file');
|
||||
$paths[] = new restore_path_element($elename, $elepath);
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
|
||||
if (!isset($plugin)) {
|
||||
$plugin = new stdClass();
|
||||
}
|
||||
$plugin->version = 2022100710;
|
||||
$plugin->version = 2022102718;
|
||||
$plugin->requires = 2020061501; // Requires Moodle 3.9 .
|
||||
$plugin->release = 'v3.11.3';
|
||||
$plugin->release = 'v3.12.1';
|
||||
$plugin->component = 'plagiarism_pchkorg';
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
$plugin->dependencies = array(
|
||||
|
Loading…
Reference in New Issue
Block a user