Fixed branch table buttons to work with JavaScript turned off. This fix lead to some minor changes to the button output, but hopefully simplified things.

Also, removed .hidden-label class because it was no longer in use due to label fixes earlier.
This commit is contained in:
mark-nielsen 2006-09-23 18:45:59 +00:00
parent 3e1e2b6968
commit 563106f0a8
3 changed files with 53 additions and 79 deletions

View 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>');

View File

@ -89,14 +89,6 @@
padding: 15px;
}
/***
*** Hide Label Class
***/
.mod-lesson .hidden-label {
display: none;
}
/***
*** Left Menu Styles
***/
@ -126,11 +118,9 @@
}
.mod-lesson .leftmenu_selected_link {
}
.mod-lesson .leftmenu_not_selected_link {
}
.mod-lesson .skip {
@ -177,59 +167,43 @@
*** 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 {
/* 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 .nexthorizontal {
}
.mod-lesson .standardhorizontal {
}
/* Next three classes are for branch table buttons when displayed vertically */
.mod-lesson .prevvertical {
}
.mod-lesson .nextvertical {
}
.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;
}
/***

View File

@ -546,7 +546,7 @@
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");
@ -684,65 +684,62 @@
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 :