Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-22414 Merge branch 'master' into backup-convert

Conflicts:
	theme/base/style/core.css
  • Loading branch information...
commit b61cf3ff8a3467a9245325f5157c1b20e090c116 2 parents fad0f24 + 6911fa1
David Mudrák authored June 09, 2011

Showing 125 changed files with 11,966 additions and 6,319 deletions. Show diff stats Hide diff stats

  1. 2  admin/generator.php
  2. 1  admin/index.php
  3. 70  admin/message.php
  4. 474  admin/qtypes.php
  5. 4  admin/registration/confirmregistration.php
  6. 4  admin/registration/index.php
  7. 8  admin/report/questioninstances/index.php
  8. 2  admin/report/spamcleaner/module.js
  9. 2  admin/roles/module.js
  10. 2  admin/settings/appearance.php
  11. 6  admin/settings/courses.php
  12. 24  admin/settings/plugins.php
  13. 53  admin/settings/server.php
  14. 4  admin/webservice/service_user_settings.php
  15. 4  admin/webservice/testclient.php
  16. 2  admin/webservice/tokens.php
  17. 3  backup/moodle2/backup_qtype_plugin.class.php
  18. 117  backup/moodle2/backup_stepslib.php
  19. 28  backup/moodle2/restore_qtype_plugin.class.php
  20. 204  backup/moodle2/restore_stepslib.php
  21. 73  enrol/externallib.php
  22. 41  lang/en/admin.php
  23. 1  lang/en/error.php
  24. 18  lang/en/message.php
  25. 6  lang/en/moodle.php
  26. 2  lang/en/notes.php
  27. 137  lang/en/question.php
  28. 3  lang/en/webservice.php
  29. 464  lib/adminlib.php
  30. 4  lib/cronlib.php
  31. 107  lib/db/install.xml
  32. 4  lib/db/messages.php
  33. 44  lib/db/services.php
  34. 432  lib/db/upgrade.php
  35. 51  lib/db/upgradelib.php
  36. 2  lib/html2text.php
  37. 1  lib/installlib.php
  38. 276  lib/messagelib.php
  39. 203  lib/moodlelib.php
  40. 40  lib/outputrenderers.php
  41. 1  lib/outputrequirementslib.php
  42. 73  lib/pagelib.php
  43. 2,445  lib/questionlib.php
  44. 7  lib/resourcelib.php
  45. 297  lib/simpletest/testmoodlelib.php
  46. 156  lib/simpletest/testquestionlib.php
  47. 7  lib/simpletest/testweblib.php
  48. 37  lib/upgradelib.php
  49. 23  lib/weblib.php
  50. 48  local/qeupgradehelper/README.txt
  51. 162  local/qeupgradehelper/afterupgradelib.php
  52. 76  local/qeupgradehelper/convertquiz.php
  53. 69  local/qeupgradehelper/cronsetup.php
  54. 62  local/qeupgradehelper/cronsetup_form.php
  55. 74  local/qeupgradehelper/extracttestcase.php
  56. 62  local/qeupgradehelper/extracttestcase_form.php
  57. 55  local/qeupgradehelper/index.php
  58. 83  local/qeupgradehelper/lang/en/local_qeupgradehelper.php
  59. 74  local/qeupgradehelper/lib.php
  60. 61  local/qeupgradehelper/listpreupgrade.php
  61. 49  local/qeupgradehelper/listtodo.php
  62. 50  local/qeupgradehelper/listupgraded.php
  63. 661  local/qeupgradehelper/locallib.php
  64. 115  local/qeupgradehelper/partialupgrade-example.php
  65. 168  local/qeupgradehelper/renderer.php
  66. 72  local/qeupgradehelper/resetquiz.php
  67. 32  local/qeupgradehelper/settings.php
  68. 6  local/qeupgradehelper/styles.css
  69. 29  local/qeupgradehelper/version.php
  70. 115  message/defaultoutputs.php
  71. 151  message/edit.php
  72. 159  message/externallib.php
  73. 371  message/lib.php
  74. 47  message/module.js
  75. 17  message/output/email/lang/en/message_email.php
  76. 2  message/output/email/message_output_email.php
  77. 44  message/output/email/settings.php
  78. 12  message/output/jabber/lang/en/message_jabber.php
  79. 92  message/output/jabber/message_output_jabber.php
  80. 34  message/output/jabber/settings.php
  81. 16  message/output/lib.php
  82. 346  message/renderer.php
  83. 6  mod/assignment/lib.php
  84. 2  mod/forum/lang/en/forum.php
  85. 9  mod/forum/settings.php
  86. 2  mod/glossary/backup/moodle2/backup_glossary_stepslib.php
  87. 227  mod/quiz/accessrules.php
  88. 32  mod/quiz/addrandom.php
  89. 54  mod/quiz/addrandomform.php
  90. 272  mod/quiz/attempt.php
  91. 1,222  mod/quiz/attemptlib.php
  92. 20  mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php
  93. 40  mod/quiz/backup/moodle2/backup_quiz_stepslib.php
  94. 133  mod/quiz/backup/moodle2/restore_quiz_activity_task.class.php
  95. 147  mod/quiz/backup/moodle2/restore_quiz_stepslib.php
  96. 114  mod/quiz/comment.php
  97. 23  mod/quiz/db/access.php
  98. 40  mod/quiz/db/install.php
  99. 117  mod/quiz/db/install.xml
  100. 3  mod/quiz/db/log.php
  101. 23  mod/quiz/db/messages.php
  102. 27  mod/quiz/db/subplugins.php
  103. 828  mod/quiz/db/upgrade.php
  104. 76  mod/quiz/db/upgradelib.php
  105. 47  mod/quiz/edit.js
  106. 205  mod/quiz/edit.php
  107. 634  mod/quiz/editlib.php
  108. 77  mod/quiz/grade.php
  109. 314  mod/quiz/index.php
  110. 160  mod/quiz/lang/en/quiz.php
  111. 812  mod/quiz/lib.php
  112. 1,125  mod/quiz/locallib.php
  113. 469  mod/quiz/mod_form.php
  114. 34  mod/quiz/module.js
  115. 84  mod/quiz/override_form.php
  116. 18  mod/quiz/overridedelete.php
  117. 34  mod/quiz/overrideedit.php
  118. 77  mod/quiz/overrides.php
  119. BIN  mod/quiz/pix/icon.gif
  120. BIN  mod/quiz/pix/icon.png
  121. BIN  mod/quiz/pix/navflagged.png
  122. 210  mod/quiz/processattempt.php
  123. 1,000  mod/quiz/renderer.php
  124. 185  mod/quiz/report.php
2  admin/generator.php
@@ -622,7 +622,7 @@ public function generate_questions($courses, $modules) {
622 622
             require_once($CFG->libdir .'/questionlib.php');
623 623
             require_once($CFG->dirroot .'/mod/quiz/editlib.php');
624 624
             $questions = array();
625  
-            $questionsmenu = question_type_menu();
  625
+            $questionsmenu = question_bank::get_creatable_qtypes();
626 626
             $questiontypes = array();
627 627
             foreach ($questionsmenu as $qtype => $qname) {
628 628
                 $questiontypes[] = $qtype;
1  admin/index.php
@@ -355,7 +355,6 @@
355 355
         }
356 356
         // login user and let him set password and admin details
357 357
         $adminuser->newadminuser = 1;
358  
-        message_set_default_message_preferences($adminuser);
359 358
         complete_user_login($adminuser, false);
360 359
         redirect("$CFG->wwwroot/user/editadvanced.php?id=$adminuser->id"); // Edit thyself
361 360
 
70  admin/message.php
... ...
@@ -0,0 +1,70 @@
  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
+ * Message outputs configuration page
  19
+ *
  20
+ * @package    message
  21
+ * @copyright  2011 Lancaster University Network Services Limited
  22
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23
+ */
  24
+require_once(dirname(__FILE__) . '/../config.php');
  25
+require_once($CFG->dirroot . '/message/lib.php');
  26
+require_once($CFG->libdir.'/adminlib.php');
  27
+
  28
+// This is an admin page
  29
+admin_externalpage_setup('managemessageoutputs');
  30
+
  31
+// Require site configuration capability
  32
+require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
  33
+
  34
+// Get the submitted params
  35
+$disable    = optional_param('disable', 0, PARAM_INT);
  36
+$enable     = optional_param('enable', 0, PARAM_INT);
  37
+
  38
+if (!empty($disable) && confirm_sesskey()) {
  39
+    if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
  40
+        print_error('outputdoesnotexist', 'message');
  41
+    }
  42
+    $DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id));      // Disable output
  43
+}
  44
+
  45
+if (!empty($enable) && confirm_sesskey() ) {
  46
+    if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
  47
+        print_error('outputdoesnotexist', 'message');
  48
+    }
  49
+    $DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id));      // Enable output
  50
+}
  51
+
  52
+if ($disable || $enable) {
  53
+    $url = new moodle_url('message.php');
  54
+    redirect($url);
  55
+}
  56
+// Page settings
  57
+$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
  58
+
  59
+// Grab the renderer
  60
+$renderer = $PAGE->get_renderer('core', 'message');
  61
+
  62
+// Display the manage message outputs interface
  63
+$processors = get_message_processors();
  64
+$messageoutputs = $renderer->manage_messageoutputs($processors);
  65
+
  66
+// Display the page
  67
+echo $OUTPUT->header();
  68
+echo $OUTPUT->heading(get_string('managemessageoutputs', 'message'));
  69
+echo $messageoutputs;
  70
+echo $OUTPUT->footer();
474  admin/qtypes.php
... ...
@@ -1,275 +1,297 @@
1 1
 <?php
2  
-// Allows the admin to manage question types.
3  
-
4  
-    require_once(dirname(__FILE__) . '/../config.php');
5  
-    require_once($CFG->libdir . '/questionlib.php');
6  
-    require_once($CFG->libdir . '/adminlib.php');
7  
-    require_once($CFG->libdir . '/tablelib.php');
8  
-
9  
-/// Check permissions.
10  
-    require_login();
11  
-    $systemcontext = get_context_instance(CONTEXT_SYSTEM);
12  
-    require_capability('moodle/question:config', $systemcontext);
13  
-    $canviewreports = has_capability('report/questioninstances:view', $systemcontext);
14  
-
15  
-    admin_externalpage_setup('manageqtypes');
16  
-
17  
-/// Get some data we will need - question counts and which types are needed.
18  
-    $counts = $DB->get_records_sql("
19  
-            SELECT qtype, COUNT(1) as numquestions, SUM(hidden) as numhidden
20  
-            FROM {question} GROUP BY qtype", array());
21  
-    $needed = array();
22  
-    foreach ($QTYPES as $qtypename => $qtype) {
23  
-        if (!isset($counts[$qtypename])) {
24  
-            $counts[$qtypename] = new stdClass;
25  
-            $counts[$qtypename]->numquestions = 0;
26  
-            $counts[$qtypename]->numhidden = 0;
27  
-        }
28  
-        $needed[$qtypename] = $counts[$qtypename]->numquestions > 0;
29  
-        $counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
30  
-    }
31  
-    $needed['missingtype'] = true; // The system needs the missing question type.
32  
-    foreach ($QTYPES as $qtypename => $qtype) {
33  
-        foreach ($qtype->requires_qtypes() as $reqtype) {
34  
-            $needed[$reqtype] = true;
35  
-        }
  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
+ * Allows the admin to manage question types.
  20
+ *
  21
+ * @package    moodlecore
  22
+ * @subpackage questionbank
  23
+ * @copyright  2008 Tim Hunt
  24
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25
+ */
  26
+
  27
+
  28
+require_once(dirname(__FILE__) . '/../config.php');
  29
+require_once($CFG->libdir . '/questionlib.php');
  30
+require_once($CFG->libdir . '/adminlib.php');
  31
+require_once($CFG->libdir . '/tablelib.php');
  32
+
  33
+// Check permissions.
  34
+require_login();
  35
+$systemcontext = get_context_instance(CONTEXT_SYSTEM);
  36
+require_capability('moodle/question:config', $systemcontext);
  37
+$canviewreports = has_capability('report/questioninstances:view', $systemcontext);
  38
+
  39
+admin_externalpage_setup('manageqtypes');
  40
+
  41
+$qtypes = question_bank::get_all_qtypes();
  42
+
  43
+// Get some data we will need - question counts and which types are needed.
  44
+$counts = $DB->get_records_sql("
  45
+        SELECT qtype, COUNT(1) as numquestions, SUM(hidden) as numhidden
  46
+        FROM {question} GROUP BY qtype", array());
  47
+$needed = array();
  48
+foreach ($qtypes as $qtypename => $qtype) {
  49
+    if (!isset($counts[$qtypename])) {
  50
+        $counts[$qtypename] = new stdClass;
  51
+        $counts[$qtypename]->numquestions = 0;
  52
+        $counts[$qtypename]->numhidden = 0;
36 53
     }
37  
-    foreach ($counts as $qtypename => $count) {
38  
-        if (!isset($QTYPES[$qtypename])) {
39  
-            $counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
40  
-            $counts['missingtype']->numhidden += $count->numhidden;
41  
-        }
  54
+    $needed[$qtypename] = $counts[$qtypename]->numquestions > 0;
  55
+    $counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
  56
+}
  57
+$needed['missingtype'] = true; // The system needs the missing question type.
  58
+foreach ($qtypes as $qtypename => $qtype) {
  59
+    foreach ($qtype->requires_qtypes() as $reqtype) {
  60
+        $needed[$reqtype] = true;
42 61
     }
43  
-
44  
-/// Work of the correct sort order.
45  
-    $config = get_config('question');
46  
-    $sortedqtypes = array();
47  
-    foreach ($QTYPES as $qtypename => $qtype) {
48  
-        $sortedqtypes[$qtypename] = $qtype->local_name();
  62
+}
  63
+foreach ($counts as $qtypename => $count) {
  64
+    if (!isset($qtypes[$qtypename])) {
  65
+        $counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
  66
+        $counts['missingtype']->numhidden += $count->numhidden;
49 67
     }
50  
-    $sortedqtypes = question_sort_qtype_array($sortedqtypes, $config);
  68
+}
51 69
 
52  
-/// Process actions ============================================================
  70
+// Work of the correct sort order.
  71
+$config = get_config('question');
  72
+$sortedqtypes = array();
  73
+foreach ($qtypes as $qtypename => $qtype) {
  74
+    $sortedqtypes[$qtypename] = $qtype->local_name();
  75
+}
  76
+$sortedqtypes = question_bank::sort_qtype_array($sortedqtypes, $config);
53 77
 
54  
-    // Disable.
55  
-    if (($disable = optional_param('disable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
56  
-        if (!isset($QTYPES[$disable])) {
57  
-            print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $disable);
58  
-        }
  78
+// Process actions ============================================================
59 79
 
60  
-        set_config($disable . '_disabled', 1, 'question');
61  
-        redirect(admin_url('qtypes.php'));
  80
+// Disable.
  81
+if (($disable = optional_param('disable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
  82
+    if (!isset($qtypes[$disable])) {
  83
+        print_error('unknownquestiontype', 'question', new moodle_url('/admin/qtypes.php'), $disable);
62 84
     }
63 85
 
64  
-    // Enable.
65  
-    if (($enable = optional_param('enable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
66  
-        if (!isset($QTYPES[$enable])) {
67  
-            print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $enable);
68  
-        }
  86
+    set_config($disable . '_disabled', 1, 'question');
  87
+    redirect(admin_url('qtypes.php'));
  88
+}
69 89
 
70  
-        if (!$QTYPES[$enable]->menu_name()) {
71  
-            print_error('cannotenable', 'question', admin_url('qtypes.php'), $enable);
72  
-        }
  90
+// Enable.
  91
+if (($enable = optional_param('enable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
  92
+    if (!isset($qtypes[$enable])) {
  93
+        print_error('unknownquestiontype', 'question', new moodle_url('/admin/qtypes.php'), $enable);
  94
+    }
73 95
 
74  
-        unset_config($enable . '_disabled', 'question');
75  
-        redirect(admin_url('qtypes.php'));
  96
+    if (!$qtypes[$enable]->menu_name()) {
  97
+        print_error('cannotenable', 'question', new moodle_url('/admin/qtypes.php'), $enable);
76 98
     }
77 99
 
78  
-    // Move up in order.
79  
-    if (($up = optional_param('up', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
80  
-        if (!isset($QTYPES[$up])) {
81  
-            print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $up);
82  
-        }
  100
+    unset_config($enable . '_disabled', 'question');
  101
+    redirect(new moodle_url('/admin/qtypes.php'));
  102
+}
83 103
 
84  
-        $neworder = question_reorder_qtypes($sortedqtypes, $up, -1);
85  
-        question_save_qtype_order($neworder, $config);
86  
-        redirect(admin_url('qtypes.php'));
  104
+// Move up in order.
  105
+if (($up = optional_param('up', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
  106
+    if (!isset($qtypes[$up])) {
  107
+        print_error('unknownquestiontype', 'question', new moodle_url('/admin/qtypes.php'), $up);
87 108
     }
88 109
 
89  
-    // Move down in order.
90  
-    if (($down = optional_param('down', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
91  
-        if (!isset($QTYPES[$down])) {
92  
-            print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $down);
93  
-        }
  110
+    $neworder = question_reorder_qtypes($sortedqtypes, $up, -1);
  111
+    question_save_qtype_order($neworder, $config);
  112
+    redirect(new moodle_url('/admin/qtypes.php'));
  113
+}
94 114
 
95  
-        $neworder = question_reorder_qtypes($sortedqtypes, $down, +1);
96  
-        question_save_qtype_order($neworder, $config);
97  
-        redirect(admin_url('qtypes.php'));
  115
+// Move down in order.
  116
+if (($down = optional_param('down', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
  117
+    if (!isset($qtypes[$down])) {
  118
+        print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $down);
98 119
     }
99 120
 
100  
-    // Delete.
101  
-    if (($delete = optional_param('delete', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
102  
-        // Check it is OK to delete this question type.
103  
-        if ($delete == 'missingtype') {
104  
-            print_error('cannotdeletemissingqtype', 'admin', admin_url('qtypes.php'));
105  
-        }
  121
+    $neworder = question_reorder_qtypes($sortedqtypes, $down, +1);
  122
+    question_save_qtype_order($neworder, $config);
  123
+    redirect(new moodle_url('/admin/qtypes.php'));
  124
+}
106 125
 
107  
-        if (!isset($QTYPES[$delete])) {
108  
-            print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $delete);
109  
-        }
  126
+// Delete.
  127
+if (($delete = optional_param('delete', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
  128
+    // Check it is OK to delete this question type.
  129
+    if ($delete == 'missingtype') {
  130
+        print_error('cannotdeletemissingqtype', 'admin', new moodle_url('/admin/qtypes.php'));
  131
+    }
110 132
 
111  
-        $qtypename = $QTYPES[$delete]->local_name();
112  
-        if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
113  
-            print_error('cannotdeleteqtypeinuse', 'admin', admin_url('qtypes.php'), $qtypename);
114  
-        }
  133
+    if (!isset($qtypes[$delete])) {
  134
+        print_error('unknownquestiontype', 'question', new moodle_url('/admin/qtypes.php'), $delete);
  135
+    }
115 136
 
116  
-        if ($needed[$delete] > 0) {
117  
-            print_error('cannotdeleteqtypeneeded', 'admin', admin_url('qtypes.php'), $qtypename);
118  
-        }
  137
+    $qtypename = $qtypes[$delete]->local_name();
  138
+    if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
  139
+        print_error('cannotdeleteqtypeinuse', 'admin', new moodle_url('/admin/qtypes.php'), $qtypename);
  140
+    }
119 141
 
120  
-        // If not yet confirmed, display a confirmation message.
121  
-        if (!optional_param('confirm', '', PARAM_BOOL)) {
122  
-            $qtypename = $QTYPES[$delete]->local_name();
123  
-            echo $OUTPUT->header();
124  
-            echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'admin', $qtypename));
125  
-            echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'admin', $qtypename),
126  
-                    admin_url('qtypes.php?delete=' . $delete . '&confirm=1'),
127  
-                    admin_url('qtypes.php'));
128  
-            echo $OUTPUT->footer();
129  
-            exit;
130  
-        }
  142
+    if ($needed[$delete] > 0) {
  143
+        print_error('cannotdeleteqtypeneeded', 'admin', new moodle_url('/admin/qtypes.php'), $qtypename);
  144
+    }
131 145
 
132  
-        // Do the deletion.
  146
+    // If not yet confirmed, display a confirmation message.
  147
+    if (!optional_param('confirm', '', PARAM_BOOL)) {
  148
+        $qtypename = $qtypes[$delete]->local_name();
133 149
         echo $OUTPUT->header();
134  
-        echo $OUTPUT->heading(get_string('deletingqtype', 'admin', $qtypename));
135  
-
136  
-        // Delete any configuration records.
137  
-        if (!unset_all_config_for_plugin('qtype_' . $delete)) {
138  
-            echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
139  
-        }
140  
-        unset_config($delete . '_disabled', 'question');
141  
-        unset_config($delete . '_sortorder', 'question');
142  
-
143  
-        // Then the tables themselves
144  
-        drop_plugin_tables($delete, $QTYPES[$delete]->plugin_dir() . '/db/install.xml', false);
145  
-
146  
-        // Remove event handlers and dequeue pending events
147  
-        events_uninstall('qtype/' . $delete);
148  
-
149  
-        $a->qtype = $qtypename;
150  
-        $a->directory = $QTYPES[$delete]->plugin_dir();
151  
-        echo $OUTPUT->box(get_string('qtypedeletefiles', 'admin', $a), 'generalbox', 'notice');
152  
-        echo $OUTPUT->continue_button(admin_url('qtypes.php'));
  150
+        echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'admin', $qtypename));
  151
+        echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'admin', $qtypename),
  152
+                new moodle_url('/admin/qtypes.php', array('delete' => $delete, 'confirm' => 1)),
  153
+                new moodle_url('/admin/qtypes.php'));
153 154
         echo $OUTPUT->footer();
154 155
         exit;
155 156
     }
156 157
 
157  
-    // End of process actions ==================================================
158  
-
159  
-/// Print the page heading.
  158
+    // Do the deletion.
160 159
     echo $OUTPUT->header();
161  
-    echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
162  
-
163  
-/// Set up the table.
164  
-    $table = new flexible_table('qtypeadmintable');
165  
-    $table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
166  
-            'availableto', 'delete', 'settings'));
167  
-    $table->define_headers(array(get_string('questiontype', 'admin'), get_string('numquestions', 'admin'),
168  
-            get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
169  
-            get_string('delete'), get_string('settings')));
170  
-    $table->set_attribute('id', 'qtypes');
171  
-    $table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
172  
-    $table->setup();
173  
-
174  
-/// Add a row for each question type.
175  
-    $createabletypes = question_type_menu();
176  
-    foreach ($sortedqtypes as $qtypename => $localname) {
177  
-        $qtype = $QTYPES[$qtypename];
178  
-        $row = array();
179  
-
180  
-        // Question icon and name.
181  
-        $fakequestion = new stdClass;
182  
-        $fakequestion->qtype = $qtypename;
183  
-        $icon = print_question_icon($fakequestion, true);
184  
-        $row[] = $icon . ' ' . $localname;
185  
-
186  
-        // Number of questions of this type.
187  
-        if ($counts[$qtypename]->numquestions + $counts[$qtypename]->numhidden > 0) {
188  
-            if ($counts[$qtypename]->numhidden > 0) {
189  
-                $strcount = get_string('numquestionsandhidden', 'admin', $counts[$qtypename]);
190  
-            } else {
191  
-                $strcount = $counts[$qtypename]->numquestions;
192  
-            }
193  
-            if ($canviewreports) {
194  
-                $row[] = '<a href="' . admin_url('/report/questioninstances/index.php?qtype=' . $qtypename) .
195  
-                        '" title="' . get_string('showdetails', 'admin') . '">' . $strcount . '</a>';
196  
-            } else {
197  
-                $strcount;
198  
-            }
199  
-        } else {
200  
-            $row[] = 0;
201  
-        }
  160
+    echo $OUTPUT->heading(get_string('deletingqtype', 'admin', $qtypename));
202 161
 
203  
-        // Question version number.
204  
-        $version = get_config('qtype_' . $qtypename, 'version');
205  
-        if ($version) {
206  
-            $row[] = $version;
207  
-        } else {
208  
-            $row[] = '<span class="disabled">' . get_string('nodatabase', 'admin') . '</span>';
209  
-        }
  162
+    // Delete any configuration records.
  163
+    if (!unset_all_config_for_plugin('qtype_' . $delete)) {
  164
+        echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
  165
+    }
  166
+    unset_config($delete . '_disabled', 'question');
  167
+    unset_config($delete . '_sortorder', 'question');
210 168
 
211  
-        // Other question types required by this one.
212  
-        $requiredtypes = $qtype->requires_qtypes();
213  
-        $strtypes = array();
214  
-        if (!empty($requiredtypes)) {
215  
-            foreach ($requiredtypes as $required) {
216  
-                $strtypes[] = $QTYPES[$required]->local_name();
217  
-            }
218  
-            $row[] = implode(', ', $strtypes);
  169
+    // Then the tables themselves
  170
+    drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false);
  171
+
  172
+    // Remove event handlers and dequeue pending events
  173
+    events_uninstall('qtype/' . $delete);
  174
+
  175
+    $a->qtype = $qtypename;
  176
+    $a->directory = $qtypes[$delete]->plugin_dir();
  177
+    echo $OUTPUT->box(get_string('qtypedeletefiles', 'admin', $a), 'generalbox', 'notice');
  178
+    echo $OUTPUT->continue_button(new moodle_url('/admin/qtypes.php'));
  179
+    echo $OUTPUT->footer();
  180
+    exit;
  181
+}
  182
+
  183
+// End of process actions ==================================================
  184
+
  185
+// Print the page heading.
  186
+echo $OUTPUT->header();
  187
+echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
  188
+
  189
+// Set up the table.
  190
+$table = new flexible_table('qtypeadmintable');
  191
+$table->define_baseurl(new moodle_url('/admin/qtypes.php'));
  192
+$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
  193
+        'availableto', 'delete', 'settings'));
  194
+$table->define_headers(array(get_string('questiontype', 'admin'), get_string('numquestions', 'admin'),
  195
+        get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
  196
+        get_string('delete'), get_string('settings')));
  197
+$table->set_attribute('id', 'qtypes');
  198
+$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
  199
+$table->setup();
  200
+
  201
+// Add a row for each question type.
  202
+$createabletypes = question_bank::get_creatable_qtypes();
  203
+foreach ($sortedqtypes as $qtypename => $localname) {
  204
+    $qtype = $qtypes[$qtypename];
  205
+    $row = array();
  206
+
  207
+    // Question icon and name.
  208
+    $fakequestion = new stdClass;
  209
+    $fakequestion->qtype = $qtypename;
  210
+    $icon = print_question_icon($fakequestion, true);
  211
+    $row[] = $icon . ' ' . $localname;
  212
+
  213
+    // Number of questions of this type.
  214
+    if ($counts[$qtypename]->numquestions + $counts[$qtypename]->numhidden > 0) {
  215
+        if ($counts[$qtypename]->numhidden > 0) {
  216
+            $strcount = get_string('numquestionsandhidden', 'admin', $counts[$qtypename]);
219 217
         } else {
220  
-            $row[] = '';
  218
+            $strcount = $counts[$qtypename]->numquestions;
221 219
         }
222  
-
223  
-        // Are people allowed to create new questions of this type?
224  
-        $rowclass = '';
225  
-        if ($qtype->menu_name()) {
226  
-            $createable = isset($createabletypes[$qtypename]);
227  
-            $icons = enable_disable_button($qtypename, $createable);
228  
-            if (!$createable) {
229  
-                $rowclass = 'dimmed_text';
230  
-            }
  220
+        if ($canviewreports) {
  221
+            $row[] = '<a href="' . new moodle_url('/admin/report/questioninstances/index.php', array('qtype' => $qtypename)) .
  222
+                    '" title="' . get_string('showdetails', 'admin') . '">' . $strcount . '</a>';
231 223
         } else {
232  
-            $icons = '<img src="' . $OUTPUT->pix_url('spacer') . '" alt="" class="spacer" />';
  224
+            $strcount;
233 225
         }
  226
+    } else {
  227
+        $row[] = 0;
  228
+    }
234 229
 
235  
-        // Move icons.
236  
-        $icons .= icon_html('up', $qtypename, 't/up', get_string('up'), '');
237  
-        $icons .= icon_html('down', $qtypename, 't/down', get_string('down'), '');
238  
-        $row[] = $icons;
  230
+    // Question version number.
  231
+    $version = get_config('qtype_' . $qtypename, 'version');
  232
+    if ($version) {
  233
+        $row[] = $version;
  234
+    } else {
  235
+        $row[] = '<span class="disabled">' . get_string('nodatabase', 'admin') . '</span>';
  236
+    }
239 237
 
240  
-        // Delete link, if available.
241  
-        if ($needed[$qtypename]) {
242  
-            $row[] = '';
243  
-        } else {
244  
-            $row[] = '<a href="' . admin_url('qtypes.php?delete=' . $qtypename .
245  
-                    '&amp;sesskey=' . sesskey()) . '" title="' .
246  
-                    get_string('uninstallqtype', 'admin') . '">' . get_string('delete') . '</a>';
  238
+    // Other question types required by this one.
  239
+    $requiredtypes = $qtype->requires_qtypes();
  240
+    $strtypes = array();
  241
+    if (!empty($requiredtypes)) {
  242
+        foreach ($requiredtypes as $required) {
  243
+            $strtypes[] = $qtypes[$required]->local_name();
247 244
         }
  245
+        $row[] = implode(', ', $strtypes);
  246
+    } else {
  247
+        $row[] = '';
  248
+    }
248 249
 
249  
-        // Settings link, if available.
250  
-        $settings = admin_get_root()->locate('qtypesetting' . $qtypename);
251  
-        if ($settings instanceof admin_externalpage) {
252  
-            $row[] = '<a href="' . $settings->url .
253  
-                    '">' . get_string('settings') . '</a>';
254  
-        } else if ($settings instanceof admin_settingpage) {
255  
-            $row[] = '<a href="' . admin_url('settings.php?section=qtypesetting' . $qtypename) .
256  
-                    '">' . get_string('settings') . '</a>';
257  
-        } else {
258  
-            $row[] = '';
  250
+    // Are people allowed to create new questions of this type?
  251
+    $rowclass = '';
  252
+    if ($qtype->menu_name()) {
  253
+        $createable = isset($createabletypes[$qtypename]);
  254
+        $icons = enable_disable_button($qtypename, $createable);
  255
+        if (!$createable) {
  256
+            $rowclass = 'dimmed_text';
259 257
         }
260  
-
261  
-        $table->add_data($row, $rowclass);
  258
+    } else {
  259
+        $icons = '<img src="' . $OUTPUT->pix_url('spacer') . '" alt="" class="spacer" />';
262 260
     }
263 261
 
264  
-    $table->finish_output();
  262
+    // Move icons.
  263
+    $icons .= icon_html('up', $qtypename, 't/up', get_string('up'), '');
  264
+    $icons .= icon_html('down', $qtypename, 't/down', get_string('down'), '');
  265
+    $row[] = $icons;
265 266
 
266  
-    echo $OUTPUT->footer();
  267
+    // Delete link, if available.
  268
+    if ($needed[$qtypename]) {
  269
+        $row[] = '';
  270
+    } else {
  271
+        $row[] = '<a href="' . new moodle_url('/admin/qtypes.php', array('delete' => $qtypename,
  272
+                'sesskey' => sesskey())) . '" title="' .
  273
+                get_string('uninstallqtype', 'admin') . '">' . get_string('delete') . '</a>';
  274
+    }
  275
+
  276
+    // Settings link, if available.
  277
+    $settings = admin_get_root()->locate('qtypesetting' . $qtypename);
  278
+    if ($settings instanceof admin_externalpage) {
  279
+        $row[] = '<a href="' . $settings->url .
  280
+                '">' . get_string('settings') . '</a>';
  281
+    } else if ($settings instanceof admin_settingpage) {
  282
+        $row[] = '<a href="' . new moodle_url('/admin/settings.php', array('section' => 'qtypesetting' . $qtypename)) .
  283
+                '">' . get_string('settings') . '</a>';
  284
+    } else {
  285
+        $row[] = '';
  286
+    }
267 287
 
268  
-function admin_url($endbit) {
269  
-    global $CFG;
270  
-    return $CFG->wwwroot . '/' . $CFG->admin . '/' . $endbit;
  288
+    $table->add_data($row, $rowclass);
271 289
 }
272 290
 
  291
+$table->finish_output();
  292
+
  293
+echo $OUTPUT->footer();
  294
+
273 295
 function enable_disable_button($qtypename, $createable) {
274 296
     if ($createable) {
275 297
         return icon_html('disable', $qtypename, 'i/hide', get_string('enabled', 'question'), get_string('disable'));
@@ -283,7 +305,7 @@ function icon_html($action, $qtypename, $icon, $alt, $tip) {
283 305
     if ($tip) {
284 306
         $tip = 'title="' . $tip . '" ';
285 307
     }
286  
-    $html = ' <form action="' . admin_url('qtypes.php') . '" method="post"><div>';
  308
+    $html = ' <form action="' . new moodle_url('/admin/qtypes.php') . '" method="post"><div>';
287 309
     $html .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
288 310
     $html .= '<input type="image" name="' . $action . '" value="' . $qtypename .
289 311
             '" src="' . $OUTPUT->pix_url($icon) . '" alt="' . $alt . '" ' . $tip . '/>';
4  admin/registration/confirmregistration.php
@@ -47,7 +47,7 @@
47 47
 admin_externalpage_setup('registrationindex');
48 48
 
49 49
 if (!empty($error) and $error == 'urlalreadyexist') {
50  
-    throw new moodle_exception('urlalreadyregistered', 'hub', 
  50
+    throw new moodle_exception('urlalreadyregistered', 'hub',
51 51
             $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
52 52
 }
53 53
 
@@ -85,7 +85,7 @@
85 85
 
86 86
     echo $OUTPUT->footer();
87 87
 } else {
88  
-    throw new moodle_exception('wrongtoken', 'hub', 
  88
+    throw new moodle_exception('wrongtoken', 'hub',
89 89
             $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
90 90
 }
91 91
 
4  admin/registration/index.php
@@ -148,12 +148,12 @@
148 148
     $moodleorghub = $registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL);
149 149
     if (!empty($moodleorghub)) {
150 150
         $registeredonmoodleorg = true;
151  
-    } 
  151
+    }
152 152
 
153 153
     echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
154 154
     echo $renderer->registrationselector($registeredonmoodleorg);
155 155
 
156  
-    if (extension_loaded('xmlrpc')) {     
  156
+    if (extension_loaded('xmlrpc')) {
157 157
         $hubs = $registrationmanager->get_registered_on_hubs();
158 158
         if (!empty($hubs)) {
159 159
             echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main');
8  admin/report/questioninstances/index.php
@@ -22,8 +22,9 @@
22 22
 add_to_log(SITEID, "admin", "report questioninstances", "report/questioninstances/index.php?qtype=$requestedqtype", $requestedqtype);
23 23
 
24 24
 // Prepare the list of capabilities to choose from
  25
+$qtypes = question_bank::get_all_qtypes();
25 26
 $qtypechoices = array();
26  
-foreach ($QTYPES as $qtype) {
  27
+foreach ($qtypes as $qtype) {
27 28
     $qtypechoices[$qtype->name()] = $qtype->local_name();
28 29
 }
29 30
 
@@ -45,7 +46,7 @@
45 46
 
46 47
     // Work out the bits needed for the SQL WHERE clauses.
47 48
     if ($requestedqtype == 'missingtype') {
48  
-        $othertypes = array_keys($QTYPES);
  49
+        $othertypes = array_keys($qtypes);
49 50
         $key = array_search('missingtype', $othertypes);
50 51
         unset($othertypes[$key]);
51 52
         list($sqlqtypetest, $params) = $DB->get_in_or_equal($othertypes, SQL_PARAMS_QM, '', false);
@@ -58,7 +59,8 @@
58 59
     } else {
59 60
         $sqlqtypetest = 'WHERE qtype = ?';
60 61
         $params = array($requestedqtype);
61  
-        $title = get_string('reportforqtype', 'report_questioninstances', $QTYPES[$requestedqtype]->local_name());
  62
+        $title = get_string('reportforqtype', 'report_questioninstances',
  63
+                question_bank::get_qtype($requestedqtype)->local_name());
62 64
     }
63 65
 
64 66
     // Get the question counts, and all the context information, for each
2  admin/report/spamcleaner/module.js
@@ -108,7 +108,7 @@ M.report_spamcleaner = {
108 108
             context.Y = Y;
109 109
             context.me = me;
110 110
             if (Y.one("#removeall_btn")) {
111  
-            	Y.on("click", context.del_all, "#removeall_btn");
  111
+                Y.on("click", context.del_all, "#removeall_btn");
112 112
             }
113 113
         });
114 114
     }
2  admin/roles/module.js
@@ -138,7 +138,7 @@ M.core_role.init_cap_table_filter = function(Y, tableid, contextid) {
138 138
                 lastheading = null;
139 139
 
140 140
             this.setFilterCookieValue(filtertext);
141  
-            
  141
+
142 142
             this.button.set('disabled', (filtertext == ''));
143 143
 
144 144
             this.table.all('tr').each(function(row){
2  admin/settings/appearance.php
@@ -18,6 +18,8 @@
18 18
     $temp->add(new admin_setting_configcheckbox('allowuserblockhiding', get_string('allowuserblockhiding', 'admin'), get_string('configallowuserblockhiding', 'admin'), 1));
19 19
     $temp->add(new admin_setting_configcheckbox('allowblockstodock', get_string('allowblockstodock', 'admin'), get_string('configallowblockstodock', 'admin'), 1));
20 20
     $temp->add(new admin_setting_configtextarea('custommenuitems', get_string('custommenuitems', 'admin'), get_string('configcustommenuitems', 'admin'), '', PARAM_TEXT, '50', '10'));
  21
+    $temp->add(new admin_setting_configcheckbox('enabledevicedetection', get_string('enabledevicedetection', 'admin'), get_string('configenabledevicedetection', 'admin'), 1));
  22
+    $temp->add(new admin_setting_devicedetectregex('devicedetectregex', get_string('devicedetectregex', 'admin'), get_string('devicedetectregex_desc', 'admin'), ''));
21 23
     $ADMIN->add('themes', $temp);
22 24
     $ADMIN->add('themes', new admin_externalpage('themeselector', get_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php'));
23 25
 
6  admin/settings/courses.php
@@ -139,7 +139,7 @@
139 139
         400 => '400',
140 140
         500 => '500');
141 141
     $temp->add(new admin_setting_configselect('backup/backup_auto_keep', get_string('keep'), get_string('backupkeephelp'), 1, $keepoptoins));
142  
-   
  142
+
143 143
 
144 144
     $temp->add(new admin_setting_heading('automatedsettings', get_string('automatedsettings','backup'), ''));
145 145
     $temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', get_string('users'), get_string('backupusershelp'), 1));
@@ -152,8 +152,8 @@
152 152
     $temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', get_string('generaluserscompletion','backup'), get_string('configgeneraluserscompletion','backup'), 1));
153 153
     $temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', get_string('logs'), get_string('backuplogshelp'), 0));
154 154
     $temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', get_string('generalhistories','backup'), get_string('configgeneralhistories','backup'), 0));
155  
-    
156  
-    
  155
+
  156
+
157 157
     //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0));
158 158
     //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 0));
159 159
 
24  admin/settings/plugins.php
@@ -46,6 +46,27 @@
46 46
         }
47 47
     }
48 48
 
  49
+    // message outputs
  50
+    $ADMIN->add('modules', new admin_category('messageoutputs', get_string('messageoutputs', 'message')));
  51
+    $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
  52
+    $ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
  53
+    require_once($CFG->dirroot.'/message/lib.php');
  54
+    $processors = get_message_processors();
  55
+    foreach ($processors as $processor) {
  56
+        $processorname = $processor->name;
  57
+        if (!$processor->available) {
  58
+            continue;
  59
+        }
  60
+        if ($processor->hassettings) {
  61
+            $strprocessorname = get_string('pluginname', 'message_'.$processorname);
  62
+            $settings = new admin_settingpage('messagesetting'.$processorname, $strprocessorname, 'moodle/site:config', !$processor->enabled);
  63
+            include($CFG->dirroot.'/message/output/'.$processor->name.'/settings.php');
  64
+            if ($settings) {
  65
+                $ADMIN->add('messageoutputs', $settings);
  66
+            }
  67
+        }
  68
+    }
  69
+
49 70
     // authentication plugins
50 71
     $ADMIN->add('modules', new admin_category('authsettings', get_string('authentication', 'admin')));
51 72
 
@@ -324,6 +345,9 @@
324 345
     $ADMIN->add('webservicesettings', $temp);
325 346
     /// manage service
326 347
     $temp = new admin_settingpage('externalservices', get_string('externalservices', 'webservice'));
  348
+    $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
  349
+    $enablemobiledoclink = html_writer::link($enablemobiledocurl, get_string('documentation'));
  350
+    $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice', get_string('enablemobilewebservice', 'admin'), get_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
327 351
     $temp->add(new admin_setting_heading('manageserviceshelpexplaination', get_string('information', 'webservice'), get_string('servicehelpexplanation', 'webservice')));
328 352
     $temp->add(new admin_setting_manageexternalservices());
329 353
     $ADMIN->add('webservicesettings', $temp);
53  admin/settings/server.php
@@ -17,46 +17,8 @@
17 17
 
18 18
 
19 19
 
20  
-// "email" settingpage
21  
-$temp = new admin_settingpage('mail', get_string('mail','admin'));
22  
-$temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_RAW));
23  
-$temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
24  
-$temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), ''));
25  
-$temp->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'admin'), get_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
26  
-$temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_NOTAGS));
27  
-$temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00',
28  
-                                                                                                                                                          '01' => '01',
29  
-                                                                                                                                                          '02' => '02',
30  
-                                                                                                                                                          '03' => '03',
31  
-                                                                                                                                                          '04' => '04',
32  
-                                                                                                                                                          '05' => '05',
33  
-                                                                                                                                                          '06' => '06',
34  
-                                                                                                                                                          '07' => '07',
35  
-                                                                                                                                                          '08' => '08',
36  
-                                                                                                                                                          '09' => '09',
37  
-                                                                                                                                                          '10' => '10',
38  
-                                                                                                                                                          '11' => '11',
39  
-                                                                                                                                                          '12' => '12',
40  
-                                                                                                                                                          '13' => '13',
41  
-                                                                                                                                                          '14' => '14',
42  
-                                                                                                                                                          '15' => '15',
43  
-                                                                                                                                                          '16' => '16',
44  
-                                                                                                                                                          '17' => '17',
45  
-                                                                                                                                                          '18' => '18',
46  
-                                                                                                                                                          '19' => '19',
47  
-                                                                                                                                                          '20' => '20',
48  
-                                                                                                                                                          '21' => '21',
49  
-                                                                                                                                                          '22' => '22',
50  
-                                                                                                                                                          '23' => '23')));
51  
-$charsets = get_list_of_charsets();
52  
-unset($charsets['UTF-8']); // not needed here
53  
-$options = array();
54  
-$options['0'] = 'UTF-8';
55  
-$options = array_merge($options, $charsets);
56  
-$temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '0', $options));
57  
-$temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0));
58  
-$options = array('LF'=>'LF', 'CRLF'=>'CRLF');
59  
-$temp->add(new admin_setting_configselect('mailnewline', get_string('mailnewline', 'admin'), get_string('configmailnewline','admin'), 'LF', $options));
  20
+// "supportcontact" settingpage
  21
+$temp = new admin_settingpage('supportcontact', get_string('supportcontact','admin'));
60 22
 if (isloggedin()) {
61 23
     global $USER;
62 24
     $primaryadminemail = $USER->email;
@@ -73,17 +35,6 @@
73 35
 $ADMIN->add('server', $temp);
74 36
 
75 37
 
76  
-// Jabber settingpage
77  
-$temp = new admin_settingpage('jabber', get_string('jabber', 'admin'));
78  
-$temp->add(new admin_setting_configtext('jabberhost', get_string('jabberhost', 'admin'), get_string('configjabberhost', 'admin'), '', PARAM_RAW));
79  
-$temp->add(new admin_setting_configtext('jabberserver', get_string('jabberserver', 'admin'), get_string('configjabberserver', 'admin'), '', PARAM_RAW));
80  
-$temp->add(new admin_setting_configtext('jabberusername', get_string('jabberusername', 'admin'), get_string('configjabberusername', 'admin'), '', PARAM_RAW));
81  
-$temp->add(new admin_setting_configpasswordunmask('jabberpassword', get_string('jabberpassword', 'admin'), get_string('configjabberpassword', 'admin'), ''));
82  
-$temp->add(new admin_setting_configtext('jabberport', get_string('jabberport', 'admin'), get_string('configjabberport', 'admin'), 5222, PARAM_INT));
83  
-$ADMIN->add('server', $temp);
84  
-
85  
-
86  
-
87 38
 // "sessionhandling" settingpage
88 39
 $temp = new admin_settingpage('sessionhandling', get_string('sessionhandling', 'admin'));
89 40
 $temp->add(new admin_setting_configcheckbox('dbsessions', get_string('dbsessions', 'admin'), get_string('configdbsessions', 'admin'), 1));
4  admin/webservice/service_user_settings.php
@@ -33,7 +33,7 @@
33 33
 admin_externalpage_setup('externalserviceusersettings');
34 34
 
35 35
 //define nav bar
36  
-$PAGE->set_url('/' . $CFG->admin . '/webservice/service_user_settings.php', 
  36
+$PAGE->set_url('/' . $CFG->admin . '/webservice/service_user_settings.php',
37 37
         array('id' => $serviceid, 'userid'  => $userid));
38 38
 $node = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING);
39 39
 if ($node) {
@@ -62,7 +62,7 @@
62 62
     $serviceuserinfo->id = $serviceuser->serviceuserid;
63 63
     $serviceuserinfo->iprestriction = $settingsformdata->iprestriction;
64 64
     $serviceuserinfo->validuntil = $settingsformdata->validuntil;
65  
-    
  65
+
66 66
     $webservicemanager->update_ws_authorised_user($serviceuserinfo);
67 67
 
68 68
     //TODO: assign capability
4  admin/webservice/testclient.php
@@ -37,7 +37,7 @@
37 37
 $PAGE->navbar->ignore_active(true);
38 38
 $PAGE->navbar->add(get_string('administrationsite'));
39 39
 $PAGE->navbar->add(get_string('development', 'admin'));
40  
-$PAGE->navbar->add(get_string('testclient', 'webservice'), 
  40
+$PAGE->navbar->add(get_string('testclient', 'webservice'),
41 41
         new moodle_url('/' . $CFG->admin . '/webservice/testclient.php'));
42 42
 if (!empty($function)) {
43 43
     $PAGE->navbar->add($function);
@@ -169,4 +169,4 @@
169 169
     $mform->display();
170 170
     echo $OUTPUT->footer();
171 171
     die;
172  
-}
  172
+}
2  admin/webservice/tokens.php
@@ -94,7 +94,7 @@
94 94
         die;
95 95
         break;
96 96
 
97  
-    case 'delete':        
  97
+    case 'delete':
98 98
         $token = $webservicemanager->get_created_by_user_ws_token($USER->id, $tokenid);
99 99
 
100 100
         //Delete the token
3  backup/moodle2/backup_qtype_plugin.class.php
@@ -111,8 +111,7 @@ protected function add_question_numerical_options($element) {
111 111
         // Define the elements
112 112
         $options = new backup_nested_element('numerical_options');
113 113
         $option = new backup_nested_element('numerical_option', array('id'), array(
114  
-            'instructions', 'instructionsformat', 'showunits', 'unitsleft',
115  
-            'unitgradingtype', 'unitpenalty'));
  114
+            'showunits', 'unitsleft', 'unitgradingtype', 'unitpenalty'));
116 115
 
117 116
         // Build the tree
118 117
         $element->add_child($options);
117  backup/moodle2/backup_stepslib.php
@@ -174,78 +174,76 @@ protected function prepare_activity_structure($activitystructure) {
174 174
 
175 175
     /**
176 176
      * Attach to $element (usually attempts) the needed backup structures
177  
-     * for question_states for a given question_attempt
  177
+     * for question_usages and all the associated data.
178 178
      */
179  
-    protected function add_question_attempts_states($element, $questionattemptname) {
  179
+    protected function add_question_usages($element, $usageidname) {
  180
+        global $CFG;
  181
+        require_once($CFG->dirroot . '/question/engine/lib.php');
  182
+
180 183
         // Check $element is one nested_backup_element
181 184
         if (! $element instanceof backup_nested_element) {
182 185
             throw new backup_step_exception('question_states_bad_parent_element', $element);
183 186
         }
184  
-        // Check that the $questionattemptname is final element in $element
185  
-        if (! $element->get_final_element($questionattemptname)) {
186  
-            throw new backup_step_exception('question_states_bad_question_attempt_element', $questionattemptname);
  187
+        if (! $element->get_final_element($usageidname)) {
  188
+            throw new backup_step_exception('question_states_bad_question_attempt_element', $usageidname);
187 189
         }
188 190
 
189  
-        // TODO: Some day we should stop these "encrypted" state->answers and
190  
-        // TODO: delegate to qtypes plugin to proper XML writting the needed info on each question
191  
-
192  
-        // TODO: Should be doing here some introspection in the "answer" element, based on qtype,
193  
-        // TODO: to know which real questions are being used (for randoms and other qtypes...)
194  
-        // TODO: Not needed if consistency is guaranteed, but it isn't right now :-(
  191
+        $quba = new backup_nested_element('question_usage', array('id'),
  192
+                array('component', 'preferredbehaviour'));
195 193
 
196  
-        // Define the elements
197  
-        $states = new backup_nested_element('states');
198  
-        $state = new backup_nested_element('state', array('id'), array(
199  
-            'question', 'seq_number', 'answer', 'timestamp',
200  
-            'event', 'grade', 'raw_grade', 'penalty'));
  194
+        $qas = new backup_nested_element('question_attempts');
  195
+        $qa = new backup_nested_element('question_attempt', array('id'), array(
  196
+                'slot', 'behaviour', 'questionid', 'maxmark', 'minfraction',
  197
+                'flagged', 'questionsummary', 'rightanswer', 'responsesummary',
  198
+                'timemodified'));
201 199
 
202  
-        // Build the tree
203  
-        $element->add_child($states);
204  
-        $states->add_child($state);
205  
-
206  
-        // Set the sources
207  
-        $state->set_source_table('question_states', array('attempt' => '../../' . $questionattemptname));
  200
+        $steps = new backup_nested_element('steps');
  201
+        $step = new backup_nested_element('step', array('id'), array(
  202
+                'sequencenumber', 'state', 'fraction', 'timecreated', 'userid'));
208 203
 
209  
-        // Annotate ids
210  
-        $state->annotate_ids('question', 'question');
211  
-    }
212  
-
213  
-    /**
214  
-     * Attach to $element (usually attempts) the needed backup structures
215  
-     * for question_sessions for a given question_attempt
216  
-     */
217  
-    protected function add_question_attempts_sessions($element, $questionattemptname) {
218  
-        // Check $element is one nested_backup_element
219  
-        if (! $element instanceof backup_nested_element) {
220  
-            throw new backup_step_exception('question_sessions_bad_parent_element', $element);
221  
-        }
222  
-        // Check that the $questionattemptname is final element in $element
223  
-        if (! $element->get_final_element($questionattemptname)) {
224  
-            throw new backup_step_exception('question_sessions_bad_question_attempt_element', $questionattemptname);
225  
-        }
226  
-
227  
-        // Define the elements
228  
-        $sessions = new backup_nested_element('sessions');
229  
-        $session = new backup_nested_element('session', array('id'), array(
230  
-            'questionid', 'newest', 'newgraded', 'sumpenalty',
231  
-            'manualcomment', 'manualcommentformat', 'flagged'));
  204
+        $response = new backup_nested_element('response');
  205
+        $variable = new backup_nested_element('variable', null,  array('name', 'value'));
232 206
 
233 207
         // Build the tree
234  
-        $element->add_child($sessions);
235  
-        $sessions->add_child($session);
  208
+        $element->add_child($quba);
  209
+        $quba->add_child($qas);
  210
+        $qas->add_child($qa);
  211
+        $qa->add_child($steps);
  212
+        $steps->add_child($step);
  213
+        $step->add_child($response);
  214
+        $response->add_child($variable);
236 215
 
237 216
         // Set the sources
238  
-        $session->set_source_table('question_sessions', array('attemptid' => '../../' . $questionattemptname));
  217
+        $quba->set_source_table('question_usages',
  218
+                array('id'                => '../' . $usageidname));
  219
+        $qa->set_source_sql('
  220
+                SELECT *
  221
+                FROM {question_attempts}
  222
+                WHERE questionusageid = :questionusageid
  223
+                ORDER BY slot',
  224
+                array('questionusageid'   => backup::VAR_PARENTID));
  225
+        $step->set_source_sql('
  226
+                SELECT *
  227
+                FROM {question_attempt_steps}
  228
+                WHERE questionattemptid = :questionattemptid
  229
+                ORDER BY sequencenumber',
  230
+                array('questionattemptid' => backup::VAR_PARENTID));
  231
+        $variable->set_source_table('question_attempt_step_data',
  232
+                array('attemptstepid'     => backup::VAR_PARENTID));
239 233
 
240 234
         // Annotate ids
241  
-        $session->annotate_ids('question', 'questionid');
  235
+        $qa->annotate_ids('question', 'questionid');
  236
+        $step->annotate_ids('user', 'userid');
242 237
 
243 238
         // Annotate files
244  
-        // Note: question_sessions haven't files associated. On purpose manualcomment is lacking
245  
-        // support for them, so we don't need to annotated them here.
  239
+        $fileareas = question_engine::get_all_response_file_areas();
  240
+        foreach ($fileareas as $filearea) {
  241
+            $step->annotate_files('question', $filearea, 'id');
  242
+        }
246 243
     }
247