Merge branch 'MDL-48067-master' of git://github.com/jethac/moodle
authorDan Poltawski <dan@moodle.com>
Wed, 5 Nov 2014 10:15:41 +0000 (10:15 +0000)
committerDan Poltawski <dan@moodle.com>
Wed, 5 Nov 2014 10:15:41 +0000 (10:15 +0000)
24 files changed:
admin/tool/monitor/classes/rule_form.php
admin/tool/monitor/lang/en/tool_monitor.php
availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-debug.js
availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js
availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form.js
availability/condition/profile/yui/src/form/js/form.js
grade/report/singleview/classes/local/screen/grade.php
grade/report/singleview/classes/local/screen/user.php
mod/assign/locallib.php
mod/data/edit.php
mod/data/field/file/field.class.php
mod/data/field/picture/field.class.php
mod/forum/index.php
mod/forum/lang/en/forum.php
mod/forum/lib.php
mod/forum/subscribe.php
mod/lesson/lang/en/lesson.php
mod/lesson/locallib.php
mod/lesson/styles.css
mod/lesson/timer.js
mod/lesson/version.php
mod/scorm/datamodels/scorm_13.js
mod/scorm/datamodels/scorm_13lib.php
user/renderer.php

index ec7beb4..549adba 100644 (file)
@@ -123,7 +123,8 @@ class rule_form extends \moodleform {
 
         // Message template.
         $mform->addElement('editor', 'template', get_string('messagetemplate', 'tool_monitor'), $editoroptions);
-        $mform->setDefault('template', get_string('defaultmessagetemplate', 'tool_monitor'));
+        $mform->setDefault('template', array('text' => get_string('defaultmessagetemplate', 'tool_monitor'),
+                'format' => FORMAT_HTML));
         $mform->addRule('template', get_string('required'), 'required');
         $mform->addHelpButton('template', 'messagetemplate', 'tool_monitor');
 
index 1d58608..cd972ae 100644 (file)
@@ -31,7 +31,7 @@ $string['area'] = 'Area';
 $string['areatomonitor'] = 'Area to monitor';
 $string['core'] = 'Core';
 $string['currentsubscriptions'] = 'Your current subscriptions';
-$string['defaultmessagetemplate'] = 'The rule "{rulename}" you have subscribed to has occurred - please find further details at {link}';
+$string['defaultmessagetemplate'] = 'Rule name: {rulename}<br />Description: {description}<br />Event name: {eventname}';
 $string['deleterule'] = 'Delete rule';
 $string['deletesubscription'] = 'Delete subscription';
 $string['description'] = 'Description:';
@@ -67,6 +67,7 @@ $string['messagetemplate_help'] = 'A notification message is sent to subscribers
 * Rule name {rulename}<br />
 * Description {description}<br />
 * Event {eventname}';
+$string['messagetemplate_link'] = 'admin/tool/monitor/managerules';
 $string['moduleinstance'] = 'Instance';
 $string['monitor:managerules'] = 'Manage event monitor rules';
 $string['monitor:subscribe'] = 'Subscribe to event monitor rules';
index 0973f47..c4b906d 100644 (file)
Binary files a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-debug.js and b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-debug.js differ
index f0ab241..6251004 100644 (file)
Binary files a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js and b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js differ
index 0973f47..c4b906d 100644 (file)
Binary files a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form.js and b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form.js differ
index afc486e..aa01d6a 100644 (file)
@@ -72,6 +72,9 @@ M.availability_profile.form.getNode = function(json) {
     if (json.op !== undefined &&
             node.one('select[name=op] > option[value=' + json.op + ']')) {
         node.one('select[name=op]').set('value', json.op);
+        if (json.op === 'isempty' || json.op === 'isnotempty') {
+            node.one('input[name=value]').set('disabled', true);
+        }
     }
     if (json.v !== undefined) {
         node.one('input').set('value', json.v);
index 1fd1c29..2739f0f 100644 (file)
@@ -329,6 +329,12 @@ class grade extends tablelike implements selectable_items, filterable_items {
 
                     $data->$field = empty($grade) ? $null : $grade->finalgrade;
                     $data->{"old$field"} = $data->$field;
+
+                    preg_match('/_(\d+)_(\d+)/', $field, $oldoverride);
+                    $oldoverride = 'oldoverride' . $oldoverride[0];
+                    if (empty($data->$oldoverride)) {
+                        $data->$field = (!isset($grade->rawgrade)) ? $null : $grade->rawgrade;
+                    }
                 }
             }
 
index 719aead..cf3fddd 100644 (file)
@@ -341,25 +341,32 @@ class user extends tablelike implements selectable_items {
             $userid = $this->item->id;
             foreach ($this->items as $gradeitemid => $gradeitem) {
                 $null = $gradeitem->gradetype == GRADE_TYPE_SCALE ? -1 : '';
-                $field = "finalgrade_{$gradeitem->id}_{$gradeitemid}";
+                $field = "finalgrade_{$gradeitem->id}_{$this->itemid}";
                 if (isset($data->$field)) {
                     continue;
                 }
 
                 $grade = grade_grade::fetch(array(
-                    'itemid' => $gradeitem->id,
+                    'itemid' => $this->itemid,
                     'userid' => $userid
                 ));
 
                 $data->$field = empty($grade) ? $null : $grade->finalgrade;
                 $data->{"old$field"} = $data->$field;
+
+                preg_match('/_(\d+)_(\d+)/', $field, $oldoverride);
+                $oldoverride = 'oldoverride' . $oldoverride[0];
+                if (empty($data->$oldoverride)) {
+                    $data->$field = (!isset($grade->rawgrade)) ? $null : $grade->rawgrade;
+                }
+
             }
 
             foreach ($data as $varname => $value) {
                 if (preg_match('/override_(\d+)_(\d+)/', $varname, $matches)) {
                     $data->$matches[0] = '1';
                 }
-                if (!preg_match('/^finalgrade_(\d+)_/', $varname, $matches)) {
+                if (!preg_match('/^finalgrade_(\d+)_(\d+)/', $varname, $matches)) {
                     continue;
                 }
 
index 14dc5d5..2e3fec6 100644 (file)
@@ -770,6 +770,11 @@ class assign {
                 // Remove all grades from gradebook.
                 require_once($CFG->dirroot.'/mod/assign/lib.php');
                 assign_reset_gradebook($data->courseid);
+
+                // Reset revealidentities if both submissions and grades have been reset.
+                if ($this->get_instance()->blindmarking && $this->get_instance()->revealidentities) {
+                    $DB->set_field('assign', 'revealidentities', 0, array('id' => $this->get_instance()->id));
+                }
             }
         }
         // Updating dates - shift may be negative too.
index 2e88e31..6dd59f7 100644 (file)
@@ -297,9 +297,13 @@ if ($data->addtemplate){
     ///then we generate strings to replace
     foreach ($possiblefields as $eachfield){
         $field = data_get_field($eachfield, $data);
-        $patterns[]="[[".$field->field->name."]]";
-        $replacements[] = $field->display_add_field($rid);
-        $patterns[]="[[".$field->field->name."#id]]";
+
+        // To skip unnecessary calls to display_add_field().
+        if (strpos($data->addtemplate, "[[".$field->field->name."]]") !== false) {
+            $patterns[] = "[[".$field->field->name."]]";
+            $replacements[] = $field->display_add_field($rid);
+        }
+        $patterns[] = "[[".$field->field->name."#id]]";
         $replacements[] = 'field_'.$field->field->id;
     }
     $newtext = str_ireplace($patterns, $replacements, $data->{$mode});
index 5ea4f56..5fd2d21 100644 (file)
@@ -87,23 +87,6 @@ class data_field_file extends data_field_base {
         $html .= '</fieldset>';
         $html .= '</div>';
 
-        $module = array(
-            'name'=>'form_filemanager',
-            'fullpath'=>'/lib/form/filemanager.js',
-            'requires' => array('core_filepicker', 'base', 'io-base', 'node',
-                    'json', 'core_dndupload', 'panel', 'resize-plugin', 'dd-plugin'),
-            'strings' => array(
-                array('error', 'moodle'), array('info', 'moodle'), array('confirmdeletefile', 'repository'),
-                array('draftareanofiles', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'),
-                array('invalidjson', 'repository'), array('popupblockeddownload', 'repository'),
-                array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'),
-                array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'),
-                array('confirmrenamefile', 'repository'), array('edit', 'moodle')
-            )
-        );
-
-        $PAGE->requires->js_init_call('M.form_filemanager.init', array($fm->options), true, $module);
-
         return $html;
     }
 
index b3e378d..a459791 100644 (file)
@@ -101,23 +101,6 @@ class data_field_picture extends data_field_base {
         $str .= '</fieldset>';
         $str .= '</div>';
 
-        $module = array(
-            'name'=>'form_filemanager',
-            'fullpath'=>'/lib/form/filemanager.js',
-            'requires' => array('core_filepicker', 'base', 'io-base', 'node',
-                    'json', 'core_dndupload', 'panel', 'resize-plugin', 'dd-plugin'),
-            'strings' => array(
-                array('error', 'moodle'), array('info', 'moodle'), array('confirmdeletefile', 'repository'),
-                array('draftareanofiles', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'),
-                array('invalidjson', 'repository'), array('popupblockeddownload', 'repository'),
-                array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'),
-                array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'),
-                array('confirmrenamefile', 'repository'), array('edit', 'moodle')
-            )
-        );
-
-        $PAGE->requires->js_init_call('M.form_filemanager.init', array($fm->options), true, $module);
-
         return $str;
     }
 
index f0ea4a8..43d1d97 100644 (file)
@@ -268,13 +268,9 @@ if ($generalforums) {
         }
 
         if ($can_subscribe) {
-            if (!\mod_forum\subscriptions::subscription_disabled($forum)) {
-                $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
-                        'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
-                        'cantsubscribe' => '-'), false, false, true);
-            } else {
-                $row[] = '-';
-            }
+            $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
+                    'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
+                    'cantsubscribe' => '-'), false, false, true);
 
             $digestoptions_selector->url->param('id', $forum->id);
             if ($forum->maildigest === null) {
@@ -418,13 +414,9 @@ if ($course->id != SITEID) {    // Only real courses have learning forums
             }
 
             if ($can_subscribe) {
-                if (!\mod_forum\subscriptions::subscription_disabled($forum)) {
-                    $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
-                        'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
-                        'cantsubscribe' => '-'), false, false, true);
-                } else {
-                    $row[] = '-';
-                }
+                $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
+                    'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
+                    'cantsubscribe' => '-'), false, false, true);
 
                 $digestoptions_selector->url->param('id', $forum->id);
                 if ($forum->maildigest === null) {
index f4a9887..7ed7e41 100644 (file)
@@ -115,6 +115,7 @@ $string['delete'] = 'Delete';
 $string['deleteddiscussion'] = 'The discussion topic has been deleted';
 $string['deletedpost'] = 'The post has been deleted';
 $string['deletedposts'] = 'Those posts have been deleted';
+$string['deleteoriginalonreply'] = 'If replying directly to this via email, please do not include a quoted copy of the post you are responding to';
 $string['deletesure'] = 'Are you sure you want to delete this post?';
 $string['deletesureplural'] = 'Are you sure you want to delete this post and all replies? ({$a} posts)';
 $string['digestmailheader'] = 'This is your daily digest of new posts from the {$a->sitename} forums. To change your default forum email preferences, go to {$a->userprefs}.';
@@ -406,8 +407,7 @@ $string['repliesmany'] = '{$a} replies so far';
 $string['repliesone'] = '{$a} reply so far';
 $string['reply'] = 'Reply';
 $string['replyforum'] = 'Reply to forum';
-$string['replytoforumpost'] = 'Reply via email to {$a}';
-$string['replytoforumpost_html'] = '<a href="mailto:{$a}">Reply via email</a>';
+$string['replytoforumpost'] = 'You can reply to this forum post by email.';
 $string['replytouser'] = 'Use email address in reply';
 $string['reply_handler'] = 'Reply to forum posts via email';
 $string['reply_handler_name'] = 'Reply to forum posts';
@@ -489,6 +489,7 @@ $string['unreadposts'] = 'Unread posts';
 $string['unreadpostsnumber'] = '{$a} unread posts';
 $string['unreadpostsone'] = '1 unread post';
 $string['unsubscribe'] = 'Unsubscribe from this forum';
+$string['unsubscribediscussion'] = 'Unsubscribe from this discussion';
 $string['unsubscribeall'] = 'Unsubscribe from all forums';
 $string['unsubscribeallconfirm'] = 'You are currently subscribed to {$a->forums} forums, and {$a->discussions} discussions. Do you really want to unsubscribe from all forums and discussions, and disable discussion auto-subscription?';
 $string['unsubscribeallconfirmforums'] = 'You are currently subscribed to {$a->forums} forums. Do you really want to unsubscribe from all forums and disable discussion auto-subscription?';
index c74a543..de9e678 100644 (file)
@@ -1182,10 +1182,14 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro
 
     $strforums = get_string('forums', 'forum');
 
-    $canunsubscribe = ! \mod_forum\subscriptions::is_forcesubscribed($forum);
+    $canunsubscribe = !\mod_forum\subscriptions::is_forcesubscribed($forum);
 
     $posttext = '';
 
+    if ($replyaddress) {
+        $posttext .= "--" . get_string('deleteoriginalonreply', 'mod_forum') . "--\n";
+    }
+
     if (!$bare) {
         $shortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
         $posttext  = "$shortname -> $strforums -> ".format_string($forum->name,true);
@@ -1211,15 +1215,25 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro
     $posttext .= "\n\n";
     $posttext .= forum_print_attachments($post, $cm, "text");
 
-    if (!$bare && $canreply) {
-        $posttext .= "---------------------------------------------------------------------\n";
-        $posttext .= get_string("postmailinfo", "forum", $shortname)."\n";
-        $posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id\n";
-    }
-    if (!$bare && $canunsubscribe) {
-        $posttext .= "\n---------------------------------------------------------------------\n";
-        $posttext .= get_string("unsubscribe", "forum");
-        $posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?id=$forum->id\n";
+    if (!$bare) {
+        if ($canreply) {
+            $posttext .= "---------------------------------------------------------------------\n";
+            $posttext .= get_string("postmailinfo", "forum", $shortname)."\n";
+            $posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id\n";
+        }
+
+        if ($canunsubscribe) {
+            if (\mod_forum\subscriptions::is_subscribed($userto->id, $forum, null, $cm)) {
+                // If subscribed to this forum, offer the unsubscribe link.
+                $posttext .= "\n---------------------------------------------------------------------\n";
+                $posttext .= get_string("unsubscribe", "forum");
+                $posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?id=$forum->id\n";
+            }
+            // Always offer the unsubscribe from discussion link.
+            $posttext .= "\n---------------------------------------------------------------------\n";
+            $posttext .= get_string("unsubscribediscussion", "forum");
+            $posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?d=$discussion->id\n";
+        }
     }
 
     $posttext .= "\n---------------------------------------------------------------------\n";
@@ -1227,7 +1241,7 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro
     $posttext .= ": {$CFG->wwwroot}/mod/forum/index.php?id={$forum->course}\n";
 
     if ($replyaddress) {
-        $posttext .= "\n\n" . get_string('replytoforumpost', 'mod_forum', $replyaddress);
+        $posttext .= "\n\n" . get_string('replytoforumpost', 'mod_forum');
     }
 
     return $posttext;
@@ -1272,6 +1286,10 @@ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfro
     $posthtml .= '</head>';
     $posthtml .= "\n<body id=\"email\">\n\n";
 
+    if ($replyaddress) {
+        $posttext .= "<p><em>--" . get_string('deleteoriginalonreply', 'mod_forum') . "--</em></p>";
+    }
+
     $posthtml .= '<div class="navbar">'.
     '<a target="_blank" href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$shortname.'</a> &raquo; '.
     '<a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/index.php?id='.$course->id.'">'.$strforums.'</a> &raquo; '.
@@ -1285,12 +1303,20 @@ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfro
     $posthtml .= forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false);
 
     if ($replyaddress) {
-        $posthtml .= "<p>" . get_string('replytoforumpost_html', 'mod_forum', $replyaddress) . "</p>";
+        $posthtml .= html_writer::tag('p', get_string('replytoforumpost', 'mod_forum'));
     }
 
     $footerlinks = array();
     if ($canunsubscribe) {
-        $footerlinks[] = '<a href="' . $CFG->wwwroot . '/mod/forum/subscribe.php?id=' . $forum->id . '">' . get_string('unsubscribe', 'forum') . '</a>';
+        if (\mod_forum\subscriptions::is_subscribed($userto->id, $forum, null, $cm)) {
+            // If subscribed to this forum, offer the unsubscribe link.
+            $unsublink = new moodle_url('/mod/forum/subscribe.php', array('id' => $forum->id));
+            $footerlinks[] = html_writer::link($unsublink, get_string('unsubscribe', 'mod_forum'));
+        }
+        // Always offer the unsubscribe from discussion link.
+        $unsublink = new moodle_url('/mod/forum/subscribe.php', array('d' => $discussion->id));
+        $footerlinks[] = html_writer::link($unsublink, get_string('unsubscribediscussion', 'mod_forum'));
+
         $footerlinks[] = '<a href="' . $CFG->wwwroot . '/mod/forum/unsubscribeall.php">' . get_string('unsubscribeall', 'forum') . '</a>';
     }
     $footerlinks[] = "<a href='{$CFG->wwwroot}/mod/forum/index.php?id={$forum->course}'>" . get_string('digestmailpost', 'forum') . '</a>';
index 41658bf..45b4a5d 100644 (file)
@@ -73,7 +73,11 @@ if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
 } else {
     $groupmode = $course->groupmode;
 }
-if ($groupmode && !\mod_forum\subscriptions::is_subscribed($user->id, $forum, null, $cm) && !has_capability('moodle/site:accessallgroups', $context)) {
+
+$issubscribed = \mod_forum\subscriptions::is_subscribed($user->id, $forum, $discussionid, $cm);
+
+// For a user to subscribe when a groupmode is set, they must have access to at least one group.
+if ($groupmode && !$issubscribed && !has_capability('moodle/site:accessallgroups')) {
     if (!groups_get_all_groups($course->id, $USER->id)) {
         print_error('cannotsubscribe', 'forum');
     }
@@ -142,7 +146,7 @@ $info = new stdClass();
 $info->name  = fullname($user);
 $info->forum = format_string($forum->name);
 
-if (\mod_forum\subscriptions::is_subscribed($user->id, $forum, $discussionid, $cm)) {
+if ($issubscribed) {
     if (is_null($sesskey)) {    // we came here via link in email
         $PAGE->set_title($course->shortname);
         $PAGE->set_heading($course->fullname);
index b0232f9..850813d 100644 (file)
@@ -420,6 +420,7 @@ $string['thatsthecorrectanswer'] = 'That\'s the correct answer';
 $string['thatsthewronganswer'] = 'That\'s the wrong answer';
 $string['thefollowingpagesjumptothispage'] = 'The following pages jump to this page';
 $string['thispage'] = 'This page';
+$string['timeisup'] = 'Time is up';
 $string['timeremaining'] = 'Time remaining';
 $string['timespenterror'] = 'Spend at least {$a} minutes in the lesson';
 $string['timespentminutes'] = 'Time spent (minutes)';
index a2e37cc..dc01852 100644 (file)
@@ -488,14 +488,15 @@ function lesson_clock_block_contents($cmid, $lesson, $timer, $page) {
         return null;
     }
 
-    $content = '<div class="jshidewhenenabled">';
+    $content = '<div id="lesson-timer">';
     $content .=  $lesson->time_remaining($timer->starttime);
     $content .= '</div>';
 
     $clocksettings = array('starttime'=>$timer->starttime, 'servertime'=>time(),'testlength'=>($lesson->maxtime * 60));
-    $page->requires->data_for_js('clocksettings', $clocksettings);
+    $page->requires->data_for_js('clocksettings', $clocksettings, true);
+    $page->requires->strings_for_js(array('timeisup'), 'lesson');
     $page->requires->js('/mod/lesson/timer.js');
-    $page->requires->js_function_call('show_clock');
+    $page->requires->js_init_call('show_clock');
 
     $bc = new block_contents();
     $bc->title = get_string('timeremaining', 'lesson');
index 583b4f8..de3ddf3 100644 (file)
@@ -78,3 +78,8 @@
 .path-mod-lesson.dir-rtl .standardtable,
 .path-mod-lesson.dir-rtl .mform .box.contents,
 .path-mod-lesson.dir-rtl .invisiblefieldset.fieldsetfix tr {text-align: right;}
+
+/* Countdown timer. */
+#lesson-timer {
+    text-align: center;
+}
index d21267d..4f08317 100644 (file)
 //
 //////////////////////////////////////////////////////////*/
 
-    var myfont_face = "Arial";
-    var myfont_size = "12";
-    var myfont_color = "#000000";
-    var myback_color = "#FFFFFF";
-    var mywidth = 80;
-    var my12_hour = 1;
     var stopclock = 0;
     var myclock = '';
     var timeleft, hours, minutes, secs;
     var javatimeDate = new Date();
     var javatime = javatimeDate.getTime();
-    javatime = Math.floor(javatime/1000);
+    javatime = Math.floor(javatime / 1000);
 
-    var dn = "";
-    var old = "";
-
-    if (document.all||document.getElementById) {
-        document.write('<span id="LiveClockIE" style="width:'+mywidth+'px;"></span>');
-    } else if (document.layers) {
-        document.write('<ilayer id="ClockPosNS"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>');
-    } else {
-        old = "true"; show_clock();
+    if (typeof(clocksettings) != 'undefined') {
+        if (clocksettings.starttime) {
+            starttime = parseInt(clocksettings.starttime);
+        }
+        if (clocksettings.servertime) {
+            servertime = parseInt(clocksettings.servertime);
+        }
+        if (clocksettings.testlength) {
+            testlength = parseInt(clocksettings.testlength);
+        }
     }
 
+    difference = javatime - servertime;
+    starttime = starttime + difference;
+
     /*function leave() {  // feable attempt to run a script when someone leaves a timed test early, failed so far
         window.onunload = window.open('http://www.google.com','','toolbar=no,menubar=no,location=no,height=500,width=500');
     }
 
     function show_clock() {
 
-        if (typeof(clocksettings) != 'undefined') {
-            if (clocksettings.starttime) {
-                starttime = parseInt(clocksettings.starttime);
-            }
-            if (clocksettings.servertime) {
-                servertime =  parseInt(clocksettings.servertime);
-            }
-            if (clocksettings.testlength) {
-                testlength =  parseInt(clocksettings.testlength);
-            }
-        }
-
-        difference = javatime - servertime;
-        starttime = starttime + difference;
-
-        //show clock in NS 4
-        if (document.layers)
-                document.ClockPosNS.visibility="show";
-        if (old == "die") { return; }
-
         currentDate = new Date();
         current = currentDate.getTime();
-        current = Math.floor(current/1000);
+        current = Math.floor(current / 1000);
 
-        var myclock = '<font style="color:'+myfont_color+'; font-family:'+myfont_face+'; font-size:'+myfont_size+'pt;">';
+        var mytime = '',
+            myclock = document.getElementById("lesson-timer");
         if (current > starttime + testlength) {
-            myclock += "Time is up";
+            mytime += M.util.get_string('timeisup', 'lesson');
             stopclock = 1;
         } else {
             timeleft = starttime + testlength - current;
-            hours = Math.floor(timeleft/3600);
+            if (timeleft < 60) {
+                myclock.className = "timeleft1";
+            }
+            hours = Math.floor(timeleft / 3600);
             timeleft = timeleft - (hours * 3600);
-            minutes = Math.floor(timeleft/60);
+            minutes = Math.floor(timeleft / 60);
             secs = timeleft - (minutes * 60);
 
             if (secs < 10) {
-                secs = "0"+secs;
+                secs = "0" + secs;
             }
             if (minutes < 10) {
-                minutes = "0"+minutes;
+                minutes = "0" + minutes;
             }
-            myclock += hours+":"+minutes+":"+secs;
+            mytime += hours + ":" + minutes + ":" + secs;
         }
-        myclock += '</font>';
 
-        if (old == "true") {
-            document.write(myclock);
-            old = "die"; return;
-        }
-
-        if (document.layers) {
-            clockpos = document.ClockPosNS;
-            liveclock = clockpos.document.LiveClockNS;
-            liveclock.document.write(myclock);
-            liveclock.document.close();
-        } else if (document.all) {
-            LiveClockIE.innerHTML = myclock;
-        } else if (document.getElementById) {
-            document.getElementById("LiveClockIE").innerHTML = myclock;
-        }
+        myclock.innerHTML = mytime;
 
         if (stopclock == 0) {
-            setTimeout("show_clock()",1000);
+            setTimeout("show_clock()", 1000);
         }
 }
-
index 9c2e2b0..c608835 100644 (file)
@@ -24,7 +24,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2014101600;       // The current module version (Date: YYYYMMDDXX)
+$plugin->version   = 2014110400;       // The current module version (Date: YYYYMMDDXX)
 $plugin->requires  = 2014050800;    // Requires this Moodle version
 $plugin->component = 'mod_lesson'; // Full name of the plugin (used for diagnostics)
 $plugin->cron      = 0;
index 403c045..e0569fd 100644 (file)
@@ -1202,7 +1202,7 @@ function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scorm
         if (storetotaltime) {
             if (cmi.mode == 'normal') {
                 if (cmi.credit == 'credit') {
-                    if ((cmi.completion_threshold != null) && (cmi.progress_measure != null)) {
+                    if ((cmi.completion_threshold) && (cmi.progress_measure)) {
                         if (cmi.progress_measure >= cmi.completion_threshold) {
                             cmi.completion_status = 'completed';
                         } else {
index e6186a5..b883223 100644 (file)
@@ -1263,22 +1263,22 @@ function get_scorm_default (&$userdata, $scorm, $scoid, $attempt, $mode) {
     $def['cmi.exit'] = scorm_isset($userdata, 'cmi.exit');
     $def['cmi.credit'] = scorm_isset($userdata, 'credit');
     $def['cmi.completion_status'] = scorm_isset($userdata, 'cmi.completion_status', 'unknown');
-    $def['cmi.completion_threshold'] = scorm_isset($userdata, 'threshold', 'null');
-    $def['cmi.learner_preference.audio_level'] = scorm_isset($userdata, 'cmi.learner_preference.audio_level', "'1'");
-    $def['cmi.learner_preference.language'] = scorm_isset($userdata, 'cmi.learner_preference.language', "''");
-    $def['cmi.learner_preference.delivery_speed'] = scorm_isset($userdata, 'cmi.learner_preference.delivery_speed', "'1'");
-    $def['cmi.learner_preference.audio_captioning'] = scorm_isset($userdata, 'cmi.learner_preference.audio_captioning', "'0'");
-    $def['cmi.location'] = scorm_isset($userdata, 'cmi.location', 'null');
-    $def['cmi.max_time_allowed'] = scorm_isset($userdata, 'attemptAbsoluteDurationLimit', 'null');
-    $def['cmi.progress_measure'] = scorm_isset($userdata, 'cmi.progress_measure', 'null');
-    $def['cmi.scaled_passing_score'] = scorm_isset($userdata, 'cmi.scaled_passing_score', 'null');
-    $def['cmi.score.scaled'] = scorm_isset($userdata, 'cmi.score.scaled', 'null');
-    $def['cmi.score.raw'] = scorm_isset($userdata, 'cmi.score.raw', 'null');
-    $def['cmi.score.min'] = scorm_isset($userdata, 'cmi.score.min', 'null');
-    $def['cmi.score.max'] = scorm_isset($userdata, 'cmi.score.max', 'null');
+    $def['cmi.completion_threshold'] = scorm_isset($userdata, 'threshold');
+    $def['cmi.learner_preference.audio_level'] = scorm_isset($userdata, 'cmi.learner_preference.audio_level', 1);
+    $def['cmi.learner_preference.language'] = scorm_isset($userdata, 'cmi.learner_preference.language');
+    $def['cmi.learner_preference.delivery_speed'] = scorm_isset($userdata, 'cmi.learner_preference.delivery_speed');
+    $def['cmi.learner_preference.audio_captioning'] = scorm_isset($userdata, 'cmi.learner_preference.audio_captioning', 0);
+    $def['cmi.location'] = scorm_isset($userdata, 'cmi.location');
+    $def['cmi.max_time_allowed'] = scorm_isset($userdata, 'attemptAbsoluteDurationLimit');
+    $def['cmi.progress_measure'] = scorm_isset($userdata, 'cmi.progress_measure');
+    $def['cmi.scaled_passing_score'] = scorm_isset($userdata, 'cmi.scaled_passing_score');
+    $def['cmi.score.scaled'] = scorm_isset($userdata, 'cmi.score.scaled');
+    $def['cmi.score.raw'] = scorm_isset($userdata, 'cmi.score.raw');
+    $def['cmi.score.min'] = scorm_isset($userdata, 'cmi.score.min');
+    $def['cmi.score.max'] = scorm_isset($userdata, 'cmi.score.max');
     $def['cmi.success_status'] = scorm_isset($userdata, 'cmi.success_status', 'unknown');
-    $def['cmi.suspend_data'] = scorm_isset($userdata, 'cmi.suspend_data', 'null');
-    $def['cmi.time_limit_action'] = scorm_isset($userdata, 'timelimitaction', 'null');
+    $def['cmi.suspend_data'] = scorm_isset($userdata, 'cmi.suspend_data');
+    $def['cmi.time_limit_action'] = scorm_isset($userdata, 'timelimitaction');
     $def['cmi.total_time'] = scorm_isset($userdata, 'cmi.total_time', 'PT0H0M0S');
 
     return $def;
index feb0473..bd14e98 100644 (file)
@@ -158,7 +158,7 @@ class core_user_renderer extends plugin_renderer_base {
         $content .= html_writer::end_tag('div');
 
         $content .= html_writer::end_tag('div');
-        $content .= html_writer::tag('div', '&nbsp');
+        $content .= html_writer::tag('div', '&nbsp;');
         $content .= html_writer::end_tag('form');
 
         return $content;