1441 |
ariadna |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
defined('MOODLE_INTERNAL') || die();
|
|
|
18 |
|
|
|
19 |
global $CFG;
|
|
|
20 |
require_once($CFG->dirroot . '/mod/qbank/backup/moodle2/backup_qbank_stepslib.php');
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Qbank module backup task that provides all the settings and steps to perform one complete backup of the activity.
|
|
|
24 |
*
|
|
|
25 |
* @package mod_qbank
|
|
|
26 |
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
|
|
|
27 |
* @author Simon Adams <simon.adams@catalyst-eu.net>
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
*/
|
|
|
30 |
class backup_qbank_activity_task extends backup_activity_task {
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Define (add) particular settings this activity can have
|
|
|
34 |
*/
|
|
|
35 |
protected function define_my_settings() {
|
|
|
36 |
// No particular settings for this activity.
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Define (add) particular steps this activity can have
|
|
|
41 |
*/
|
|
|
42 |
protected function define_my_steps() {
|
|
|
43 |
$this->add_step(new backup_qbank_activity_structure_step('qbank_structure', 'qbank.xml'));
|
|
|
44 |
$this->add_step(new backup_calculate_question_categories('qbank_activity_question_categories'));
|
|
|
45 |
$this->add_step(new backup_delete_temp_questions('clean_temp_questions'));
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Code the transformations to perform in the activity in
|
|
|
50 |
* order to get transportable (encoded) links
|
|
|
51 |
*
|
|
|
52 |
* @param string $content some HTML text that eventually contains URLs to the activity instance scripts
|
|
|
53 |
* @return string encoded content
|
|
|
54 |
*/
|
|
|
55 |
public static function encode_content_links($content) {
|
|
|
56 |
global $CFG;
|
|
|
57 |
|
|
|
58 |
$base = preg_quote($CFG->wwwroot, '/');
|
|
|
59 |
|
|
|
60 |
// Link to qbank view by moduleid.
|
|
|
61 |
$search = "/(".$base."\/mod\/qbank\/view.php\?id\=)([0-9]+)/";
|
|
|
62 |
|
|
|
63 |
return preg_replace($search, '$@QBANKVIEWBYID*$2@$', $content);
|
|
|
64 |
}
|
|
|
65 |
}
|