Merge branch 'MDL-56698-master' of git://github.com/damyon/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 2 Nov 2016 07:34:06 +0000 (15:34 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 2 Nov 2016 07:34:06 +0000 (15:34 +0800)
18 files changed:
auth/email/classes/external.php
cache/classes/dummystore.php
cache/stores/apcu/lib.php
cache/stores/file/lib.php
cache/stores/memcache/lib.php
cache/stores/memcache/tests/memcache_test.php
cache/stores/memcached/lib.php
cache/stores/memcached/tests/memcached_test.php
cache/stores/mongodb/tests/mongodb_test.php
cache/tests/fixtures/stores.php
cohort/index.php
mod/lesson/view.php
mod/scorm/locallib.php
mod/scorm/report/basic/classes/report.php
mod/scorm/report/interactions/classes/report.php
mod/scorm/report/objectives/classes/report.php
user/profile/lib.php
webservice/renderer.php

index 6a1b387..4ecff91 100644 (file)
@@ -169,7 +169,7 @@ class auth_email_external extends external_api {
                 ),
                 'recaptchapublickey' => new external_value(PARAM_RAW, 'Recaptcha public key', VALUE_OPTIONAL),
                 'recaptchachallengehash' => new external_value(PARAM_RAW, 'Recaptcha challenge hash', VALUE_OPTIONAL),
-                'recaptchachallengeimage' => new external_value(PARAM_URL, 'Recaptcha challenge <noscript> image', VALUE_OPTIONAL),
+                'recaptchachallengeimage' => new external_value(PARAM_URL, 'Recaptcha challenge noscript image', VALUE_OPTIONAL),
                 'recaptchachallengejs' => new external_value(PARAM_URL, 'Recaptcha challenge js url', VALUE_OPTIONAL),
                 'warnings'  => new external_warnings(),
             )
index c11e197..bcc9ca1 100644 (file)
@@ -258,7 +258,9 @@ class cachestore_dummy extends cache_store {
      */
     public static function initialise_test_instance(cache_definition $definition) {
         $cache = new cachestore_dummy('Dummy store test');
-        $cache->initialise($definition);
+        if ($cache->is_ready()) {
+            $cache->initialise($definition);
+        }
         return $cache;
     }
 
index cbb20db..077a5d7 100644 (file)
@@ -155,15 +155,6 @@ class cachestore_apcu extends cache_store implements cache_is_key_aware, cache_i
         return ($this->definition !== null);
     }
 
-    /**
-     * Returns true if this cache store instance is ready to use.
-     * @return bool
-     */
-    public function is_ready() {
-        // No set up is actually required, providing apc is installed and enabled.
-        return true;
-    }
-
     /**
      * Prepares the given key for use.
      *
@@ -325,6 +316,7 @@ class cachestore_apcu extends cache_store implements cache_is_key_aware, cache_i
         }
         $name = 'APCu test';
         $cache = new cachestore_apcu($name);
+        // No need to check if is_ready() as this has already being done by requirement check.
         $cache->initialise($definition);
         return $cache;
     }
index 91a0839..dd5e058 100644 (file)
@@ -673,7 +673,9 @@ class cachestore_file extends cache_store implements cache_is_key_aware, cache_i
         $name = 'File test';
         $path = make_cache_directory('cachestore_file_test');
         $cache = new cachestore_file($name, array('path' => $path));
-        $cache->initialise($definition);
+        if ($cache->is_ready()) {
+            $cache->initialise($definition);
+        }
         return $cache;
     }
 
index 6f89d1a..60ee49b 100644 (file)
@@ -576,7 +576,9 @@ class cachestore_memcache extends cache_store implements cache_is_configurable {
         }
 
         $store = new cachestore_memcache('Test memcache', $configuration);
-        $store->initialise($definition);
+        if ($store->is_ready()) {
+            $store->initialise($definition);
+        }
 
         return $store;
     }
index 18f486a..f5d4f08 100644 (file)
@@ -58,12 +58,12 @@ class cachestore_memcache_test extends cachestore_tests {
 
         $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_memcache', 'phpunit_test');
         $instance = new cachestore_memcache('Memcache Test', cachestore_memcache::unit_test_configuration());
-        $instance->initialise($definition);
 
         if (!$instance->is_ready()) {
             // Something prevented memcache store to be inited (extension, TEST_CACHESTORE_MEMCACHE_TESTSERVERS...).
             $this->markTestSkipped();
         }
+        $instance->initialise($definition);
 
         $keys = array(
             // Alphanumeric.
index 0c7be7b..56df937 100644 (file)
@@ -733,7 +733,10 @@ class cachestore_memcached extends cache_store implements cache_is_configurable
         }
 
         $store = new cachestore_memcached($name, $configuration);
-        $store->initialise($definition);
+        // If store is ready then only initialise.
+        if ($store->is_ready()) {
+            $store->initialise($definition);
+        }
 
         return $store;
     }
index 87517c0..bef5cbe 100644 (file)
@@ -62,12 +62,12 @@ class cachestore_memcached_test extends cachestore_tests {
 
         $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_memcached', 'phpunit_test');
         $instance = new cachestore_memcached('Memcached Test', cachestore_memcached::unit_test_configuration());
-        $instance->initialise($definition);
 
         if (!$instance->is_ready()) {
             // Something prevented memcached store to be inited (extension, TEST_CACHESTORE_MEMCACHED_TESTSERVERS...).
             $this->markTestSkipped();
         }
+        $instance->initialise($definition);
 
         $keys = array(
             // Alphanumeric.
@@ -183,7 +183,7 @@ class cachestore_memcached_test extends cachestore_tests {
             set_config('testname', $testserver, 'cachestore_memcached');
             set_config('testservers', $testserver, 'cachestore_memcached');
             $checkinstance = cachestore_memcached::initialise_test_instance($definition);
-            if (!$checkinstance) {
+            if (!$checkinstance->is_ready()) {
                 $this->markTestSkipped();
             }
             $checkinstances[] = $checkinstance;
index edb7f76..8e97822 100644 (file)
@@ -57,11 +57,11 @@ class cachestore_mongodb_test extends cachestore_tests {
         // This generates a definition that has a hash starting with a number. MDL-46208.
         $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_mongodb', 'abc');
         $instance = new cachestore_mongodb('MongoDB_Test', cachestore_mongodb::unit_test_configuration());
-        $instance->initialise($definition);
 
         if (!$instance->is_ready()) {
             $this->markTestSkipped();
         }
+        $instance->initialise($definition);
 
         $this->assertTrue($instance->set(1, 'alpha'));
         $this->assertTrue($instance->set(2, 'beta'));
index 4f9c757..0eee86e 100644 (file)
@@ -63,33 +63,33 @@ abstract class cachestore_tests extends advanced_testcase {
         if ($modes & cache_store::MODE_APPLICATION) {
             $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, $class, 'phpunit_test');
             $instance = new $class($class.'_test', $class::unit_test_configuration());
-            $instance->initialise($definition);
 
             if (!$instance->is_ready()) {
                 $this->markTestSkipped('Could not test '.$class.'. No test instance configured for application caches.');
             } else {
+                $instance->initialise($definition);
                 $this->run_tests($instance);
             }
         }
         if ($modes & cache_store::MODE_SESSION) {
             $definition = cache_definition::load_adhoc(cache_store::MODE_SESSION, $class, 'phpunit_test');
             $instance = new $class($class.'_test', $class::unit_test_configuration());
-            $instance->initialise($definition);
 
             if (!$instance->is_ready()) {
                 $this->markTestSkipped('Could not test '.$class.'. No test instance configured for session caches.');
             } else {
+                $instance->initialise($definition);
                 $this->run_tests($instance);
             }
         }
         if ($modes & cache_store::MODE_REQUEST) {
             $definition = cache_definition::load_adhoc(cache_store::MODE_REQUEST, $class, 'phpunit_test');
             $instance = new $class($class.'_test', $class::unit_test_configuration());
-            $instance->initialise($definition);
 
             if (!$instance->is_ready()) {
                 $this->markTestSkipped('Could not test '.$class.'. No test instance configured for request caches.');
             } else {
+                $instance->initialise($definition);
                 $this->run_tests($instance);
             }
         }
index 7352bb8..cf0a4f0 100644 (file)
@@ -103,14 +103,17 @@ if ($editcontrols = cohort_edit_controls($context, $baseurl)) {
 }
 
 // Add search form.
-$search  = html_writer::start_tag('form', array('id'=>'searchcohortquery', 'method'=>'get'));
-$search .= html_writer::start_tag('div');
-$search .= html_writer::label(get_string('searchcohort', 'cohort'), 'cohort_search_q'); // No : in form labels!
-$search .= html_writer::empty_tag('input', array('id'=>'cohort_search_q', 'type'=>'text', 'name'=>'search', 'value'=>$searchquery));
-$search .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('search', 'cohort')));
+$search  = html_writer::start_tag('form', array('id'=>'searchcohortquery', 'method'=>'get', 'class' => 'form-inline'));
+$search .= html_writer::start_div('m-b-1');
+$search .= html_writer::label(get_string('searchcohort', 'cohort'), 'cohort_search_q', true,
+        array('class' => 'm-r-1')); // No : in form labels!
+$search .= html_writer::empty_tag('input', array('id' => 'cohort_search_q', 'type' => 'text', 'name' => 'search',
+        'value' => $searchquery, 'class' => 'form-control m-r-1'));
+$search .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('search', 'cohort'),
+        'class' => 'btn btn-secondary'));
 $search .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'contextid', 'value'=>$contextid));
 $search .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'showall', 'value'=>$showall));
-$search .= html_writer::end_tag('div');
+$search .= html_writer::end_div();
 $search .= html_writer::end_tag('form');
 echo $search;
 
index b032cd6..3680559 100644 (file)
@@ -604,7 +604,8 @@ if ($pageid != LESSON_EOL) {
 
             $url = new moodle_url('/mod/lesson/view.php', array('id'=>$PAGE->cm->id, 'pageid'=>$pageid));
         }
-        $lessoncontent .= html_writer::link($url, get_string('reviewlesson', 'lesson'), array('class' => 'centerpadded lessonbutton standardbutton'));
+        $lessoncontent .= html_writer::link($url, get_string('reviewlesson', 'lesson'),
+                array('class' => 'centerpadded lessonbutton standardbutton p-r-1'));
     } elseif ($lesson->modattempts && $canmanage) {
         $lessoncontent .= $lessonoutput->paragraph(get_string("modattemptsnoteacher", "lesson"), 'centerpadded');
     }
@@ -614,13 +615,14 @@ if ($pageid != LESSON_EOL) {
     }
 
     $url = new moodle_url('/course/view.php', array('id'=>$course->id));
-    $lessoncontent .= html_writer::link($url, get_string('returnto', 'lesson', format_string($course->fullname, true)), array('class'=>'centerpadded lessonbutton standardbutton'));
+    $lessoncontent .= html_writer::link($url, get_string('returnto', 'lesson', format_string($course->fullname, true)),
+            array('class' => 'centerpadded lessonbutton standardbutton p-r-1'));
 
     if (has_capability('gradereport/user:view', context_course::instance($course->id))
             && $course->showgrades && $lesson->grade != 0 && !$lesson->practice) {
         $url = new moodle_url('/grade/index.php', array('id' => $course->id));
         $lessoncontent .= html_writer::link($url, get_string('viewgrades', 'lesson'),
-            array('class' => 'centerpadded lessonbutton standardbutton'));
+            array('class' => 'centerpadded lessonbutton standardbutton p-r-1'));
     }
 
     lesson_add_fake_blocks($PAGE, $cm, $lesson, $timer);
index 3a9488a..7b71623 100644 (file)
@@ -949,11 +949,13 @@ function scorm_print_launch ($user, $scorm, $action, $cm) {
                                                         'action' => $CFG->wwwroot.'/mod/scorm/player.php'));
         if ($scorm->hidebrowse == 0) {
             print_string('mode', 'scorm');
-            echo ': '.html_writer::empty_tag('input', array('type' => 'radio', 'id' => 'b', 'name' => 'mode', 'value' => 'browse')).
+            echo ': '.html_writer::empty_tag('input', array('type' => 'radio', 'id' => 'b', 'name' => 'mode',
+                    'value' => 'browse', 'class' => 'm-r-1')).
                         html_writer::label(get_string('browse', 'scorm'), 'b');
             echo html_writer::empty_tag('input', array('type' => 'radio',
                                                         'id' => 'n', 'name' => 'mode',
-                                                        'value' => 'normal', 'checked' => 'checked')).
+                                                        'value' => 'normal', 'checked' => 'checked',
+                                                        'class' => 'm-x-1')).
                     html_writer::label(get_string('normal', 'scorm'), 'n');
 
         } else {
@@ -976,7 +978,8 @@ function scorm_print_launch ($user, $scorm, $action, $cm) {
         echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scoid', 'value' => $scorm->launch));
         echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'cm', 'value' => $cm->id));
         echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'currentorg', 'value' => $orgidentifier));
-        echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('enter', 'scorm')));
+        echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('enter', 'scorm'),
+                'class' => 'btn btn-primary'));
         echo html_writer::end_tag('form');
         echo html_writer::end_div();
     }
index 41e1da5..6c3da63 100644 (file)
@@ -498,7 +498,8 @@ class report extends \mod_scorm\report {
                                                     get_string('selectnone', 'scorm'));
                         echo '&nbsp;&nbsp;';
                         echo \html_writer::empty_tag('input', array('type' => 'submit',
-                                                                    'value' => get_string('deleteselected', 'scorm')));
+                                                                    'value' => get_string('deleteselected', 'scorm'),
+                                                                    'class' => 'btn btn-secondary'));
                         echo \html_writer::end_tag('td').\html_writer::end_tag('tr').\html_writer::end_tag('table');
                         // Close form.
                         echo \html_writer::end_tag('div');
index 7af4050..0def88c 100644 (file)
@@ -588,7 +588,8 @@ class report extends \mod_scorm\report {
                                                     get_string('selectnone', 'scorm'));
                         echo '&nbsp;&nbsp;';
                         echo \html_writer::empty_tag('input', array('type' => 'submit',
-                                                                    'value' => get_string('deleteselected', 'scorm')));
+                                                                    'value' => get_string('deleteselected', 'scorm'),
+                                                                    'class' => 'btn btn-secondary'));
                         echo \html_writer::end_tag('td').\html_writer::end_tag('tr').\html_writer::end_tag('table');
                         // Close form.
                         echo \html_writer::end_tag('div');
@@ -600,17 +601,23 @@ class report extends \mod_scorm\report {
                         echo \html_writer::start_tag('td');
                         echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
                                                                    array('download' => 'ODS') + $displayoptions),
-                                                                   get_string('downloadods'));
+                                                                   get_string('downloadods'),
+                                                                   'post',
+                                                                   ['class' => 'm-t-1']);
                         echo \html_writer::end_tag('td');
                         echo \html_writer::start_tag('td');
                         echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
                                                                    array('download' => 'Excel') + $displayoptions),
-                                                                   get_string('downloadexcel'));
+                                                                   get_string('downloadexcel'),
+                                                                   'post',
+                                                                   ['class' => 'm-t-1']);
                         echo \html_writer::end_tag('td');
                         echo \html_writer::start_tag('td');
                         echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
                                                                    array('download' => 'CSV') + $displayoptions),
-                                                                   get_string('downloadtext'));
+                                                                   get_string('downloadtext'),
+                                                                   'post',
+                                                                   ['class' => 'm-t-1']);
                         echo \html_writer::end_tag('td');
                         echo \html_writer::start_tag('td');
                         echo \html_writer::end_tag('td');
index 231b973..c671d21 100644 (file)
@@ -580,7 +580,8 @@ class report extends \mod_scorm\report {
                                                     get_string('selectnone', 'scorm'));
                         echo '&nbsp;&nbsp;';
                         echo \html_writer::empty_tag('input', array('type' => 'submit',
-                                                                    'value' => get_string('deleteselected', 'scorm')));
+                                                                    'value' => get_string('deleteselected', 'scorm'),
+                                                                    'class' => 'btn btn-secondary'));
                         echo \html_writer::end_tag('td').\html_writer::end_tag('tr').\html_writer::end_tag('table');
                         // Close form.
                         echo \html_writer::end_tag('div');
@@ -592,17 +593,23 @@ class report extends \mod_scorm\report {
                         echo \html_writer::start_tag('td');
                         echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
                                                                    array('download' => 'ODS') + $displayoptions),
-                                                                   get_string('downloadods'));
+                                                                   get_string('downloadods'),
+                                                                   'post',
+                                                                   ['class' => 'm-t-1']);
                         echo \html_writer::end_tag('td');
                         echo \html_writer::start_tag('td');
                         echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
                                                                    array('download' => 'Excel') + $displayoptions),
-                                                                   get_string('downloadexcel'));
+                                                                   get_string('downloadexcel'),
+                                                                   'post',
+                                                                   ['class' => 'm-t-1']);
                         echo \html_writer::end_tag('td');
                         echo \html_writer::start_tag('td');
                         echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
                                                                    array('download' => 'CSV') + $displayoptions),
-                                                                   get_string('downloadtext'));
+                                                                   get_string('downloadtext'),
+                                                                   'post',
+                                                                   ['class' => 'm-t-1']);
                         echo \html_writer::end_tag('td');
                         echo \html_writer::start_tag('td');
                         echo \html_writer::end_tag('td');
index 4bb3f26..36a63e2 100644 (file)
@@ -208,7 +208,7 @@ class profile_field_base {
      * @param  moodleform $mform instance of the moodleform class
      */
     public function edit_field_set_default($mform) {
-        if (!empty($default)) {
+        if (!empty($this->field->defaultdata)) {
             $mform->setDefault($this->inputname, $this->field->defaultdata);
         }
     }
index d83f5a0..6a751de 100644 (file)
@@ -410,7 +410,7 @@ class core_webservice_renderer extends plugin_renderer_base {
             $paramdesc .= html_writer::start_tag('i', array());
             $paramdesc .= "//";
 
-            $paramdesc .= $params->desc;
+            $paramdesc .= s($params->desc);
 
             $paramdesc .= html_writer::end_tag('i');
 
@@ -685,7 +685,7 @@ EOF;
             $documentationhtml .= html_writer::start_tag('div',
                             array('style' => 'border:solid 1px #DEDEDE;background:#E2E0E0;
                         color:#222222;padding:4px;'));
-            $documentationhtml .= $description->description;
+            $documentationhtml .= s($description->description);
             $documentationhtml .= html_writer::end_tag('div');
             $documentationhtml .= $br . $br;
 
@@ -719,7 +719,7 @@ EOF;
                 $documentationhtml .= " (" . $required . ")"; // argument is required or optional ?
                 $documentationhtml .= $br;
                 $documentationhtml .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
-                        . $paramdesc->desc; // argument description
+                        . s($paramdesc->desc); // Argument description.
                 $documentationhtml .= $br . $br;
                 // general structure of the argument
                 $documentationhtml .= $this->colored_box_with_pre_tag(