MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / lesson / action / addbranchtable.php
blob3fb28ef18e0b6b16e332fb9e42dcbbbb38ab95bc
1 <?php // $Id$
2 /**
3 * Action for adding a branch table. Prints an HTML form.
5 * @version $Id$
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
7 * @package lesson
8 **/
10 $CFG->pagepath = 'mod/lesson/addbranchtable';
12 // first get the preceeding page
13 $pageid = required_param('pageid', PARAM_INT);
15 // set of jump array
16 $jump = array();
17 $jump[0] = get_string("thispage", "lesson");
18 $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
19 $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
20 $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
21 if (!optional_param('firstpage', 0, PARAM_INT)) {
22 if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
23 error("Add page: first page not found");
25 while (true) {
26 if ($apageid) {
27 $title = get_field("lesson_pages", "title", "id", $apageid);
28 $jump[$apageid] = $title;
29 $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid);
30 } else {
31 // last page reached
32 break;
36 // give teacher a blank proforma
37 print_heading_with_help(get_string("addabranchtable", "lesson"), "overview", "lesson");
39 <form id="form" method="post" action="lesson.php" class="addform">
40 <fieldset class="invisiblefieldset fieldsetfix">
41 <input type="hidden" name="id" value="<?PHP echo $cm->id ?>" />
42 <input type="hidden" name="action" value="insertpage" />
43 <input type="hidden" name="pageid" value="<?PHP echo $pageid ?>" />
44 <input type="hidden" name="qtype" value="<?PHP echo LESSON_BRANCHTABLE ?>" />
45 <input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>" />
46 <table class="generalbox boxaligncenter" cellpadding="5" border="1">
47 <tr valign="top">
48 <td><strong><label for="title"><?php print_string("pagetitle", "lesson"); ?>:</label></strong><br />
49 <input type="text" id="title" name="title" size="80" value="" /></td></tr>
50 <?php
51 echo "<tr><td><strong>";
52 echo get_string("pagecontents", "lesson").":</strong><br />\n";
53 print_textarea($usehtmleditor, 25,70, 0, 0, "contents");
54 if ($usehtmleditor) {
55 use_html_editor("contents");
57 echo "</td></tr>\n";
58 echo "<tr><td>\n";
59 echo "<div class=\"boxaligncenter addform\"><input name=\"layout\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
60 echo get_string("arrangebuttonshorizontally", "lesson")."\n";
61 echo "<br /><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
62 echo get_string("displayinleftmenu", "lesson");
63 echo "</div>\n";
64 echo "</td></tr>\n";
65 for ($i = 0; $i < $lesson->maxanswers; $i++) {
66 $iplus1 = $i + 1;
67 echo "<tr><td><strong>".get_string("description", "lesson")." $iplus1:</strong><br />\n";
68 print_textarea(false, 10, 70, 630, 300, "answer[$i]"); // made the default set to off also removed use_html_editor(); line from down below, which made all textareas turn into html editors
69 echo "</td></tr>\n";
70 echo "<tr><td><strong>".get_string("jump", "lesson")." $iplus1:</strong> \n";
71 if ($i) {
72 // answers 2, 3, 4... jumpto this page
73 choose_from_menu($jump, "jumpto[$i]", 0, "");
74 } else {
75 // answer 1 jumpto next page
76 choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
78 helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
79 echo "</td></tr>\n";
81 // close table and form
83 </table><br />
84 <input type="submit" value="<?php print_string("addabranchtable", "lesson") ?>" />
85 <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
86 </fieldset>
87 </form>