File: addbranchtable.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 (81 lines) | stat: -rw-r--r-- 3,779 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
<?php
/************** add branch table ************************************/
    $CFG->pagepath = 'mod/lesson/addbranchtable';
    
    if (!isteacher($course->id)) {
        error("Only teachers can look at this page");
    }

    // first get the preceeding page
    $pageid = required_param('pageid', 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");
    $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
    if (!optional_param('firstpage', 0, PARAM_INT)) {
        if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
            error("Add page: first page not found");
        }
        while (true) {
            if ($apageid) {
                $title = get_field("lesson_pages", "title", "id", $apageid);
                $jump[$apageid] = $title;
                $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid);
            } else {
                // last page reached
                break;
            }
        }
     }
    // give teacher a blank proforma
    print_heading_with_help(get_string("addabranchtable", "lesson"), "overview", "lesson");
    ?>
    <form name="form" method="post" action="lesson.php" />
    <input type="hidden" name="id" value="<?PHP echo $cm->id ?>" />
    <input type="hidden" name="action" value="insertpage">
    <input type="hidden" name="pageid" value="<?PHP echo $pageid ?>" />
    <input type="hidden" name="qtype" value="<?PHP echo LESSON_BRANCHTABLE ?>" />
    <input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>" />
    <center><table class="generalbox" cellpadding=5 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="" /></td></tr>
    <?PHP
    echo "<tr><td><b>";
    echo get_string("pagecontents", "lesson").":</b><br />\n";
    print_textarea($usehtmleditor, 25,70, 630, 400, "contents");
    use_html_editor("contents");
    echo "</td></tr>\n";
    echo "<tr><td>\n";
    echo "<center><input name=\"layout\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
    echo get_string("arrangebuttonshorizontally", "lesson")."\n";
    echo "<br><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
    echo get_string("displayinleftmenu", "lesson");
    echo "</center>\n";
    echo "</td></tr>\n";
    for ($i = 0; $i < $lesson->maxanswers; $i++) {
        $iplus1 = $i + 1;
        echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b><br />\n";
        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
        echo "</td></tr>\n";
        echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
        if ($i) {
            // answers 2, 3, 4... jumpto this page
            lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
        } else {
            // answer 1 jumpto next page
            lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
        }
        helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
        echo "</td></tr>\n";
    }
    // close table and form
    ?>
    </table><br />
    <input type="submit" value="<?php  print_string("addabranchtable", "lesson") ?>" />
    <input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
    </center>
    </form>