• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FormulasQuestion / moodle-qtype_formulas / 13244722393

10 Feb 2025 03:44PM UTC coverage: 93.907% (+18.9%) from 75.045%
13244722393

push

github

web-flow
Merge pull request #159 from PhilippImhof/replace-parser

Prepare for version 6

3072 of 3136 new or added lines in 22 files covered. (97.96%)

16 existing lines in 5 files now uncovered.

3668 of 3906 relevant lines covered (93.91%)

1199.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/backup/moodle2/backup_qtype_formulas_plugin.class.php
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
/**
18
 * Provides the information to backup formulas questions
19
 *
20
 * @package    qtype_formulas
21
 * @copyright  2010 Hon Wai, Lau <lau65536@gmail.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
class backup_qtype_formulas_plugin extends backup_qtype_plugin {
25

26
    /**
27
     * Returns the qtype information to attach to question element
28
     */
29
    protected function define_question_plugin_structure() {
30

31
        // Define the virtual plugin element with the condition to fulfill.
32
        $plugin = $this->get_plugin_element(null, '../../qtype', 'formulas');
×
33

34
        // Create one standard named plugin element (the visible container).
35
        $pluginwrapper = new backup_nested_element($this->get_recommended_name());
×
36

37
        // Connect the visible container ASAP.
38
        $plugin->add_child($pluginwrapper);
×
39

40
        // WARNING This qtype don't uses standard question_answers, qtype_formulas_answers are differents.
41

42
        // Now create the qtype own structures.
43

NEW
44
        $formulas = new backup_nested_element('formulas', ['id'], [
×
45
            'varsrandom', 'varsglobal',
×
46
            'correctfeedback', 'correctfeedbackformat',
×
47
            'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
×
48
            'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect',
×
NEW
49
            'answernumbering']);
×
50

51
        $formulasanswers = new backup_nested_element('formulas_answers');
×
NEW
52
        $formulasanswer = new backup_nested_element('formulas_answer', ['id'], [
×
53
            'placeholder', 'answermark', 'answertype', 'numbox', 'vars1', 'answer', 'answernotunique', 'vars2', 'correctness',
×
54
            'unitpenalty', 'postunit', 'ruleid', 'otherrule', 'subqtext', 'subqtextformat', 'feedback', 'feedbackformat',
×
55
            'partcorrectfb', 'partcorrectfbformat',
×
56
            'partpartiallycorrectfb', 'partpartiallycorrectfbformat',
×
NEW
57
            'partincorrectfb', 'partincorrectfbformat']);
×
58

59
        // Don't need to annotate ids nor files.
60
        // Now the own qtype tree.
61
        // Order is important because we need to know formulas_answers ids,
62
        // to fill the formulas answerids field at restore.
63
        $pluginwrapper->add_child($formulasanswers);
×
64
        $formulasanswers->add_child($formulasanswer);
×
65
        $pluginwrapper->add_child($formulas);
×
66

67
        // Set source to populate the data.
68
        $formulasanswer->set_source_sql('
×
69
                SELECT *
70
                FROM {qtype_formulas_answers}
71
                WHERE questionid = :questionid
72
                ORDER BY partindex',
×
NEW
73
                ['questionid' => backup::VAR_PARENTID]);
×
74

NEW
75
        $formulas->set_source_table('qtype_formulas_options', ['questionid' => backup::VAR_PARENTID]);
×
76

77
        // Don't need to annotate ids nor files.
78

79
        return $plugin;
×
80
    }
81

82
    /**
83
     * Returns one array with filearea => mappingname elements for the qtype
84
     *
85
     * Used by {@link get_components_and_fileareas} to know about all the qtype
86
     * files to be processed both in backup and restore.
87
     */
88
    public static function get_qtype_fileareas() {
NEW
89
        return [
×
90
            'answersubqtext' => 'qtype_formulas_answers',
×
91
            'answerfeedback' => 'qtype_formulas_answers',
×
92
            'correctfeedback' => 'question_created',
×
93
            'partiallycorrectfeedback' => 'question_created',
×
94
            'incorrectfeedback' => 'question_created',
×
95
            'partcorrectfb' => 'qtype_formulas_answers',
×
96
            'partpartiallycorrectfb' => 'qtype_formulas_answers',
×
NEW
97
            'partincorrectfb' => 'qtype_formulas_answers'];
×
98
    }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc