Merge branch 'MDL-34019-pluginlib-notice' of git://github.com/mudrd8mz/moodle into...
authorDan Poltawski <dan@moodle.com>
Mon, 2 Jul 2012 07:02:37 +0000 (15:02 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 2 Jul 2012 07:02:37 +0000 (15:02 +0800)
89 files changed:
admin/tool/customlang/db/upgrade.php
auth/manual/db/upgrade.php
auth/mnet/db/upgrade.php
blocks/community/db/upgrade.php
blocks/completionstatus/block_completionstatus.php
blocks/feedback/block_feedback.php
blocks/html/db/upgrade.php
blocks/navigation/db/upgrade.php
blocks/settings/db/upgrade.php
course/completion.php
course/completion_form.php
course/externallib.php
course/tests/externallib_test.php [new file with mode: 0644]
enrol/authorize/db/upgrade.php
enrol/database/db/upgrade.php
enrol/flatfile/db/upgrade.php
enrol/guest/db/upgrade.php
enrol/imsenterprise/db/upgrade.php
enrol/mnet/db/upgrade.php
enrol/paypal/db/upgrade.php
files/renderer.php
filter/mediaplugin/db/upgrade.php
filter/tex/db/upgrade.php
grade/grading/form/rubric/db/upgrade.php
lang/en/completion.php
lib/completion/completion_criteria_grade.php
lib/db/upgrade.php
lib/dml/tests/dml_test.php
message/output/email/db/upgrade.php
message/output/jabber/db/upgrade.php
message/output/popup/db/upgrade.php
mod/assign/db/upgrade.php
mod/assign/feedback/comments/db/upgrade.php
mod/assign/feedback/file/db/upgrade.php
mod/assign/submission/comments/db/upgrade.php
mod/assign/submission/file/db/upgrade.php
mod/assign/submission/onlinetext/db/upgrade.php
mod/assignment/db/upgrade.php
mod/book/db/upgrade.php
mod/chat/db/upgrade.php
mod/choice/db/upgrade.php
mod/data/db/upgrade.php
mod/feedback/db/upgrade.php
mod/feedback/item/multichoice/lib.php
mod/folder/db/upgrade.php
mod/forum/db/upgrade.php
mod/glossary/db/upgrade.php
mod/imscp/db/upgrade.php
mod/label/db/upgrade.php
mod/lesson/db/upgrade.php
mod/lti/db/upgrade.php
mod/page/db/upgrade.php
mod/quiz/db/upgrade.php
mod/quiz/report/attemptsreport_options.php
mod/quiz/report/overview/db/upgrade.php
mod/quiz/report/reportlib.php
mod/quiz/report/statistics/db/upgrade.php
mod/resource/db/upgrade.php
mod/scorm/db/upgrade.php
mod/scorm/lib.php
mod/survey/db/upgrade.php
mod/url/db/upgrade.php
mod/wiki/db/upgrade.php
mod/wiki/lang/en/wiki.php
mod/wiki/parser/markups/wikimarkup.php
mod/workshop/db/upgrade.php
mod/workshop/form/accumulative/db/upgrade.php
mod/workshop/form/comments/db/upgrade.php
mod/workshop/form/numerrors/db/upgrade.php
mod/workshop/form/rubric/db/upgrade.php
portfolio/googledocs/db/upgrade.php
portfolio/picasa/db/upgrade.php
question/type/calculated/db/upgrade.php
question/type/essay/db/upgrade.php
question/type/match/db/upgrade.php
question/type/multianswer/db/upgrade.php
question/type/multichoice/db/upgrade.php
question/type/numerical/db/upgrade.php
repository/googledocs/db/upgrade.php
repository/picasa/db/upgrade.php
theme/formal_white/db/upgrade.php
theme/splash/config.php
theme/splash/javascript/colourswitcher.js [new file with mode: 0644]
theme/splash/layout/general.php
theme/splash/layout/report.php
theme/splash/lib.php
theme/splash/style/pagelayout.css
version.php
webservice/tests/helpers.php [new file with mode: 0644]

index efe645e..07c7e3b 100644 (file)
@@ -30,5 +30,9 @@ function xmldb_tool_customlang_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 82aab0a..46fd720 100644 (file)
@@ -33,5 +33,9 @@ function xmldb_auth_manual_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index fa5d157..d10cda5 100644 (file)
@@ -34,5 +34,9 @@ function xmldb_auth_mnet_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index e3eb9a4..53e2222 100644 (file)
@@ -46,5 +46,9 @@
 function xmldb_block_community_upgrade($oldversion) {
     global $CFG, $DB;
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 07a7b47..0daec7c 100644 (file)
@@ -171,7 +171,7 @@ class block_completionstatus extends block_base {
             $a = new stdClass();
             $a->first = $prerequisites_complete;
             $a->second = count($prerequisites);
-            $shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
+            $phtml .= get_string('firstofsecond', 'block_completionstatus', $a);
             $phtml .= '</td></tr>';
 
             $shtml = $phtml . $shtml;
index 75a5126..5d41a50 100644 (file)
@@ -4,7 +4,7 @@ if (is_file($CFG->dirroot.'/mod/feedback/lib.php')) {
     define('FEEDBACK_BLOCK_LIB_IS_OK', true);
 }
 
-class block_feedback extends block_base {
+class block_feedback extends block_list {
 
     function init() {
         $this->title = get_string('feedback', 'block_feedback');
@@ -21,10 +21,13 @@ class block_feedback extends block_base {
             return $this->content;
         }
 
+        $this->content = new stdClass;
+        $this->content->items = array();
+        $this->content->icons = array();
+        $this->content->footer = '';
+
         if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) {
-            $this->content = new stdClass;
-            $this->content->text = get_string('missing_feedback_module', 'block_feedback');
-            $this->content->footer = '';
+            $this->content->items = array(get_string('missing_feedback_module', 'block_feedback'));
             return $this->content;
         }
 
@@ -33,9 +36,7 @@ class block_feedback extends block_base {
             $courseid = SITEID;
         }
 
-        $this->content = new stdClass;
-        $this->content->text = '';
-        $this->content->footer = '';
+        $icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />';
 
 
         if (empty($this->instance->pageid)) {
@@ -47,8 +48,7 @@ class block_feedback extends block_base {
             foreach ($feedbacks as $feedback) {
                 $url = new moodle_url($baseurl);
                 $url->params(array('id'=>$feedback->cmid, 'courseid'=>$courseid));
-                $icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />&nbsp;';
-                $this->content->text = ' <a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
+                $this->content->items[] = '<a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
             }
         }
 
index 8eec672..54bb53d 100644 (file)
@@ -32,5 +32,9 @@
 function xmldb_block_html_upgrade($oldversion) {
     global $CFG, $DB;
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 4ad9818..32c5d8d 100644 (file)
@@ -58,5 +58,9 @@ function xmldb_block_navigation_upgrade($oldversion, $block) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
\ No newline at end of file
index 65c265c..feb241a 100644 (file)
@@ -58,5 +58,9 @@ function xmldb_block_settings_upgrade($oldversion, $block) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
\ No newline at end of file
index 3d4e17b..a25c2af 100644 (file)
@@ -141,16 +141,6 @@ if ($form->is_cancelled()){
     $aggregation->setMethod($data->role_aggregation);
     $aggregation->save();
 
-    // Update course total passing grade
-    if (!empty($data->criteria_grade)) {
-        if ($grade_item = grade_category::fetch_course_category($course->id)->grade_item) {
-            $grade_item->gradepass = $data->criteria_grade_value;
-            if (method_exists($grade_item, 'update')) {
-                $grade_item->update('course/completion.php');
-            }
-        }
-    }
-
     add_to_log($course->id, 'course', 'completion updated', 'completion.php?id='.$course->id);
 
     $url = new moodle_url('/course/view.php', array('id' => $course->id));
index 0a5b543..951776a 100644 (file)
@@ -179,10 +179,13 @@ class course_completion_form extends moodleform {
         $criteria->config_form_display($mform);
 
         // Completion on course grade
-        $mform->addElement('header', 'grade', get_string('grade'));
+        $mform->addElement('header', 'grade', get_string('coursegrade', 'completion'));
 
         // Grade enable and passing grade
         $course_grade = $DB->get_field('grade_items', 'gradepass', array('courseid' => $course->id, 'itemtype' => 'course'));
+        if (!$course_grade) {
+            $course_grade = '0.00000';
+        }
         $criteria = new completion_criteria_grade($params);
         $criteria->config_form_display($mform, $course_grade);
 
index e14ce90..41c5ab4 100644 (file)
@@ -904,9 +904,10 @@ class core_course_external extends external_api {
                                          '"parent" (int) the parent category id,'.
                                          '"idnumber" (string) category idnumber'.
                                          ' - user must have \'moodle/category:manage\' to search on idnumber,'.
-                                         '"visible" (int) whether the category is visible or not'.
+                                         '"visible" (int) whether the returned categories must be visible or hidden. If the key is not passed,
+                                             then the function return all categories that the user can see.'.
                                          ' - user must have \'moodle/category:manage\' or \'moodle/category:viewhiddencategories\' to search on visible,'.
-                                         '"theme" (string) category theme'.
+                                         '"theme" (string) only return the categories having this theme'.
                                          ' - user must have \'moodle/category:manage\' to search on theme'),
                             'value' => new external_value(PARAM_RAW, 'the value to match')
                         )
@@ -1017,10 +1018,22 @@ class core_course_external extends external_api {
                 if ($categories and !empty($params['addsubcategories'])) {
                     $newcategories = array();
 
+                    // Check if we required visible/theme checks.
+                    $additionalselect = '';
+                    $additionalparams = array();
+                    if (isset($conditions['visible'])) {
+                        $additionalselect .= ' AND visible = :visible';
+                        $additionalparams['visible'] = $conditions['visible'];
+                    }
+                    if (isset($conditions['theme'])) {
+                        $additionalselect .= ' AND theme= :theme';
+                        $additionalparams['theme'] = $conditions['theme'];
+                    }
+
                     foreach ($categories as $category) {
-                        $sqllike = $DB->sql_like('path', ':path');
-                        $sqlparams = array('path' => $category->path.'/%'); // It will NOT include the specified category.
-                        $subcategories = $DB->get_records_select('course_categories', $sqllike, $sqlparams);
+                        $sqlselect = $DB->sql_like('path', ':path') . $additionalselect;
+                        $sqlparams = array('path' => $category->path.'/%') + $additionalparams; // It will NOT include the specified category.
+                        $subcategories = $DB->get_records_select('course_categories', $sqlselect, $sqlparams);
                         $newcategories = $newcategories + $subcategories;   // Both arrays have integer as keys.
                     }
                     $categories = $categories + $newcategories;
diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php
new file mode 100644 (file)
index 0000000..ac3c4d9
--- /dev/null
@@ -0,0 +1,570 @@
+<?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/>.
+
+/**
+ * External course functions unit tests
+ *
+ * @package    core_course
+ * @category   external
+ * @copyright  2012 Jerome Mouneyrac
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+
+require_once($CFG->dirroot . '/webservice/tests/helpers.php');
+
+/**
+ * External course functions unit tests
+ *
+ * @package    core_course
+ * @category   external
+ * @copyright  2012 Jerome Mouneyrac
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_course_external_testcase extends externallib_advanced_testcase {
+
+    /**
+     * Tests set up
+     */
+    protected function setUp() {
+        global $CFG;
+        require_once($CFG->dirroot . '/course/externallib.php');
+    }
+
+    /**
+     * Test create_categories
+     */
+    public function test_create_categories() {
+
+        global $DB;
+
+        $this->resetAfterTest(true);
+
+        // Set the required capabilities by the external function
+        $contextid = context_system::instance()->id;
+        $roleid = $this->assignUserCapability('moodle/category:manage', $contextid);
+
+        // Create base categories.
+        $category1 = new stdClass();
+        $category1->name = 'Root Test Category 1';
+        $category2 = new stdClass();
+        $category2->name = 'Root Test Category 2';
+        $category2->idnumber = 'rootcattest2';
+        $category2->desc = 'Description for root test category 1';
+        $category2->theme = 'base';
+        $categories = array(
+            array('name' => $category1->name, 'parent' => 0),
+            array('name' => $category2->name, 'parent' => 0, 'idnumber' => $category2->idnumber,
+                'description' => $category2->desc, 'theme' => $category2->theme)
+        );
+
+        $createdcats = core_course_external::create_categories($categories);
+
+        // Initially confirm that base data was inserted correctly.
+        $this->assertEquals($category1->name, $createdcats[0]['name']);
+        $this->assertEquals($category2->name, $createdcats[1]['name']);
+
+        // Save the ids.
+        $category1->id = $createdcats[0]['id'];
+        $category2->id = $createdcats[1]['id'];
+
+        // Create on sub category.
+        $category3 = new stdClass();
+        $category3->name = 'Sub Root Test Category 3';
+        $subcategories = array(
+            array('name' => $category3->name, 'parent' => $category1->id)
+        );
+
+        $createdsubcats = core_course_external::create_categories($subcategories);
+
+        // Confirm that sub categories were inserted correctly.
+        $this->assertEquals($category3->name, $createdsubcats[0]['name']);
+
+        // Save the ids.
+        $category3->id = $createdsubcats[0]['id'];
+
+        // Calling the ws function should provide a new sortorder to give category1,
+        // category2, category3. New course categories are ordered by id not name.
+        $category1 = $DB->get_record('course_categories', array('id' => $category1->id));
+        $category2 = $DB->get_record('course_categories', array('id' => $category2->id));
+        $category3 = $DB->get_record('course_categories', array('id' => $category3->id));
+
+        $this->assertGreaterThanOrEqual($category1->sortorder, $category3->sortorder);
+        $this->assertGreaterThanOrEqual($category2->sortorder, $category3->sortorder);
+
+        // Call without required capability
+        $this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
+        $this->setExpectedException('required_capability_exception');
+        $createdsubcats = core_course_external::create_categories($subcategories);
+
+    }
+
+    /**
+     * Test delete categories
+     */
+    public function test_delete_categories() {
+        global $DB;
+
+        $this->resetAfterTest(true);
+
+        // Set the required capabilities by the external function
+        $contextid = context_system::instance()->id;
+        $roleid = $this->assignUserCapability('moodle/category:manage', $contextid);
+
+        $category1  = self::getDataGenerator()->create_category();
+        $category2  = self::getDataGenerator()->create_category(
+                array('parent' => $category1->id));
+        $category3  = self::getDataGenerator()->create_category();
+        $category4  = self::getDataGenerator()->create_category(
+                array('parent' => $category3->id));
+        $category5  = self::getDataGenerator()->create_category(
+                array('parent' => $category4->id));
+
+        //delete category 1 and 2 + delete category 4, category 5 moved under category 3
+        core_course_external::delete_categories(array(
+            array('id' => $category1->id, 'recursive' => 1),
+            array('id' => $category4->id)
+        ));
+
+        //check $category 1 and 2 are deleted
+        $notdeletedcount = $DB->count_records_select('course_categories',
+            'id IN ( ' . $category1->id . ',' . $category2->id . ',' . $category4->id . ')');
+        $this->assertEquals(0, $notdeletedcount);
+
+        //check that $category5 as $category3 for parent
+        $dbcategory5 = $DB->get_record('course_categories', array('id' => $category5->id));
+        $this->assertEquals($dbcategory5->path, $category3->path . '/' . $category5->id);
+
+         // Call without required capability
+        $this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
+        $this->setExpectedException('required_capability_exception');
+        $createdsubcats = core_course_external::delete_categories(
+                array(array('id' => $category3->id)));
+    }
+
+    /**
+     * Test get categories
+     */
+    public function test_get_categories() {
+        global $DB;
+
+        $this->resetAfterTest(true);
+        $category1data['idnumber'] = 'idnumbercat1';
+        $category1data['name'] = 'Category 1 for PHPunit test';
+        $category1data['description'] = 'Category 1 description';
+        $category1data['descriptionformat'] = FORMAT_MOODLE;
+        $category1  = self::getDataGenerator()->create_category($category1data);
+        $category2  = self::getDataGenerator()->create_category(
+                array('parent' => $category1->id));
+        $category6  = self::getDataGenerator()->create_category(
+                array('parent' => $category1->id, 'visible' => 0));
+        $category3  = self::getDataGenerator()->create_category();
+        $category4  = self::getDataGenerator()->create_category(
+                array('parent' => $category3->id));
+        $category5  = self::getDataGenerator()->create_category(
+                array('parent' => $category4->id));
+
+        // Set the required capabilities by the external function.
+        $context = context_system::instance();
+        $roleid = $this->assignUserCapability('moodle/category:manage', $context->id);
+
+        // Retrieve category1 + sub-categories except not visible ones
+        $categories = core_course_external::get_categories(array(
+            array('key' => 'id', 'value' => $category1->id),
+            array('key' => 'visible', 'value' => 1)), 1);
+
+        // Check we retrieve the good total number of categories.
+        $this->assertEquals(2, count($categories));
+
+        // Check the return values
+        $this->assertEquals($categories[0]['id'], $category1->id);
+        $this->assertEquals($categories[0]['idnumber'], $category1->idnumber);
+        $this->assertEquals($categories[0]['name'], $category1->name);
+        $this->assertEquals($categories[0]['description'], $category1->description);
+        $this->assertEquals($categories[0]['descriptionformat'], FORMAT_HTML);
+
+        // Check different params.
+        $categories = core_course_external::get_categories(array(
+            array('key' => 'id', 'value' => $category1->id),
+            array('key' => 'idnumber', 'value' => $category1->idnumber),
+            array('key' => 'visible', 'value' => 1)), 0);
+        $this->assertEquals(1, count($categories));
+
+        // Retrieve categories from parent.
+        $categories = core_course_external::get_categories(array(
+            array('key' => 'parent', 'value' => $category3->id)), 1);
+        $this->assertEquals(2, count($categories));
+
+        // Retrieve all categories.
+        $categories = core_course_external::get_categories();
+        $this->assertEquals($DB->count_records('course_categories'), count($categories));
+
+        // Call without required capability (it will fail cause of the search on idnumber).
+        $this->unassignUserCapability('moodle/category:manage', $context->id, $roleid);
+        $this->setExpectedException('moodle_exception');
+        $categories = core_course_external::get_categories(array(
+            array('key' => 'id', 'value' => $category1->id),
+            array('key' => 'idnumber', 'value' => $category1->idnumber),
+            array('key' => 'visible', 'value' => 1)), 0);
+    }
+
+    /**
+     * Test update_categories
+     */
+    public function test_update_categories() {
+        global $DB;
+
+        $this->resetAfterTest(true);
+
+        // Set the required capabilities by the external function
+        $contextid = context_system::instance()->id;
+        $roleid = $this->assignUserCapability('moodle/category:manage', $contextid);
+
+        // Create base categories.
+        $category1data['idnumber'] = 'idnumbercat1';
+        $category1data['name'] = 'Category 1 for PHPunit test';
+        $category1data['description'] = 'Category 1 description';
+        $category1data['descriptionformat'] = FORMAT_MOODLE;
+        $category1  = self::getDataGenerator()->create_category($category1data);
+        $category2  = self::getDataGenerator()->create_category(
+                array('parent' => $category1->id));
+        $category3  = self::getDataGenerator()->create_category();
+        $category4  = self::getDataGenerator()->create_category(
+                array('parent' => $category3->id));
+        $category5  = self::getDataGenerator()->create_category(
+                array('parent' => $category4->id));
+
+        // We update all category1 attribut.
+        // Then we move cat4 and cat5 parent: cat3 => cat1
+        $categories = array(
+            array('id' => $category1->id,
+                'name' => $category1->name . '_updated',
+                'idnumber' => $category1->idnumber . '_updated',
+                'description' => $category1->description . '_updated',
+                'descriptionformat' => FORMAT_HTML,
+                'theme' => $category1->theme),
+            array('id' => $category4->id, 'parent' => $category1->id));
+
+        core_course_external::update_categories($categories);
+
+        // Check the values were updated.
+        $dbcategories = $DB->get_records_select('course_categories',
+                'id IN (' . $category1->id . ',' . $category2->id . ',' . $category2->id
+                . ',' . $category3->id . ',' . $category4->id . ',' . $category5->id .')');
+        $this->assertEquals($category1->name . '_updated',
+                $dbcategories[$category1->id]->name);
+        $this->assertEquals($category1->idnumber . '_updated',
+                $dbcategories[$category1->id]->idnumber);
+        $this->assertEquals($category1->description . '_updated',
+                $dbcategories[$category1->id]->description);
+        $this->assertEquals(FORMAT_HTML, $dbcategories[$category1->id]->descriptionformat);
+
+        // Check that category4 and category5 have been properly moved.
+        $this->assertEquals('/' . $category1->id . '/' . $category4->id,
+                $dbcategories[$category4->id]->path);
+        $this->assertEquals('/' . $category1->id . '/' . $category4->id . '/' . $category5->id,
+                $dbcategories[$category5->id]->path);
+
+        // Call without required capability.
+        $this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
+        $this->setExpectedException('required_capability_exception');
+        core_course_external::update_categories($categories);
+    }
+
+    /**
+     * Test create_courses
+     */
+    public function test_create_courses() {
+        global $DB;
+
+        $this->resetAfterTest(true);
+
+        // Set the required capabilities by the external function
+        $contextid = context_system::instance()->id;
+        $roleid = $this->assignUserCapability('moodle/course:create', $contextid);
+        $this->assignUserCapability('moodle/course:visibility', $contextid, $roleid);
+
+        $category  = self::getDataGenerator()->create_category();
+
+        // Create base categories.
+        $course1['fullname'] = 'Test course 1';
+        $course1['shortname'] = 'Testcourse1';
+        $course1['categoryid'] = $category->id;
+        $course2['fullname'] = 'Test course 2';
+        $course2['shortname'] = 'Testcourse2';
+        $course2['categoryid'] = $category->id;
+        $course2['idnumber'] = 'testcourse2idnumber';
+        $course2['summary'] = 'Description for course 2';
+        $course2['summaryformat'] = FORMAT_MOODLE;
+        $course2['format'] = 'weeks';
+        $course2['showgrades'] = 1;
+        $course2['newsitems'] = 3;
+        $course2['startdate'] = 32882306400; // 01/01/3012
+        $course2['numsections'] = 4;
+        $course2['maxbytes'] = 100000;
+        $course2['showreports'] = 1;
+        $course2['visible'] = 0;
+        $course2['hiddensections'] = 0;
+        $course2['groupmode'] = 0;
+        $course2['groupmodeforce'] = 0;
+        $course2['defaultgroupingid'] = 0;
+        $course2['enablecompletion'] = 1;
+        $course2['completionstartonenrol'] = 1;
+        $course2['completionnotify'] = 1;
+        $course2['lang'] = 'en';
+        $course2['forcetheme'] = 'base';
+        $courses = array($course1, $course2);
+
+        $createdcourses = core_course_external::create_courses($courses);
+
+        // Check that right number of courses were created.
+        $this->assertEquals(2, count($createdcourses));
+
+        // Check that the courses were correctly created.
+        foreach ($createdcourses as $createdcourse) {
+            $dbcourse = $DB->get_record('course', array('id' => $createdcourse['id']));
+
+            if ($createdcourse['shortname'] == $course2['shortname']) {
+                $this->assertEquals($dbcourse->fullname, $course2['fullname']);
+                $this->assertEquals($dbcourse->shortname, $course2['shortname']);
+                $this->assertEquals($dbcourse->category, $course2['categoryid']);
+                $this->assertEquals($dbcourse->idnumber, $course2['idnumber']);
+                $this->assertEquals($dbcourse->summary, $course2['summary']);
+                $this->assertEquals($dbcourse->summaryformat, $course2['summaryformat']);
+                $this->assertEquals($dbcourse->format, $course2['format']);
+                $this->assertEquals($dbcourse->showgrades, $course2['showgrades']);
+                $this->assertEquals($dbcourse->newsitems, $course2['newsitems']);
+                $this->assertEquals($dbcourse->startdate, $course2['startdate']);
+                $this->assertEquals($dbcourse->numsections, $course2['numsections']);
+                $this->assertEquals($dbcourse->maxbytes, $course2['maxbytes']);
+                $this->assertEquals($dbcourse->showreports, $course2['showreports']);
+                $this->assertEquals($dbcourse->visible, $course2['visible']);
+                $this->assertEquals($dbcourse->hiddensections, $course2['hiddensections']);
+                $this->assertEquals($dbcourse->groupmode, $course2['groupmode']);
+                $this->assertEquals($dbcourse->groupmodeforce, $course2['groupmodeforce']);
+                $this->assertEquals($dbcourse->defaultgroupingid, $course2['defaultgroupingid']);
+                $this->assertEquals($dbcourse->completionnotify, $course2['completionnotify']);
+                $this->assertEquals($dbcourse->lang, $course2['lang']);
+
+                if (!empty($CFG->allowcoursethemes)) {
+                    $this->assertEquals($dbcourse->theme, $course2['forcetheme']);
+                }
+
+                if (completion_info::is_enabled_for_site()) {
+                    $this->assertEquals($dbcourse->enablecompletion, $course2['enabledcompletion']);
+                    $this->assertEquals($dbcourse->completionstartonenrol, $course2['completionstartonenrol']);
+                } else {
+                    $this->assertEquals($dbcourse->enablecompletion, 0);
+                    $this->assertEquals($dbcourse->completionstartonenrol, 0);
+                }
+
+            } else if ($createdcourse['shortname'] == $course1['shortname']) {
+                $courseconfig = get_config('moodlecourse');
+                $this->assertEquals($dbcourse->fullname, $course1['fullname']);
+                $this->assertEquals($dbcourse->shortname, $course1['shortname']);
+                $this->assertEquals($dbcourse->category, $course1['categoryid']);
+                $this->assertEquals($dbcourse->summaryformat, FORMAT_HTML);
+                $this->assertEquals($dbcourse->format, $courseconfig->format);
+                $this->assertEquals($dbcourse->showgrades, $courseconfig->showgrades);
+                $this->assertEquals($dbcourse->newsitems, $courseconfig->newsitems);
+                $this->assertEquals($dbcourse->numsections, $courseconfig->numsections);
+                $this->assertEquals($dbcourse->maxbytes, $courseconfig->maxbytes);
+                $this->assertEquals($dbcourse->showreports, $courseconfig->showreports);
+                $this->assertEquals($dbcourse->hiddensections, $courseconfig->hiddensections);
+                $this->assertEquals($dbcourse->groupmode, $courseconfig->groupmode);
+                $this->assertEquals($dbcourse->groupmodeforce, $courseconfig->groupmodeforce);
+                $this->assertEquals($dbcourse->defaultgroupingid, 0);
+            } else {
+                throw moodle_exception('Unexpected shortname');
+            }
+        }
+
+        // Call without required capability
+        $this->unassignUserCapability('moodle/course:create', $contextid, $roleid);
+        $this->setExpectedException('required_capability_exception');
+        $createdsubcats = core_course_external::create_courses($courses);
+    }
+
+    /**
+     * Test delete_courses
+     */
+    public function test_delete_courses() {
+        global $DB, $USER;
+
+        $this->resetAfterTest(true);
+
+        // Admin can delete a course.
+        $this->setAdminUser();
+        // Validate_context() will fail as the email is not set by $this->setAdminUser().
+        $USER->email = 'emailtopass@contextvalidation.me';
+
+        $course1  = self::getDataGenerator()->create_course();
+        $course2  = self::getDataGenerator()->create_course();
+        $course3  = self::getDataGenerator()->create_course();
+
+        // Delete courses.
+        core_course_external::delete_courses(array($course1->id, $course2->id));
+
+        // Check $course 1 and 2 are deleted.
+        $notdeletedcount = $DB->count_records_select('course',
+            'id IN ( ' . $course1->id . ',' . $course2->id . ')');
+        $this->assertEquals(0, $notdeletedcount);
+
+         // Fail when the user is not allow to access the course (enrolled) or is not admin.
+        $this->setGuestUser();
+        $this->setExpectedException('require_login_exception');
+        $createdsubcats = core_course_external::delete_courses(array($course3->id));
+    }
+
+    /**
+     * Test get_courses
+     */
+    public function test_get_courses () {
+        global $DB;
+
+        $this->resetAfterTest(true);
+
+        $coursedata['idnumber'] = 'idnumbercourse1';
+        $coursedata['fullname'] = 'Course 1 for PHPunit test';
+        $coursedata['summary'] = 'Course 1 description';
+        $coursedata['summaryformat'] = FORMAT_MOODLE;
+        $course1  = self::getDataGenerator()->create_course($coursedata);
+        $course2  = self::getDataGenerator()->create_course();
+        $course3  = self::getDataGenerator()->create_course();
+
+        // Set the required capabilities by the external function.
+        $context = context_system::instance();
+        $roleid = $this->assignUserCapability('moodle/course:view', $context->id);
+        $this->assignUserCapability('moodle/course:update',
+                context_course::instance($course1->id)->id, $roleid);
+        $this->assignUserCapability('moodle/course:update',
+                context_course::instance($course2->id)->id, $roleid);
+        $this->assignUserCapability('moodle/course:update',
+                context_course::instance($course3->id)->id, $roleid);
+
+        $courses = core_course_external::get_courses(array('ids' =>
+            array($course1->id, $course2->id)));
+
+        // Check we retrieve the good total number of categories.
+        $this->assertEquals(2, count($courses));
+
+        // Check the return values for course 1
+        $dbcourse = $DB->get_record('course', array('id' => $course1->id));
+        $this->assertEquals($courses[0]['id'], $dbcourse->id);
+        $this->assertEquals($courses[0]['idnumber'], $coursedata['idnumber']);
+        $this->assertEquals($courses[0]['fullname'], $coursedata['fullname']);
+        $this->assertEquals($courses[0]['summary'], $coursedata['summary']);
+        $this->assertEquals($courses[0]['summaryformat'], FORMAT_HTML);
+        $this->assertEquals($courses[0]['shortname'], $dbcourse->shortname);
+        $this->assertEquals($courses[0]['categoryid'], $dbcourse->category);
+        $this->assertEquals($courses[0]['format'], $dbcourse->format);
+        $this->assertEquals($courses[0]['showgrades'], $dbcourse->showgrades);
+        $this->assertEquals($courses[0]['newsitems'], $dbcourse->newsitems);
+        $this->assertEquals($courses[0]['startdate'], $dbcourse->startdate);
+        $this->assertEquals($courses[0]['numsections'], $dbcourse->numsections);
+        $this->assertEquals($courses[0]['maxbytes'], $dbcourse->maxbytes);
+        $this->assertEquals($courses[0]['showreports'], $dbcourse->showreports);
+        $this->assertEquals($courses[0]['visible'], $dbcourse->visible);
+        $this->assertEquals($courses[0]['hiddensections'], $dbcourse->hiddensections);
+        $this->assertEquals($courses[0]['groupmode'], $dbcourse->groupmode);
+        $this->assertEquals($courses[0]['groupmodeforce'], $dbcourse->groupmodeforce);
+        $this->assertEquals($courses[0]['defaultgroupingid'], $dbcourse->defaultgroupingid);
+        $this->assertEquals($courses[0]['completionnotify'], $dbcourse->completionnotify);
+        $this->assertEquals($courses[0]['lang'], $dbcourse->lang);
+        $this->assertEquals($courses[0]['forcetheme'], $dbcourse->theme);
+        $this->assertEquals($courses[0]['completionstartonenrol'], $dbcourse->completionstartonenrol);
+        $this->assertEquals($courses[0]['enablecompletion'], $dbcourse->enablecompletion);
+        $this->assertEquals($courses[0]['completionstartonenrol'], $dbcourse->completionstartonenrol);
+
+        // Get all courses in the DB
+        $courses = core_course_external::get_courses(array());
+        $this->assertEquals($DB->count_records('course'), count($courses));
+    }
+
+    /**
+     * Test get_course_contents
+     */
+    public function test_get_course_contents() {
+        $this->resetAfterTest(true);
+
+        $course  = self::getDataGenerator()->create_course();
+        $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
+        $forumcm = get_coursemodule_from_id('forum', $forum->cmid);
+        $forumcontext = context_module::instance($forum->cmid);
+        $data = $this->getDataGenerator()->create_module('data', array('assessed'=>1, 'scale'=>100, 'course'=>$course->id));
+        $datacontext = context_module::instance($data->cmid);
+        $datacm = get_coursemodule_from_instance('page', $data->id);
+        $page = $this->getDataGenerator()->create_module('page', array('course'=>$course->id));
+        $pagecontext = context_module::instance($page->cmid);
+        $pagecm = get_coursemodule_from_instance('page', $page->id);
+
+        // Set the required capabilities by the external function.
+        $context = context_course::instance($course->id);
+        $roleid = $this->assignUserCapability('moodle/course:view', $context->id);
+        $this->assignUserCapability('moodle/course:update', $context->id, $roleid);
+
+        $courses = core_course_external::get_course_contents($course->id, array());
+
+        // Check that the course has the 3 created modules
+        $this->assertEquals(3, count($courses[0]['modules']));
+    }
+
+    /**
+     * Test duplicate_course
+     */
+    public function test_duplicate_course() {
+        $this->resetAfterTest(true);
+
+        // Create one course with three modules.
+        $course  = self::getDataGenerator()->create_course();
+        $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
+        $forumcm = get_coursemodule_from_id('forum', $forum->cmid);
+        $forumcontext = context_module::instance($forum->cmid);
+        $data = $this->getDataGenerator()->create_module('data', array('assessed'=>1, 'scale'=>100, 'course'=>$course->id));
+        $datacontext = context_module::instance($data->cmid);
+        $datacm = get_coursemodule_from_instance('page', $data->id);
+        $page = $this->getDataGenerator()->create_module('page', array('course'=>$course->id));
+        $pagecontext = context_module::instance($page->cmid);
+        $pagecm = get_coursemodule_from_instance('page', $page->id);
+
+        // Set the required capabilities by the external function.
+        $coursecontext = context_course::instance($course->id);
+        $categorycontext = context_coursecat::instance($course->category);
+        $roleid = $this->assignUserCapability('moodle/course:create', $categorycontext->id);
+        $this->assignUserCapability('moodle/course:view', $categorycontext->id, $roleid);
+        $this->assignUserCapability('moodle/restore:restorecourse', $categorycontext->id, $roleid);
+        $this->assignUserCapability('moodle/backup:backupcourse', $coursecontext->id, $roleid);
+        $this->assignUserCapability('moodle/backup:configure', $coursecontext->id, $roleid);
+        // Optional capabilities to copy user data.
+        $this->assignUserCapability('moodle/backup:userinfo', $coursecontext->id, $roleid);
+        $this->assignUserCapability('moodle/restore:userinfo', $categorycontext->id, $roleid);
+
+        $newcourse['fullname'] = 'Course duplicate';
+        $newcourse['shortname'] = 'courseduplicate';
+        $newcourse['categoryid'] = $course->category;
+        $newcourse['visible'] = true;
+        $newcourse['options'][] = array('name' => 'users', 'value' => true);
+
+        $duplicate = core_course_external::duplicate_course($course->id, $newcourse['fullname'],
+                $newcourse['shortname'], $newcourse['categoryid'], $newcourse['visible'], $newcourse['options']);
+
+        // Check that the course has been duplicated.
+        $this->assertEquals($newcourse['shortname'], $duplicate['shortname']);
+    }
+}
index 9a11f48..ad71ff7 100644 (file)
@@ -26,5 +26,9 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index c21880c..7aae081 100644 (file)
@@ -30,5 +30,9 @@ function xmldb_enrol_database_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index b8e4a73..67785c2 100644 (file)
@@ -32,5 +32,9 @@ function xmldb_enrol_flatfile_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index b19b5a6..b14e8f8 100644 (file)
@@ -40,6 +40,10 @@ function xmldb_enrol_guest_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2011112901, 'enrol', 'guest');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index a348d69..39b8fdc 100644 (file)
@@ -31,6 +31,10 @@ function xmldb_enrol_imsenterprise_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 6564435..8c70236 100644 (file)
@@ -32,5 +32,9 @@ function xmldb_enrol_mnet_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index b66c655..8bcb41f 100644 (file)
@@ -47,5 +47,9 @@ function xmldb_enrol_paypal_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 33a70f6..78096e2 100644 (file)
@@ -455,10 +455,10 @@ class core_files_renderer extends plugin_renderer_base {
      */
     private function fm_print_restrictions($fm) {
         $maxbytes = display_size($fm->options->maxbytes);
-        if (empty($options->maxfiles) || $options->maxfiles == -1) {
+        if (empty($fm->options->maxfiles) || $fm->options->maxfiles == -1) {
             $maxsize = get_string('maxfilesize', 'moodle', $maxbytes);
         } else {
-            $strparam = (object)array('size' => $maxbytes, 'attachments' => $options->maxfiles);
+            $strparam = (object)array('size' => $maxbytes, 'attachments' => $fm->options->maxfiles);
             $maxsize = get_string('maxsizeandattachments', 'moodle', $strparam);
         }
         // TODO MDL-32020 also should say about 'File types accepted'
index c77415f..a9c7964 100644 (file)
@@ -54,5 +54,9 @@ function xmldb_filter_mediaplugin_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2011121200, 'filter', 'mediaplugin');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index fea5c3d..74b0ef5 100644 (file)
@@ -33,5 +33,9 @@ function xmldb_filter_tex_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index e60160d..7c1d214 100644 (file)
@@ -38,5 +38,9 @@ function xmldb_gradingform_rubric_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 0683c79..9a9d10c 100644 (file)
@@ -110,6 +110,7 @@ $string['courseprerequisites']='Course prerequisites';
 $string['coursesavailable']='Courses available';
 $string['coursesavailableexplaination']='<i>Course completion criteria must be set for a course to appear in this list</i>';
 $string['criteria']='Criteria';
+$string['criteriagradenote'] = 'Please note that updating the required grade here will not update the current course pass grade.';
 $string['criteriagroup']='Criteria group';
 $string['criteriarequiredall']='All criteria below are required';
 $string['criteriarequiredany']='Any criteria below are required';
@@ -124,6 +125,8 @@ $string['datepassed']='Date passed';
 $string['daysafterenrolment']='Days after enrolment';
 $string['durationafterenrolment']='Duration after enrolment';
 $string['fraction']='Fraction';
+$string['gradexrequired']='{$a} required';
+$string['graderequired']='Grade required';
 $string['inprogress']='In progress';
 $string['manualcompletionby']='Manual completion by';
 $string['manualselfcompletion']='Manual self completion';
@@ -136,7 +139,6 @@ $string['nocriteriaset']='No completion criteria set for this course';
 $string['notenroled']='You are not enrolled in this course';
 $string['notyetstarted']='Not yet started';
 $string['overallcriteriaaggregation']='Overall criteria type aggregation';
-$string['passinggrade']='Passing grade';
 $string['pending']='Pending';
 $string['periodpostenrolment']='Period post enrolment';
 $string['prerequisites']='Prerequisites';
index 6bc32ed..56a4d0f 100644 (file)
@@ -62,8 +62,9 @@ class completion_criteria_grade extends completion_criteria {
      */
     public function config_form_display(&$mform, $data = null) {
         $mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
-        $mform->addElement('text', 'criteria_grade_value', get_string('passinggrade', 'completion'));
+        $mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
         $mform->setDefault('criteria_grade_value', $data);
+        $mform->addElement('static', 'criteria_grade_value_note', '', get_string('criteriagradenote', 'completion'));
 
         if ($this->id) {
             $mform->setDefault('criteria_grade', 1);
@@ -128,7 +129,7 @@ class completion_criteria_grade extends completion_criteria {
      * @return  string
      */
     public function get_title() {
-        return get_string('grade');
+        return get_string('coursegrade', 'completion');
     }
 
     /**
@@ -137,7 +138,8 @@ class completion_criteria_grade extends completion_criteria {
      * @return string
      */
     public function get_title_detailed() {
-        return (float) $this->gradepass . '% required';
+        $graderequired = round($this->gradepass, 2).'%';
+        return get_string('gradexrequired', 'completion', $graderequired);
     }
 
     /**
@@ -156,15 +158,16 @@ class completion_criteria_grade extends completion_criteria {
      * @return string
      */
     public function get_status($completion) {
-        // Cast as floats to get rid of excess decimal places
-        $grade = (float) $this->get_grade($completion);
-        $gradepass = (float) $this->gradepass;
+        $grade = $this->get_grade($completion);
+        $graderequired = $this->get_title_detailed();
 
         if ($grade) {
-            return $grade.'% ('.$gradepass.'% to pass)';
+            $grade = round($grade, 2).'%';
         } else {
-            return $gradepass.'% to pass';
+            $grade = get_string('nograde');
         }
+
+        return $grade.' ('.$graderequired.')';
     }
 
     /**
@@ -231,11 +234,11 @@ class completion_criteria_grade extends completion_criteria {
     public function get_details($completion) {
         $details = array();
         $details['type'] = get_string('coursegrade', 'completion');
-        $details['criteria'] = get_string('passinggrade', 'completion');
-        $details['requirement'] = ((float)$this->gradepass).'%';
+        $details['criteria'] = get_string('graderequired', 'completion');
+        $details['requirement'] = round($this->gradepass, 2).'%';
         $details['status'] = '';
 
-        $grade = (float)$this->get_grade($completion);
+        $grade = round($this->get_grade($completion), 2);
         if ($grade) {
             $details['status'] = $grade.'%';
         }
index 3be8b80..dd52946 100644 (file)
@@ -872,5 +872,9 @@ function xmldb_main_upgrade($oldversion) {
     }
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index e431b91..a5ad8c2 100644 (file)
@@ -308,6 +308,7 @@ class dml_testcase extends database_driver_testcase {
 
     function test_fix_sql_params() {
         $DB = $this->tdb;
+        $prefix = $DB->get_prefix();
 
         $table = $this->get_test_table();
         $tablename = $table->getName();
@@ -315,13 +316,13 @@ class dml_testcase extends database_driver_testcase {
         // Correct table placeholder substitution
         $sql = "SELECT * FROM {{$tablename}}";
         $sqlarray = $DB->fix_sql_params($sql);
-        $this->assertEquals("SELECT * FROM {$DB->get_prefix()}".$tablename, $sqlarray[0]);
+        $this->assertEquals("SELECT * FROM {$prefix}".$tablename, $sqlarray[0]);
 
         // Conversions of all param types
         $sql = array();
-        $sql[SQL_PARAMS_NAMED]  = "SELECT * FROM {$DB->get_prefix()}testtable WHERE name = :param1, course = :param2";
-        $sql[SQL_PARAMS_QM]     = "SELECT * FROM {$DB->get_prefix()}testtable WHERE name = ?, course = ?";
-        $sql[SQL_PARAMS_DOLLAR] = "SELECT * FROM {$DB->get_prefix()}testtable WHERE name = \$1, course = \$2";
+        $sql[SQL_PARAMS_NAMED]  = "SELECT * FROM {$prefix}testtable WHERE name = :param1, course = :param2";
+        $sql[SQL_PARAMS_QM]     = "SELECT * FROM {$prefix}testtable WHERE name = ?, course = ?";
+        $sql[SQL_PARAMS_DOLLAR] = "SELECT * FROM {$prefix}testtable WHERE name = \$1, course = \$2";
 
         $params = array();
         $params[SQL_PARAMS_NAMED]  = array('param1'=>'first record', 'param2'=>1);
@@ -921,12 +922,12 @@ class dml_testcase extends database_driver_testcase {
         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
         $dbman->create_table($table);
 
-        $data = array(array('id' => 1, 'course' => 3, 'name' => 'record1', 'onetext'=>'abc'),
-            array('id' => 2, 'course' => 3, 'name' => 'record2', 'onetext'=>'abcd'),
-            array('id' => 3, 'course' => 5, 'name' => 'record3', 'onetext'=>'abcde'));
+        $data = array(array('course' => 3, 'name' => 'record1', 'onetext'=>'abc'),
+            array('course' => 3, 'name' => 'record2', 'onetext'=>'abcd'),
+            array('course' => 5, 'name' => 'record3', 'onetext'=>'abcde'));
 
-        foreach ($data as $record) {
-            $DB->insert_record($tablename, $record);
+        foreach ($data as $key=>$record) {
+            $data[$key]['id'] = $DB->insert_record($tablename, $record);
         }
 
         // standard recordset iteration
@@ -990,11 +991,79 @@ class dml_testcase extends database_driver_testcase {
             $this->assertEquals($e->errorcode, 'textconditionsnotallowed');
         }
 
+        // Test nested iteration.
+        $rs1 = $DB->get_recordset($tablename);
+        $i = 0;
+        foreach($rs1 as $record1) {
+            $rs2 = $DB->get_recordset($tablename);
+            $i++;
+            $j = 0;
+            foreach($rs2 as $record2) {
+                $j++;
+            }
+            $rs2->close();
+            $this->assertEquals($j, count($data));
+        }
+        $rs1->close();
+        $this->assertEquals($i, count($data));
+
         // notes:
         //  * limits are tested in test_get_recordset_sql()
         //  * where_clause() is used internally and is tested in test_get_records()
     }
 
+    public function test_get_recordset_static() {
+        $DB = $this->tdb;
+        $dbman = $DB->get_manager();
+
+        $table = $this->get_test_table();
+        $tablename = $table->getName();
+
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $dbman->create_table($table);
+
+        $DB->insert_record($tablename, array('course' => 1));
+        $DB->insert_record($tablename, array('course' => 2));
+        $DB->insert_record($tablename, array('course' => 3));
+        $DB->insert_record($tablename, array('course' => 4));
+
+        $rs = $DB->get_recordset($tablename, array(), 'id');
+
+        $DB->set_field($tablename, 'course', 666, array('course'=>1));
+        $DB->delete_records($tablename, array('course'=>2));
+
+        $i = 0;
+        foreach($rs as $record) {
+            $i++;
+            $this->assertEquals($i, $record->course);
+        }
+        $rs->close();
+        $this->assertEquals(4, $i);
+
+        // Now repeat with limits because it may use different code.
+        $DB->delete_records($tablename, array());
+
+        $DB->insert_record($tablename, array('course' => 1));
+        $DB->insert_record($tablename, array('course' => 2));
+        $DB->insert_record($tablename, array('course' => 3));
+        $DB->insert_record($tablename, array('course' => 4));
+
+        $rs = $DB->get_recordset($tablename, array(), 'id', '*', 0, 3);
+
+        $DB->set_field($tablename, 'course', 666, array('course'=>1));
+        $DB->delete_records($tablename, array('course'=>2));
+
+        $i = 0;
+        foreach($rs as $record) {
+            $i++;
+            $this->assertEquals($i, $record->course);
+        }
+        $rs->close();
+        $this->assertEquals(3, $i);
+    }
+
     public function test_get_recordset_iterator_keys() {
         $DB = $this->tdb;
         $dbman = $DB->get_manager();
@@ -1009,11 +1078,11 @@ class dml_testcase extends database_driver_testcase {
         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
         $dbman->create_table($table);
 
-        $data = array(array('id'=> 1, 'course' => 3, 'name' => 'record1'),
-            array('id'=> 2, 'course' => 3, 'name' => 'record2'),
-            array('id'=> 3, 'course' => 5, 'name' => 'record3'));
-        foreach ($data as $record) {
-            $DB->insert_record($tablename, $record);
+        $data = array(array('course' => 3, 'name' => 'record1'),
+            array('course' => 3, 'name' => 'record2'),
+            array('course' => 5, 'name' => 'record3'));
+        foreach ($data as $key=>$record) {
+            $data[$key]['id'] = $DB->insert_record($tablename, $record);
         }
 
         // Test repeated numeric keys are returned ok
@@ -4128,6 +4197,43 @@ class dml_testcase extends database_driver_testcase {
         $this->assertEquals(0, $DB->count_records($tablename)); // finally rolled back
 
         $DB->delete_records($tablename);
+
+        // Test interactions of recordset and transactions - this causes problems in SQL Server.
+        $table2 = $this->get_test_table('2');
+        $tablename2 = $table2->getName();
+
+        $table2->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table2->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+        $table2->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $dbman->create_table($table2);
+
+        $DB->insert_record($tablename, array('course'=>1));
+        $DB->insert_record($tablename, array('course'=>2));
+        $DB->insert_record($tablename, array('course'=>3));
+
+        $DB->insert_record($tablename2, array('course'=>5));
+        $DB->insert_record($tablename2, array('course'=>6));
+        $DB->insert_record($tablename2, array('course'=>7));
+        $DB->insert_record($tablename2, array('course'=>8));
+
+        $rs1 = $DB->get_recordset($tablename);
+        $i = 0;
+        foreach ($rs1 as $record1) {
+            $i++;
+            $rs2 = $DB->get_recordset($tablename2);
+            $j = 0;
+            foreach ($rs2 as $record2) {
+                $t = $DB->start_delegated_transaction();
+                $DB->set_field($tablename, 'course', $record1->course+1, array('id'=>$record1->id));
+                $DB->set_field($tablename2, 'course', $record2->course+1, array('id'=>$record2->id));
+                $t->allow_commit();
+                $j++;
+            }
+            $rs2->close();
+            $this->assertEquals(4, $j);
+        }
+        $rs1->close();
+        $this->assertEquals(3, $i);
     }
 
     function test_transactions_forbidden() {
index dd79b5c..da3d22a 100644 (file)
@@ -36,6 +36,10 @@ function xmldb_message_email_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index d884f25..eb78904 100644 (file)
@@ -36,6 +36,10 @@ function xmldb_message_jabber_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 63a4f73..ef556ee 100644 (file)
@@ -36,6 +36,10 @@ function xmldb_message_popup_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index e918367..de7a154 100644 (file)
@@ -47,6 +47,10 @@ function xmldb_assign_upgrade($oldversion) {
         upgrade_mod_savepoint(true, 2012051700, 'assign');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 9321ecc..97409c6 100644 (file)
  */
 function xmldb_assignfeedback_comments_upgrade($oldversion) {
     // do the upgrades
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index cf6594e..e59722d 100644 (file)
  */
 function xmldb_assignfeedback_file_upgrade($oldversion) {
     // do the upgrades
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 6bc5bce..565fc0f 100644 (file)
  * @return bool
  */
 function xmldb_assignsubmission_comments_upgrade($oldversion) {
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index b00f57b..a86a5fb 100644 (file)
  * @return bool
  */
 function xmldb_assignsubmission_file_upgrade($oldversion) {
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 183e602..056c0bb 100644 (file)
  * @return bool
  */
 function xmldb_assignsubmission_onlinetext_upgrade($oldversion) {
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 6608b6c..d9c46ea 100644 (file)
@@ -29,6 +29,10 @@ function xmldb_assignment_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 735116c..3fb1085 100644 (file)
@@ -37,5 +37,9 @@ function xmldb_book_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 2b9ad1d..c716494 100644 (file)
@@ -29,6 +29,10 @@ function xmldb_chat_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index f86bbe4..e46ab79 100644 (file)
@@ -29,6 +29,10 @@ function xmldb_choice_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index a84c883..745d0cb 100644 (file)
@@ -29,6 +29,10 @@ function xmldb_data_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index c4ededd..fd0d9a5 100644 (file)
@@ -43,6 +43,10 @@ function xmldb_feedback_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 3e5501f..33955c1 100644 (file)
@@ -561,6 +561,9 @@ class feedback_item_multichoice extends feedback_item_base {
 
     public function create_value($data) {
         $vallist = $data;
+        if (is_array($vallist)) {
+            $vallist = array_unique($vallist);
+        }
         return trim($this->item_array_to_string($vallist));
     }
 
index 7a2b6e2..d996b61 100644 (file)
@@ -55,5 +55,9 @@ function xmldb_folder_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index d493b2b..4c2f297 100644 (file)
@@ -50,6 +50,10 @@ function xmldb_forum_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index ccebcd2..48e85b8 100644 (file)
@@ -44,6 +44,10 @@ function xmldb_glossary_upgrade($oldversion) {
         upgrade_mod_savepoint(true, 2012022000, 'glossary');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 2b027f7..e4c4b0a 100644 (file)
@@ -35,5 +35,9 @@ function xmldb_imscp_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 0511d0f..a083759 100644 (file)
@@ -55,6 +55,10 @@ function xmldb_label_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 04b0b8f..0cc8e03 100644 (file)
@@ -61,6 +61,10 @@ function xmldb_lesson_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 2b5f1bc..9fd4e13 100644 (file)
@@ -68,6 +68,10 @@ function xmldb_lti_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 4a81df9..b1c4e91 100644 (file)
@@ -55,5 +55,9 @@ function xmldb_page_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index d3a8e72..b0a4a4f 100644 (file)
@@ -327,6 +327,10 @@ function xmldb_quiz_upgrade($oldversion) {
         upgrade_mod_savepoint(true, 2012040206, 'quiz');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index cca3d30..ffd4287 100644 (file)
@@ -105,7 +105,7 @@ class mod_quiz_attempts_report_options {
         $this->cm     = $cm;
         $this->course = $course;
 
-        $this->usercanseegrades = quiz_report_should_show_grades($quiz);
+        $this->usercanseegrades = quiz_report_should_show_grades($quiz, context_module::instance($cm->id));
     }
 
     /**
index eefc978..f8aa7c8 100644 (file)
@@ -38,5 +38,9 @@ function xmldb_quiz_overview_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line.
     // Put any upgrade step following this.
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 9bfa402..d3e4e99 100644 (file)
@@ -401,9 +401,10 @@ function quiz_no_questions_message($quiz, $cm, $context) {
  * Should the grades be displayed in this report. That depends on the quiz
  * display options, and whether the quiz is graded.
  * @param object $quiz the quiz settings.
+ * @param context $context the quiz context.
  * @return bool
  */
-function quiz_report_should_show_grades($quiz) {
+function quiz_report_should_show_grades($quiz, context $context) {
     if ($quiz->timeclose && time() > $quiz->timeclose) {
         $when = mod_quiz_display_options::AFTER_CLOSE;
     } else {
@@ -413,5 +414,5 @@ function quiz_report_should_show_grades($quiz) {
 
     return quiz_has_grades($quiz) &&
             ($reviewoptions->marks >= question_display_options::MARK_AND_MAX ||
-            has_capability('moodle/grade:viewhidden', $this->context));
+            has_capability('moodle/grade:viewhidden', $context));
 }
index f3a7871..144d95a 100644 (file)
@@ -63,6 +63,10 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2012061801, 'quiz', 'statistics');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index fc6245e..383e888 100644 (file)
@@ -55,5 +55,9 @@ function xmldb_resource_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index a7bcbd7..a85397f 100644 (file)
@@ -60,6 +60,10 @@ function xmldb_scorm_upgrade($oldversion) {
         upgrade_mod_savepoint(true, 2012032101, 'scorm');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 7b395f5..822d3e2 100644 (file)
@@ -150,7 +150,7 @@ function scorm_add_instance($scorm, $mform=null) {
 
     scorm_parse($record, true);
 
-    scorm_grade_item_update($record);
+    scorm_grade_item_update($record, null, false);
 
     return $record->id;
 }
@@ -646,9 +646,10 @@ function scorm_upgrade_grades() {
  * @uses GRADE_TYPE_NONE
  * @param object $scorm object with extra cmidnumber
  * @param mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
+ * @param boolean $updatecompletion  set whether to update completion stuff
  * @return object grade_item
  */
-function scorm_grade_item_update($scorm, $grades=null) {
+function scorm_grade_item_update($scorm, $grades=null, $updatecompletion=true) {
     global $CFG, $DB;
     require_once($CFG->dirroot.'/mod/scorm/locallib.php');
     if (!function_exists('grade_update')) { //workaround for buggy PHP versions
@@ -680,15 +681,16 @@ function scorm_grade_item_update($scorm, $grades=null) {
     }
 
     // Update activity completion if applicable
-    // Get course info
-    $course = new object();
-    $course->id = $scorm->course;
-
-    $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id);
-    // CM will be false if this has been run from scorm_add_instance
-    if ($cm) {
-        $completion = new completion_info($course);
-        $completion->update_state($cm, COMPLETION_COMPLETE);
+    if ($updatecompletion) {
+        // Get course info
+        $course = new stdClass();
+        $course->id = $scorm->course;
+
+        $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id);
+        if (!empty($cm)) {
+            $completion = new completion_info($course);
+            $completion->update_state($cm, COMPLETION_COMPLETE);
+        }
     }
 
     return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, $grades, $params);
index 3a10f28..10c6ef8 100644 (file)
@@ -29,6 +29,10 @@ function xmldb_survey_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 88e0ba0..5449ecb 100644 (file)
@@ -55,5 +55,9 @@ function xmldb_url_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index c8ac218..9925711 100644 (file)
@@ -45,5 +45,9 @@ function xmldb_wiki_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 4815ba3..9781d7b 100644 (file)
@@ -195,6 +195,7 @@ $string['searchcontent'] = 'Search in page content';
 $string['searchresult'] = 'Search results:';
 $string['searchwikis'] = 'Search wikis';
 $string['special'] = 'Special';
+$string['tableofcontents'] = 'Table of contents';
 $string['tagsdeleted'] = 'Wiki tags have been deleted';
 $string['tagtitle'] = 'See the "{$a}" tag';
 $string['teacherrating'] = 'Teacher rating';
index 30976db..cf7a2b3 100644 (file)
@@ -239,7 +239,7 @@ abstract class wiki_markup_parser extends generic_parser {
             $i++;
         }
 
-        $this->returnvalues['toc'] = "<div class=\"wiki-toc\"><p class=\"wiki-toc-title\">Table of contents</p>$toc</div>";
+        $this->returnvalues['toc'] = "<div class=\"wiki-toc\"><p class=\"wiki-toc-title\">" . get_string('tableofcontents', 'wiki') . "</p>$toc</div>";
     }
 
     /**
index 6f848b9..061d599 100644 (file)
@@ -87,5 +87,9 @@ function xmldb_workshop_upgrade($oldversion) {
         upgrade_mod_savepoint(true, 2012041701, 'workshop');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 5ff3a28..fd8065d 100644 (file)
@@ -38,5 +38,9 @@ function xmldb_workshopform_accumulative_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 07100d5..a369ae9 100644 (file)
@@ -38,5 +38,9 @@ function xmldb_workshopform_comments_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 3da3066..459abbb 100644 (file)
@@ -38,5 +38,9 @@ function xmldb_workshopform_numerrors_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 62927bf..968f8e5 100644 (file)
@@ -38,5 +38,9 @@ function xmldb_workshopform_rubric_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 01420b5..39164bf 100644 (file)
@@ -39,6 +39,10 @@ function xmldb_portfolio_googledocs_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2012053001, 'portfolio', 'googledocs');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 38df9d5..cb1eeb7 100644 (file)
@@ -39,6 +39,10 @@ function xmldb_portfolio_picasa_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2012053001, 'portfolio', 'picasa');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index f141e02..3d7bc0c 100644 (file)
@@ -40,6 +40,10 @@ function xmldb_qtype_calculated_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 6d60323..0441751 100644 (file)
@@ -90,6 +90,10 @@ function xmldb_qtype_essay_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2011102702, 'qtype', 'essay');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 6277068..b99732c 100644 (file)
@@ -40,5 +40,9 @@ function xmldb_qtype_match_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 8c7e04e..a83470f 100644 (file)
@@ -40,5 +40,9 @@ function xmldb_qtype_multianswer_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 41b56bf..48b658f 100644 (file)
@@ -40,5 +40,9 @@ function xmldb_qtype_multichoice_upgrade($oldversion) {
     // Moodle v2.2.0 release upgrade line
     // Put any upgrade step following this
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 43db9a6..3336f4d 100644 (file)
@@ -37,5 +37,9 @@ function xmldb_qtype_numerical_upgrade($oldversion) {
     $dbman = $DB->get_manager();
 
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
index 80a77a6..7c78301 100644 (file)
@@ -42,6 +42,10 @@ function xmldb_repository_googledocs_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2012053000, 'repository', 'googledocs');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index 1cd2f2a..3d50bba 100644 (file)
@@ -42,6 +42,10 @@ function xmldb_repository_picasa_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2012053000, 'repository', 'picasa');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
 
index aeb58d2..fccbb15 100644 (file)
@@ -76,5 +76,9 @@ function xmldb_theme_formal_white_upgrade($oldversion) {
         upgrade_plugin_savepoint(true, 2012051503, 'theme', 'formal_white');
     }
 
+    // Moodle v2.3.0 release upgrade line
+    // Put any upgrade step following this
+
+
     return true;
 }
\ No newline at end of file
index f9bca28..c428ce5 100644 (file)
@@ -33,10 +33,10 @@ $THEME->sheets = array(
     'pagelayout',
     'core',
     'menus',
-    'red',
-    'green',
-    'blue',
     'orange',
+    'blue',
+    'green',
+    'red',
     'settings',
 );
 
@@ -53,48 +53,57 @@ $THEME->layouts = array(
     'standard' => array(
         'file' => 'general.php',
         'regions' => array('side-pre', 'side-post'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     // Course page
     'course' => array(
         'file' => 'general.php',
         'regions' => array('side-pre', 'side-post'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     // Course page
     'coursecategory' => array(
         'file' => 'general.php',
         'regions' => array('side-pre', 'side-post'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     'incourse' => array(
         'file' => 'general.php',
         'regions' => array('side-pre', 'side-post'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     'frontpage' => array(
         'file' => 'general.php',
         'regions' => array('side-pre', 'side-post'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     'admin' => array(
         'file' => 'general.php',
         'regions' => array('side-pre'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     'mydashboard' => array(
         'file' => 'general.php',
         'regions' => array('side-pre', 'side-post'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     'mypublic' => array(
         'file' => 'general.php',
         'regions' => array('side-pre', 'side-post'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
     'login' => array(
         'file' => 'general.php',
-        'regions' => array()
+        'regions' => array(),
+        'options' => array('langmenu'=>true),
     ),
     // Pages that appear in pop-up windows - no navigation, no blocks, no header.
     'popup' => array(
@@ -137,8 +146,11 @@ $THEME->layouts = array(
     'report' => array(
         'file' => 'report.php',
         'regions' => array('side-pre'),
-        'defaultregion' => 'side-pre'
+        'defaultregion' => 'side-pre',
+        'options' => array('langmenu'=>true),
     ),
 );
 
 $THEME->csspostprocess = 'splash_process_css';
+
+$THEME->javascripts = array('colourswitcher');
diff --git a/theme/splash/javascript/colourswitcher.js b/theme/splash/javascript/colourswitcher.js
new file mode 100644 (file)
index 0000000..578f96b
--- /dev/null
@@ -0,0 +1,63 @@
+YUI.add('moodle-theme_splash-colourswitcher', function(Y) {
+
+// Available colours
+var COLOURS = ['red','green','blue','orange'];
+
+/**
+ * Splash theme colour switcher class.
+ * Initialise this class by calling M.theme_splash.init
+ */
+var ColourSwitcher = function() {
+    ColourSwitcher.superclass.constructor.apply(this, arguments);
+};
+ColourSwitcher.prototype = {
+    /**
+     * Constructor for this class
+     * @param {object} config
+     */
+    initializer : function(config) {
+        var i, c;
+        // Attach events to the links to change colours so we can do it with
+        // JavaScript without refreshing the page
+        for (i in COLOURS) {
+            c = COLOURS[i];
+            // Check if this is the current colour
+            if (Y.one(document.body).hasClass('splash-'+c)) {
+                this.set('colour', c);
+            }
+            Y.all(config.div+' .colour-'+c).on('click', this.setColour, this, c);
+        }
+    },
+    /**
+     * Sets the colour being used for the splash theme
+     * @param {Y.Event} e The event that fired
+     * @param {string} colour The new colour
+     */
+    setColour : function(e, colour) {
+        // Prevent the event from refreshing the page
+        e.preventDefault();
+        // Switch over the CSS classes on the body
+        Y.one(document.body).replaceClass('splash-'+this.get('colour'), 'splash-'+colour);
+        // Update the current colour
+        this.set('colour', colour);
+        // Store the users selection (Uses AJAX to save to the database)
+        M.util.set_user_preference('theme_splash_chosen_colour', colour);
+    }
+};
+// Make the colour switcher a fully fledged YUI module
+Y.extend(ColourSwitcher, Y.Base, ColourSwitcher.prototype, {
+    NAME : 'Splash theme colour switcher',
+    ATTRS : {
+        colour : {
+            value : 'red'
+        }
+    }
+});
+// Our splash theme namespace
+M.theme_splash = M.theme_splash || {};
+// Initialisation function for the colour switcher
+M.theme_splash.initColourSwitcher = function(cfg) {
+    return new ColourSwitcher(cfg);
+}
+
+}, '@VERSION@', {requires:['base','node']});
index 4763983..3def7ed 100644 (file)
@@ -107,7 +107,12 @@ echo $OUTPUT->doctype() ?>
         alt="orange" /></a></li>
         </ul>
         </div>
-        <?php echo $OUTPUT->lang_menu();?>
+        <?php
+        if (!empty($PAGE->layout_options['langmenu'])) {
+            echo $OUTPUT->lang_menu();
+        }
+            echo $PAGE->headingmenu
+        ?>
         </div>
         <div id="logobox">
         <?php
index 2602e64..10d7390 100644 (file)
@@ -107,7 +107,12 @@ echo $OUTPUT->doctype() ?>
         alt="orange" /></a></li>
         </ul>
         </div>
-        <?php echo $OUTPUT->lang_menu();?>
+        <?php
+        if (!empty($PAGE->layout_options['langmenu'])) {
+            echo $OUTPUT->lang_menu();
+        }
+        echo $PAGE->headingmenu
+        ?>
         </div>
         <div id="logobox">
         <?php
index 191ec32..f9f1fb6 100644 (file)
@@ -90,12 +90,14 @@ function splash_set_customcss($css, $customcss) {
 /**
  * Adds the JavaScript for the colour switcher to the page.
  *
+ * The colour switcher is a YUI moodle module that is located in
+ *     theme/splash/yui/splash/splash.js
+ *
  * @param moodle_page $page
  */
 function splash_initialise_colourswitcher(moodle_page $page) {
     user_preference_allow_ajax_update('theme_splash_chosen_colour', PARAM_ALPHA);
-    $page->requires->yui_module('moodle-theme_splash-colourswitcher',
-     'M.theme_splash.initColourSwitcher', array(array('div'=>'#colourswitcher')));
+    $page->requires->yui_module('moodle-theme_splash-colourswitcher', 'M.theme_splash.initColourSwitcher', array(array('div'=>'#colourswitcher')));
 }
 
 /**
index bfb4f6e..eca577c 100644 (file)
@@ -199,7 +199,6 @@ p.prolog a:link {
     margin:10px 0 0 15px;
 }
 .logininfo{
-    background:url([[pix:theme|loginicon]]) left no-repeat;
     color:#fff;
     margin:0;
     padding:10px 10px 10px 40px;
@@ -213,7 +212,7 @@ p.prolog a:link {
 }
 #headermenu .langmenu{
     position:relative;
-    top:35px;
+    top:30px;
     width:210px;
 }
 a,
index 6739bbe..728ef4d 100644 (file)
 defined('MOODLE_INTERNAL') || die();
 
 
-$version  = 2012062500.00;              // 2012062500    = branching date YYYYMMDD - do not modify!
+$version  = 2012062500.01;              // 2012062500    = branching date YYYYMMDD - do not modify!
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes
 
-$release  = '2.3 (Build: 20120625)';    // Human-friendly version name
+$release  = '2.3+ (Build: 20120701)';   // Human-friendly version name
 
 $branch   = '23';                       // this version's branch
 $maturity = MATURITY_STABLE;            // this version's maturity level
diff --git a/webservice/tests/helpers.php b/webservice/tests/helpers.php
new file mode 100644 (file)
index 0000000..161a1b7
--- /dev/null
@@ -0,0 +1,82 @@
+<?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/>.
+
+/**
+ * This file contains helper classes for testing the web service and external files.
+ *
+ * @package    core_webservice
+ * @copyright  2012 Jerome Mouneyrac
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Helper base class for external tests. Helpfull to test capabilities.
+ *
+ * @package    core_webservice
+ * @copyright  2012 Jerome Mouneyrac
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class externallib_advanced_testcase extends advanced_testcase {
+
+    /**
+     * Assign a capability to $USER
+     * The function creates a student $USER if $USER->id is empty
+     *
+     * @param string $capability capability name
+     * @param int $contextid
+     * @param int $roleid
+     * @return int the role id - mainly returned for creation, so calling function can reuse it
+     */
+    public static function assignUserCapability($capability, $contextid, $roleid = null) {
+        global $USER;
+
+        // Create a new student $USER if $USER doesn't exist
+        if (empty($USER->id)) {
+            $user  = self::getDataGenerator()->create_user();
+            self::setUser($user);
+        }
+
+        if (empty($roleid)) {
+            $roleid = create_role('Dummy role', 'dummyrole', 'dummy role description');
+        }
+
+        assign_capability($capability, CAP_ALLOW, $roleid, $contextid);
+
+        role_assign($roleid, $USER->id, $contextid);
+
+        accesslib_clear_all_caches_for_unit_testing();
+
+        return $roleid;
+    }
+
+    /**
+     * Unassign a capability to $USER
+     *
+     * @param string $capability capability name
+     * @param int $contextid
+     * @param int $roleid
+     */
+    public static function unassignUserCapability($capability, $contextid, $roleid) {
+        global $USER;
+
+        unassign_capability($capability, $roleid, $contextid);
+
+        accesslib_clear_all_caches_for_unit_testing();
+    }
+}
+