MDL-29509 move qeupgradehelper to admin tools
authorPetr Skoda <commits@skodak.org>
Sun, 25 Sep 2011 10:20:01 +0000 (12:20 +0200)
committerPetr Skoda <commits@skodak.org>
Mon, 26 Sep 2011 22:39:20 +0000 (00:39 +0200)
AMOS BEGIN
 MOV [action,local_qeupgradehelper],[action,tool_qeupgradehelper]
 MOV [alreadydone,local_qeupgradehelper],[alreadydone,tool_qeupgradehelper]
 MOV [areyousure,local_qeupgradehelper],[areyousure,tool_qeupgradehelper]
 MOV [areyousuremessage,local_qeupgradehelper],[areyousuremessage,tool_qeupgradehelper]
 MOV [areyousureresetmessage,local_qeupgradehelper],[areyousureresetmessage,tool_qeupgradehelper]
 MOV [attemptstoconvert,local_qeupgradehelper],[attemptstoconvert,tool_qeupgradehelper]
 MOV [backtoindex,local_qeupgradehelper],[backtoindex,tool_qeupgradehelper]
 MOV [conversioncomplete,local_qeupgradehelper],[conversioncomplete,tool_qeupgradehelper]
 MOV [convertattempts,local_qeupgradehelper],[convertattempts,tool_qeupgradehelper]
 MOV [convertquiz,local_qeupgradehelper],[convertquiz,tool_qeupgradehelper]
 MOV [convertedattempts,local_qeupgradehelper],[convertedattempts,tool_qeupgradehelper]
 MOV [cronenabled,local_qeupgradehelper],[cronenabled,tool_qeupgradehelper]
 MOV [croninstructions,local_qeupgradehelper],[croninstructions,tool_qeupgradehelper]
 MOV [cronprocesingtime,local_qeupgradehelper],[cronprocesingtime,tool_qeupgradehelper]
 MOV [cronsetup,local_qeupgradehelper],[cronsetup,tool_qeupgradehelper]
 MOV [cronsetup_desc,local_qeupgradehelper],[cronsetup_desc,tool_qeupgradehelper]
 MOV [cronstarthour,local_qeupgradehelper],[cronstarthour,tool_qeupgradehelper]
 MOV [cronstophour,local_qeupgradehelper],[cronstophour,tool_qeupgradehelper]
 MOV [extracttestcase,local_qeupgradehelper],[extracttestcase,tool_qeupgradehelper]
 MOV [extracttestcase_desc,local_qeupgradehelper],[extracttestcase_desc,tool_qeupgradehelper]
 MOV [gotoindex,local_qeupgradehelper],[gotoindex,tool_qeupgradehelper]
 MOV [gotoquizreport,local_qeupgradehelper],[gotoquizreport,tool_qeupgradehelper]
 MOV [gotoresetlink,local_qeupgradehelper],[gotoresetlink,tool_qeupgradehelper]
 MOV [includedintheupgrade,local_qeupgradehelper],[includedintheupgrade,tool_qeupgradehelper]
 MOV [invalidquizid,local_qeupgradehelper],[invalidquizid,tool_qeupgradehelper]
 MOV [listpreupgrade,local_qeupgradehelper],[listpreupgrade,tool_qeupgradehelper]
 MOV [listpreupgrade_desc,local_qeupgradehelper],[listpreupgrade_desc,tool_qeupgradehelper]
 MOV [listpreupgradeintro,local_qeupgradehelper],[listpreupgradeintro,tool_qeupgradehelper]
 MOV [listtodo,local_qeupgradehelper],[listtodo,tool_qeupgradehelper]
 MOV [listtodo_desc,local_qeupgradehelper],[listtodo_desc,tool_qeupgradehelper]
 MOV [listtodointro,local_qeupgradehelper],[listtodointro,tool_qeupgradehelper]
 MOV [listupgraded,local_qeupgradehelper],[listupgraded,tool_qeupgradehelper]
 MOV [listupgraded_desc,local_qeupgradehelper],[listupgraded_desc,tool_qeupgradehelper]
 MOV [listupgradedintro,local_qeupgradehelper],[listupgradedintro,tool_qeupgradehelper]
 MOV [noquizattempts,local_qeupgradehelper],[noquizattempts,tool_qeupgradehelper]
 MOV [nothingupgradedyet,local_qeupgradehelper],[nothingupgradedyet,tool_qeupgradehelper]
 MOV [notupgradedsiterequired,local_qeupgradehelper],[notupgradedsiterequired,tool_qeupgradehelper]
 MOV [numberofattempts,local_qeupgradehelper],[numberofattempts,tool_qeupgradehelper]
 MOV [oldsitedetected,local_qeupgradehelper],[oldsitedetected,tool_qeupgradehelper]
 MOV [outof,local_qeupgradehelper],[outof,tool_qeupgradehelper]
 MOV [pluginname,local_qeupgradehelper],[pluginname,tool_qeupgradehelper]
 MOV [pretendupgrade,local_qeupgradehelper],[pretendupgrade,tool_qeupgradehelper]
 MOV [pretendupgrade_desc,local_qeupgradehelper],[pretendupgrade_desc,tool_qeupgradehelper]
 MOV [questionsessions,local_qeupgradehelper],[questionsessions,tool_qeupgradehelper]
 MOV [quizid,local_qeupgradehelper],[quizid,tool_qeupgradehelper]
 MOV [quizupgrade,local_qeupgradehelper],[quizupgrade,tool_qeupgradehelper]
 MOV [quizzesthatcanbereset,local_qeupgradehelper],[quizzesthatcanbereset,tool_qeupgradehelper]
 MOV [quizzestobeupgraded,local_qeupgradehelper],[quizzestobeupgraded,tool_qeupgradehelper]
 MOV [quizzeswithunconverted,local_qeupgradehelper],[quizzeswithunconverted,tool_qeupgradehelper]
 MOV [resetquiz,local_qeupgradehelper],[resetquiz,tool_qeupgradehelper]
 MOV [resetcomplete,local_qeupgradehelper],[resetcomplete,tool_qeupgradehelper]
 MOV [resettingquizattempts,local_qeupgradehelper],[resettingquizattempts,tool_qeupgradehelper]
 MOV [resettingquizattemptsprogress,local_qeupgradehelper],[resettingquizattemptsprogress,tool_qeupgradehelper]
 MOV [upgradingquizattempts,local_qeupgradehelper],[upgradingquizattempts,tool_qeupgradehelper]
 MOV [upgradedsitedetected,local_qeupgradehelper],[upgradedsitedetected,tool_qeupgradehelper]
 MOV [upgradedsiterequired,local_qeupgradehelper],[upgradedsiterequired,tool_qeupgradehelper]
 MOV [veryoldattemtps,local_qeupgradehelper],[veryoldattemtps,tool_qeupgradehelper]
AMOS END

23 files changed:
admin/tool/qeupgradehelper/README.txt [moved from local/qeupgradehelper/README.txt with 74% similarity]
admin/tool/qeupgradehelper/afterupgradelib.php [moved from local/qeupgradehelper/afterupgradelib.php with 96% similarity]
admin/tool/qeupgradehelper/convertquiz.php [moved from local/qeupgradehelper/convertquiz.php with 64% similarity]
admin/tool/qeupgradehelper/cronsetup.php [moved from local/qeupgradehelper/cronsetup.php with 53% similarity]
admin/tool/qeupgradehelper/cronsetup_form.php [moved from local/qeupgradehelper/cronsetup_form.php with 82% similarity]
admin/tool/qeupgradehelper/db/install.php [new file with mode: 0644]
admin/tool/qeupgradehelper/extracttestcase.php [moved from local/qeupgradehelper/extracttestcase.php with 75% similarity]
admin/tool/qeupgradehelper/extracttestcase_form.php [moved from local/qeupgradehelper/extracttestcase_form.php with 96% similarity]
admin/tool/qeupgradehelper/index.php [moved from local/qeupgradehelper/index.php with 63% similarity]
admin/tool/qeupgradehelper/lang/en/tool_qeupgradehelper.php [moved from local/qeupgradehelper/lang/en/local_qeupgradehelper.php with 99% similarity]
admin/tool/qeupgradehelper/lib.php [moved from local/qeupgradehelper/lib.php with 76% similarity]
admin/tool/qeupgradehelper/listpreupgrade.php [moved from local/qeupgradehelper/listpreupgrade.php with 67% similarity]
admin/tool/qeupgradehelper/listtodo.php [moved from local/qeupgradehelper/listtodo.php with 78% similarity]
admin/tool/qeupgradehelper/listupgraded.php [moved from local/qeupgradehelper/listupgraded.php with 78% similarity]
admin/tool/qeupgradehelper/locallib.php [moved from local/qeupgradehelper/locallib.php with 83% similarity]
admin/tool/qeupgradehelper/partialupgrade-example.php [moved from local/qeupgradehelper/partialupgrade-example.php with 92% similarity]
admin/tool/qeupgradehelper/renderer.php [moved from local/qeupgradehelper/renderer.php with 83% similarity]
admin/tool/qeupgradehelper/resetquiz.php [moved from local/qeupgradehelper/resetquiz.php with 64% similarity]
admin/tool/qeupgradehelper/settings.php [moved from local/qeupgradehelper/settings.php with 87% similarity]
admin/tool/qeupgradehelper/styles.css [new file with mode: 0644]
admin/tool/qeupgradehelper/version.php [moved from local/qeupgradehelper/version.php with 83% similarity]
lib/pluginlib.php
local/qeupgradehelper/styles.css [deleted file]

similarity index 74%
rename from local/qeupgradehelper/README.txt
rename to admin/tool/qeupgradehelper/README.txt
index 6167e35..ce0825b 100644 (file)
@@ -5,17 +5,6 @@ With a lot of question attempts, doing the whole conversion on upgrade is very
 slow. The plugin can help with that in various ways.
 
 
-To install using git, type this command in the root of your Moodle install
-    git clone git://github.com/timhunt/moodle-local_qeupgradehelper.git local/qeupgradehelper
-Then add /local/qeupgradehelper to your git ignore.
-
-Alternatively, download the zip from
-    https://github.com/timhunt/moodle-local_qeupgradehelper/zipball/master
-unzip it into the local folder, and then rename the new folder to qeupgradehelper.
-
-
-When installed in a Moodle 2.0 site:
-
 1. It provies a report of how much data there is to upgrade.
 
 2. It can extract test-cases from the database. This can help you report bugs
similarity index 96%
rename from local/qeupgradehelper/afterupgradelib.php
rename to admin/tool/qeupgradehelper/afterupgradelib.php
index f6dce5d..5aeb316 100644 (file)
  * Question engine upgrade helper library code that relies on other parts of the
  * new question engine code.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+defined('MOODLE_INTERNAL') || die;
 
 require_once($CFG->dirroot . '/question/engine/upgrade/upgradelib.php');
 
 
-class local_qeupgradehelper_attempt_upgrader extends question_engine_attempt_upgrader {
+class tool_qeupgradehelper_attempt_upgrader extends question_engine_attempt_upgrader {
     public $quizid;
     public $attemptsdone = 0;
     public $attemptstodo;
@@ -62,7 +63,7 @@ class local_qeupgradehelper_attempt_upgrader extends question_engine_attempt_upg
         $a->done = $done;
         $a->outof = $outof;
         $this->progressbar->update($done, $outof,
-                get_string('resettingquizattemptsprogress', 'local_qeupgradehelper', $a));
+                get_string('resettingquizattemptsprogress', 'tool_qeupgradehelper', $a));
     }
 
     protected function get_resettable_attempts($quiz) {
similarity index 64%
rename from local/qeupgradehelper/convertquiz.php
rename to admin/tool/qeupgradehelper/convertquiz.php
index 69636b7..f4176fc 100644 (file)
 /**
  * Script to upgrade the attempts at a particular quiz, after confirmation.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once(dirname(__FILE__) . '/afterupgradelib.php');
 require_once($CFG->libdir . '/adminlib.php');
@@ -34,20 +34,20 @@ $confirmed = optional_param('confirmed', false, PARAM_BOOL);
 
 require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-local_qeupgradehelper_require_upgraded();
+tool_qeupgradehelper_require_upgraded();
 
 admin_externalpage_setup('qeupgradehelper', '', array(),
-        local_qeupgradehelper_url('convertquiz', array('quizid' => $quizid)));
-$PAGE->navbar->add(get_string('listtodo', 'local_qeupgradehelper'),
-        local_qeupgradehelper_url('listtodo'));
-$PAGE->navbar->add(get_string('convertattempts', 'local_qeupgradehelper'));
+        tool_qeupgradehelper_url('convertquiz', array('quizid' => $quizid)));
+$PAGE->navbar->add(get_string('listtodo', 'tool_qeupgradehelper'),
+        tool_qeupgradehelper_url('listtodo'));
+$PAGE->navbar->add(get_string('convertattempts', 'tool_qeupgradehelper'));
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
-$quizsummary = local_qeupgradehelper_get_quiz($quizid);
+$quizsummary = tool_qeupgradehelper_get_quiz($quizid);
 if (!$quizsummary) {
-    print_error('invalidquizid', 'local_qeupgradehelper',
-            local_qeupgradehelper_url('listtodo'));
+    print_error('invalidquizid', 'tool_qeupgradehelper',
+            tool_qeupgradehelper_url('listtodo'));
 }
 
 $quizsummary->name = format_string($quizsummary->name);
@@ -56,18 +56,18 @@ if ($confirmed && data_submitted() && confirm_sesskey()) {
     // Actually do the conversion.
     echo $renderer->header();
     echo $renderer->heading(get_string(
-            'upgradingquizattempts', 'local_qeupgradehelper', $quizsummary));
+            'upgradingquizattempts', 'tool_qeupgradehelper', $quizsummary));
 
-    $upgrader = new local_qeupgradehelper_attempt_upgrader(
+    $upgrader = new tool_qeupgradehelper_attempt_upgrader(
             $quizsummary->id, $quizsummary->numtoconvert);
     $upgrader->convert_all_quiz_attempts();
 
-    echo $renderer->heading(get_string('conversioncomplete', 'local_qeupgradehelper'));
+    echo $renderer->heading(get_string('conversioncomplete', 'tool_qeupgradehelper'));
     echo $renderer->end_of_page_link(
             new moodle_url('/mod/quiz/report.php', array('q' => $quizsummary->id)),
-            get_string('gotoquizreport', 'local_qeupgradehelper'));
-    echo $renderer->end_of_page_link(local_qeupgradehelper_url('listtodo'),
-            get_string('listtodo', 'local_qeupgradehelper'));
+            get_string('gotoquizreport', 'tool_qeupgradehelper'));
+    echo $renderer->end_of_page_link(tool_qeupgradehelper_url('listtodo'),
+            get_string('listtodo', 'tool_qeupgradehelper'));
 
     echo $renderer->footer();
     exit;
similarity index 53%
rename from local/qeupgradehelper/cronsetup.php
rename to admin/tool/qeupgradehelper/cronsetup.php
index e89958a..58280a9 100644 (file)
 /**
  * Script to set up cron to complete the upgrade automatically.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once(dirname(__FILE__) . '/cronsetup_form.php');
 require_once($CFG->libdir . '/adminlib.php');
@@ -33,37 +33,37 @@ require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
 
 admin_externalpage_setup('qeupgradehelper', '', array(),
-        local_qeupgradehelper_url('cronsetup'));
-$PAGE->navbar->add(get_string('cronsetup', 'local_qeupgradehelper'));
+        tool_qeupgradehelper_url('cronsetup'));
+$PAGE->navbar->add(get_string('cronsetup', 'tool_qeupgradehelper'));
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
-$form = new local_qeupgradehelper_cron_setup_form(
-        new moodle_url('/local/qeupgradehelper/cronsetup.php'));
-$form->set_data(get_config('local_qeupgradehelper'));
+$form = new tool_qeupgradehelper_cron_setup_form(
+        new moodle_url('/admin/tool/qeupgradehelper/cronsetup.php'));
+$form->set_data(get_config('tool_qeupgradehelper'));
 
 if ($form->is_cancelled()) {
-    redirect(local_qeupgradehelper_url('index'));
+    redirect(tool_qeupgradehelper_url('index'));
 
 } else if ($fromform = $form->get_data()) {
     if ($fromform->cronenabled) {
-        set_config('cronenabled', $fromform->cronenabled, 'local_qeupgradehelper');
-        set_config('starthour', $fromform->starthour, 'local_qeupgradehelper');
-        set_config('stophour', $fromform->stophour, 'local_qeupgradehelper');
-        set_config('procesingtime', $fromform->procesingtime, 'local_qeupgradehelper');
+        set_config('cronenabled', $fromform->cronenabled, 'tool_qeupgradehelper');
+        set_config('starthour', $fromform->starthour, 'tool_qeupgradehelper');
+        set_config('stophour', $fromform->stophour, 'tool_qeupgradehelper');
+        set_config('procesingtime', $fromform->procesingtime, 'tool_qeupgradehelper');
 
     } else {
-        unset_config('cronenabled', 'local_qeupgradehelper');
-        unset_config('starthour', 'local_qeupgradehelper');
-        unset_config('stophour', 'local_qeupgradehelper');
-        unset_config('procesingtime', 'local_qeupgradehelper');
+        unset_config('cronenabled', 'tool_qeupgradehelper');
+        unset_config('starthour', 'tool_qeupgradehelper');
+        unset_config('stophour', 'tool_qeupgradehelper');
+        unset_config('procesingtime', 'tool_qeupgradehelper');
     }
-    redirect(local_qeupgradehelper_url('index'));
+    redirect(tool_qeupgradehelper_url('index'));
 
 }
 
 echo $renderer->header();
-echo $renderer->heading(get_string('cronsetup', 'local_qeupgradehelper'));
-echo $renderer->box(get_string('croninstructions', 'local_qeupgradehelper'));
+echo $renderer->heading(get_string('cronsetup', 'tool_qeupgradehelper'));
+echo $renderer->box(get_string('croninstructions', 'tool_qeupgradehelper'));
 $form->display();
 echo $renderer->footer();
similarity index 82%
rename from local/qeupgradehelper/cronsetup_form.php
rename to admin/tool/qeupgradehelper/cronsetup_form.php
index affd7d0..ec41f8e 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * Settings form for cronsetup.php.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2011 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -34,23 +34,23 @@ require_once($CFG->libdir . '/formslib.php');
  * @copyright  2011 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_cron_setup_form extends moodleform {
+class tool_qeupgradehelper_cron_setup_form extends moodleform {
     public function definition() {
         $mform = $this->_form;
 
         $mform->addElement('selectyesno', 'cronenabled',
-                get_string('cronenabled', 'local_qeupgradehelper'));
+                get_string('cronenabled', 'tool_qeupgradehelper'));
 
         $mform->addElement('select', 'starthour',
-                get_string('cronstarthour', 'local_qeupgradehelper'), range(0, 23));
+                get_string('cronstarthour', 'tool_qeupgradehelper'), range(0, 23));
 
         $mform->addElement('select', 'stophour',
-                get_string('cronstophour', 'local_qeupgradehelper'),
+                get_string('cronstophour', 'tool_qeupgradehelper'),
                 array_combine(range(1, 24), range(1, 24)));
         $mform->setDefault('stophour', 24);
 
         $mform->addElement('duration', 'procesingtime',
-                get_string('cronprocesingtime', 'local_qeupgradehelper'));
+                get_string('cronprocesingtime', 'tool_qeupgradehelper'));
         $mform->setDefault('procesingtime', 60);
 
         $mform->disabledIf('starthour', 'cronenabled', 'eq', 0);
diff --git a/admin/tool/qeupgradehelper/db/install.php b/admin/tool/qeupgradehelper/db/install.php
new file mode 100644 (file)
index 0000000..c77ba2c
--- /dev/null
@@ -0,0 +1,38 @@
+<?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/>.
+
+/**
+ * Post installation and migration code.
+ *
+ * @package    tool
+ * @subpackage qeupgradehelper
+ * @copyright  2011 Petr Skoda {@link http://skodak.org}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+function xmldb_tool_qeupgradehelper_install() {
+    global $CFG;
+
+    // this is a hack - this plugin used to live in local/qeupgradehelper,
+    // we want to remove the orphaned version info and capability
+    // unless there is a local plugin type with the same name
+
+    if (!file_exists("$CFG->dirroot/local/qeupgradehelper")) {
+        unset_all_config_for_plugin('local_qeupgradehelper');
+    }
+}
similarity index 75%
rename from local/qeupgradehelper/extracttestcase.php
rename to admin/tool/qeupgradehelper/extracttestcase.php
index 4cbc5cb..d67fe65 100644 (file)
  * database from backup, and then use this script to extract the problem case
  * as a unit test. Then you can fix that unit tests. Then you can repeat the upgrade.)
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2009 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once(dirname(__FILE__) . '/extracttestcase_form.php');
 require_once($CFG->libdir . '/questionlib.php');
@@ -40,31 +40,31 @@ require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
 
 admin_externalpage_setup('qeupgradehelper', '', array(),
-        local_qeupgradehelper_url('extracttestcase'));
-$PAGE->navbar->add(get_string('extracttestcase', 'local_qeupgradehelper'));
+        tool_qeupgradehelper_url('extracttestcase'));
+$PAGE->navbar->add(get_string('extracttestcase', 'tool_qeupgradehelper'));
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
-$mform = new local_qeupgradehelper_extract_options_form(
-        new moodle_url('/local/qeupgradehelper/extracttestcase.php'), null, 'get');
+$mform = new tool_qeupgradehelper_extract_options_form(
+        new moodle_url('/admin/tool/qeupgradehelper/extracttestcase.php'), null, 'get');
 
 echo $OUTPUT->header();
 if ($fromform = $mform->get_data()) {
     $qsid = null;
     if (!empty($fromform->attemptid) && !empty($fromform->questionid)) {
-        $qsid = local_qeupgradehelper_get_session_id($fromform->attemptid, $fromform->questionid);
+        $qsid = tool_qeupgradehelper_get_session_id($fromform->attemptid, $fromform->questionid);
         $name = 'qsession' . $qsid;
 
     } else if (!empty($fromform->statehistory)) {
         notify('Searching ...', 'notifysuccess');
         flush();
-        $qsid = local_qeupgradehelper_find_test_case($fromform->behaviour, $fromform->statehistory,
+        $qsid = tool_qeupgradehelper_find_test_case($fromform->behaviour, $fromform->statehistory,
                 $fromform->qtype, $fromform->extratests);
         $name = 'history' . $fromform->statehistory;
     }
 
     if ($qsid) {
-        local_qeupgradehelper_generate_unit_test($qsid, $name);
+        tool_qeupgradehelper_generate_unit_test($qsid, $name);
     } else {
         notify('No suitable attempts found.');
     }
@@ -17,7 +17,7 @@
 /**
  * Settings form for extracttestcase.php.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2009 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -34,7 +34,7 @@ require_once($CFG->libdir . '/formslib.php');
  * @copyright  2009 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_extract_options_form extends moodleform {
+class tool_qeupgradehelper_extract_options_form extends moodleform {
     public function definition() {
         $mform = $this->_form;
 
similarity index 63%
rename from local/qeupgradehelper/index.php
rename to admin/tool/qeupgradehelper/index.php
index 4973871..2fe2642 100644 (file)
  * This screen is the main entry-point to the plugin, it gives the admin a list
  * of options available to them.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once($CFG->libdir . '/adminlib.php');
 
@@ -35,21 +35,21 @@ require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
 admin_externalpage_setup('qeupgradehelper');
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
 $actions = array();
-if (local_qeupgradehelper_is_upgraded()) {
-    $detected = get_string('upgradedsitedetected', 'local_qeupgradehelper');
-    $actions[] = local_qeupgradehelper_action::make('listtodo');
-    $actions[] = local_qeupgradehelper_action::make('listupgraded');
-    $actions[] = local_qeupgradehelper_action::make('extracttestcase');
-    $actions[] = local_qeupgradehelper_action::make('cronsetup');
+if (tool_qeupgradehelper_is_upgraded()) {
+    $detected = get_string('upgradedsitedetected', 'tool_qeupgradehelper');
+    $actions[] = tool_qeupgradehelper_action::make('listtodo');
+    $actions[] = tool_qeupgradehelper_action::make('listupgraded');
+    $actions[] = tool_qeupgradehelper_action::make('extracttestcase');
+    $actions[] = tool_qeupgradehelper_action::make('cronsetup');
 
 } else {
-    $detected = get_string('oldsitedetected', 'local_qeupgradehelper');
-    $actions[] = local_qeupgradehelper_action::make('listpreupgrade');
-    $actions[] = local_qeupgradehelper_action::make('extracttestcase');
-    $actions[] = local_qeupgradehelper_action::make('cronsetup');
+    $detected = get_string('oldsitedetected', 'tool_qeupgradehelper');
+    $actions[] = tool_qeupgradehelper_action::make('listpreupgrade');
+    $actions[] = tool_qeupgradehelper_action::make('extracttestcase');
+    $actions[] = tool_qeupgradehelper_action::make('cronsetup');
 }
 
 echo $renderer->index_page($detected, $actions);
@@ -17,7 +17,7 @@
 /**
  * Question engine upgrade helper langauge strings.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
similarity index 76%
rename from local/qeupgradehelper/lib.php
rename to admin/tool/qeupgradehelper/lib.php
index 7441375..a6fc034 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
  * Lib functions (cron) to automatically complete the question engine upgrade
  * if it was not done all at once during the main upgrade.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2011 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+defined('MOODLE_INTERNAL') || die;
+
 /**
  * Standard cron function
  */
-function local_qeupgradehelper_cron() {
-    $settings = get_config('local_qeupgradehelper');
+function tool_qeupgradehelper_cron() {
+    $settings = get_config('tool_qeupgradehelper');
     if (empty($settings->cronenabled)) {
         return;
     }
 
-    mtrace('qeupgradehelper: local_qeupgradehelper_cron() started at '. date('H:i:s'));
+    mtrace('qeupgradehelper: tool_qeupgradehelper_cron() started at '. date('H:i:s'));
     try {
-        local_qeupgradehelper_process($settings);
+        tool_qeupgradehelper_process($settings);
     } catch (Exception $e) {
-        mtrace('qeupgradehelper: local_qeupgradehelper_cron() failed with an exception:');
+        mtrace('qeupgradehelper: tool_qeupgradehelper_cron() failed with an exception:');
         mtrace($e->getMessage());
     }
-    mtrace('qeupgradehelper: local_qeupgradehelper_cron() finished at ' . date('H:i:s'));
+    mtrace('qeupgradehelper: tool_qeupgradehelper_cron() finished at ' . date('H:i:s'));
 }
 
 /**
  * This function does the cron process within the time range according to settings.
  */
-function local_qeupgradehelper_process($settings) {
+function tool_qeupgradehelper_process($settings) {
     global $CFG;
     require_once(dirname(__FILE__) . '/locallib.php');
 
-    if (!local_qeupgradehelper_is_upgraded()) {
+    if (!tool_qeupgradehelper_is_upgraded()) {
         mtrace('qeupgradehelper: site not yet upgraded. Doing nothing.');
         return;
     }
@@ -70,17 +71,17 @@ function local_qeupgradehelper_process($settings) {
     mtrace('qeupgradehelper: processing ...');
     while (time() < $stoptime) {
 
-        $quiz = local_qeupgradehelper_get_quiz_for_upgrade();
+        $quiz = tool_qeupgradehelper_get_quiz_for_upgrade();
         if (!$quiz) {
             mtrace('qeupgradehelper: No more quizzes to process. You should probably disable the qeupgradehelper cron settings now.');
             break; // No more to do;
         }
 
         $quizid = $quiz->id;
-        $quizsummary = local_qeupgradehelper_get_quiz($quizid);
+        $quizsummary = tool_qeupgradehelper_get_quiz($quizid);
         if ($quizsummary) {
             mtrace('  starting upgrade of attempts at quiz ' . $quizid);
-            $upgrader = new local_qeupgradehelper_attempt_upgrader(
+            $upgrader = new tool_qeupgradehelper_attempt_upgrader(
                     $quizsummary->id, $quizsummary->numtoconvert);
             $upgrader->convert_all_quiz_attempts();
             mtrace('  upgrade of quiz ' . $quizid . ' complete.');
similarity index 67%
rename from local/qeupgradehelper/listpreupgrade.php
rename to admin/tool/qeupgradehelper/listpreupgrade.php
index e70f04b..e243dc3 100644 (file)
  * Script to show all the quizzes in the site with how many attempts they have
  * that will need to be upgraded.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once($CFG->libdir . '/adminlib.php');
 
 require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-local_qeupgradehelper_require_not_upgraded();
+tool_qeupgradehelper_require_not_upgraded();
 
-admin_externalpage_setup('qeupgradehelper', '', array(), local_qeupgradehelper_url(''));
-$PAGE->navbar->add(get_string('listpreupgrade', 'local_qeupgradehelper'));
+admin_externalpage_setup('qeupgradehelper', '', array(), tool_qeupgradehelper_url(''));
+$PAGE->navbar->add(get_string('listpreupgrade', 'tool_qeupgradehelper'));
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
-$quizzes = new local_qeupgradehelper_pre_upgrade_quiz_list();
+$quizzes = new tool_qeupgradehelper_pre_upgrade_quiz_list();
 
 // Look to see if the admin has set things up to only upgrade certain attempts.
-$partialupgradefile = $CFG->dirroot . '/local/qeupgradehelper/partialupgrade.php';
-$partialupgradefunction = 'local_qeupgradehelper_get_quizzes_to_upgrade';
+$partialupgradefile = $CFG->dirroot . '/' . $CFG->admin . '/tool/qeupgradehelper/partialupgrade.php';
+$partialupgradefunction = 'tool_qeupgradehelper_get_quizzes_to_upgrade';
 if (is_readable($partialupgradefile)) {
     include_once($partialupgradefile);
     if (function_exists($partialupgradefunction)) {
-        $quizzes = new local_qeupgradehelper_pre_upgrade_quiz_list_restricted(
+        $quizzes = new tool_qeupgradehelper_pre_upgrade_quiz_list_restricted(
                 $partialupgradefunction());
     }
 }
 
-$numveryoldattemtps = local_qeupgradehelper_get_num_very_old_attempts();
+$numveryoldattemtps = tool_qeupgradehelper_get_num_very_old_attempts();
 
 if ($quizzes->is_empty()) {
-    echo $renderer->simple_message_page(get_string('noquizattempts', 'local_qeupgradehelper'));
+    echo $renderer->simple_message_page(get_string('noquizattempts', 'tool_qeupgradehelper'));
 
 } else {
     echo $renderer->quiz_list_page($quizzes, $numveryoldattemtps);
similarity index 78%
rename from local/qeupgradehelper/listtodo.php
rename to admin/tool/qeupgradehelper/listtodo.php
index ae0a6ad..6e923ec 100644 (file)
  * Script to show all the quizzes with attempts that still need to be upgraded
  * after the main upgrade.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once($CFG->libdir . '/adminlib.php');
 
 require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-local_qeupgradehelper_require_upgraded();
+tool_qeupgradehelper_require_upgraded();
 
 admin_externalpage_setup('qeupgradehelper', '', array(),
-        local_qeupgradehelper_url('listtodo'));
-$PAGE->navbar->add(get_string('listtodo', 'local_qeupgradehelper'));
+        tool_qeupgradehelper_url('listtodo'));
+$PAGE->navbar->add(get_string('listtodo', 'tool_qeupgradehelper'));
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
-$quizzes = new local_qeupgradehelper_upgradable_quiz_list();
+$quizzes = new tool_qeupgradehelper_upgradable_quiz_list();
 
 if ($quizzes->is_empty()) {
-    echo $renderer->simple_message_page(get_string('alreadydone', 'local_qeupgradehelper'));
+    echo $renderer->simple_message_page(get_string('alreadydone', 'tool_qeupgradehelper'));
 
 } else {
     echo $renderer->quiz_list_page($quizzes);
similarity index 78%
rename from local/qeupgradehelper/listupgraded.php
rename to admin/tool/qeupgradehelper/listupgraded.php
index 9355ff9..8aa3dca 100644 (file)
  * after the main upgrade. With an option to reset the conversion, so it can be
  * re-done if necessary.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once($CFG->libdir . '/adminlib.php');
 
 require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-local_qeupgradehelper_require_upgraded();
+tool_qeupgradehelper_require_upgraded();
 
 admin_externalpage_setup('qeupgradehelper', '', array(),
-        local_qeupgradehelper_url('listupgraded'));
-$PAGE->navbar->add(get_string('listupgraded', 'local_qeupgradehelper'));
+        tool_qeupgradehelper_url('listupgraded'));
+$PAGE->navbar->add(get_string('listupgraded', 'tool_qeupgradehelper'));
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
-$quizzes = new local_qeupgradehelper_resettable_quiz_list();
+$quizzes = new tool_qeupgradehelper_resettable_quiz_list();
 
 if ($quizzes->is_empty()) {
-    echo $renderer->simple_message_page(get_string('nothingupgradedyet', 'local_qeupgradehelper'));
+    echo $renderer->simple_message_page(get_string('nothingupgradedyet', 'tool_qeupgradehelper'));
 
 } else {
     echo $renderer->quiz_list_page($quizzes);
similarity index 83%
rename from local/qeupgradehelper/locallib.php
rename to admin/tool/qeupgradehelper/locallib.php
index dabae54..7c001d4 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * Question engine upgrade helper library code.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
  * Detect whether this site has been upgraded to the new question engine yet.
  * @return bool whether the site has been upgraded.
  */
-function local_qeupgradehelper_is_upgraded() {
+function tool_qeupgradehelper_is_upgraded() {
     global $CFG, $DB;
     $dbman = $DB->get_manager();
     return is_readable($CFG->dirroot . '/question/engine/upgrade/upgradelib.php') &&
@@ -41,20 +41,20 @@ function local_qeupgradehelper_is_upgraded() {
 /**
  * If the site has not yet been upgraded, display an error.
  */
-function local_qeupgradehelper_require_upgraded() {
-    if (!local_qeupgradehelper_is_upgraded()) {
-        throw new moodle_exception('upgradedsiterequired', 'local_qeupgradehelper',
-                local_qeupgradehelper_url('index'));
+function tool_qeupgradehelper_require_upgraded() {
+    if (!tool_qeupgradehelper_is_upgraded()) {
+        throw new moodle_exception('upgradedsiterequired', 'tool_qeupgradehelper',
+                tool_qeupgradehelper_url('index'));
     }
 }
 
 /**
  * If the site has been upgraded, display an error.
  */
-function local_qeupgradehelper_require_not_upgraded() {
-    if (local_qeupgradehelper_is_upgraded()) {
-        throw new moodle_exception('notupgradedsiterequired', 'local_qeupgradehelper',
-                local_qeupgradehelper_url('index'));
+function tool_qeupgradehelper_require_not_upgraded() {
+    if (tool_qeupgradehelper_is_upgraded()) {
+        throw new moodle_exception('notupgradedsiterequired', 'tool_qeupgradehelper',
+                tool_qeupgradehelper_url('index'));
     }
 }
 
@@ -63,8 +63,8 @@ function local_qeupgradehelper_require_not_upgraded() {
  * @param string $script the script name, without .php. E.g. 'index'.
  * @param array $params URL parameters (optional).
  */
-function local_qeupgradehelper_url($script, $params = array()) {
-    return new moodle_url('/local/qeupgradehelper/' . $script . '.php', $params);
+function tool_qeupgradehelper_url($script, $params = array()) {
+    return new moodle_url('/admin/tool/qeupgradehelper/' . $script . '.php', $params);
 }
 
 
@@ -74,7 +74,7 @@ function local_qeupgradehelper_url($script, $params = array()) {
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_action {
+class tool_qeupgradehelper_action {
     /** @var string the name of this action. */
     public $name;
     /** @var moodle_url the URL to launch this action. */
@@ -99,9 +99,9 @@ class local_qeupgradehelper_action {
      */
     public static function make($shortname, $params = array()) {
         return new self(
-                get_string($shortname, 'local_qeupgradehelper'),
-                local_qeupgradehelper_url($shortname, $params),
-                get_string($shortname . '_desc', 'local_qeupgradehelper'));
+                get_string($shortname, 'tool_qeupgradehelper'),
+                tool_qeupgradehelper_url($shortname, $params),
+                get_string($shortname . '_desc', 'tool_qeupgradehelper'));
     }
 }
 
@@ -113,7 +113,7 @@ class local_qeupgradehelper_action {
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-abstract class local_qeupgradehelper_quiz_list {
+abstract class tool_qeupgradehelper_quiz_list {
     public $title;
     public $intro;
     public $quizacolheader;
@@ -124,9 +124,9 @@ abstract class local_qeupgradehelper_quiz_list {
 
     protected function __construct($title, $intro, $quizacolheader) {
         global $DB;
-        $this->title = get_string($title, 'local_qeupgradehelper');
-        $this->intro = get_string($intro, 'local_qeupgradehelper');
-        $this->quizacolheader = get_string($quizacolheader, 'local_qeupgradehelper');
+        $this->title = get_string($title, 'tool_qeupgradehelper');
+        $this->intro = get_string($intro, 'tool_qeupgradehelper');
+        $this->quizacolheader = get_string($quizacolheader, 'tool_qeupgradehelper');
         $this->build_sql();
         $this->quizlist = $DB->get_records_sql($this->sql);
     }
@@ -162,11 +162,11 @@ abstract class local_qeupgradehelper_quiz_list {
 
     public function get_col_headings() {
         return array(
-            get_string('quizid', 'local_qeupgradehelper'),
+            get_string('quizid', 'tool_qeupgradehelper'),
             get_string('course'),
             get_string('pluginname', 'quiz'),
             $this->quizacolheader,
-            get_string('questionsessions', 'local_qeupgradehelper'),
+            get_string('questionsessions', 'tool_qeupgradehelper'),
         );
     }
 
@@ -210,7 +210,7 @@ abstract class local_qeupgradehelper_quiz_list {
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_upgradable_quiz_list extends local_qeupgradehelper_quiz_list {
+class tool_qeupgradehelper_upgradable_quiz_list extends tool_qeupgradehelper_quiz_list {
     public function __construct() {
         parent::__construct('quizzeswithunconverted', 'listtodointro', 'attemptstoconvert');
     }
@@ -221,14 +221,14 @@ class local_qeupgradehelper_upgradable_quiz_list extends local_qeupgradehelper_q
 
     public function get_col_headings() {
         $headings = parent::get_col_headings();
-        $headings[] = get_string('action', 'local_qeupgradehelper');
+        $headings[] = get_string('action', 'tool_qeupgradehelper');
         return $headings;
     }
 
     public function get_row($quizinfo) {
         $row = parent::get_row($quizinfo);
-        $row[] = html_writer::link(local_qeupgradehelper_url('convertquiz', array('quizid' => $quizinfo->id)),
-                        get_string('convertquiz', 'local_qeupgradehelper'));
+        $row[] = html_writer::link(tool_qeupgradehelper_url('convertquiz', array('quizid' => $quizinfo->id)),
+                        get_string('convertquiz', 'tool_qeupgradehelper'));
         return $row;
     }
 }
@@ -240,7 +240,7 @@ class local_qeupgradehelper_upgradable_quiz_list extends local_qeupgradehelper_q
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_resettable_quiz_list extends local_qeupgradehelper_quiz_list {
+class tool_qeupgradehelper_resettable_quiz_list extends tool_qeupgradehelper_quiz_list {
     public function __construct() {
         parent::__construct('quizzesthatcanbereset', 'listupgradedintro', 'convertedattempts');
     }
@@ -253,14 +253,14 @@ class local_qeupgradehelper_resettable_quiz_list extends local_qeupgradehelper_q
 
     public function get_col_headings() {
         $headings = parent::get_col_headings();
-        $headings[] = get_string('action', 'local_qeupgradehelper');
+        $headings[] = get_string('action', 'tool_qeupgradehelper');
         return $headings;
     }
 
     public function get_row($quizinfo) {
         $row = parent::get_row($quizinfo);
-        $row[] = html_writer::link(local_qeupgradehelper_url('resetquiz', array('quizid' => $quizinfo->id)),
-                        get_string('resetquiz', 'local_qeupgradehelper'));
+        $row[] = html_writer::link(tool_qeupgradehelper_url('resetquiz', array('quizid' => $quizinfo->id)),
+                        get_string('resetquiz', 'tool_qeupgradehelper'));
         return $row;
     }
 }
@@ -272,7 +272,7 @@ class local_qeupgradehelper_resettable_quiz_list extends local_qeupgradehelper_q
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_pre_upgrade_quiz_list extends local_qeupgradehelper_quiz_list {
+class tool_qeupgradehelper_pre_upgrade_quiz_list extends tool_qeupgradehelper_quiz_list {
     public function __construct() {
         parent::__construct('quizzestobeupgraded', 'listpreupgradeintro', 'numberofattempts');
     }
@@ -290,7 +290,7 @@ class local_qeupgradehelper_pre_upgrade_quiz_list extends local_qeupgradehelper_
  * @copyright  2011 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_pre_upgrade_quiz_list_restricted extends local_qeupgradehelper_pre_upgrade_quiz_list {
+class tool_qeupgradehelper_pre_upgrade_quiz_list_restricted extends tool_qeupgradehelper_pre_upgrade_quiz_list {
     protected $quizids;
     protected $restrictedtotalquizas = 0;
     protected $restrictedtotalqas = 0;
@@ -310,7 +310,7 @@ class local_qeupgradehelper_pre_upgrade_quiz_list_restricted extends local_qeupg
 
     public function get_col_headings() {
         $headings = parent::get_col_headings();
-        $headings[] = get_string('includedintheupgrade', 'local_qeupgradehelper');
+        $headings[] = get_string('includedintheupgrade', 'tool_qeupgradehelper');
         return $headings;
     }
 
@@ -330,7 +330,7 @@ class local_qeupgradehelper_pre_upgrade_quiz_list_restricted extends local_qeupg
         $a = new stdClass();
         $a->some = $a->some = html_writer::tag('b', $restrictedtotal);
         $a->total = $fulltotal;
-        return get_string('outof', 'local_qeupgradehelper', $a);
+        return get_string('outof', 'tool_qeupgradehelper', $a);
     }
 
     public function get_total_row() {
@@ -349,7 +349,7 @@ class local_qeupgradehelper_pre_upgrade_quiz_list_restricted extends local_qeupg
  * List the number of quiz attempts that were never upgraded from 1.4 -> 1.5.
  * @return int the number of such attempts.
  */
-function local_qeupgradehelper_get_num_very_old_attempts() {
+function tool_qeupgradehelper_get_num_very_old_attempts() {
     global $DB;
     return $DB->count_records_sql('
             SELECT COUNT(1)
@@ -366,9 +366,9 @@ function local_qeupgradehelper_get_num_very_old_attempts() {
  * Get the information about a quiz to be upgraded.
  * @param integer $quizid the quiz id.
  * @return object the information about that quiz, as for
- *      {@link local_qeupgradehelper_get_upgradable_quizzes()}.
+ *      {@link tool_qeupgradehelper_get_upgradable_quizzes()}.
  */
-function local_qeupgradehelper_get_quiz($quizid) {
+function tool_qeupgradehelper_get_quiz($quizid) {
     global $DB;
     return $DB->get_record_sql("
             SELECT
@@ -395,10 +395,10 @@ function local_qeupgradehelper_get_quiz($quizid) {
  * Get the information about a quiz to be upgraded.
  * @param integer $quizid the quiz id.
  * @return object the information about that quiz, as for
- *      {@link local_qeupgradehelper_get_resettable_quizzes()}, but with extra fields
+ *      {@link tool_qeupgradehelper_get_resettable_quizzes()}, but with extra fields
  *      totalattempts and resettableattempts.
  */
-function local_qeupgradehelper_get_resettable_quiz($quizid) {
+function tool_qeupgradehelper_get_resettable_quiz($quizid) {
     global $DB;
     return $DB->get_record_sql("
             SELECT
@@ -440,7 +440,7 @@ function local_qeupgradehelper_get_resettable_quiz($quizid) {
  * @param int $questionid a question id.
  * @return int the question session id.
  */
-function local_qeupgradehelper_get_session_id($attemptid, $questionid) {
+function tool_qeupgradehelper_get_session_id($attemptid, $questionid) {
     global $DB;
     $attempt = $DB->get_record('quiz_attempts', array('id' => $attemptid));
     if (!$attempt) {
@@ -458,7 +458,7 @@ function local_qeupgradehelper_get_session_id($attemptid, $questionid) {
  * @param string $qtype question type.
  * @return integer question_session.id.
  */
-function local_qeupgradehelper_find_test_case($behaviour, $statehistory, $qtype, $extratests) {
+function tool_qeupgradehelper_find_test_case($behaviour, $statehistory, $qtype, $extratests) {
     global $DB;
 
     $params = array(
@@ -516,7 +516,7 @@ function local_qeupgradehelper_find_test_case($behaviour, $statehistory, $qtype,
  * Grab all the data that upgrade will need for upgrading one
  * attempt at one question from the old DB.
  */
-function local_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffix) {
+function tool_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffix) {
     global $DB;
 
     $qsession = $DB->get_record('question_sessions', array('id' => $questionsessionid));
@@ -526,9 +526,9 @@ function local_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffi
             array('attempt' => $qsession->attemptid, 'question' => $qsession->questionid),
             'seq_number, id');
 
-    $question = local_qeupgradehelper_load_question($qsession->questionid, $quiz->id);
+    $question = tool_qeupgradehelper_load_question($qsession->questionid, $quiz->id);
 
-    if (!local_qeupgradehelper_is_upgraded()) {
+    if (!tool_qeupgradehelper_is_upgraded()) {
         if (!$quiz->optionflags) {
             $quiz->preferredbehaviour = 'deferredfeedback';
         } else if ($quiz->penaltyscheme) {
@@ -548,16 +548,16 @@ function local_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffi
     echo '<textarea readonly="readonly" rows="80" cols="120" >' . "
     public function test_{$question->qtype}_{$quiz->preferredbehaviour}_{$namesuffix}() {
 ";
-    local_qeupgradehelper_display_convert_attempt_input($quiz, $attempt,
+    tool_qeupgradehelper_display_convert_attempt_input($quiz, $attempt,
             $question, $qsession, $qstates);
 
     if ($question->qtype == 'random') {
         list($randombit, $realanswer) = explode('-', reset($qstates)->answer, 2);
         $newquestionid = substr($randombit, 6);
-        $newquestion = local_qeupgradehelper_load_question($newquestionid);
+        $newquestion = tool_qeupgradehelper_load_question($newquestionid);
         $newquestion->maxmark = $question->maxmark;
 
-        echo local_qeupgradehelper_format_var('$realquestion', $newquestion);
+        echo tool_qeupgradehelper_format_var('$realquestion', $newquestion);
         echo '        $this->loader->put_question_in_cache($realquestion);
 ';
     }
@@ -598,7 +598,7 @@ function local_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffi
 </textarea>';
 }
 
-function local_qeupgradehelper_format_var($name, $var) {
+function tool_qeupgradehelper_format_var($name, $var) {
     $out = var_export($var, true);
     $out = str_replace('<', '&lt;', $out);
     $out = str_replace('ADOFetchObj::__set_state(array(', '(object) array(', $out);
@@ -624,16 +624,16 @@ function local_qeupgradehelper_format_var($name, $var) {
     return "        $name = $out;\n";
 }
 
-function local_qeupgradehelper_display_convert_attempt_input($quiz, $attempt,
+function tool_qeupgradehelper_display_convert_attempt_input($quiz, $attempt,
         $question, $qsession, $qstates) {
-    echo local_qeupgradehelper_format_var('$quiz', $quiz);
-    echo local_qeupgradehelper_format_var('$attempt', $attempt);
-    echo local_qeupgradehelper_format_var('$question', $question);
-    echo local_qeupgradehelper_format_var('$qsession', $qsession);
-    echo local_qeupgradehelper_format_var('$qstates', $qstates);
+    echo tool_qeupgradehelper_format_var('$quiz', $quiz);
+    echo tool_qeupgradehelper_format_var('$attempt', $attempt);
+    echo tool_qeupgradehelper_format_var('$question', $question);
+    echo tool_qeupgradehelper_format_var('$qsession', $qsession);
+    echo tool_qeupgradehelper_format_var('$qstates', $qstates);
 }
 
-function local_qeupgradehelper_load_question($questionid, $quizid) {
+function tool_qeupgradehelper_load_question($questionid, $quizid) {
     global $CFG, $DB;
 
     $question = $DB->get_record_sql('
@@ -643,7 +643,7 @@ function local_qeupgradehelper_load_question($questionid, $quizid) {
             WHERE q.id = :questionid AND qqi.quiz = :quizid',
             array('questionid' => $questionid, 'quizid' => $quizid));
 
-    if (local_qeupgradehelper_is_upgraded()) {
+    if (tool_qeupgradehelper_is_upgraded()) {
         require_once($CFG->dirroot . '/question/engine/bank.php');
         $qtype = question_bank::get_qtype($question->qtype, false);
     } else {
@@ -660,7 +660,7 @@ function local_qeupgradehelper_load_question($questionid, $quizid) {
     return $question;
 }
 
-function local_qeupgradehelper_get_quiz_for_upgrade() {
+function tool_qeupgradehelper_get_quiz_for_upgrade() {
     global $DB;
 
     return $DB->get_record_sql("SELECT quiz.id
@@ -28,7 +28,7 @@
  *    display updated information.
  * 4. Once you are sure that works, you can proceed with the upgrade as usual.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2011 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -44,7 +44,7 @@
  * have to take steps to upgrade them yourself using the facilities provided by
  * this plugin.
  */
-//function local_qeupgradehelper_get_quizzes_to_upgrade() {
+//function tool_qeupgradehelper_get_quizzes_to_upgrade() {
 //    return array(1, 2, 3);
 //}
 
@@ -63,9 +63,9 @@
  * have to take steps to upgrade them yourself using the facilities provided by
  * this plugin.
  */
-//function local_qeupgradehelper_get_quizzes_to_upgrade() {
+//function tool_qeupgradehelper_get_quizzes_to_upgrade() {
 //    global $CFG;
-//    $rawids = file($CFG->dirroot . '/local/qeupgradehelper/quiz-ids-to-upgrade.txt');
+//    $rawids = file($CFG->dirroot . '/' . $CFG->admin . '/tool/qeupgradehelper/quiz-ids-to-upgrade.txt');
 //    $cleanids = array();
 //    foreach ($rawids as $id) {
 //        $id = clean_param($id, PARAM_INT);
@@ -92,7 +92,7 @@
  * have to take steps to upgrade them yourself using the facilities provided by
  * this plugin.
  */
-//function local_qeupgradehelper_get_quizzes_to_upgrade() {
+//function tool_qeupgradehelper_get_quizzes_to_upgrade() {
 //    global $DB;
 //
 //    $quizmoduleid = $DB->get_field('modules', 'id', array('name' => 'quiz'));
similarity index 83%
rename from local/qeupgradehelper/renderer.php
rename to admin/tool/qeupgradehelper/renderer.php
index 340f939..6d291ed 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * Defines the renderer for the question engine upgrade helper plugin.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class local_qeupgradehelper_renderer extends plugin_renderer_base {
+class tool_qeupgradehelper_renderer extends plugin_renderer_base {
 
     /**
      * Render the index page.
@@ -44,7 +44,7 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
     public function index_page($detected, array $actions) {
         $output = '';
         $output .= $this->header();
-        $output .= $this->heading(get_string('pluginname', 'local_qeupgradehelper'));
+        $output .= $this->heading(get_string('pluginname', 'tool_qeupgradehelper'));
         $output .= $this->box($detected);
         $output .= html_writer::start_tag('ul');
         foreach ($actions as $action) {
@@ -77,7 +77,7 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
      * @param int $numveryoldattemtps only relevant before upgrade.
      * @return string html to output.
      */
-    public function quiz_list_page(local_qeupgradehelper_quiz_list $quizzes,
+    public function quiz_list_page(tool_qeupgradehelper_quiz_list $quizzes,
             $numveryoldattemtps = null) {
         $output = '';
         $output .= $this->header();
@@ -99,7 +99,7 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
         $output .= html_writer::table($table);
 
         if ($numveryoldattemtps) {
-            $output .= $this->box(get_string('veryoldattemtps', 'local_qeupgradehelper',
+            $output .= $this->box(get_string('veryoldattemtps', 'tool_qeupgradehelper',
                     $numveryoldattemtps));
         }
 
@@ -116,12 +116,12 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
     public function convert_quiz_are_you_sure($quizsummary) {
         $output = '';
         $output .= $this->header();
-        $output .= $this->heading(get_string('areyousure', 'local_qeupgradehelper'));
+        $output .= $this->heading(get_string('areyousure', 'tool_qeupgradehelper'));
 
         $params = array('quizid' => $quizsummary->id, 'confirmed' => 1, 'sesskey' => sesskey());
-        $output .= $this->confirm(get_string('areyousuremessage', 'local_qeupgradehelper', $quizsummary),
-                new single_button(local_qeupgradehelper_url('convertquiz', $params), get_string('yes')),
-                local_qeupgradehelper_url('listtodo'));
+        $output .= $this->confirm(get_string('areyousuremessage', 'tool_qeupgradehelper', $quizsummary),
+                new single_button(tool_qeupgradehelper_url('convertquiz', $params), get_string('yes')),
+                tool_qeupgradehelper_url('listtodo'));
 
         $output .= $this->footer();
         return $output;
@@ -135,12 +135,12 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
     public function reset_quiz_are_you_sure($quizsummary) {
         $output = '';
         $output .= $this->header();
-        $output .= $this->heading(get_string('areyousure', 'local_qeupgradehelper'));
+        $output .= $this->heading(get_string('areyousure', 'tool_qeupgradehelper'));
 
         $params = array('quizid' => $quizsummary->id, 'confirmed' => 1, 'sesskey' => sesskey());
-        $output .= $this->confirm(get_string('areyousureresetmessage', 'local_qeupgradehelper', $quizsummary),
-                new single_button(local_qeupgradehelper_url('resetquiz', $params), get_string('yes')),
-                local_qeupgradehelper_url('listupgraded'));
+        $output .= $this->confirm(get_string('areyousureresetmessage', 'tool_qeupgradehelper', $quizsummary),
+                new single_button(tool_qeupgradehelper_url('resetquiz', $params), get_string('yes')),
+                tool_qeupgradehelper_url('listupgraded'));
 
         $output .= $this->footer();
         return $output;
@@ -162,7 +162,7 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
      * @return string html to output.
      */
     public function back_to_index() {
-        return $this->end_of_page_link(local_qeupgradehelper_url('index'),
-                get_string('backtoindex', 'local_qeupgradehelper'));
+        return $this->end_of_page_link(tool_qeupgradehelper_url('index'),
+                get_string('backtoindex', 'tool_qeupgradehelper'));
     }
 }
similarity index 64%
rename from local/qeupgradehelper/resetquiz.php
rename to admin/tool/qeupgradehelper/resetquiz.php
index a4d15da..a3bf94a 100644 (file)
 /**
  * Script to reset the upgrade of attempts at a particular quiz, after confirmation.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2010 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-require_once(dirname(__FILE__) . '/../../config.php');
+require_once(dirname(__FILE__) . '/../../../config.php');
 require_once(dirname(__FILE__) . '/locallib.php');
 require_once(dirname(__FILE__) . '/afterupgradelib.php');
 require_once($CFG->libdir . '/adminlib.php');
@@ -33,20 +33,20 @@ $confirmed = optional_param('confirmed', false, PARAM_BOOL);
 
 require_login();
 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-local_qeupgradehelper_require_upgraded();
+tool_qeupgradehelper_require_upgraded();
 
 admin_externalpage_setup('qeupgradehelper', '', array(),
-        local_qeupgradehelper_url('resetquiz', array('quizid' => $quizid)));
-$PAGE->navbar->add(get_string('listupgraded', 'local_qeupgradehelper'),
-        local_qeupgradehelper_url('listtodo'));
-$PAGE->navbar->add(get_string('resetquiz', 'local_qeupgradehelper'));
+        tool_qeupgradehelper_url('resetquiz', array('quizid' => $quizid)));
+$PAGE->navbar->add(get_string('listupgraded', 'tool_qeupgradehelper'),
+        tool_qeupgradehelper_url('listtodo'));
+$PAGE->navbar->add(get_string('resetquiz', 'tool_qeupgradehelper'));
 
-$renderer = $PAGE->get_renderer('local_qeupgradehelper');
+$renderer = $PAGE->get_renderer('tool_qeupgradehelper');
 
-$quizsummary = local_qeupgradehelper_get_resettable_quiz($quizid);
+$quizsummary = tool_qeupgradehelper_get_resettable_quiz($quizid);
 if (!$quizsummary) {
-    print_error('invalidquizid', 'local_qeupgradehelper',
-            local_qeupgradehelper_url('listupgraded'));
+    print_error('invalidquizid', 'tool_qeupgradehelper',
+            tool_qeupgradehelper_url('listupgraded'));
 }
 
 $quizsummary->name = format_string($quizsummary->name);
@@ -55,15 +55,15 @@ if ($confirmed && data_submitted() && confirm_sesskey()) {
     // Actually do the conversion.
     echo $renderer->header();
     echo $renderer->heading(get_string(
-            'resettingquizattempts', 'local_qeupgradehelper', $quizsummary));
+            'resettingquizattempts', 'tool_qeupgradehelper', $quizsummary));
 
-    $upgrader = new local_qeupgradehelper_attempt_upgrader(
+    $upgrader = new tool_qeupgradehelper_attempt_upgrader(
             $quizsummary->id, $quizsummary->resettableattempts);
     $upgrader->reset_all_resettable_attempts();
 
-    echo $renderer->heading(get_string('resetcomplete', 'local_qeupgradehelper'));
-    echo $renderer->end_of_page_link(local_qeupgradehelper_url('listupgraded'),
-            get_string('listupgraded', 'local_qeupgradehelper'));
+    echo $renderer->heading(get_string('resetcomplete', 'tool_qeupgradehelper'));
+    echo $renderer->end_of_page_link(tool_qeupgradehelper_url('listupgraded'),
+            get_string('listupgraded', 'tool_qeupgradehelper'));
 
     echo $renderer->footer();
     exit;
similarity index 87%
rename from local/qeupgradehelper/settings.php
rename to admin/tool/qeupgradehelper/settings.php
index 2991f38..8e88a01 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * Adds this plugin to the admin menu.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2011 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -27,6 +27,6 @@ defined('MOODLE_INTERNAL') || die;
 
 if ($hassiteconfig) { // needs this condition or there is error on login page
     $ADMIN->add('root', new admin_externalpage('qeupgradehelper',
-            get_string('pluginname', 'local_qeupgradehelper'),
-            new moodle_url('/local/qeupgradehelper/index.php')));
+            get_string('pluginname', 'tool_qeupgradehelper'),
+            new moodle_url('/admin/tool/qeupgradehelper/index.php')));
 }
diff --git a/admin/tool/qeupgradehelper/styles.css b/admin/tool/qeupgradehelper/styles.css
new file mode 100644 (file)
index 0000000..16ad976
--- /dev/null
@@ -0,0 +1,6 @@
+#page-admin-tool-qeupgradehelper-index .dimmed {
+    color: grey;
+}
+#page-admin-tool-qeupgradehelper-index .dimmed a {
+    color: #88c;
+}
similarity index 83%
rename from local/qeupgradehelper/version.php
rename to admin/tool/qeupgradehelper/version.php
index 606099e..3cd9d24 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * Version details.
  *
- * @package    local
+ * @package    tool
  * @subpackage qeupgradehelper
  * @copyright  2011 The Open University
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -25,5 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die;
 
-$plugin->version  = 2011040400;
-$plugin->requires = 2010080300;
+$plugin->version   = 2011092500;
+$plugin->requires  = 2011092100;
+$plugin->component = 'tool_qeupgradehelper'; // Full name of the plugin (used for diagnostics)
index 1fae2ea..ec5b690 100644 (file)
@@ -289,7 +289,6 @@ class plugin_manager {
             ),
 
             'local' => array(
-                'qeupgradehelper'
             ),
 
             'message' => array(
@@ -368,8 +367,8 @@ class plugin_manager {
 
             'tool' => array(
                 'bloglevelupgrade', 'capability', 'customlang', 'dbtransfer', 'generator',
-                'health', 'innodb', 'langimport', 'multilangupgrade',
-                'profiling', 'unittest', 'uploaduser', 'unsuproles', 'xmldb'
+                'health', 'innodb', 'langimport', 'multilangupgrade', 'profiling',
+                'qeupgradehelper', 'unittest', 'uploaduser', 'unsuproles', 'xmldb'
             ),
 
             'webservice' => array(
diff --git a/local/qeupgradehelper/styles.css b/local/qeupgradehelper/styles.css
deleted file mode 100644 (file)
index b328ced..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#page-admin-local-qeupgradehelper-index .dimmed {
-    color: grey;
-}
-#page-admin-local-qeupgradehelper-index .dimmed a {
-    color: #88c;
-}