]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed branch table buttons to work with JavaScript turned off. This fix lead to...
authormark-nielsen <mark-nielsen>
Sat, 23 Sep 2006 18:45:59 +0000 (18:45 +0000)
committermark-nielsen <mark-nielsen>
Sat, 23 Sep 2006 18:45:59 +0000 (18:45 +0000)
Also, removed .hidden-label class because it was no longer in use due to label fixes earlier.

mod/lesson/locallib.php
mod/lesson/styles.php
mod/lesson/view.php

index ae828bf07105c2af77039cb7d81540acc3bdd8e1..11c13e44efb101b179751759eb7d953b59bb0453 100644 (file)
@@ -395,6 +395,9 @@ function lesson_print_messages() {
  * @return mixed boolean/html
  **/
 function lesson_print_submit_link($name, $form, $align = 'center', $class='standardbutton', $title = '', $id = '', $return = false) {
+    if (!empty($align)) {
+        $align = " align=\"$align\"";
+    }
     if (!empty($id)) {
         $id = " id=\"$id\"";
     }
@@ -402,7 +405,7 @@ function lesson_print_submit_link($name, $form, $align = 'center', $class='stand
         $title = $name;
     }
 
-    $output = "<div align=\"$align\" class=\"lessonbutton $class\">\n";
+    $output = "<div class=\"lessonbutton $class\"$align>\n";
     $output .= "<script type=\"text/javascript\" charset=\"utf-8\">
                 <!--
                     document.write('<a href=\"javascript: document.$form.submit();\" title=\"".addslashes($title)."\"$id>".addslashes($name)."</a>');
index 3f2db206643dd159b242bc805f1178f1fc3dd0ce..0e01c985f063a02c7e05da48cb4df28e64321d52 100644 (file)
     padding: 15px;
 }
 
-/***
- *** Hide Label Class
- ***/
-
-.mod-lesson .hidden-label {
-  display: none;
-}
-
 /***
  *** Left Menu Styles
  ***/
 }
 
 .mod-lesson .leftmenu_selected_link {
-    
 }
 
 .mod-lesson .leftmenu_not_selected_link {
-    
 }
 
 .mod-lesson .skip {
  ***  Or just comment out all of lessonbutton class definitions and start from scratch below
  ***/
 
-/* for branch tables only */
+/* for previous branch buttons only */
 .mod-lesson .previousbutton {
 }
 
-/* for branch tables only */
+/* for next branch buttons only */
 .mod-lesson .nextbutton {
 }
 
-/* All other buttons */
+/* All other branch buttons */
 .mod-lesson .standardbutton {
 }
 
-/* Next three classes are for branch table buttons when displayed horizontally */
-.mod-lesson .prevhorizontal {
-}
-
-.mod-lesson .nexthorizontal {
-}
-
-.mod-lesson .standardhorizontal {
-}
-
-/* Next three classes are for branch table buttons when displayed vertically */
-.mod-lesson .prevvertical {
-}
-
-.mod-lesson .nextvertical {
+/* Next classes are for branch table buttons when displayed horizontally */
+.mod-lesson .prevhorizontal,
+.mod-lesson .prevhorizontal .lessonbutton,
+.mod-lesson .nexthorizontal,
+.mod-lesson .nexthorizontal .lessonbutton,
+.mod-lesson .standardhorizontal,
+.mod-lesson .standardhorizontal .lessonbutton {
+    display: inline;
 }
 
-.mod-lesson .standardvertical {
+/* Next classes are for branch table buttons when displayed vertically */
+.mod-lesson .prevvertical .lessonbutton,
+.mod-lesson .nextvertical .lessonbutton,
+.mod-lesson .standardvertical .lessonbutton {
+    padding: 5px;
 }
 
 /*  branchbuttoncontainer wraps around branch table buttons */
 .mod-lesson .branchbuttoncontainer {
     text-align: center;
-    padding: 3px;
+    padding: 13px 3px 3px 3px;
 }
 
-/*  branchslidetop and branchslidebottom classes are wrapped around the branch buttons (branchslidetop around 
-    top ones and branchslidebottom around the bottom ones)
-    that are printed out with the branch table in slide show mode. */
-.mod-lesson .branchslidetop {
-    /*  You could float them out of the slide
-    position: absolute;
-    top: 60px;*/
-    /*  You may choose to not show them at all */
-    display: none;
-}
-
-.mod-lesson .branchslidebottom {
-    /*  You may choose to not show them at all
-    display: none; */
-    padding-top: 10px;
+.mod-lesson .branchbuttoncontainer form {
+    display: inline;
 }
 
 /***
index 324326b59f5320c7dde2343566fcbf05938f48b0..ca0bcc04240bc1213effb3395ad25f4102eef264 100644 (file)
             echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />";
             echo "<input type=\"hidden\" name=\"action\" value=\"continue\" />";
             echo "<input type=\"hidden\" name=\"pageid\" value=\"$pageid\" />";
-            echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
+            echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
             if (!$lesson->slideshow) {
                 if ($page->qtype != LESSON_BRANCHTABLE) {
                     print_simple_box_start("center");
                     print_simple_box_end();
                     lesson_print_submit_link(get_string('pleasematchtheabovepairs', 'lesson'), 'answerform');
                     break;
-                case LESSON_BRANCHTABLE :                        
+                case LESSON_BRANCHTABLE :
+                    echo '</form>';
                     $options = new stdClass;
                     $options->para = false;
                     $buttons = array('next' => array(), 'prev' => array(), 'other' => array());
                 /// seperate out next and previous jumps from the other jumps 
+                    $i = 0;
                     foreach ($answers as $answer) {
                         if ($answer->jumpto == LESSON_NEXTPAGE) {
-                            $type = 'next';
+                            $type  = 'next';
+                            $class = 'nextbutton';
                         } else if ($answer->jumpto == LESSON_PREVIOUSPAGE) {
-                            $type = 'prev';
+                            $type  = 'prev';
+                            $class = 'prevbutton';
                         } else {
-                            $type = 'other';
+                            $type  = 'other';
+                            $class = 'standardbutton';
                         }
-                        $buttons[$type][] = '<a href="javascript:document.answerform.jumpto.value='.$answer->jumpto.';document.answerform.submit();">'.
-                                strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)).'</a>';
+                        // Each button must have its own form inorder for it to work with JavaScript turned off
+                        $button  = "<form name=\"answerform$i\" method=\"post\" action=\"$CFG->wwwroot/mod/lesson/lesson.php\">\n".
+                                   "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n".
+                                   "<input type=\"hidden\" name=\"action\" value=\"continue\" />\n".
+                                   "<input type=\"hidden\" name=\"pageid\" value=\"$pageid\" />\n".
+                                   "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n".
+                                   "<input type=\"hidden\" name=\"jumpto\" value=\"$answer->jumpto\" />\n".
+                                   lesson_print_submit_link(strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)), "answerform$i", '', $class, '', '', true).
+                                   '</form>';
+                        
+                        $buttons[$type][] = $button;
+                        $i++;
                     }
-                
-                /// set the order and orientation (order is very important for the divs to work for horizontal!)
+                    
+                /// Set the orientation
                     if ($page->layout) {
                         $orientation = 'horizontal';
-                        $a = 'a';
-                        $b = 'b';
-                        $c = 'c';
-                        $implode = ' ';
-                        $implode2 = "\n    ";
-                        if (empty($buttons['other'])) {
-                            $buttons['other'][] = '&nbsp;';  // very critical! If nothing is in the middle, 
-                                                             // then the div style float left/right will not 
-                                                             // render properly with next/previous buttons
-                        }
                     } else {
                         $orientation = 'vertical';
-                        $a = 'c';
-                        $b = 'a';
-                        $c = 'b';
-                        $implode = '<br /><br />';
-                        $implode2 = "<br /><br />\n    ";
                     }
-                    $buttonsarranged = array();
-                    $buttonsarranged[$a] = '<span class="lessonbutton prevbutton prev'.$orientation.'">'.implode($implode, $buttons['prev']).'</span>';
-                    $buttonsarranged[$b] = '<span class="lessonbutton nextbutton next'.$orientation.'">'.implode($implode, $buttons['next']).'</span>';
-                    $buttonsarranged[$c] = '<span class="lessonbutton standardbutton standard'.$orientation.'">'.implode($implode, $buttons['other']).'</span>';
-                    ksort($buttonsarranged); // sort by key
                     
-                    $fullbuttonhtml = "\n<div class=\"branchbuttoncontainer\">\n    " . implode($implode2, $buttonsarranged). "\n</div>\n";
+                    $fullbuttonhtml = "\n<div class=\"branchbuttoncontainer\">\n    " .
+                                      "<div class=\"prev$orientation\">".implode("\n", $buttons['prev']).'</div>'.
+                                      "<div class=\"next$orientation\">".implode("\n", $buttons['other']).'</div>'.
+                                      "<div class=\"standard$orientation\">".implode("\n", $buttons['next']).'</div>'.
+                                      "\n</div>\n";
                 
                     if ($lesson->slideshow) {
-                        echo '<div class="branchslidetop">' . $fullbuttonhtml . '</div>';
                         $options = new stdClass;
                         $options->noclean = true;
                         echo '<div class="contents">'.format_text($page->contents, FORMAT_MOODLE, $options)."</div>\n";
                         echo '</div><!--end slideshow div-->';
-                        echo '<div class="branchslidebottom">' . $fullbuttonhtml . '</div>';
+                        echo $fullbuttonhtml;
                     } else {
                         echo '<tr><td>';
                         print_simple_box($fullbuttonhtml, 'center');
                         echo '</td></tr></table>'; // ends the answers table
                     }
-                    echo '<input type="hidden" name="jumpto" />';
                     
                     break;
                 case LESSON_ESSAY :