Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
// This file is part of Moodle - http://moodle.org/
4
//
5
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// Moodle is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17
 
18
/**
19
 * @package    workshopform_rubric
20
 * @copyright  2010 David Mudrak <david@moodle.com>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
defined('MOODLE_INTERNAL') || die();
24
 
25
/**
26
 * Provides the information to backup rubric grading strategy information
27
 */
28
class backup_workshopform_rubric_subplugin extends backup_subplugin {
29
 
30
    /**
31
     * Returns the assessment form definition to attach to 'workshop' XML element
32
     */
33
    protected function define_workshop_subplugin_structure() {
34
 
35
        // XML nodes declaration
36
        $subplugin = $this->get_subplugin_element(); // virtual optigroup element
37
        $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
38
        $subpluginconfig = new backup_nested_element('workshopform_rubric_config', null, 'layout');
39
        $subplugindimension = new backup_nested_element('workshopform_rubric_dimension', array('id'), array(
40
            'sort', 'description', 'descriptionformat'));
41
        $subpluginlevel = new backup_nested_element('workshopform_rubric_level', array('id'), array(
42
            'grade', 'definition', 'definitionformat'));
43
 
44
        // connect XML elements into the tree
45
        $subplugin->add_child($subpluginwrapper);
46
        $subpluginwrapper->add_child($subpluginconfig);
47
        $subpluginwrapper->add_child($subplugindimension);
48
        $subplugindimension->add_child($subpluginlevel);
49
 
50
        // set source to populate the data
51
        $subpluginconfig->set_source_table('workshopform_rubric_config', array('workshopid' => backup::VAR_ACTIVITYID));
52
        $subplugindimension->set_source_table('workshopform_rubric', array('workshopid' => backup::VAR_ACTIVITYID));
53
        $subpluginlevel->set_source_table('workshopform_rubric_levels', array('dimensionid' => backup::VAR_PARENTID));
54
 
55
        // file annotations
56
        $subplugindimension->annotate_files('workshopform_rubric', 'description', 'id');
57
 
58
        return $subplugin;
59
    }
60
 
61
    /**
62
     * Returns the dimension grades to attach to 'referenceassessment' XML element
63
     */
64
    protected function define_referenceassessment_subplugin_structure() {
65
        return $this->dimension_grades_structure('workshopform_rubric_referencegrade');
66
    }
67
 
68
    /**
69
     * Returns the dimension grades to attach to 'exampleassessment' XML element
70
     */
71
    protected function define_exampleassessment_subplugin_structure() {
72
        return $this->dimension_grades_structure('workshopform_rubric_examplegrade');
73
    }
74
 
75
    /**
76
     * Returns the dimension grades to attach to 'assessment' XML element
77
     */
78
    protected function define_assessment_subplugin_structure() {
79
        return $this->dimension_grades_structure('workshopform_rubric_grade');
80
    }
81
 
82
    ////////////////////////////////////////////////////////////////////////////
83
    // internal private methods
84
    ////////////////////////////////////////////////////////////////////////////
85
 
86
    /**
87
     * Returns the structure of dimension grades
88
     *
89
     * @param string first parameter of {@link backup_nested_element} constructor
90
     */
91
    private function dimension_grades_structure($elementname) {
92
 
93
        // create XML elements
94
        $subplugin = $this->get_subplugin_element(); // virtual optigroup element
95
        $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
96
        $subplugingrade = new backup_nested_element($elementname, array('id'), array(
97
            'dimensionid', 'grade'));
98
 
99
        // connect XML elements into the tree
100
        $subplugin->add_child($subpluginwrapper);
101
        $subpluginwrapper->add_child($subplugingrade);
102
 
103
        // set source to populate the data
104
        $subplugingrade->set_source_sql(
105
            "SELECT id, dimensionid, grade
106
               FROM {workshop_grades}
107
              WHERE strategy = 'rubric' AND assessmentid = ?",
108
              array(backup::VAR_PARENTID));
109
 
110
        return $subplugin;
111
    }
112
}