Permalink
Browse files

Merge remote-tracking branch 'moodle/master' into MDL-20636_master_ne…

…w_question_engine

Conflicts:
	lib/db/upgrade.php
	mod/quiz/lib.php
  • Loading branch information...
2 parents 4c57433 + a56c68e commit 54771d89d1571ae8521a3565f87c5ed1623565b0 @timhunt timhunt committed Jun 6, 2011
Showing with 4,633 additions and 1,415 deletions.
  1. +1 −0 admin/roles/lib.php
  2. +34 −0 backup/moodle2/backup_coursereport_plugin.class.php
  3. +1 −0 backup/moodle2/backup_plan_builder.class.php
  4. +4 −0 backup/moodle2/backup_stepslib.php
  5. +29 −0 backup/moodle2/restore_coursereport_plugin.class.php
  6. +2 −0 backup/moodle2/restore_plan_builder.class.php
  7. +17 −0 backup/moodle2/restore_plugin.class.php
  8. +3 −0 backup/moodle2/restore_stepslib.php
  9. +37 −0 backup/util/plan/restore_structure_step.class.php
  10. +7 −0 backup/util/plan/restore_task.class.php
  11. +9 −6 backup/util/xml/parser/processors/grouped_parser_processor.class.php
  12. +66 −3 backup/util/xml/parser/processors/simplified_parser_processor.class.php
  13. +24 −0 backup/util/xml/parser/simpletest/fixtures/test5.xml
  14. +211 −0 backup/util/xml/parser/simpletest/testparser.php
  15. +88 −4 blocks/dock.js
  16. +1 −0 blocks/navigation/renderer.php
  17. +108 −8 blocks/navigation/yui/navigation/navigation.js
  18. +1 −1 calendar/export_execute.php
  19. +6 −8 comment/lib.php
  20. +2 −2 course/moodleform_mod.php
  21. +1 −0 lang/en/error.php
  22. +6 −4 lib/db/install.xml
  23. +2 −2 lib/enrollib.php
  24. +2 −0 lib/modinfolib.php
  25. +110 −28 lib/navigationlib.php
  26. +44 −137 lib/outputrenderers.php
  27. +5 −4 lib/pluginlib.php
  28. +1 −1 lib/rsslib.php
  29. +22 −0 lib/simpletest/testnavigationlib.php
  30. +1 −1 lib/statslib.php
  31. +9 −1 lib/xhprof/xhprof_moodle.php
  32. +11 −9 message/lib.php
  33. +2 −1 mod/assignment/lang/en/assignment.php
  34. +149 −142 mod/assignment/lib.php
  35. +4 −1 mod/assignment/styles.css
  36. +2 −1 mod/chat/lib.php
  37. +1 −1 mod/choice/backup/moodle2/backup_choice_stepslib.php
  38. +2 −0 mod/choice/lib.php
  39. +1 −1 mod/choice/renderer.php
  40. +5 −3 mod/data/backup/moodle2/backup_data_stepslib.php
  41. +8 −0 mod/data/backup/moodle2/restore_data_stepslib.php
  42. +23 −0 mod/data/db/upgrade.php
  43. +114 −53 mod/data/lib.php
  44. +2 −2 mod/data/version.php
  45. +3 −2 mod/data/view.php
  46. +3 −0 mod/feedback/db/messages.php
  47. +1 −0 mod/feedback/lib.php
  48. +2 −2 mod/feedback/show_nonrespondents.php
  49. +1 −1 mod/feedback/version.php
  50. +2 −0 mod/folder/lib.php
  51. +5 −3 mod/forum/backup/moodle2/backup_forum_stepslib.php
  52. +8 −0 mod/forum/backup/moodle2/restore_forum_stepslib.php
  53. +22 −0 mod/forum/db/upgrade.php
  54. +164 −134 mod/forum/lib.php
  55. +30 −39 mod/forum/user.php
  56. +3 −5 mod/forum/version.php
  57. +0 −4 mod/forum/view.php
  58. +5 −3 mod/glossary/backup/moodle2/backup_glossary_stepslib.php
  59. +9 −0 mod/glossary/backup/moodle2/restore_glossary_stepslib.php
  60. +23 −0 mod/glossary/db/upgrade.php
  61. +3 −1 mod/glossary/deleteentry.php
  62. +119 −54 mod/glossary/lib.php
  63. +2 −2 mod/glossary/version.php
  64. +3 −3 mod/glossary/view.php
  65. +2 −0 mod/imscp/lib.php
  66. +2 −0 mod/label/lib.php
  67. +37 −32 mod/lesson/essay.php
  68. +11 −4 mod/lesson/lib.php
  69. +2 −0 mod/page/lib.php
  70. +10 −1 mod/quiz/lib.php
  71. +2 −0 mod/resource/lib.php
  72. +10 −1 mod/scorm/lib.php
  73. +2 −1 mod/survey/lib.php
  74. +2 −0 mod/url/lib.php
  75. +2 −0 mod/wiki/lib.php
  76. +2 −0 mod/workshop/lib.php
  77. +36 −31 rating/index.php
  78. +696 −301 rating/lib.php
  79. +27 −24 rating/rate.php
  80. +45 −48 rating/rate_ajax.php
  81. +3 −3 repository/webdav/lib.php
  82. +133 −0 theme/afterburner/config.php
  83. +55 −0 theme/afterburner/lang/en/theme_afterburner.php
  84. +128 −0 theme/afterburner/layout/default.php
  85. +23 −0 theme/afterburner/layout/embedded.php
  86. BIN theme/afterburner/pix/core/bg.png
  87. BIN theme/afterburner/pix/core/bground.jpg
  88. BIN theme/afterburner/pix/core/h2grad.jpg
  89. BIN theme/afterburner/pix/favicon.ico
  90. BIN theme/afterburner/pix/footer/moodle-logo.png
  91. BIN theme/afterburner/pix/forum/gradient.png
  92. BIN theme/afterburner/pix/images/light3.png
  93. BIN theme/afterburner/pix/menu/ab-arrowover.png
  94. BIN theme/afterburner/pix/menu/nav-arrow-right.png
  95. BIN theme/afterburner/pix/screenshot.jpg
  96. BIN theme/afterburner/pix/sideblocks/sidegrad.jpg
  97. BIN theme/afterburner/pix/tab/left.gif
  98. BIN theme/afterburner/pix/tab/left_active.gif
  99. BIN theme/afterburner/pix/tab/left_active_hover.gif
  100. BIN theme/afterburner/pix/tab/left_hover.gif
  101. BIN theme/afterburner/pix/tab/right.gif
  102. BIN theme/afterburner/pix/tab/right_active.gif
  103. BIN theme/afterburner/pix/tab/right_active_hover.gif
  104. BIN theme/afterburner/pix/tab/right_end.gif
  105. BIN theme/afterburner/pix/tab/right_hover.gif
  106. BIN theme/afterburner/pix/tab/right_last.gif
  107. BIN theme/afterburner/pix/tab/rtlbg.gif
  108. BIN theme/afterburner/pix/tab/tabrow1.gif
  109. BIN theme/afterburner/pix_core/a/em1_bwgreater.gif
  110. BIN theme/afterburner/pix_core/a/em1_greater.gif
  111. BIN theme/afterburner/pix_core/a/em1_lesser.gif
  112. BIN theme/afterburner/pix_core/a/em1_raquo.gif
  113. BIN theme/afterburner/pix_core/a/help.png
  114. BIN theme/afterburner/pix_core/a/l_breadcrumb.gif
  115. BIN theme/afterburner/pix_core/a/logout.png
  116. BIN theme/afterburner/pix_core/a/r_breadcrumb.gif
  117. BIN theme/afterburner/pix_core/a/r_go.gif
  118. BIN theme/afterburner/pix_core/a/r_next.gif
  119. BIN theme/afterburner/pix_core/a/r_previous.gif
  120. BIN theme/afterburner/pix_core/a/refresh.png
  121. BIN theme/afterburner/pix_core/a/search.png
  122. BIN theme/afterburner/pix_core/a/setting.png
  123. BIN theme/afterburner/pix_core/c/course.png
  124. BIN theme/afterburner/pix_core/c/event.png
  125. BIN theme/afterburner/pix_core/c/groups.png
  126. BIN theme/afterburner/pix_core/c/site.png
  127. BIN theme/afterburner/pix_core/c/user.png
  128. BIN theme/afterburner/pix_core/docs.png
  129. BIN theme/afterburner/pix_core/f/access.png
  130. BIN theme/afterburner/pix_core/f/avi.png
  131. BIN theme/afterburner/pix_core/f/excel.png
  132. BIN theme/afterburner/pix_core/f/flash.png
  133. BIN theme/afterburner/pix_core/f/folder-32.png
  134. BIN theme/afterburner/pix_core/f/folder.png
  135. BIN theme/afterburner/pix_core/f/help.png
  136. BIN theme/afterburner/pix_core/f/html.png
  137. BIN theme/afterburner/pix_core/f/image-32.png
  138. BIN theme/afterburner/pix_core/f/image.png
  139. BIN theme/afterburner/pix_core/f/odb.png
  140. BIN theme/afterburner/pix_core/f/odf.png
  141. BIN theme/afterburner/pix_core/f/odg.png
  142. BIN theme/afterburner/pix_core/f/odm.png
  143. BIN theme/afterburner/pix_core/f/odp.png
  144. BIN theme/afterburner/pix_core/f/ods.png
  145. BIN theme/afterburner/pix_core/f/odt.png
  146. BIN theme/afterburner/pix_core/f/pdf.png
  147. BIN theme/afterburner/pix_core/f/powerpoint.png
  148. BIN theme/afterburner/pix_core/f/text-32.png
  149. BIN theme/afterburner/pix_core/f/text.png
  150. BIN theme/afterburner/pix_core/f/unknown-32.png
  151. BIN theme/afterburner/pix_core/f/unknown.png
  152. BIN theme/afterburner/pix_core/f/video.png
  153. BIN theme/afterburner/pix_core/f/web.png
  154. BIN theme/afterburner/pix_core/f/word.png
  155. BIN theme/afterburner/pix_core/f/xml.png
  156. BIN theme/afterburner/pix_core/f/zip.png
  157. BIN theme/afterburner/pix_core/g/f1.png
  158. BIN theme/afterburner/pix_core/g/f2.png
  159. BIN theme/afterburner/pix_core/g/user100.png
  160. BIN theme/afterburner/pix_core/g/user35.png
  161. BIN theme/afterburner/pix_core/help.png
  162. BIN theme/afterburner/pix_core/i/all.png
  163. BIN theme/afterburner/pix_core/i/backup.png
  164. BIN theme/afterburner/pix_core/i/calc.png
  165. BIN theme/afterburner/pix_core/i/checkpermissions.png
  166. BIN theme/afterburner/pix_core/i/course.png
  167. BIN theme/afterburner/pix_core/i/db.png
  168. BIN theme/afterburner/pix_core/i/edit.gif
  169. BIN theme/afterburner/pix_core/i/email.png
  170. BIN theme/afterburner/pix_core/i/feedback.png
  171. BIN theme/afterburner/pix_core/i/feedback_add.png
  172. BIN theme/afterburner/pix_core/i/files.png
  173. BIN theme/afterburner/pix_core/i/filter.png
  174. BIN theme/afterburner/pix_core/i/flagged.png
  175. BIN theme/afterburner/pix_core/i/grades.png
  176. BIN theme/afterburner/pix_core/i/group.png
  177. BIN theme/afterburner/pix_core/i/hide.png
  178. BIN theme/afterburner/pix_core/i/info.png
  179. BIN theme/afterburner/pix_core/i/lock.png
  180. BIN theme/afterburner/pix_core/i/marker.png
  181. BIN theme/afterburner/pix_core/i/menu.png
  182. BIN theme/afterburner/pix_core/i/new.png
  183. BIN theme/afterburner/pix_core/i/news.png
  184. BIN theme/afterburner/pix_core/i/one.png
  185. BIN theme/afterburner/pix_core/i/payment.png
  186. BIN theme/afterburner/pix_core/i/permissions.png
  187. BIN theme/afterburner/pix_core/i/publish.png
  188. BIN theme/afterburner/pix_core/i/questions.png
  189. BIN theme/afterburner/pix_core/i/report.png
  190. BIN theme/afterburner/pix_core/i/restore.png
  191. BIN theme/afterburner/pix_core/i/return.png
  192. BIN theme/afterburner/pix_core/i/roles.png
  193. BIN theme/afterburner/pix_core/i/scales.png
  194. BIN theme/afterburner/pix_core/i/settings.png
  195. BIN theme/afterburner/pix_core/i/show.png
  196. BIN theme/afterburner/pix_core/i/unflagged.png
  197. BIN theme/afterburner/pix_core/i/user.png
  198. BIN theme/afterburner/pix_core/i/users.png
  199. BIN theme/afterburner/pix_core/icon.png
  200. BIN theme/afterburner/pix_core/m/USD.gif
  201. +1 −0 theme/afterburner/pix_core/s/SMILEYS
  202. BIN theme/afterburner/pix_core/s/angry.png
  203. BIN theme/afterburner/pix_core/s/approve.png
  204. BIN theme/afterburner/pix_core/s/biggrin.png
  205. BIN theme/afterburner/pix_core/s/blackeye.gif
  206. BIN theme/afterburner/pix_core/s/blush.png
  207. BIN theme/afterburner/pix_core/s/clown.gif
  208. BIN theme/afterburner/pix_core/s/cool.png
  209. BIN theme/afterburner/pix_core/s/dead.png
  210. BIN theme/afterburner/pix_core/s/egg.gif
  211. BIN theme/afterburner/pix_core/s/evil.png
  212. BIN theme/afterburner/pix_core/s/heart.png
  213. BIN theme/afterburner/pix_core/s/kiss.png
  214. BIN theme/afterburner/pix_core/s/martin.gif
  215. BIN theme/afterburner/pix_core/s/mixed.png
  216. BIN theme/afterburner/pix_core/s/no.gif
  217. BIN theme/afterburner/pix_core/s/sad.png
  218. BIN theme/afterburner/pix_core/s/shy.png
  219. BIN theme/afterburner/pix_core/s/sleepy.png
  220. BIN theme/afterburner/pix_core/s/smiley.png
  221. BIN theme/afterburner/pix_core/s/surprise.png
  222. BIN theme/afterburner/pix_core/s/thoughtful.png
  223. BIN theme/afterburner/pix_core/s/tongueout.png
  224. BIN theme/afterburner/pix_core/s/wideeyes.png
  225. BIN theme/afterburner/pix_core/s/wink.png
  226. BIN theme/afterburner/pix_core/s/yes.png
  227. BIN theme/afterburner/pix_core/t/adddir.png
  228. BIN theme/afterburner/pix_core/t/addfile.png
  229. BIN theme/afterburner/pix_core/t/addgreen.png
  230. BIN theme/afterburner/pix_core/t/backup.png
  231. BIN theme/afterburner/pix_core/t/block.png
  232. BIN theme/afterburner/pix_core/t/calendar.png
  233. BIN theme/afterburner/pix_core/t/clear.png
  234. BIN theme/afterburner/pix_core/t/copy.png
  235. BIN theme/afterburner/pix_core/t/delete.png
  236. BIN theme/afterburner/pix_core/t/down.png
  237. BIN theme/afterburner/pix_core/t/download.png
  238. BIN theme/afterburner/pix_core/t/edit.png
  239. BIN theme/afterburner/pix_core/t/email.png
  240. BIN theme/afterburner/pix_core/t/emailno.png
  241. BIN theme/afterburner/pix_core/t/feedback.png
  242. BIN theme/afterburner/pix_core/t/feedback_add.png
  243. BIN theme/afterburner/pix_core/t/go.png
  244. BIN theme/afterburner/pix_core/t/groupn.png
  245. BIN theme/afterburner/pix_core/t/groups.png
  246. BIN theme/afterburner/pix_core/t/hide.png
  247. BIN theme/afterburner/pix_core/t/lock.png
  248. BIN theme/afterburner/pix_core/t/move.png
  249. BIN theme/afterburner/pix_core/t/preview.png
  250. BIN theme/afterburner/pix_core/t/restore.png
  251. BIN theme/afterburner/pix_core/t/show.png
  252. BIN theme/afterburner/pix_core/t/stop.png
  253. BIN theme/afterburner/pix_core/t/unlock.png
  254. BIN theme/afterburner/pix_core/t/up.png
  255. BIN theme/afterburner/pix_core/t/user.png
  256. BIN theme/afterburner/pix_core/t/userblue.png
  257. BIN theme/afterburner/pix_core/t/usernot.png
  258. BIN theme/afterburner/pix_core/u/f1.png
  259. BIN theme/afterburner/pix_core/u/f2.png
  260. BIN theme/afterburner/pix_plugins/enrol/self/withoutkey.png
  261. BIN theme/afterburner/pix_plugins/mod/assignment/icon.png
  262. BIN theme/afterburner/pix_plugins/mod/chat/icon.png
  263. BIN theme/afterburner/pix_plugins/mod/choice/icon.png
  264. BIN theme/afterburner/pix_plugins/mod/data/icon.png
  265. BIN theme/afterburner/pix_plugins/mod/folder/icon.png
  266. BIN theme/afterburner/pix_plugins/mod/forum/icon.png
  267. BIN theme/afterburner/pix_plugins/mod/glossary/icon.png
  268. BIN theme/afterburner/pix_plugins/mod/imscp/icon.png
  269. BIN theme/afterburner/pix_plugins/mod/label/icon.png
  270. BIN theme/afterburner/pix_plugins/mod/lesson/icon.png
  271. BIN theme/afterburner/pix_plugins/mod/page/icon.png
  272. BIN theme/afterburner/pix_plugins/mod/quiz/icon.png
  273. BIN theme/afterburner/pix_plugins/mod/resource/icon.png
  274. BIN theme/afterburner/pix_plugins/mod/scorm/icon.png
  275. BIN theme/afterburner/pix_plugins/mod/survey/icon.png
  276. BIN theme/afterburner/pix_plugins/mod/url/icon.png
  277. BIN theme/afterburner/pix_plugins/mod/wiki/icon.png
  278. BIN theme/afterburner/pix_plugins/mod/workshop/icon.png
  279. +139 −0 theme/afterburner/renderers.php
  280. +155 −0 theme/afterburner/style/afterburner_blocks.css
  281. +167 −0 theme/afterburner/style/afterburner_calendar.css
  282. +125 −0 theme/afterburner/style/afterburner_dock.css
  283. +148 −0 theme/afterburner/style/afterburner_layout.css
  284. +193 −0 theme/afterburner/style/afterburner_menu.css
  285. +86 −0 theme/afterburner/style/afterburner_mod.css
  286. +436 −0 theme/afterburner/style/afterburner_styles.css
  287. +7 −0 theme/afterburner/style/rtl.css
  288. +5 −0 theme/base/style/core.css
  289. +300 −232 theme/canvas/style/core.css
  290. +55 −60 theme/canvas/style/text.css
View
@@ -1316,6 +1316,7 @@ public function load_current_settings() {
foreach ($rs as $allow) {
$this->allowed[$allow->roleid][$allow->{$this->targetcolname}] = true;
}
+ $rs->close();
}
/**
@@ -0,0 +1,34 @@
+<?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();
+
+/**
+ * Base class for course report backup plugins.
+ *
+ * NOTE: When you back up a course, it potentially may run backup for all
+ * course reports. In order to control whether a particular report gets
+ * backed up, a course report should make use of the second and third
+ * parameters in get_plugin_element().
+ *
+ * @package moodlecore
+ * @subpackage backup-moodle2
+ * @copyright 2011 onwards The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class backup_coursereport_plugin extends backup_plugin {
+ // Use default parent behaviour
+}
@@ -36,6 +36,7 @@
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_subplugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_settingslib.php');
@@ -417,6 +417,10 @@ protected function define_structure() {
// save course data (in case of user theme, legacy theme, etc)
$this->add_plugin_structure('theme', $course, true);
+ // attach course report plugin structure to $course element; multiple
+ // course reports can save course data if required
+ $this->add_plugin_structure('coursereport', $course, true);
+
// attach plagiarism plugin structure to $course element, only one allowed
$this->add_plugin_structure('plagiarism', $course, false);
@@ -0,0 +1,29 @@
+<?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();
+
+/**
+ * Restore for course plugin: course report.
+ *
+ * @package moodlecore
+ * @subpackage backup-moodle2
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class restore_coursereport_plugin extends restore_plugin {
+ // Use default parent behaviour
+}
@@ -35,11 +35,13 @@
require_once($CFG->dirroot . '/backup/moodle2/restore_qtype_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_format_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/restore_coursereport_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_subplugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_settingslib.php');
@@ -80,6 +80,23 @@ public function launch_after_execute_methods() {
}
}
+ /**
+ * after_restore dispatcher for any restore_plugin class
+ *
+ * This method will dispatch execution to the corresponding
+ * after_restore_xxx() method when available, with xxx
+ * being the connection point of the instance, so plugin
+ * classes with multiple connection points will support
+ * multiple after_restore methods, one for each connection point
+ */
+ public function launch_after_restore_methods() {
+ // Check if the after_restore method exists and launch it
+ $afterrestore = 'after_restore_' . basename($this->connectionpoint->get_path());
+ if (method_exists($this, $afterrestore)) {
+ $this->$afterrestore();
+ }
+ }
+
/**
* Returns one array with all the decode contents
* to be processed by the links decoder
@@ -1010,6 +1010,9 @@ protected function define_structure() {
// Apply for 'theme' plugins optional paths at course level
$this->add_plugin_structure('theme', $course);
+ // Apply for 'course report' plugins optional paths at course level
+ $this->add_plugin_structure('coursereport', $course);
+
// Apply for plagiarism plugins optional paths at course level
$this->add_plugin_structure('plagiarism', $course);
@@ -360,6 +360,43 @@ protected function launch_after_execute_methods() {
}
+ /**
+ * Launch all the after_restore methods present in all the processing objects
+ *
+ * This method will launch all the after_restore methods that can be defined
+ * both in restore_plugin class
+ *
+ * For restore_plugin classes the name of the method to be executed will be
+ * "after_restore_" + connection point (as far as can be multiple connection
+ * points in the same class)
+ */
+ public function launch_after_restore_methods() {
+ $alreadylaunched = array(); // To avoid multiple executions
+ foreach ($this->pathelements as $pathelement) {
+ // Get the processing object
+ $pobject = $pathelement->get_processing_object();
+ // Skip null processors (child of grouped ones for sure)
+ if (is_null($pobject)) {
+ continue;
+ }
+ // Skip restore structure step processors (this)
+ if ($pobject instanceof restore_structure_step) {
+ continue;
+ }
+ // Skip already launched processing objects
+ if (in_array($pobject, $alreadylaunched, true)) {
+ continue;
+ }
+ // Add processing object to array of launched ones
+ $alreadylaunched[] = $pobject;
+ // If the processing object has support for
+ // launching after_restore methods, use it
+ if (method_exists($pobject, 'launch_after_restore_methods')) {
+ $pobject->launch_after_restore_methods();
+ }
+ }
+ }
+
/**
* This method will be executed after the whole structure step have been processed
*
@@ -100,6 +100,13 @@ public function get_old_system_contextid() {
* method if available
*/
public function execute_after_restore() {
+ if ($this->executed) {
+ foreach ($this->steps as $step) {
+ if (method_exists($step, 'launch_after_restore_methods')) {
+ $step->launch_after_restore_methods();
+ }
+ }
+ }
if ($this->executed && method_exists($this, 'after_restore')) {
$this->after_restore();
}
@@ -71,20 +71,23 @@ public function add_path($path, $grouped = false) {
}
/**
- * Notify start of path if selected and not under grouped
+ * The parser fires this each time one path is going to be parsed
+ *
+ * @param string $path xml path which parsing has started
*/
public function before_path($path) {
- if ($this->path_is_selected($path) && !$this->grouped_parent_exists($path)) {
+ if (!$this->grouped_parent_exists($path)) {
parent::before_path($path);
}
}
-
/**
- * Dispatch grouped chunks safely once their end tag happens.
- * Also notify end of path if selected and not under grouped
+ * The parser fires this each time one path has been parsed
+ *
+ * @param string $path xml path which parsing has ended
*/
public function after_path($path) {
+ // Have finished one grouped path, dispatch it
if ($this->path_is_grouped($path)) {
// Any accumulated information must be in
// currentdata, properly built
@@ -95,7 +98,7 @@ public function after_path($path) {
}
// Normal notification of path end
// Only if path is selected and not child of grouped
- if ($this->path_is_selected($path) && !$this->grouped_parent_exists($path)) {
+ if (!$this->grouped_parent_exists($path)) {
parent::after_path($path);
}
}
@@ -41,12 +41,14 @@
protected $paths; // array of paths we are interested on
protected $parentpaths; // array of parent paths of the $paths
protected $parentsinfo; // array of parent attributes to be added as child tags
+ protected $startendinfo;// array (stack) of startend information
- public function __construct(array $paths) {
+ public function __construct(array $paths = array()) {
parent::__construct();
$this->paths = array();
$this->parentpaths = array();
$this->parentsinfo = array();
+ $this->startendinfo = array();
// Add paths and parentpaths. We are looking for attributes there
foreach ($paths as $key => $path) {
$this->add_path($path);
@@ -95,6 +97,10 @@ public function process_chunk($data) {
// If the path is a registered one, let's process it
if ($this->path_is_selected($path)) {
+
+ // Send all the pending notify_path_start/end() notifications
+ $this->process_pending_startend_notifications($path, 'start');
+
// First of all, look for attributes available at parentsinfo
// in order to get them available as normal tags
if (isset($this->parentsinfo[$parentpath][$tag]['attrs'])) {
@@ -146,29 +152,86 @@ public function process_chunk($data) {
} else {
$this->chunks--; // Chunk skipped
}
+
return true;
}
/**
* The parser fires this each time one path is going to be parsed
+ *
+ * @param string $path xml path which parsing has started
*/
public function before_path($path) {
if ($this->path_is_selected($path)) {
- $this->notify_path_start($path);
+ $this->startendinfo[] = array('path' => $path, 'action' => 'start');
}
}
/**
* The parser fires this each time one path has been parsed
+ *
+ * @param string $path xml path which parsing has ended
*/
public function after_path($path) {
+ $toprocess = false;
+ // If the path being closed matches (same or parent) the first path in the stack
+ // we process pending startend notifications until one matching end is found
+ if ($element = reset($this->startendinfo)) {
+ $elepath = $element['path'];
+ $eleaction = $element['action'];
+ if (strpos($elepath, $path) === 0) {
+ $toprocess = true;
+ }
+
+ // Also, if the stack of startend notifications is empty, we can process current end
+ // path safely
+ } else {
+ $toprocess = true;
+ }
if ($this->path_is_selected($path)) {
- $this->notify_path_end($path);
+ $this->startendinfo[] = array('path' => $path, 'action' => 'end');
+ }
+ // Send all the pending startend notifications if decided to do so
+ if ($toprocess) {
+ $this->process_pending_startend_notifications($path, 'end');
}
}
+
// Protected API starts here
+ /**
+ * Adjust start/end til finding one match start/end path (included)
+ *
+ * This will trigger all the pending {@see notify_path_start} and
+ * {@see notify_path_end} calls for one given path and action
+ *
+ * @param string path the path to look for as limit
+ * @param string action the action to look for as limit
+ */
+ protected function process_pending_startend_notifications($path, $action) {
+
+ // Iterate until one matching path and action is found (or the array is empty)
+ $elecount = count($this->startendinfo);
+ $elematch = false;
+ while ($elecount > 0 && !$elematch) {
+ $element = array_shift($this->startendinfo);
+ $elecount--;
+ $elepath = $element['path'];
+ $eleaction = $element['action'];
+
+ if ($elepath == $path && $eleaction == $action) {
+ $elematch = true;
+ }
+
+ if ($eleaction == 'start') {
+ $this->notify_path_start($elepath);
+ } else {
+ $this->notify_path_end($elepath);
+ }
+ }
+ }
+
protected function postprocess_chunk($data) {
$this->dispatch_chunk($data);
}
@@ -0,0 +1,24 @@
+<MOODLE_BACKUP>
+ <COURSE ID="100">
+ <SECTIONS>
+ <SECTION>
+ <ID>200</ID>
+ <MODS>
+ <MOD>
+ <ID>300</ID>
+ <ROLES_OVERRIDES>
+ </ROLES_OVERRIDES>
+ </MOD>
+ <MOD />
+ <MOD />
+ <MOD ID="400" />
+ <MOD>
+ <ID>500</ID>
+ </MOD>
+ <MOD />
+ <MOD />
+ </MODS>
+ </SECTION>
+ </SECTIONS>
+ </COURSE>
+</MOODLE_BACKUP>
Oops, something went wrong.

0 comments on commit 54771d8

Please sign in to comment.