Permalink
Browse files

Merge branch 'MOODLE_27_STABLE' into install_27_STABLE

  • Loading branch information...
2 parents 6e7a7ae + c41ace2 commit 807d45073abcb32bf95793c83447fd627652c122 AMOS bot committed Jun 13, 2014
Showing with 1,541 additions and 189 deletions.
  1. +1 −1 admin/renderer.php
  2. +6 −8 backup/moodle2/backup_stepslib.php
  3. +86 −50 backup/moodle2/restore_stepslib.php
  4. +21 −1 backup/util/dbops/backup_structure_dbops.class.php
  5. +1 −1 backup/util/structure/backup_structure_processor.class.php
  6. +190 −0 blocks/navigation/tests/behat/expand_courses_node.feature
  7. +0 −2 blocks/navigation/tests/behat/view_my_courses.feature
  8. +1 −1 composer.json
  9. +2 −2 enrol/self/tests/behat/self_enrolment.feature
  10. +2 −2 grade/grading/tests/behat/behat_grading.php
  11. +20 −3 group/group_form.php
  12. +39 −0 group/tests/behat/create_groups.feature
  13. +51 −0 group/tests/behat/update_groups.feature
  14. +1 −0 lang/en/cache.php
  15. +1 −1 lang/en/error.php
  16. +1 −0 lang/en/group.php
  17. +26 −0 lib/behat/form_field/behat_form_editor.php
  18. +0 −1 lib/behat/form_field/behat_form_field.php
  19. +1 −1 lib/classes/task/scheduled_task.php
  20. +6 −1 lib/classes/useragent.php
  21. +10 −0 lib/db/caches.php
  22. +7 −0 lib/db/upgrade.php
  23. +20 −0 lib/db/upgradelib.php
  24. +21 −0 lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature
  25. +33 −0 lib/editor/atto/plugins/accessibilityhelper/tests/behat/accessibilityhelper.feature
  26. +44 −0 lib/editor/atto/plugins/align/tests/behat/align.feature
  27. +29 −0 lib/editor/atto/plugins/bold/tests/behat/bold.feature
  28. +18 −0 lib/editor/atto/plugins/charmap/tests/behat/charmap.feature
  29. +3 −0 ...tor/atto/plugins/charmap/yui/build/moodle-atto_charmap-button/moodle-atto_charmap-button-debug.js
  30. +1 −1 ...ditor/atto/plugins/charmap/yui/build/moodle-atto_charmap-button/moodle-atto_charmap-button-min.js
  31. +3 −0 lib/editor/atto/plugins/charmap/yui/build/moodle-atto_charmap-button/moodle-atto_charmap-button.js
  32. +3 −0 lib/editor/atto/plugins/charmap/yui/src/button/js/button.js
  33. +17 −0 lib/editor/atto/plugins/clear/tests/behat/clear.feature
  34. +13 −0 lib/editor/atto/plugins/collapse/tests/behat/collapse.feature
  35. +21 −0 lib/editor/atto/plugins/equation/tests/behat/equation.feature
  36. +13 −0 lib/editor/atto/plugins/html/tests/behat/html.feature
  37. +28 −0 lib/editor/atto/plugins/image/tests/behat/image.feature
  38. +30 −0 lib/editor/atto/plugins/indent/tests/behat/indent.feature
  39. +29 −0 lib/editor/atto/plugins/italic/tests/behat/italic.feature
  40. +23 −0 lib/editor/atto/plugins/link/tests/behat/link.feature
  41. +2 −0 lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js
  42. +1 −1 lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js
  43. +2 −0 lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js
  44. +2 −0 lib/editor/atto/plugins/link/yui/src/button/js/button.js
  45. +27 −0 lib/editor/atto/plugins/media/tests/behat/media.feature
  46. +16 −0 lib/editor/atto/plugins/orderedlist/tests/behat/orderedlist.feature
  47. +17 −0 lib/editor/atto/plugins/strike/tests/behat/strike.feature
  48. +17 −0 lib/editor/atto/plugins/subscript/tests/behat/subscript.feature
  49. +17 −0 lib/editor/atto/plugins/superscript/tests/behat/superscript.feature
  50. +40 −0 lib/editor/atto/plugins/table/tests/behat/table.feature
  51. +2 −0 lib/editor/atto/plugins/table/yui/build/moodle-atto_table-button/moodle-atto_table-button-debug.js
  52. +3 −3 lib/editor/atto/plugins/table/yui/build/moodle-atto_table-button/moodle-atto_table-button-min.js
  53. +2 −0 lib/editor/atto/plugins/table/yui/build/moodle-atto_table-button/moodle-atto_table-button.js
  54. +2 −0 lib/editor/atto/plugins/table/yui/src/button/js/button.js
  55. +17 −0 lib/editor/atto/plugins/title/tests/behat/title.feature
  56. +17 −0 lib/editor/atto/plugins/underline/tests/behat/underline.feature
  57. +16 −0 lib/editor/atto/plugins/unorderedlist/tests/behat/unorderedlist.feature
  58. +62 −0 lib/editor/atto/tests/behat/behat_editor_atto.php
  59. BIN lib/editor/atto/tests/fixtures/moodle-logo.png
  60. BIN lib/editor/atto/tests/fixtures/moodle-logo.webm
  61. +1 −1 lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-debug.js
  62. +2 −2 lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-min.js
  63. +1 −1 lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin.js
  64. +1 −1 lib/editor/atto/yui/src/editor/js/editor-plugin-buttons.js
  65. +1 −2 lib/editor/tinymce/tests/behat/edit_available_icons.feature
  66. +2 −2 lib/filelib.php
  67. +8 −1 lib/filestorage/stored_file.php
  68. +4 −3 lib/filestorage/tests/file_storage_test.php
  69. +70 −1 lib/navigationlib.php
  70. +1 −1 lib/outputcomponents.php
  71. +0 −3 lib/questionlib.php
  72. +22 −0 lib/tests/scheduled_task_test.php
  73. +27 −0 lib/tests/theme_config_test.php
  74. +5 −1 mod/assign/feedback/comments/locallib.php
  75. +3 −1 mod/data/locallib.php
  76. +17 −9 mod/lti/return.php
  77. +9 −2 mod/quiz/editlib.php
  78. +13 −0 mod/quiz/lib.php
  79. +66 −1 mod/quiz/tests/editlib_test.php
  80. +42 −2 mod/quiz/tests/lib_test.php
  81. +2 −1 mod/scorm/locallib.php
  82. +10 −17 mod/scorm/module.js
  83. +2 −2 mod/wiki/classes/event/comments_viewed.php
  84. +1 −1 mod/workshop/classes/event/submission_reassessed.php
  85. BIN pix/f/publisher-128.png
  86. BIN pix/f/publisher-24.png
  87. BIN pix/f/publisher-256.png
  88. BIN pix/f/publisher-32.png
  89. BIN pix/f/publisher-48.png
  90. BIN pix/f/publisher-64.png
  91. BIN pix/f/publisher-72.png
  92. BIN pix/f/publisher-80.png
  93. BIN pix/f/publisher-96.png
  94. BIN pix/f/publisher.png
  95. +4 −1 question/type/questiontypebase.php
  96. +46 −0 question/type/random/backup/moodle2/restore_qtype_random_plugin.class.php
  97. +68 −0 question/type/random/db/upgrade.php
  98. +7 −1 question/type/random/questiontype.php
  99. +1 −1 question/type/random/version.php
  100. +1 −2 report/log/index.php
  101. +3 −2 theme/base/style/core.css
  102. +14 −44 theme/bootstrapbase/less/moodle/core.less
  103. +1 −1 theme/bootstrapbase/style/moodle.css
  104. +2 −2 version.php
View
@@ -1384,7 +1384,7 @@ public function environment_check_table($result, $environment_results) {
get_string('report'),
get_string('status'),
);
- $servertable->colclasses = array('centeralign name', 'centeralign status', 'leftalign report', 'centeralign info');
+ $servertable->colclasses = array('centeralign name', 'centeralign info', 'leftalign report', 'centeralign status');
$servertable->attributes['class'] = 'admintable environmenttable generaltable';
$servertable->id = 'serverstatus';
@@ -28,8 +28,7 @@
defined('MOODLE_INTERNAL') || die();
/**
- * create the temp dir where backup/restore will happen,
- * delete old directories and create temp ids table
+ * Create the temp dir where backup/restore will happen and create temp ids table.
*/
class create_and_clean_temp_stuff extends backup_execution_step {
@@ -38,19 +37,18 @@ protected function define_execution() {
$progress->start_progress('Deleting backup directories');
backup_helper::check_and_create_backup_dir($this->get_backupid());// Create backup temp dir
backup_helper::clear_backup_dir($this->get_backupid(), $progress); // Empty temp dir, just in case
- backup_helper::delete_old_backup_dirs(time() - (4 * 60 * 60), $progress); // Delete > 4 hours temp dirs
backup_controller_dbops::drop_backup_ids_temp_table($this->get_backupid()); // Drop ids temp table
backup_controller_dbops::create_backup_ids_temp_table($this->get_backupid()); // Create ids temp table
$progress->end_progress();
}
}
/**
- * delete the temp dir used by backup/restore (conditionally),
- * delete old directories and drop tem ids table. Note we delete
+ * Delete the temp dir used by backup/restore (conditionally),
+ * delete old directories and drop temp ids table. Note we delete
* the directory but not the corresponding log file that will be
- * there for, at least, 4 hours - only delete_old_backup_dirs()
- * deletes log files (for easier access to them)
+ * there for, at least, 1 week - only delete_old_backup_dirs() or cron
+ * deletes log files (for easier access to them).
*/
class drop_and_clean_temp_stuff extends backup_execution_step {
@@ -60,7 +58,7 @@ protected function define_execution() {
global $CFG;
backup_controller_dbops::drop_backup_ids_temp_table($this->get_backupid()); // Drop ids temp table
- backup_helper::delete_old_backup_dirs(time() - (4 * 60 * 60)); // Delete > 4 hours temp dirs
+ backup_helper::delete_old_backup_dirs(strtotime('-1 week')); // Delete > 1 week old temp dirs.
// Delete temp dir conditionally:
// 1) If $CFG->keeptempdirectoriesonbackup is not enabled
// 2) If backup temp dir deletion has been marked to be avoided
@@ -67,7 +67,7 @@ protected function define_execution() {
restore_controller_dbops::drop_restore_temp_tables($this->get_restoreid()); // Drop ids temp table
$progress = $this->task->get_progress();
$progress->start_progress('Deleting backup dir');
- backup_helper::delete_old_backup_dirs(time() - (4 * 60 * 60), $progress); // Delete > 4 hours temp dirs
+ backup_helper::delete_old_backup_dirs(strtotime('-1 week'), $progress); // Delete > 1 week old temp dirs.
if (empty($CFG->keeptempdirectoriesonbackup)) { // Conditionally
backup_helper::delete_backup_dir($this->task->get_tempdir(), $progress); // Empty restore dir
}
@@ -3676,74 +3676,110 @@ protected function define_execution() {
* Execution step that will create all the question/answers/qtype-specific files for the restored
* questions. It must be executed after {@link restore_move_module_questions_categories}
* because only then each question is in its final category and only then the
- * context can be determined
- *
- * TODO: Improve this. Instead of looping over each question, it can be reduced to
- * be done by contexts (this will save a huge ammount of queries)
+ * contexts can be determined.
*/
class restore_create_question_files extends restore_execution_step {
+ /** @var array Question-type specific component items cache. */
+ private $qtypecomponentscache = array();
+
+ /**
+ * Preform the restore_create_question_files step.
+ */
protected function define_execution() {
global $DB;
// Track progress, as this task can take a long time.
$progress = $this->task->get_progress();
$progress->start_progress($this->get_name(), \core\progress\base::INDETERMINATE);
- // Let's process only created questions
- $questionsrs = $DB->get_recordset_sql("SELECT bi.itemid, bi.newitemid, bi.parentitemid, q.qtype
+ // Parentitemids of question_createds in backup_ids_temp are the category it is in.
+ // MUST use a recordset, as there is no unique key in the first (or any) column.
+ $catqtypes = $DB->get_recordset_sql("SELECT DISTINCT bi.parentitemid AS categoryid, q.qtype as qtype
FROM {backup_ids_temp} bi
JOIN {question} q ON q.id = bi.newitemid
WHERE bi.backupid = ?
- AND bi.itemname = 'question_created'", array($this->get_restoreid()));
- foreach ($questionsrs as $question) {
- // Report progress for each question.
- $progress->progress();
-
- // Get question_category mapping, it contains the target context for the question
- if (!$qcatmapping = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'question_category', $question->parentitemid)) {
- // Something went really wrong, cannot find the question_category for the question
- debugging('Error fetching target context for question', DEBUG_DEVELOPER);
- continue;
- }
- // Calculate source and target contexts
- $oldctxid = $qcatmapping->info->contextid;
- $newctxid = $qcatmapping->parentitemid;
-
- // Add common question files (question and question_answer ones)
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'questiontext',
- $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true, $progress);
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'generalfeedback',
- $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true, $progress);
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'answer',
- $oldctxid, $this->task->get_userid(), 'question_answer', null, $newctxid, true, $progress);
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'answerfeedback',
- $oldctxid, $this->task->get_userid(), 'question_answer', null, $newctxid, true, $progress);
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'hint',
- $oldctxid, $this->task->get_userid(), 'question_hint', null, $newctxid, true, $progress);
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'correctfeedback',
- $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true, $progress);
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'partiallycorrectfeedback',
- $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true, $progress);
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'incorrectfeedback',
- $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true, $progress);
-
- // Add qtype dependent files
- $components = backup_qtype_plugin::get_components_and_fileareas($question->qtype);
- foreach ($components as $component => $fileareas) {
- foreach ($fileareas as $filearea => $mapping) {
- // Use itemid only if mapping is question_created
- $itemid = ($mapping == 'question_created') ? $question->itemid : null;
- restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $filearea,
- $oldctxid, $this->task->get_userid(), $mapping, $itemid, $newctxid, true, $progress);
+ AND bi.itemname = 'question_created'
+ ORDER BY categoryid ASC", array($this->get_restoreid()));
+
+ $currentcatid = -1;
+ foreach ($catqtypes as $categoryid => $row) {
+ $qtype = $row->qtype;
+
+ // Check if we are in a new category.
+ if ($currentcatid !== $categoryid) {
+ // Report progress for each category.
+ $progress->progress();
+
+ if (!$qcatmapping = restore_dbops::get_backup_ids_record($this->get_restoreid(),
+ 'question_category', $categoryid)) {
+ // Something went really wrong, cannot find the question_category for the question_created records.
+ debugging('Error fetching target context for question', DEBUG_DEVELOPER);
+ continue;
}
+
+ // Calculate source and target contexts.
+ $oldctxid = $qcatmapping->info->contextid;
+ $newctxid = $qcatmapping->parentitemid;
+
+ $this->send_common_files($oldctxid, $newctxid, $progress);
+ $currentcatid = $categoryid;
}
+
+ $this->send_qtype_files($qtype, $oldctxid, $newctxid, $progress);
}
- $questionsrs->close();
+ $catqtypes->close();
$progress->end_progress();
}
-}
+ /**
+ * Send the common question files to a new context.
+ *
+ * @param int $oldctxid Old context id.
+ * @param int $newctxid New context id.
+ * @param \core\progress $progress Progress object to use.
+ */
+ private function send_common_files($oldctxid, $newctxid, $progress) {
+ // Add common question files (question and question_answer ones).
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'questiontext',
+ $oldctxid, $this->task->get_userid(), 'question_created', null, $newctxid, true, $progress);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'generalfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_created', null, $newctxid, true, $progress);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'answer',
+ $oldctxid, $this->task->get_userid(), 'question_answer', null, $newctxid, true, $progress);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'answerfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_answer', null, $newctxid, true, $progress);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'hint',
+ $oldctxid, $this->task->get_userid(), 'question_hint', null, $newctxid, true, $progress);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'correctfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_created', null, $newctxid, true, $progress);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'partiallycorrectfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_created', null, $newctxid, true, $progress);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'incorrectfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_created', null, $newctxid, true, $progress);
+ }
+
+ /**
+ * Send the question type specific files to a new context.
+ *
+ * @param text $qtype The qtype name to send.
+ * @param int $oldctxid Old context id.
+ * @param int $newctxid New context id.
+ * @param \core\progress $progress Progress object to use.
+ */
+ private function send_qtype_files($qtype, $oldctxid, $newctxid, $progress) {
+ if (!isset($this->qtypecomponentscache[$qtype])) {
+ $this->qtypecomponentscache[$qtype] = backup_qtype_plugin::get_components_and_fileareas($qtype);
+ }
+ $components = $this->qtypecomponentscache[$qtype];
+ foreach ($components as $component => $fileareas) {
+ foreach ($fileareas as $filearea => $mapping) {
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $filearea,
+ $oldctxid, $this->task->get_userid(), $mapping, null, $newctxid, true, $progress);
+ }
+ }
+ }
+}
/**
* Try to restore aliases and references to external files.
@@ -103,7 +103,18 @@ public static function insert_backup_ids_record($backupid, $itemname, $itemid) {
}
}
- public static function annotate_files($backupid, $contextid, $component, $filearea, $itemid) {
+ /**
+ * Adds backup id database record for all files in the given file area.
+ *
+ * @param string $backupid Backup ID
+ * @param int $contextid Context id
+ * @param string $component Component
+ * @param string $filearea File area
+ * @param int $itemid Item id
+ * @param \core\progress\base $progress
+ */
+ public static function annotate_files($backupid, $contextid, $component, $filearea, $itemid,
+ \core\progress\base $progress = null) {
global $DB;
$sql = 'SELECT id
FROM {files}
@@ -120,10 +131,19 @@ public static function annotate_files($backupid, $contextid, $component, $filear
$sql .= ' AND itemid = ?';
$params[] = $itemid;
}
+ if ($progress) {
+ $progress->start_progress('');
+ }
$rs = $DB->get_recordset_sql($sql, $params);
foreach ($rs as $record) {
+ if ($progress) {
+ $progress->progress();
+ }
self::insert_backup_ids_record($backupid, 'file', $record->id);
}
+ if ($progress) {
+ $progress->end_progress();
+ }
$rs->close();
}
@@ -86,7 +86,7 @@ public function process_nested_element(base_nested_element $nested) {
foreach ($area as $filearea => $info) {
$contextid = !is_null($info->contextid) ? $info->contextid : $this->get_var(backup::VAR_CONTEXTID);
$itemid = !is_null($info->element) ? $info->element->get_value() : null;
- backup_structure_dbops::annotate_files($backupid, $contextid, $component, $filearea, $itemid);
+ backup_structure_dbops::annotate_files($backupid, $contextid, $component, $filearea, $itemid, $this->progress);
}
}
}
Oops, something went wrong.

0 comments on commit 807d450

Please sign in to comment.