File: editpage.php

package info (click to toggle)
moodle 1.6.3-2%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,172 kB
  • ctags: 51,688
  • sloc: php: 231,916; sql: 5,631; xml: 2,688; sh: 1,185; perl: 638; makefile: 48; pascal: 36
file content (476 lines) | stat: -rw-r--r-- 29,372 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<?php

/************** edit page ************************************/

    if (!isteacher($course->id)) {
        error("Only teachers can look at this page");
    }

    // get the page
    $pageid = required_param('pageid', PARAM_INT);
    $redirect = optional_param('redirect', '', PARAM_ALPHA);
    
    if (!$page = get_record("lesson_pages", "id", $pageid)) {
        error("Edit page: page record not found");
    }

    $page->qtype = optional_param('qtype', $page->qtype, PARAM_INT);

    // set of jump array
    $jump = array();
    $jump[0] = get_string("thispage", "lesson");
    $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
    $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
    if(lesson_display_branch_jumps($lesson->id, $page->id)) {
        $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson");
        $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson");
    }
    if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_BRANCHTABLE) {
        $jump[LESSON_RANDOMBRANCH] = get_string("randombranch", "lesson");
    }
    if(lesson_display_cluster_jump($lesson->id, $page->id) && $page->qtype != LESSON_BRANCHTABLE && $page->qtype != LESSON_ENDOFCLUSTER) {
        $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson");
    }
    $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
    if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
        error("Edit page: first page not found");
    }
    while (true) {
        if ($apageid) {
            if (!$apage = get_record("lesson_pages", "id", $apageid)) {
                error("Edit page: apage record not found");
            }
            // removed != LESSON_ENDOFBRANCH...
            if (trim($page->title)) { // ...nor nuffin pages
                $jump[$apageid] = strip_tags(format_string($apage->title,true));
            }
            $apageid = $apage->nextpageid;
        } else {
            // last page reached
            break;
        }
    }
    // give teacher a proforma
    ?>
    <form name="editpage" method="post" action="lesson.php">
    <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
    <input type="hidden" name="action" value="updatepage">
    <input type="hidden" name="pageid" value="<?php echo $pageid ?>" />
    <input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />        
    <input type="hidden" name="redirect" value="<?php echo $redirect ?>" />        
    <input type="hidden" name="redisplay" value="0" />
    <center>
       <?php
        switch ($page->qtype) {
            case LESSON_MULTICHOICE :
                echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
                echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>";
                lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, 
                                  "lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
                                  "document.editpage.redisplay.value=1;document.editpage.submit();");
                echo "<p><b>".get_string("multianswer", "lesson").":</b> \n";
                if ($page->qoption) {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\" checked=\"checked\"/>";
                } else {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>";
                }
                helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
                echo "</p>\n";
                break;
            case LESSON_SHORTANSWER :
                echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
                echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>";
                lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, 
                                  "lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
                                  "document.editpage.redisplay.value=1;document.editpage.submit();");
                echo "<p><b>".get_string("casesensitive", "lesson").":</b> \n";
                if ($page->qoption) {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\" checked=\"checked\"/>";
                } else {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>";
                }
                helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
                echo "</p>\n";
                break;
            case LESSON_TRUEFALSE :
            case LESSON_ESSAY :
            case LESSON_MATCHING :
            case LESSON_NUMERICAL :
                echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
                echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>";
                lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, 
                                  "lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
                                  "document.editpage.redisplay.value=1;document.editpage.submit();");
                break;
        }
    ?>
    <table cellpadding="5" class="generalbox" border="1">
    <tr valign="top">
    <td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br />
    <!-- hidden-label added.--><label for="title" class="hidden-label">Title</label><input type="text" id="title" name="title" size="80" maxsize="255" value="<?php p($page->title) ?>"></td>
    </tr>
    <?PHP
    echo "<tr><td><b>";
    echo get_string("pagecontents", "lesson").":</b><br />\n";
    print_textarea($usehtmleditor, 25, 70, 630, 400, "contents", $page->contents);
    use_html_editor("contents"); // always the editor
    echo "</td></tr>\n";
    $n = 0;
    switch ($page->qtype) {
        case LESSON_BRANCHTABLE :
            echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
            echo "<tr><td>\n";
            echo "<center>";
            if ($page->layout) {
                echo "<input checked=\"checked\" name=\"layout\" type=\"checkbox\" value=\"1\">";
            } else {
                echo "<input name=\"layout\" type=\"checkbox\" value=\"1\">";
            }
            echo get_string("arrangebuttonshorizontally", "lesson")."<center>\n";
            echo "<br>";
            if ($page->display) {
                echo "<center><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\">";
            } else {
                echo "<center><input name=\"display\" type=\"checkbox\" value=\"1\">";
            }                
            echo get_string("displayinleftmenu", "lesson")."<center>\n";
            echo "</td></tr>\n";
            echo "<tr><td><b>".get_string("branchtable", "lesson")."</b> \n";
            break;
        case LESSON_CLUSTER :
            echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
            echo "<tr><td><b>".get_string("clustertitle", "lesson")."</b> \n";
            break;                
        case LESSON_ENDOFCLUSTER :
            echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
            echo "<tr><td><b>".get_string("endofclustertitle", "lesson")."</b> \n";
            break;                            
        case LESSON_ENDOFBRANCH :
            echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
            echo "<tr><td><b>".get_string("endofbranch", "lesson")."</b> \n";
            break;                
    }       
    echo "</td></tr>\n";
    // get the answers in a set order, the id order
    if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) {
        foreach ($answers as $answer) {
            $flags = intval($answer->flags); // force into an integer
            $nplus1 = $n + 1;
            echo "<input type=\"hidden\" name=\"answerid[$n]\" value=\"$answer->id\">\n";
            switch ($page->qtype) {
                case LESSON_MATCHING:
                    if ($n == 0) {
                        echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b>\n";
                        if ($flags & LESSON_ANSWER_EDITOR) {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" 
                                checked=\"checked\">";
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
                            use_html_editor("answer[$n]"); // switch on the editor
                        } else {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">";
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
                        }
                    } elseif ($n == 1) {
                        echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b>\n";
                        if ($flags & LESSON_ANSWER_EDITOR) {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" 
                                checked=\"checked\">";
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
                            use_html_editor("answer[$n]"); // switch on the editor
                        } else {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">";
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
                        }
                    } else {
                        $ncorrected = $n - 1;
                        echo "<tr><td><b>".get_string("answer", "lesson")." $ncorrected:</b>\n";
                        if ($flags & LESSON_ANSWER_EDITOR) {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" 
                                checked=\"checked\">"; 
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
                            use_html_editor("answer[$n]"); // switch on the editor
                        } else {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">";
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
                        }
                        echo "</td></tr>\n";
                        echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $ncorrected:</b>\n";
                        if ($flags & LESSON_RESPONSE_EDITOR) {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" 
                                checked=\"checked\">";
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response);
                            use_html_editor("response[$n]"); // switch on the editor
                        } else {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\">";
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response);
                        }
                    }
                    echo "</td></tr>\n";
                    break;
                case LESSON_TRUEFALSE:
                case LESSON_MULTICHOICE:
                case LESSON_SHORTANSWER:
                case LESSON_NUMERICAL:                    
                    echo "<tr><td><b>".get_string("answer", "lesson")." $nplus1:</b>\n";
                    if ($flags & LESSON_ANSWER_EDITOR and $page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
                        echo " [".get_string("useeditor", "lesson").": ".
                            "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" 
                            checked=\"checked\">";
                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                        echo "]<br />\n";
                        print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
                        use_html_editor("answer[$n]"); // switch on the editor
                    } else {
                        if ($page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
                            echo " [".get_string("useeditor", "lesson").": ".
                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label.
                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                            echo "]<br />\n";
                            print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
                        } else {
                            echo "<br />\n";
                            print_textarea(false, 1, 70, 630, 300, "answer[$n]", $answer->answer);
                        }
                    }
                    echo "</td></tr>\n";
                    echo "<tr><td><b>".get_string("response", "lesson")." $nplus1:</b>\n";
                    if ($flags & LESSON_RESPONSE_EDITOR) {
                        echo " [".get_string("useeditor", "lesson").": ".
                            "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" 
                            checked=\"checked\">";
                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                        echo "]<br />\n";
                        print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response);
                        use_html_editor("response[$n]"); // switch on the editor
                    } else {
                        echo " [".get_string("useeditor", "lesson").": ".
                            "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\">";
                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                        echo "]<br />\n";
                        print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response);
                    }
                    echo "</td></tr>\n";
                    break;
                case LESSON_BRANCHTABLE:
                    echo "<tr><td><b>".get_string("description", "lesson")." $nplus1:</b>\n";
                    if ($flags & LESSON_ANSWER_EDITOR) {
                        echo " [".get_string("useeditor", "lesson").": ".
                            "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" name=\"answereditor[$n]\" value=\"1\" 
                            checked=\"checked\">";
                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                        echo "]<br />\n";
                        print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
                        use_html_editor("answer[$n]"); // switch on the editor
                    } else {
                        echo " [".get_string("useeditor", "lesson").": ".
                            "<input type=\"checkbox\" name=\"answereditor[$n]\" value=\"1\">";
                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                        echo "]<br />\n";
                        print_textarea(false, 10, 70, 630, 300, "answer[$n]", $answer->answer);
                    }
                    echo "</td></tr>\n";
                    break;
            }
            switch ($page->qtype) {
                case LESSON_MATCHING :
                    if ($n == 2) {
                        echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n";
                        lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
                        helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                        if($lesson->custom)
                            echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
                        }
                    if ($n == 3) {
                        echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n";
                        lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
                        helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                        if($lesson->custom)
                            echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
                        }
                    echo "</td></tr>\n";
                    break;
                case LESSON_ESSAY :
                    echo "<tr><td><b>".get_string("jump", "lesson").":</b> \n";
                    lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
                    helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                    if($lesson->custom) {
                        echo get_string("score", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
                    }
                    echo "</td></tr>\n";
                    break;
                case LESSON_TRUEFALSE:
                case LESSON_MULTICHOICE:
                case LESSON_SHORTANSWER:
                case LESSON_NUMERICAL:
                    echo "<tr><td><b>".get_string("jump", "lesson")." $nplus1:</b> \n";
                    lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
                    helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                    if($lesson->custom) {
                        echo get_string("score", "lesson")." $nplus1: <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
                    }
                    echo "</td></tr>\n";
                    break;
                case LESSON_BRANCHTABLE:
                case LESSON_CLUSTER:
                case LESSON_ENDOFCLUSTER:
                case LESSON_ENDOFBRANCH:
                    echo "<tr><td><b>".get_string("jump", "lesson")." $nplus1:</b> \n";
                    lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
                    helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                    echo "</td></tr>\n";
                    break;
            }
            $n++;
            if ($page->qtype == LESSON_ESSAY) {
                break; // only one answer for essays
            }                
        }
    }
    if ($page->qtype != LESSON_ENDOFBRANCH && $page->qtype != LESSON_CLUSTER && $page->qtype != LESSON_ENDOFCLUSTER) {
        if ($page->qtype == LESSON_MATCHING) {
            $maxanswers = $lesson->maxanswers + 2;
        } else {
            $maxanswers = $lesson->maxanswers;
        }
        for ($i = $n; $i < $maxanswers; $i++) {
            if ($page->qtype == LESSON_TRUEFALSE && $i > 1) {
                break; // stop printing answers... only need two for true/false
            }
            $iplus1 = $i + 1;
            echo "<input type=\"hidden\" name=\"answerid[$i]\" value=\"0\">\n";
            switch ($page->qtype) {
                case LESSON_MATCHING:
                    $icorrected = $i - 1;
                    echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b>\n";
                    echo " [".get_string("useeditor", "lesson").": ".
                        "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
                    helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                    echo "]<br />\n";
                    print_textarea(false, 10, 70, 630, 300, "answer[$i]");
                    echo "</td></tr>\n";
                    echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b>\n";
                    echo " [".get_string("useeditor", "lesson").": ".
                        "<input type=\"checkbox\" name=\"responseeditor[$i]\" value=\"1\">";
                    helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                    echo "]<br />\n";
                    print_textarea(false, 10, 70, 630, 300, "response[$i]");
                    echo "</td></tr>\n";
                    break;
                case LESSON_TRUEFALSE:
                case LESSON_MULTICHOICE:
                case LESSON_SHORTANSWER:
                case LESSON_NUMERICAL:
                    echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b>\n";
                    if ($page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
                        echo " [".get_string("useeditor", "lesson").": ".
                            "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                        echo "]<br />\n";
                        print_textarea(false, 10, 70, 630, 300, "answer[$i]");
                    } else {
                        echo "<br />\n";
                        print_textarea(false, 1, 70, 630, 300, "answer[$i]");
                    }
                    echo "</td></tr>\n";
                    echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b>\n";
                    echo " [".get_string("useeditor", "lesson").": ".
                        "<input type=\"checkbox\" name=\"responseeditor[$i]\" value=\"1\">";
                    helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                    echo "]<br />\n";
                    print_textarea(false, 10, 70, 630, 300, "response[$i]");
                    echo "</td></tr>\n";
                    break;
                case LESSON_BRANCHTABLE:
                    echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b>\n";
                    echo " [".get_string("useeditor", "lesson").": ".
                        "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
                    helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
                    echo "]<br />\n";
                    print_textarea(false, 10, 70, 630, 300, "answer[$i]");
                    echo "</td></tr>\n";
                    break;
            }
            switch ($page->qtype) {
                case LESSON_ESSAY :
                    if ($i < 1) {
                        echo "<tr><td><B>".get_string("jump", "lesson").":</b> \n";
                        lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
                        helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                        if($lesson->custom) {
                            echo get_string("score", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
                        }
                        echo "</td></tr>\n";
                    }
                    break;
                case LESSON_MATCHING :
                    if ($i == 2) {
                        echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n";
                        lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, "");
                        helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                        if($lesson->custom)
                            echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"$answer->score\" size=\"5\">";
                        }
                    if ($i == 3) {
                        echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n";
                        lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, "");
                        helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                        if($lesson->custom)
                            echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"$answer->score\" size=\"5\">";
                        }

                    echo "</td></tr>\n";
                    break;
                case LESSON_TRUEFALSE:
                case LESSON_MULTICHOICE:
                case LESSON_SHORTANSWER:
                case LESSON_NUMERICAL:
                    echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
                    lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
                    helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                    if($lesson->custom) {
                        echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
                    }
                    echo "</td></tr>\n";
                    break;
                case LESSON_BRANCHTABLE :
                    echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
                    lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
                    helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
                    echo "</td></tr>\n";
                    break;
            }
        }
    }
    // close table and form
    ?>
    </table><br />
    <input type="button" value="<?php print_string("redisplaypage", "lesson") ?>" 
        onClick="document.editpage.redisplay.value=1;document.editpage.submit();" />
    <input type="submit" value="<?php  print_string("savepage", "lesson") ?>" />
    <input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
    </center>
    </form>