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_numerrors
|
|
|
20 |
* @copyright 2010 onwards David Mudrak <david@moodle.com>
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
defined('MOODLE_INTERNAL') || die();
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Provides the information to backup numerrors grading strategy information
|
|
|
28 |
*/
|
|
|
29 |
class backup_workshopform_numerrors_subplugin extends backup_subplugin {
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Returns the assessment form definition to attach to 'workshop' XML element
|
|
|
33 |
*/
|
|
|
34 |
protected function define_workshop_subplugin_structure() {
|
|
|
35 |
|
|
|
36 |
// XML nodes declaration
|
|
|
37 |
$subplugin = $this->get_subplugin_element(); // virtual optigroup element
|
|
|
38 |
$subpluginwrapper = new backup_nested_element($this->get_recommended_name());
|
|
|
39 |
$subpluginmap = new backup_nested_element('workshopform_numerrors_map', array('id'), array(
|
|
|
40 |
'nonegative', 'grade'));
|
|
|
41 |
$subplugindimension = new backup_nested_element('workshopform_numerrors_dimension', array('id'), array(
|
|
|
42 |
'sort', 'description', 'descriptionformat', 'grade0', 'grade1', 'weight'));
|
|
|
43 |
|
|
|
44 |
// connect XML elements into the tree
|
|
|
45 |
$subplugin->add_child($subpluginwrapper);
|
|
|
46 |
$subpluginwrapper->add_child($subpluginmap);
|
|
|
47 |
$subpluginwrapper->add_child($subplugindimension);
|
|
|
48 |
|
|
|
49 |
// set source to populate the data
|
|
|
50 |
$subpluginmap->set_source_table('workshopform_numerrors_map', array('workshopid' => backup::VAR_ACTIVITYID));
|
|
|
51 |
$subplugindimension->set_source_table('workshopform_numerrors', array('workshopid' => backup::VAR_ACTIVITYID));
|
|
|
52 |
|
|
|
53 |
// file annotations
|
|
|
54 |
$subplugindimension->annotate_files('workshopform_numerrors', 'description', 'id');
|
|
|
55 |
|
|
|
56 |
return $subplugin;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Returns the dimension grades to attach to 'referenceassessment' XML element
|
|
|
61 |
*/
|
|
|
62 |
protected function define_referenceassessment_subplugin_structure() {
|
|
|
63 |
return $this->dimension_grades_structure('workshopform_numerrors_referencegrade');
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* Returns the dimension grades to attach to 'exampleassessment' XML element
|
|
|
68 |
*/
|
|
|
69 |
protected function define_exampleassessment_subplugin_structure() {
|
|
|
70 |
return $this->dimension_grades_structure('workshopform_numerrors_examplegrade');
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
/**
|
|
|
74 |
* Returns the dimension grades to attach to 'assessment' XML element
|
|
|
75 |
*/
|
|
|
76 |
protected function define_assessment_subplugin_structure() {
|
|
|
77 |
return $this->dimension_grades_structure('workshopform_numerrors_grade');
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
////////////////////////////////////////////////////////////////////////////
|
|
|
81 |
// internal private methods
|
|
|
82 |
////////////////////////////////////////////////////////////////////////////
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Returns the structure of dimension grades
|
|
|
86 |
*
|
|
|
87 |
* @param string forst parameter of {@link backup_nested_element} constructor
|
|
|
88 |
*/
|
|
|
89 |
private function dimension_grades_structure($elementname) {
|
|
|
90 |
|
|
|
91 |
// create XML elements
|
|
|
92 |
$subplugin = $this->get_subplugin_element(); // virtual optigroup element
|
|
|
93 |
$subpluginwrapper = new backup_nested_element($this->get_recommended_name());
|
|
|
94 |
$subplugingrade = new backup_nested_element($elementname, array('id'), array(
|
|
|
95 |
'dimensionid', 'grade', 'peercomment', 'peercommentformat'));
|
|
|
96 |
|
|
|
97 |
// connect XML elements into the tree
|
|
|
98 |
$subplugin->add_child($subpluginwrapper);
|
|
|
99 |
$subpluginwrapper->add_child($subplugingrade);
|
|
|
100 |
|
|
|
101 |
// set source to populate the data
|
|
|
102 |
$subplugingrade->set_source_sql(
|
|
|
103 |
"SELECT id, dimensionid, grade, peercomment, peercommentformat
|
|
|
104 |
FROM {workshop_grades}
|
|
|
105 |
WHERE strategy = 'numerrors' AND assessmentid = ?",
|
|
|
106 |
array(backup::VAR_PARENTID));
|
|
|
107 |
|
|
|
108 |
return $subplugin;
|
|
|
109 |
}
|
|
|
110 |
}
|