<commit_before><?php

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

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

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

    if (isset($_GET['qtype'])) {
        $page->qtype = required_param('qtype', PARAM_INT);
    }

    // set of jump array
    $jump = array();
    $jump[0] = get_string("thispage", "lesson");
    $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
    //// CDC-FLAG 6/18/04 /////
    $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");
    }
    //// CDC-FLAG /////        
    $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");
            }
            /// CDC-FLAG /// 6/15/04 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="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\"/>"; //CDC hidden label added.
                } else {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
                }
                helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
                echo "</p>\n";
                break;
            case LESSON_SHORTANSWER :
                echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
                echo helpbutton("questiontype", 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\"/>"; //CDC hidden label added.
                } else {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
                }
                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("questiontype", 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();");<commit_msg>Bug 1650 fixed: help button calling the wrong help file<commit_after><?php

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

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

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

    if (isset($_GET['qtype'])) {
        $page->qtype = required_param('qtype', PARAM_INT);
    }

    // set of jump array
    $jump = array();
    $jump[0] = get_string("thispage", "lesson");
    $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
    //// CDC-FLAG 6/18/04 /////
    $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");
    }
    //// CDC-FLAG /////        
    $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");
            }
            /// CDC-FLAG /// 6/15/04 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="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\"/>"; //CDC hidden label added.
                } else {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
                }
                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\"/>"; //CDC hidden label added.
                } else {
                    echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
                }
                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();");
{'fraction_non_alphanumeric': 0.18869426751592358, 'fraction_numerical': 0.00389242745930644, 'mean_word_length': 2.325, 'pattern_counts': {'":': 10, '<': 85, '<?xml version=': 0, '>': 139, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1184951', 'n_tokens_mistral': 3572, 'n_tokens_neox': 3447, 'n_words': 604}