]> git.mjollnir.org Git - moodle.git/commitdiff
Lesson buttons should now work with javascript disabled
authormark-nielsen <mark-nielsen>
Sat, 9 Sep 2006 21:39:11 +0000 (21:39 +0000)
committermark-nielsen <mark-nielsen>
Sat, 9 Sep 2006 21:39:11 +0000 (21:39 +0000)
Also improved the layout of action/continue.html

mod/lesson/action/continue.html
mod/lesson/locallib.php
mod/lesson/styles.php
mod/lesson/view.php

index e1743b3a2e9cf592766e323944901cc33d9c5f40..83cdb2655f38c3cf1805af3d3a8be6264c4a6528 100644 (file)
@@ -7,12 +7,15 @@
  **/
 ?>
 
+<!-- Primary layout table -->
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+    <tr valign="top">
+
 <?php
 if ($lesson->displayleft) {
-   if($firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
-?>
-<table>
-    <tr valign="top">
+// Displaying left menu
+   if($firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) { ?>
+
         <td>
             <a href="#maincontent" class="skip"><?php print_string('skip', 'lesson') ?></a>
             <div class="leftmenu_container">
@@ -25,84 +28,118 @@ if ($lesson->displayleft) {
             </div>
             </div>
         </td>
-        <td align="center" width="100%">
-        <a name="maincontent" id="maincontent" title="<?php print_string('anchortitle', 'lesson') ?>"></a>
+        
 <?php 
     }  // End if($firstpageid = get...
 } // End if ($lesson->displayleft)
 ?>
+        <!-- Start Primary column -->
+        <td>
+    
+<?php if ($lesson->displayleft) { // Skip navigation anchor ?>
+        
+        <a name="maincontent" id="maincontent" title="<?php print_string('anchortitle', 'lesson') ?>"></a>
+        
+<?php } ?>
 
-<?php if($lesson->timed and !has_capability('mod/lesson:manage', $context)) {
-        // code for the clock
-        print_simple_box_start("right", "150px", "#ffffff", 0);
-?>
-        <table border="0" valign="top" align="center" class="generaltable" width="100%" cellspacing="0">
-            <tr>
-                <th valign="top" class="generaltableheader"><?php print_string("timeremaining", "lesson") ?></th>
-            </tr>
-            <tr>
-                <td align="center" class="generaltablecell">
-                    <script language="javascript">
-                        var starttime  = "<?php echo $timer->starttime ?>";
-                        var servertime = "<?php echo time()?>";
-                        var testlength = "<?php echo $lesson->maxtime * 60 ?>";
-                        document.write('<SCRIPT LANGUAGE="JavaScript" SRC="timer.js"></SCRIPT>');
-                        window.onload = function () { show_clock(); }
-                    </script>
-                </td>
-            </tr>
-        </table>
-        <?php print_simple_box_end(); ?>
-        <br /><br /><br /><br />
-<?php } //end if($lesson->timed) {
-
-// This calculates and prints the ongoing score message
-if ($lesson->ongoing) {
-    lesson_print_ongoing_score($lesson);
-}
+<?php
+    // This calculates and prints the ongoing score message
+    if ($lesson->ongoing) {
+        lesson_print_ongoing_score($lesson);
+    }
 ?>
-<table border="0" align="center">
-    <tr>
-        <td><?php echo $feedback ?></td>
-    </tr>
-</table>
-
-<form name="pageform" method ="post" action="view.php">
-<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-<input type="hidden" name="action" value="navigation" />
-<input type="hidden" name="pageid" value="<?php echo $newpageid ?>" />
-
-<?php if (isset($USER->modattempts[$lesson->id])) { ?>
-<p align="center"><?php print_string("savechangesandeol", "lesson") ?> <br /><br />
-    <div align="center" class="lessonbutton standardbutton">
-        <a href="javascript:document.pageform.pageid.value=<?php echo LESSON_EOL ?>;document.pageform.submit();"><?php print_string("savechanges", "lesson") ?></a>
-    </div>
-</p>
-<p align="center">
-    <?php print_string("or", "lesson") ?>
-    <br /><br />
-    <?php print_string("continuetoanswer", "lesson") ?>
-</p>
-<?php }
-    if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) { ?>
-        <p>
-            <div align="center" class="lessonbutton standardbutton">
-                <a href="javascript:document.pageform.pageid.value=<?php echo $pageid ?>;document.pageform.submit();"><?php print_string("reviewquestionback", "lesson") ?></a>
-            </div>
-        </p>
-        <p><div align="center" class="lessonbutton standardbutton">
-            <a href="javascript:document.pageform.submit();"><?php print_string("reviewquestioncontinue", "lesson") ?></a>
-            </div>
-        </p>
-<?php } else { ?>
-<p>
-    <div align="center" class="lessonbutton standardbutton">
-        <a href="javascript:document.pageform.submit();"><?php print_string("continue", "lesson") ?></a>
-    </div>
-</p>
+
+            <table border="0" align="center">
+                <tr>
+                    <td class="c0"><?php echo $feedback ?></td>
+                </tr>
+            </table>
+
+<?php if (isset($USER->modattempts[$lesson->id])) { // User is modifying attempts - save button and some instructions ?>
+
+            <form name="endoflesson" method ="post" action="view.php">
+            <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
+            <input type="hidden" name="action" value="navigation" />
+            <input type="hidden" name="pageid" value="<?php echo LESSON_EOL; ?>" />
+    
+            <p align="center">
+                <?php print_string("savechangesandeol", "lesson") ?>
+            </p>
+            <p align="center">
+                <?php lesson_print_submit_link(get_string('savechanges', 'lesson'), 'endoflesson'); ?>
+            </p>
+            <p align="center">
+                <?php print_string("or", "lesson") ?>
+            </p>
+            <p align="center">
+                <?php print_string("continuetoanswer", "lesson") ?>
+            </p>
+    
+            </form>
+<?php } ?>
+
+<?php if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) { // Review button back ?>
+    
+            <form name="reviewback" method ="post" action="view.php">
+            <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
+            <input type="hidden" name="action" value="navigation" />
+            <input type="hidden" name="pageid" value="<?php echo $pageid; ?>" />
+    
+            <p>
+                <?php lesson_print_submit_link(get_string('reviewquestionback', 'lesson'), 'reviewback'); ?>
+            </p>
+    
+            </form>
+            
+<?php } ?>
+
+            <form name="pageform" method ="post" action="view.php">
+            <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
+            <input type="hidden" name="action" value="navigation" />
+            <input type="hidden" name="pageid" value="<?php echo $newpageid ?>" />
+
+<?php if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) { // Review button continue ?>
+
+            <p>
+                <?php lesson_print_submit_link(get_string('reviewquestioncontinue', 'lesson'), 'pageform'); ?>
+            </p>
+
+<?php } else { // Normal continue button ?>
+
+            <p>
+                <?php lesson_print_submit_link(get_string('continue', 'lesson'), 'pageform'); ?>
+            </p>
+
 <?php } ?>
-</form>
 
-<?php if ($lesson->displayleft) { ?>
-</td></tr></table>
-<?php } ?>
\ No newline at end of file
+            </form>
+        </td>
+        <!-- End primary column -->
+
+<?php if($lesson->timed and !has_capability('mod/lesson:manage', $context)) { // Display for timed lessons and for students only ?>
+    
+        <td>
+            <table align="right" width="150px" class="generaltable generalbox" cellspacing="0" cellpadding="5px" border="0" valign="top">
+                <tr>
+                    <th class="header"><?php print_string("timeremaining", "lesson") ?></th>
+                </tr>
+                <tr class="r0">
+                    <td align="center" class="c0">
+                        <script type="text/javascript" charset="utf-8">
+                        <!--
+                            var starttime  = <?php echo $timer->starttime ?>;
+                            var servertime = <?php echo time() ?>;
+                            var testlength = <?php echo $lesson->maxtime * 60 ?>;
+                            document.write('<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/mod/lesson/timer.js" charset="utf-8"><\/script>');
+                            window.onload = function () { show_clock(); };
+                        // -->
+                        </script>
+                    </td>
+                </tr>
+            </table>
+        </td>
+<?php } //end if($lesson->timed) { ?>
+
+<!-- End primary layout table -->
+    </tr>
+</table>
\ No newline at end of file
index ec589c4ad1e7efe8c889ad416b11080a261b56dc..382859545405da50360d7a83eae3e3b2336b51c4 100644 (file)
@@ -335,6 +335,40 @@ function lesson_print_messages() {
     return true;
 }
 
+/**
+ * Prints a lesson link that submits a form.
+ *
+ * If Javascript is disabled, then a regular submit button is printed
+ *
+ * @return mixed boolean/html
+ **/
+function lesson_print_submit_link($name, $form, $align = 'center', $class='standardbutton', $title = '', $id = '', $return = false) {
+    if (!empty($id)) {
+        $id = " id=\"$id\"";
+    }
+    if (empty($title)) {
+        $title = $name;
+    }
+    
+    $output = "<div align=\"$align\" class=\"lessonbutton $class\">\n";
+    $output .= "<script type=\"text/javascript\" charset=\"utf-8\">
+                <!--
+                    document.write('<a href=\"javascript: document.$form.submit();\" title=\"$title\"$id>$name</a>');
+                // -->
+                </script>
+                <noscript>
+                <input type=\"submit\" value=\"$name\" align=\"$align\"$id />
+                </noscript>\n";
+    $output .= "</div>\n";
+    
+    if ($return) {
+        return $output;
+    } else {
+        echo $output;
+        return true;
+    }
+}
+
 /**
  * Given some question info and some data about the the answers
  * this function parses, organises and saves the question
index 54c5718fe24e1ff1110477f8eb0a619412c8403c..e1606583ab7edddcd84233d6591781db4f2f397f 100644 (file)
@@ -6,6 +6,19 @@
     text-align: left;
 }
 
+/***
+ *** Style for view.php
+ ***/
+
+#mod-lesson-view .password-form {
+    text-align: center;
+    margin-top: 20px;
+}
+
+#mod-lesson-view .password-form .submitbutton {
+    display: inline;
+}
+
 /***
  *** Style for essay.php
  ***/
index 02267043e4df3caa39f19bad01c7b1b5eaeec1f3..e89a532596515c79884743e09aecdae2a01ec076 100644 (file)
             }
 
             if (!$correctpass) {
+                echo "<div class=\"password-form\">\n";
                 print_simple_box_start('center');
                 echo '<form name="password" method="post" action="view.php">' . "\n";
                 echo '<input type="hidden" name="id" value="'. $cm->id .'" />' . "\n";
                 if (optional_param('userpassword', 0, PARAM_CLEAN)) {
                     notify(get_string('loginfail', 'lesson'));
                 }
-                echo "<div align=\"center\">\n".
-                    get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name))."<br /><br />\n".
-                    get_string('enterpassword', 'lesson')." <input type=\"password\" name=\"userpassword\" /><br /><br />\n";
-
-                echo '<span class="lessonbutton standardbutton"><a href="'.$CFG->wwwroot.'/course/view.php?id='. $course->id .'">'. get_string('cancel', 'lesson') .'</a></span> '.
-                    ' <span class="lessonbutton standardbutton"><a href="javascript:document.password.submit();">'. get_string('continue', 'lesson') .'</a></span>'.
-                    "</div>\n";
+                
+                echo get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name))."<br /><br />\n".
+                     get_string('enterpassword', 'lesson')." <input type=\"password\" name=\"userpassword\" /><br /><br />\n".
+                     '<span class="lessonbutton standardbutton"><a href="'.$CFG->wwwroot.'/course/view.php?id='. $course->id .'">'. get_string('cancel', 'lesson') .'</a></span> ';
+                
+                lesson_print_submit_link(get_string('continue', 'lesson'), 'password', 'center', 'standardbutton submitbutton');
                 print_simple_box_end();
+                echo "</div>\n";
                 exit();
             }
         }
                             ": <input type=\"text\" id=\"answer\" name=\"answer\" size=\"50\" maxlength=\"200\" $value />\n";
                         echo '</table>';
                         print_simple_box_end();
-                        echo "<div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.answerform.submit();\">".
-                             get_string("pleaseenteryouranswerinthebox", "lesson")."</a></div></p>\n";
+                        lesson_print_submit_link(get_string('pleaseenteryouranswerinthebox', 'lesson'), 'answerform');
                         break;
                     case LESSON_TRUEFALSE :
                         shuffle($answers);
                         }
                         echo '</table>';
                         print_simple_box_end();
-                        echo "<div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.answerform.submit();\">".
-                            get_string("pleasecheckoneanswer", "lesson")."</a></div>\n"; 
+                        lesson_print_submit_link(get_string('pleasecheckoneanswer', 'lesson'), 'answerform');
                         break;
                     case LESSON_MULTICHOICE :
                         $i = 0;
                         echo '</table>';
                         print_simple_box_end();
                         if ($page->qoption) {
-                            echo "<div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.answerform.submit();\">".
-                                get_string("pleasecheckoneormoreanswers", "lesson")."</a></div>\n";
+                            $linkname = get_string('pleasecheckoneormoreanswers', 'lesson');
                         } else {
-                            echo "<div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.answerform.submit();\">".
-                                get_string("pleasecheckoneanswer", "lesson")."</a></div>\n";
+                            $linkname = get_string('pleasecheckoneanswer', 'lesson');
                         }
+                        lesson_print_submit_link($linkname, 'answerform');
                         break;
                         
                     case LESSON_MATCHING :
                         }
                         echo '</table></table>';
                         print_simple_box_end();
-                        echo "<div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.answerform.submit();\">".
-                            get_string("pleasematchtheabovepairs", "lesson")."</a></div>\n";
+                        lesson_print_submit_link(get_string('pleasematchtheabovepairs', 'lesson'), 'answerform');
                         break;
                     case LESSON_BRANCHTABLE :                        
                         $options = new stdClass;
                              '<textarea id="answer" name="answer" rows="15" cols="60">'.$value."</textarea>\n";
                         echo '</td></tr></table>';
                         print_simple_box_end();
-                        echo '<div align="center" class="lessonbutton standardbutton"><a href="javascript:document.answerform.submit();">'.
-                             get_string("pleaseenteryouranswerinthebox", "lesson")."</a></div>\n";
+                        lesson_print_submit_link(get_string('pleaseenteryouranswerinthebox', 'lesson'), 'answerform');
                         break;
                 }
                 echo "</form>\n";