Merge branch 'master_MDL-28542'
authorPetr Skoda <commits@skodak.org>
Tue, 2 Aug 2011 12:30:20 +0000 (14:30 +0200)
committerPetr Skoda <commits@skodak.org>
Tue, 2 Aug 2011 12:30:20 +0000 (14:30 +0200)
25 files changed:
admin/blocks.php
admin/cli/install_database.php
admin/settings/security.php
backup/moodle2/backup_stepslib.php
config-dist.php
filter/mediaplugin/lang/en/filter_mediaplugin.php
filter/mediaplugin/styles.css
lang/en/admin.php
lib/blocklib.php
lib/formslib.php
lib/outputrequirementslib.php
lib/pear/HTML/QuickForm.php
lib/pear/README_MOODLE.txt
lib/simpletest/testformslib.php [new file with mode: 0644]
message/lib.php
mod/assignment/lang/en/assignment.php
mod/quiz/editlib.php
mod/quiz/report/statistics/report.php
mod/quiz/styles.css
mod/scorm/db/install.xml
mod/scorm/db/upgrade.php
mod/scorm/module.js
mod/scorm/version.php
question/format/aiken/format.php
repository/youtube/lib.php

index 17b0350..b4fa841 100644 (file)
@@ -12,6 +12,8 @@
     $hide     = optional_param('hide', 0, PARAM_INT);
     $show     = optional_param('show', 0, PARAM_INT);
     $delete   = optional_param('delete', 0, PARAM_INT);
+    $unprotect = optional_param('unprotect', 0, PARAM_INT);
+    $protect = optional_param('protect', 0, PARAM_INT);
 
 /// Print headings
 
@@ -24,6 +26,9 @@
     $strcourses = get_string('blockinstances', 'admin');
     $strname = get_string('name');
     $strshowblockcourse = get_string('showblockcourse');
+    $strprotecthdr = get_string('blockprotect', 'admin'). $OUTPUT->help_icon('blockprotect','admin');
+    $strprotect = get_string('blockprotect', 'admin');
+    $strunprotect = get_string('blockunprotect', 'admin');
 
 /// If data submitted, then process and store.
 
         admin_get_root(true, false);  // settings not required - only pages
     }
 
+    if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
+        $undeletableblocktypes = array('navigation', 'settings');
+    } else if (is_string($CFG->undeletableblocktypes)) {
+        $undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
+    } else {
+        $undeletableblocktypes = $CFG->undeletableblocktypes;
+    }
+
+    if (!empty($protect) && confirm_sesskey()) {
+        if (!$block = $DB->get_record('block', array('id'=>$protect))) {
+            print_error('blockdoesnotexist', 'error');
+        }
+        if (!in_array($block->name, $undeletableblocktypes)) {
+            $undeletableblocktypes[] = $block->name;
+            set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
+        }
+        admin_get_root(true, false);  // settings not required - only pages
+    }
+
+    if (!empty($unprotect) && confirm_sesskey()) {
+        if (!$block = $DB->get_record('block', array('id'=>$unprotect))) {
+            print_error('blockdoesnotexist', 'error');
+        }
+        if (in_array($block->name, $undeletableblocktypes)) {
+            $undeletableblocktypes = array_diff($undeletableblocktypes, array($block->name));
+            set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
+        }
+        admin_get_root(true, false);  // settings not required - only pages
+    }
+
     if (!empty($delete) && confirm_sesskey()) {
         echo $OUTPUT->header();
         echo $OUTPUT->heading($strmanageblocks);
 
     $table = new flexible_table('admin-blocks-compatible');
 
-    $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
-    $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings));
+    $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
+    $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
     $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
     $table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
     $table->setup();
             $version = "$block->version ($plugin->version)";
         }
 
+        if (!$blockobject) {
+            // ignore
+            $undeletable = '';
+        } else if (in_array($blockname, $undeletableblocktypes)) {
+            $undeletable = '<a href="blocks.php?unprotect='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strunprotect.'">'.
+                       '<img src="'.$OUTPUT->pix_url('t/unlock') . '" class="icon" alt="'.$strunprotect.'" /></a>';
+        } else {
+            $undeletable = '<a href="blocks.php?protect='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strprotect.'">'.
+                       '<img src="'.$OUTPUT->pix_url('t/unlock_gray') . '" class="icon" alt="'.$strprotect.'" /></a>';
+        }
 
         $table->add_data(array(
             '<span'.$class.'>'.$strblockname.'</span>',
             $blocklist,
             '<span'.$class.'>'.$version.'</span>',
             $visible,
+            $undeletable,
             $delete,
             $settings
         ));
index ac58928..9e55c9c 100644 (file)
@@ -46,6 +46,8 @@ Options:
 --adminuser=USERNAME  Username for the moodle admin account. Default is admin.
 --adminpass=PASSWORD  Password for the moodle admin account.
 --agree-license       Indicates agreement with software license.
+--fullname            Name of the site
+--shortname           Name of the site
 -h, --help            Print out this help
 
 Example:
@@ -93,6 +95,8 @@ list($options, $unrecognized) = cli_get_params(
         'lang'              => 'en',
         'adminuser'         => 'admin',
         'adminpass'         => '',
+        'fullname'          => '',
+        'shortname'         => '',
         'agree-license'     => false,
         'help'              => false
     ),
index b2b264c..b72333c 100644 (file)
@@ -72,6 +72,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
     $temp->add(new admin_setting_configcheckbox('disableuserimages', get_string('disableuserimages', 'admin'), get_string('configdisableuserimages', 'admin'), 0));
     $temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', get_string('emailchangeconfirmation', 'admin'), get_string('configemailchangeconfirmation', 'admin'), 1));
     $temp->add(new admin_setting_configselect('rememberusername', get_string('rememberusername','admin'), get_string('rememberusername_desc','admin'), 2, array(1=>get_string('yes'), 0=>get_string('no'), 2=>get_string('optional'))));
+    $temp->add(new admin_setting_configcheckbox('strictformsrequired', get_string('strictformsrequired', 'admin'), get_string('configstrictformsrequired', 'admin'), 0));
     $ADMIN->add('security', $temp);
 
 
index ffc310e..d1b5d24 100644 (file)
@@ -319,8 +319,9 @@ class backup_module_structure_step extends backup_structure_step {
         // attach format plugin structure to $module element, only one allowed
         $this->add_plugin_structure('format', $module, false);
 
-        // attach plagiarism plugin structure to $module element, only one allowed
-        $this->add_plugin_structure('plagiarism', $module, false);
+        // attach plagiarism plugin structure to $module element, there can be potentially
+        // many plagiarism plugins storing information about this course
+        $this->add_plugin_structure('plagiarism', $module, true);
 
         // Define the tree
         $module->add_child($availinfo);
@@ -421,8 +422,9 @@ class backup_course_structure_step extends backup_structure_step {
         // course reports can save course data if required
         $this->add_plugin_structure('coursereport', $course, true);
 
-        // attach plagiarism plugin structure to $course element, only one allowed
-        $this->add_plugin_structure('plagiarism', $course, false);
+        // attach plagiarism plugin structure to $course element, there can be potentially
+        // many plagiarism plugins storing information about this course
+        $this->add_plugin_structure('plagiarism', $course, true);
 
         // Build the tree
 
index 61c4e20..4ca2b72 100644 (file)
@@ -208,11 +208,6 @@ $CFG->admin = 'admin';
 // These blocks are used when no other default setting is found.
 //      $CFG->defaultblocks = 'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity';
 //
-// The blocks in this list will be protected from deletion, and this is primarily
-// used to protect the navigation and settings blocks which can be very hard to
-// get back if accidentally delete.
-//      $CFG->undeletableblocktypes = 'navigation,settings';
-//
 // You can specify a different class to be created for the $PAGE global, and to
 // compute which blocks appear on each page. However, I cannot think of any good
 // reason why you would need to change that. It just felt wrong to hard-code the
index de7e98e..94062fa 100644 (file)
@@ -28,7 +28,7 @@ $string['filtername'] = 'Multimedia plugins';
 $string['flashanimation'] = 'Flash animation';
 $string['flashanimation_help'] = 'Files with extension *.swf. For security reasons this filter is used only in trusted texts.';
 $string['flashvideo'] = 'Flash video';
-$string['flashvideo_help'] = 'Files with extension *.flv and *.f4v. Plays video clips using Flowplayer, requires Flash plugin and javascript. Uses HTML 5 video fallback if multiple sources psecified.';
+$string['flashvideo_help'] = 'Files with extension *.flv and *.f4v. Plays video clips using Flowplayer, requires Flash plugin and javascript. Uses HTML 5 video fallback if multiple sources specified.';
 $string['html5audio'] = 'HTML 5 audio';
 $string['html5audio_help'] = 'Audio files with extension *.ogg, *.aac and others. It is compatible with latest web browsers only, unfortunately there is no format that is supported by all browsers.
 Workaround is to specify fallbacks separated with # (ex: http://example.org/audio.aac#http://example.org/audio.aac#http://example.org/audio.mp3#), QuickTime player is used as a fallback for old browsers, fallback can be any audio type.';
index bb39c83..a1283ce 100644 (file)
@@ -11,4 +11,4 @@
  * see http://flowplayer.org/documentation/skinning/controlbar.html?skin=default for more color properties,
  * any property that ends with '...Color' is supported here.
  */
-.mp3flowplayer_backgroundColor {color: #000000};
+.mp3flowplayer_backgroundColor {color: #000000;}
index cec064f..bf5b8b0 100644 (file)
@@ -72,6 +72,9 @@ $string['badwordslist'] = 'Custom bad words list';
 $string['blockediplist'] = 'Blocked IP List';
 $string['blockinstances'] = 'Instances';
 $string['blockmultiple'] = 'Multiple';
+$string['blockprotect'] = 'Protect from delete';
+$string['blockprotect_help'] = 'Selected block instances will be protected from deletion from the site-wide context. This is primarily used to protect the navigation and settings blocks which can be very hard to get back if accidentally deleted.';
+$string['blockunprotect'] = 'Unprotect';
 $string['blocksettings'] = 'Manage blocks';
 $string['bloglevel'] = 'Blog visibility';
 $string['bloglevelupgrade'] = 'Blog visibility upgrade';
@@ -330,6 +333,7 @@ $string['configstatsmaxruntime3'] = 'Specify the maximum time allowed to calcula
 $string['configstatsruntimedays'] = 'Specify the maximum number of days processed in each stats execution. When stats are up-to-date, only one day will be processed, so adjust this value depending of your server load, reducing it if shorter cron executions are needed.';
 $string['configstatsruntimestart'] = 'What time should the cronjob that does the stats processing <b>start</b>? Please specify different times if there are multiple Moodles on one physical server.';
 $string['configstatsuserthreshold'] = 'This setting specifies the minimum number of enrolled users for a course to be included in statistics calculations.';
+$string['configstrictformsrequired'] = 'If enabled, users are prevented from entering a space or line break only in required fields in forms.';
 $string['configstripalltitletags'] = 'Uncheck this setting to allow HTML tags in activity and resource names.';
 $string['configsupportemail'] = 'This email address will be published to users of this site as the one to email when they need general help (for example, when new users create their own accounts).  If this email is left blank then no such helpful email address is supplied.';
 $string['configsupportname'] = 'This is the name of a person or other entity offering general help via the support email or web address.';
@@ -958,6 +962,7 @@ $string['stickyblockscourseview'] = 'Course page';
 $string['stickyblocksduplicatenotice'] = 'If any block you add here is already present in a particular page, it will result in a duplicate.<br />Only the pinned block will be non-editable, the duplicate will still be editable.';
 $string['stickyblocksmymoodle'] = 'My Moodle';
 $string['stickyblockspagetype'] = 'Page type to configure';
+$string['strictformsrequired'] = 'Strict validation of required fields';
 $string['stripalltitletags'] = 'Remove HTML tags from all activity names';
 $string['supportcontact'] = 'Support contact';
 $string['supportemail'] = 'Support email';
index 4c816c2..d8a1987 100644 (file)
@@ -997,9 +997,11 @@ class block_manager {
         global $CFG;
 
         if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
-            $CFG->undeletableblocktypes = array('navigation','settings');
+            $undeletableblocktypes = array('navigation','settings');
         } else if (is_string($CFG->undeletableblocktypes)) {
-            $CFG->undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
+            $undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
+        } else {
+            $undeletableblocktypes = $CFG->undeletableblocktypes;
         }
 
         $controls = array();
@@ -1037,7 +1039,9 @@ class block_manager {
         }
 
         if ($this->page->user_can_edit_blocks() && $block->user_can_edit() && $block->user_can_addto($this->page)) {
-            if (!in_array($block->instance->blockname, $CFG->undeletableblocktypes)) {
+            if (!in_array($block->instance->blockname, $undeletableblocktypes)
+                    || !in_array($block->instance->pagetypepattern, array('*', 'site-index'))
+                    || $block->instance->parentcontextid != SITEID) {
                 // Delete icon.
                 $controls[] = array('url' => $actionurl . '&bui_deleteid=' . $block->instance->id,
                         'icon' => 't/delete', 'caption' => get_string('delete'));
index fbc6a50..1787b0f 100644 (file)
@@ -43,6 +43,7 @@ defined('MOODLE_INTERNAL') || die();
 require_once 'HTML/QuickForm.php';
 require_once 'HTML/QuickForm/DHTMLRulesTableless.php';
 require_once 'HTML/QuickForm/Renderer/Tableless.php';
+require_once 'HTML/QuickForm/Rule.php';
 
 require_once $CFG->libdir.'/filelib.php';
 
@@ -2344,6 +2345,57 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
     }
 }
 
+/**
+ * Required elements validation
+ * This class overrides QuickForm validation since it allowed space or empty tag as a value
+ */
+class MoodleQuickForm_Rule_Required extends HTML_QuickForm_Rule {
+    /**
+     * Checks if an element is not empty.
+     * This is a server-side validation, it works for both text fields and editor fields
+     *
+     * @param     string    $value      Value to check
+     * @param     mixed     $options    Not used yet
+     * @return    boolean   true if value is not empty
+     */
+    function validate($value, $options = null) {
+        global $CFG;
+        if (is_array($value) && array_key_exists('text', $value)) {
+            $value = $value['text'];
+        }
+        $stripvalues = array(
+            '#</?(?!img|canvas|hr).*?>#im', // all tags except img, canvas and hr
+            '#(\xc2|\xa0|\s|&nbsp;)#', //any whitespaces actually
+        );
+        if (!empty($CFG->strictformsrequired)) {
+            $value = preg_replace($stripvalues, '', (string)$value);
+        }
+        if ((string)$value == '') {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * This function returns Javascript code used to build client-side validation.
+     * It checks if an element is not empty.
+     * Note, that QuickForm does not know how to work with editor text field and builds not correct
+     * JS code for validation. If client check is enabled for editor field it will not be validated
+     * on client side no matter what this function returns.
+     *
+     * @param     mixed     $options    Not used yet
+     * @return array
+     */
+    function getValidationScript($options = null) {
+        global $CFG;
+        if (!empty($CFG->strictformsrequired)) {
+            return array('', "{jsVar}.replace(/^\s+$/g, '') == ''");
+        } else {
+            return array('', "{jsVar} == ''");
+        }
+    }
+}
+
 /**
  * @global object $GLOBALS['_HTML_QuickForm_default_renderer']
  * @name $_HTML_QuickForm_default_renderer
@@ -2387,3 +2439,5 @@ MoodleQuickForm::registerElementType('text', "$CFG->libdir/form/text.php", 'Mood
 MoodleQuickForm::registerElementType('textarea', "$CFG->libdir/form/textarea.php", 'MoodleQuickForm_textarea');
 MoodleQuickForm::registerElementType('url', "$CFG->libdir/form/url.php", 'MoodleQuickForm_url');
 MoodleQuickForm::registerElementType('warning', "$CFG->libdir/form/warning.php", 'MoodleQuickForm_warning');
+
+MoodleQuickForm::registerRule('required', null, 'MoodleQuickForm_Rule_Required', "$CFG->libdir/formslib.php");
index 6c7d0e4..8cb253e 100644 (file)
@@ -198,7 +198,6 @@ class page_requirements_manager {
             )
         );
         $this->add_yui2_modules(); // adds loading info for all YUI2 modules
-        $this->js_module($this->find_module('core_filepicker'));
         $this->js_module($this->find_module('core_dock'));
 
         // YUI3 init code
index fe6c3f6..e9e4a7e 100644 (file)
@@ -1502,13 +1502,6 @@ class HTML_QuickForm extends HTML_Common {
                         $values[] = $this->getSubmitValue($elName);
                     }
                     $result = $registry->validate($rule['type'], $values, $rule['format'], true);
-                } else if ($rule['type'] === 'required' and $this->getElement($target)->_type === 'editor') {
-                    //horrible horrible hack
-                    if (!isset($submitValue['text']) or $submitValue['text'] === '') {
-                        $result = false;
-                    } else {
-                        $result = true;
-                    }
                 } elseif (is_array($submitValue) && !isset($rule['howmany'])) {
                     $result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
                 } else {
index 8fa59f4..00eeff5 100644 (file)
@@ -22,8 +22,6 @@ and documented for Moodle at:
 
 4/ MDL-20876 - replaced deprecated split() with explode() or str_split() where appropriate
 
-5/ hardcoded editor element required rule validation
-
 Such modifications should be carefully each time the Excel PEAR package is updated
 to a new release within Moodle.
 
diff --git a/lib/simpletest/testformslib.php b/lib/simpletest/testformslib.php
new file mode 100644 (file)
index 0000000..0330895
--- /dev/null
@@ -0,0 +1,119 @@
+<?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/>.
+
+
+/**
+ * Unit tests for /lib/formslib.php.
+ *
+ * @package   file
+ * @copyright 2011 Sam Hemelryk
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+    die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
+}
+require_once($CFG->libdir . '/formslib.php');
+
+class formslib_test extends UnitTestCase {
+
+    public function test_require_rule() {
+        global $CFG;
+
+        $strictformsrequired = false;
+        if (!empty($CFG->strictformsrequired)) {
+            $strictformsrequired = $CFG->strictformsrequired;
+        }
+
+        $rule = new MoodleQuickForm_Rule_Required();
+
+        // First run the tests with strictformsrequired off
+        $CFG->strictformsrequired = false;
+        // Passes
+        $this->assertTrue($rule->validate('Something'));
+        $this->assertTrue($rule->validate("Something\nmore"));
+        $this->assertTrue($rule->validate("\nmore"));
+        $this->assertTrue($rule->validate(" more "));
+        $this->assertTrue($rule->validate("0"));
+        $this->assertTrue($rule->validate(0));
+        $this->assertTrue($rule->validate(true));
+        $this->assertTrue($rule->validate(' '));
+        $this->assertTrue($rule->validate('      '));
+        $this->assertTrue($rule->validate("\t"));
+        $this->assertTrue($rule->validate("\n"));
+        $this->assertTrue($rule->validate("\r"));
+        $this->assertTrue($rule->validate("\r\n"));
+        $this->assertTrue($rule->validate(" \t  \n  \r "));
+        $this->assertTrue($rule->validate('<p></p>'));
+        $this->assertTrue($rule->validate('<p> </p>'));
+        $this->assertTrue($rule->validate('<p>x</p>'));
+        $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile" />'));
+        $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"/>'));
+        $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"></img>'));
+        $this->assertTrue($rule->validate('<hr />'));
+        $this->assertTrue($rule->validate('<hr/>'));
+        $this->assertTrue($rule->validate('<hr>'));
+        $this->assertTrue($rule->validate('<hr></hr>'));
+        $this->assertTrue($rule->validate('<br />'));
+        $this->assertTrue($rule->validate('<br/>'));
+        $this->assertTrue($rule->validate('<br>'));
+        $this->assertTrue($rule->validate('&nbsp;'));
+        // Fails
+        $this->assertFalse($rule->validate(''));
+        $this->assertFalse($rule->validate(false));
+        $this->assertFalse($rule->validate(null));
+
+        // Now run the same tests with it on to make sure things work as expected
+        $CFG->strictformsrequired = true;
+        // Passes
+        $this->assertTrue($rule->validate('Something'));
+        $this->assertTrue($rule->validate("Something\nmore"));
+        $this->assertTrue($rule->validate("\nmore"));
+        $this->assertTrue($rule->validate(" more "));
+        $this->assertTrue($rule->validate("0"));
+        $this->assertTrue($rule->validate(0));
+        $this->assertTrue($rule->validate(true));
+        $this->assertTrue($rule->validate('<p>x</p>'));
+        $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile" />'));
+        $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"/>'));
+        $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"></img>'));
+        $this->assertTrue($rule->validate('<hr />'));
+        $this->assertTrue($rule->validate('<hr/>'));
+        $this->assertTrue($rule->validate('<hr>'));
+        $this->assertTrue($rule->validate('<hr></hr>'));
+        // Fails
+        $this->assertFalse($rule->validate(' '));
+        $this->assertFalse($rule->validate('      '));
+        $this->assertFalse($rule->validate("\t"));
+        $this->assertFalse($rule->validate("\n"));
+        $this->assertFalse($rule->validate("\r"));
+        $this->assertFalse($rule->validate("\r\n"));
+        $this->assertFalse($rule->validate(" \t  \n  \r "));
+        $this->assertFalse($rule->validate('<p></p>'));
+        $this->assertFalse($rule->validate('<p> </p>'));
+        $this->assertFalse($rule->validate('<br />'));
+        $this->assertFalse($rule->validate('<br/>'));
+        $this->assertFalse($rule->validate('<br>'));
+        $this->assertFalse($rule->validate('&nbsp;'));
+        $this->assertFalse($rule->validate(''));
+        $this->assertFalse($rule->validate(false));
+        $this->assertFalse($rule->validate(null));
+
+        $CFG->strictformsrequired = $strictformsrequired;
+    }
+
+}
\ No newline at end of file
index 9de50e0..1d4013f 100644 (file)
@@ -1000,14 +1000,14 @@ function message_get_contact($contactid) {
  *
  * @param mixed $frm submitted form data
  * @param bool $showicontext show text next to action icons?
- * @param object $user1 the current user
+ * @param object $currentuser the current user
  * @return void
  */
-function message_print_search_results($frm, $showicontext=false, $user1=null) {
+function message_print_search_results($frm, $showicontext=false, $currentuser=null) {
     global $USER, $DB, $OUTPUT;
 
-    if (empty($user1)) {
-        $user1 = $USER;
+    if (empty($currentuser)) {
+        $currentuser = $USER;
     }
 
     echo html_writer::start_tag('div', array('class' => 'mdl-left'));
@@ -1227,14 +1227,17 @@ function message_print_search_results($frm, $showicontext=false, $user1=null) {
                 echo message_get_fragment($message->fullmessage, $keywords);
                 echo html_writer::start_tag('div', array('class' => 'link'));
 
-                //find the user involved that isn't the current user
-                $user2id = null;
-                if ($user1->id == $message->useridto) {
-                    $user2id = $message->useridfrom;
+                //If the user clicks the context link display message sender on the left
+                //EXCEPT if the current user is in the conversation. Current user == always on the left
+                $leftsideuserid = $rightsideuserid = null;
+                if ($currentuser->id == $message->useridto) {
+                    $leftsideuserid = $message->useridto;
+                    $rightsideuserid = $message->useridfrom;
                 } else {
-                    $user2id = $message->useridto;
+                    $leftsideuserid = $message->useridfrom;
+                    $rightsideuserid = $message->useridto;
                 }
-                message_history_link($user1->id, $user2id, false,
+                message_history_link($leftsideuserid, $rightsideuserid, false,
                                      $messagesearchstring, 'm'.$message->id, $strcontext);
                 echo html_writer::end_tag('div');
                 echo html_writer::end_tag('td');
@@ -1393,7 +1396,7 @@ function message_contact_link($userid, $linktype='add', $return=false, $script=n
  * echo or return a link to take the user to the full message history between themselves and another user
  *
  * @staticvar type $strmessagehistory
- * @param int $userid1 the ID of the current user
+ * @param int $userid1 the ID of the user displayed on the left (usually the current user)
  * @param int $userid2 the ID of the other user
  * @param bool $return true to return the link as a string. False to echo the link.
  * @param string $keywords any keywords to highlight in the message history
@@ -1403,7 +1406,6 @@ function message_contact_link($userid, $linktype='add', $return=false, $script=n
  */
 function message_history_link($userid1, $userid2, $return=false, $keywords='', $position='', $linktext='') {
     global $OUTPUT;
-
     static $strmessagehistory;
 
     if (empty($strmessagehistory)) {
@@ -1437,7 +1439,7 @@ function message_history_link($userid1, $userid2, $return=false, $keywords='', $
             'scrollbars' => true,
             'resizable' => true);
 
-    $link = new moodle_url('/message/index.php?history='.MESSAGE_HISTORY_ALL."&user=$userid1&id=$userid2$keywords$position");
+    $link = new moodle_url('/message/index.php?history='.MESSAGE_HISTORY_ALL."&user1=$userid1&user2=$userid2$keywords$position");
     $action = null;
     $str = $OUTPUT->action_link($link, $fulllink, $action, array('title' => $strmessagehistory));
 
index b7f559e..e9a9031 100644 (file)
@@ -98,7 +98,7 @@ $string['errornosubmissions'] = 'There are no submissions to download';
 $string['existingfiledeleted'] = 'Existing file has been deleted: {$a}';
 $string['failedupdatefeedback'] = 'Failed to update submission feedback for user {$a}';
 $string['feedback'] = 'Feedback';
-$string['feedbackfromteacher'] = 'Feedback from the {$a}';
+$string['feedbackfromteacher'] = 'Feedback from {$a}';
 $string['feedbackupdated'] = 'Submissions feedback updated for {$a} people';
 $string['finalize'] = 'Prevent submission updates';
 $string['finalizeerror'] = 'An error occurred and that submission could not be finalised';
index 21ad231..43dffcc 100644 (file)
@@ -534,23 +534,20 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool,
                     $reordercheckboxlabel = '<label for="s' . $question->id . '">';
                     $reordercheckboxlabelclose = '</label>';
                 }
-                if (!$quiz->shufflequestions) {
-                    // Print and increment question number
-                    $questioncountstring = '';
-                    if ($questioncount>999 || ($reordertool && $questioncount>99)) {
-                        $questioncountstring =
-                                "$reordercheckboxlabel<small>$questioncount</small>" .
-                                $reordercheckboxlabelclose . $reordercheckbox;
+                if ($question->length == 0) {
+                    $qnodisplay = get_string('infoshort', 'quiz');
+                } else if ($quiz->shufflequestions) {
+                    $qnodisplay = '?';
+                } else {
+                    if ($qno > 999 || ($reordertool && $qno > 99)) {
+                        $qnodisplay = html_writer::tag('small', $qno);
                     } else {
-                        $questioncountstring = $reordercheckboxlabel . $questioncount .
-                                $reordercheckboxlabelclose . $reordercheckbox;
+                        $qnodisplay = $qno;
                     }
-                    echo $questioncountstring;
                     $qno += $question->length;
-                } else {
-                    echo "$reordercheckboxlabel ? $reordercheckboxlabelclose" .
-                            " $reordercheckbox";
                 }
+                echo $reordercheckboxlabel . $qnodisplay . $reordercheckboxlabelclose .
+                        $reordercheckbox;
 
                 ?>
         </div>
index 2c8f534..d7875e3 100644 (file)
@@ -209,7 +209,7 @@ class quiz_statistics_report extends quiz_default_report {
             // Back to overview link.
             echo $OUTPUT->box('<a href="' . $reporturl->out() . '">' .
                     get_string('backtoquizreport', 'quiz_statistics') . '</a>',
-                    'boxaligncenter generalbox boxwidthnormal mdl-align');
+                    'backtomainstats boxaligncenter generalbox boxwidthnormal mdl-align');
 
         } else if ($qid) {
             // Report on an individual sub-question indexed questionid.
@@ -313,7 +313,7 @@ class quiz_statistics_report extends quiz_default_report {
 
         echo $OUTPUT->box(format_text($question->questiontext, $question->questiontextformat,
                 array('overflowdiv' => true)) . $actions,
-                'boxaligncenter generalbox boxwidthnormal mdl-align');
+                'questiontext boxaligncenter generalbox boxwidthnormal mdl-align');
 
         echo $OUTPUT->heading(get_string('questionstatistics', 'quiz_statistics'));
         echo html_writer::table($questionstatstable);
index be2d4ea..60d83d4 100644 (file)
@@ -374,6 +374,7 @@ bank window's title is prominent enough*/
 .ie6#page-mod-quiz-edit div.question div.content .questionname {width:20%;}
 .ie6#page-mod-quiz-edit .editq div.question div.content .randomquestioncategory a{width:40%;}
 .ie6#page-mod-quiz-edit .reorder .questioncontentcontainer .randomquestioncategory label{width: 35%;}
+.qnum label {padding-right: 0.25em;}
 
 /** settings.php */
 #adminquizreviewoptions {margin-bottom: 0.5em;}
index ab1d6e1..ca356ba 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/scorm/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/scorm"
+<XMLDB PATH="mod/scorm/db" VERSION="20110731" COMMENT="XMLDB file for Moodle mod/scorm"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="scoid"/>
         <FIELD NAME="scoid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="primaryobj"/>
         <FIELD NAME="primaryobj" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="scoid" NEXT="objectiveid"/>
-        <FIELD NAME="objectiveid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="primaryobj" NEXT="satisfiedbymeasure"/>
+        <FIELD NAME="objectiveid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="primaryobj" NEXT="satisfiedbymeasure"/>
         <FIELD NAME="satisfiedbymeasure" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" PREVIOUS="objectiveid" NEXT="minnormalizedmeasure"/>
         <FIELD NAME="minnormalizedmeasure" TYPE="float" LENGTH="11" NOTNULL="true" UNSIGNED="true" DEFAULT="0.0000" SEQUENCE="false" DECIMALS="4" PREVIOUS="satisfiedbymeasure"/>
       </FIELDS>
       </KEYS>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 31d5b55..2f24c87 100644 (file)
@@ -546,6 +546,14 @@ function xmldb_scorm_upgrade($oldversion) {
         unset_config('updatetime', 'scorm');
         upgrade_mod_savepoint(true, 2011021402, 'scorm');
     }
+    
+    if ($oldversion < 2011073100) {
+        // change field type of objectiveid
+        $table = new xmldb_table('scorm_seq_objective');
+        $field = new xmldb_field('objectiveid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'primaryobj');
+        $dbman->change_field_type($table, $field);
+        upgrade_main_savepoint(true, 2011073100, 'scorm');
+    }
 
     return true;
 }
index f523509..8467dfd 100644 (file)
@@ -183,6 +183,16 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
             }
 
             scorm_layout_widget.setStyle('height', '100%');
+            var center = scorm_layout_widget.getUnitByPosition('center');
+            center.setStyle('height', '100%');
+
+            // calculate the rough new height
+            newheight = YAHOO.util.Dom.getViewportHeight() *.82;
+            if (newheight < 600) {
+                newheight = 600;
+            }
+            scorm_layout_widget.set('height', newheight);
+
             scorm_layout_widget.render();
             scorm_resize_frame();
 
index ed58a07..14ccce0 100644 (file)
@@ -23,6 +23,6 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-$module->version  = 2011060500;   // The (date) version of this module
+$module->version  = 2011073100;   // The (date) version of this module
 $module->requires = 2010080300;   // The version of Moodle that is required
 $module->cron     = 300;            // How often should cron check this module (seconds)?
index f5f2c58..d9db4bb 100644 (file)
@@ -96,8 +96,8 @@ class qformat_aiken extends qformat_default {
                 } else {
                     // Must be the first line of a new question, since no recognised prefix.
                     $question->qtype = MULTICHOICE;
-                    $question->name = htmlspecialchars(substr($nowline, 0, 50));
-                    $question->questiontext = htmlspecialchars($nowline);
+                    $question->name = shorten_text(s($nowline), 50);
+                    $question->questiontext = s($nowline);
                     $question->single = 1;
                     $question->feedback[] = '';
                 }
index a845f16..67166df 100644 (file)
@@ -57,7 +57,7 @@ class repository_youtube extends repository {
         foreach ($xml->entry as $entry) {
             $media = $entry->children('http://search.yahoo.com/mrss/');
             $title = $media->group->title;
-            $attrs = $media->group->thumbnail->attributes();
+            $attrs = $media->group->thumbnail[2]->attributes();
             $thumbnail = $attrs['url'];
             $arr = explode('/', $entry->id);
             $id = $arr[count($arr)-1];