3 * Action for adding a question page. Prints an HTML form.
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
9 $CFG->pagepath
= 'mod/lesson/addpage';
11 // first get the preceeding page
12 $pageid = required_param('pageid', PARAM_INT
);
13 $qtype = optional_param('qtype', LESSON_MULTICHOICE
, PARAM_INT
);
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(lesson_display_branch_jumps($lesson->id
, $pageid)) {
22 $jump[LESSON_UNSEENBRANCHPAGE
] = get_string("unseenpageinbranch", "lesson");
23 $jump[LESSON_RANDOMPAGE
] = get_string("randompageinbranch", "lesson");
25 if(lesson_display_cluster_jump($lesson->id
, $pageid)) {
26 $jump[LESSON_CLUSTERJUMP
] = get_string("clusterjump", "lesson");
28 if (!optional_param('firstpage', 0, PARAM_INT
)) {
30 $apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id
, "prevpageid", 0);
34 $title = get_field("lesson_pages", "title", "id", $apageid);
35 $jump[$apageid] = strip_tags(format_string($title,true));
36 $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid);
43 $linkadd = "&firstpage=1";
46 // give teacher a blank proforma
47 print_heading_with_help(get_string("addaquestionpage", "lesson"), "overview", "lesson");
49 <form id
="form" method
="post" action
="lesson.php" class="addform">
50 <fieldset
class="invisiblefieldset fieldsetfix">
51 <input type
="hidden" name
="id" value
="<?php echo $cm->id ?>" />
52 <input type
="hidden" name
="action" value
="insertpage" />
53 <input type
="hidden" name
="pageid" value
="<?php echo $pageid ?>" />
54 <input type
="hidden" name
="sesskey" value
="<?php echo $USER->sesskey ?>" />
56 echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
57 echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br />";
58 lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype,
59 "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd);
61 if ( $qtype == LESSON_SHORTANSWER ||
$qtype == LESSON_MULTICHOICE
) { // only display this option for Multichoice and shortanswer
63 if ($qtype == LESSON_SHORTANSWER
) {
64 $qoptionstr = get_string('casesensitive', 'lesson');
66 $qoptionstr = get_string('multianswer', 'lesson');
68 echo "<label for=\"qoption\"><strong>$qoptionstr</strong></label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>";
69 helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
73 <table cellpadding
="5" class="generalbox boxaligncenter" border
="1">
75 <td
><b
><label
for="title"><?php
print_string("pagetitle", "lesson"); ?
>:</label
></b
><br
/>
76 <input type
="text" id
="title" name
="title" size
="80" value
="" /></td
></tr
>
79 echo get_string("pagecontents", "lesson").":</b><br />\n";
80 print_textarea($usehtmleditor, 25,70, 630, 400, "contents");
82 use_html_editor("contents");
86 case LESSON_TRUEFALSE
:
87 for ($i = 0; $i < 2; $i++
) {
89 echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
90 print_textarea(false, 6, 70, 630, 300, "answer[$i]");
92 echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
93 print_textarea(false, 6, 70, 630, 300, "response[$i]");
95 echo "<tr><td><b>".get_string("jump", "lesson")." $iplus1:</b> \n";
97 // answers 2, 3, 4... jumpto this page
98 choose_from_menu($jump, "jumpto[$i]", 0, "");
100 // answer 1 jumpto next page
101 choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE
, "");
103 helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
104 if($lesson->custom
) {
106 echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\" />";
108 echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\" />";
115 echo "<tr><td><b>".get_string("jump", "lesson").":</b> \n";
116 choose_from_menu($jump, "jumpto[0]", LESSON_NEXTPAGE
, "");
117 helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
118 if ($lesson->custom
) {
119 echo get_string("score", "lesson").": <input type=\"text\" name=\"score[0]\" value=\"1\" size=\"5\" />";
123 case LESSON_MATCHING
:
124 for ($i = 0; $i < $lesson->maxanswers+
2; $i++
) {
125 $icorrected = $i - 1;
127 echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b><br />\n";
128 print_textarea(false, 6, 70, 630, 300, "answer[$i]");
131 echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b><br />\n";
132 print_textarea(false, 6, 70, 630, 300, "answer[$i]");
135 echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b><br />\n";
136 print_textarea(false, 6, 70, 630, 300, "answer[$i]");
138 echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b><br />\n";
139 print_textarea(false, 6, 70, 630, 300, "response[$i]");
143 echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n";
144 choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE
, "");
145 helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
146 if($lesson->custom
) {
147 echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\" />";
151 echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n";
152 choose_from_menu($jump, "jumpto[$i]", 0, "");
153 helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
154 if($lesson->custom
) {
155 echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\" />";
161 case LESSON_SHORTANSWER
:
162 case LESSON_NUMERICAL
:
163 case LESSON_MULTICHOICE
:
165 for ($i = 0; $i < $lesson->maxanswers
; $i++
) {
167 echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
168 print_textarea(false, 6, 70, 630, 300, "answer[$i]");
170 echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
171 print_textarea(false, 6, 70, 630, 300, "response[$i]");
173 echo "<tr><td><b>".get_string("jump", "lesson")." $iplus1:</b> \n";
175 // answers 2, 3, 4... jumpto this page
176 choose_from_menu($jump, "jumpto[$i]", 0, "");
178 // answer 1 jumpto next page
179 choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE
, "");
181 helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
182 if($lesson->custom
) {
184 echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\" />";
186 echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\" />";
193 // close table and form
196 <input type
="submit" value
="<?php print_string("addaquestionpage
", "lesson
") ?>" />
197 <input type
="submit" name
="cancel" value
="<?php print_string("cancel
") ?>" />