<?php
    if (empty($form->name)) {
        $form->name = "";
    }
    if (empty($form->text)) {
        $form->text = "";
    }
    if (empty($form->format)) {
        $form->format = 0;
    }
    if (empty($form->answer1)) {
        $form->answer1 = get_string("yes");
    }
    if (empty($form->answer2)) {
        $form->answer2 = get_string("no");
    }
    if (empty($form->answer3)) {
        $form->answer3 = "";
    }
    if (empty($form->answer4)) {
        $form->answer4 = "";
    }
    if (empty($form->answer5)) {
        $form->answer5 = "";
    }
    if (empty($form->answer6)) {
        $form->answer6 = "";
    }
    if (empty($form->publish)) {
        $form->publish = 0;
    }
    if (empty($form->showunanswered)) {
        $form->showunanswered = 0;
    }

    if ($usehtmleditor = can_use_richtext_editor()) {
        $defaultformat = FORMAT_HTML;
        $onsubmit = "onsubmit=\"copyrichtext(document.form.text);\"";
    } else {
        $defaultformat = FORMAT_MOODLE;
        $onsubmit = "";
    }

?>
<form name="form" method="post" <?php echo $onsubmit ?> action="mod.php">

<table cellpadding=5>

<tr valign=top>
    <td align=right><p><b><?php print_string("choicename","choice") ?>:</b></p></td>
    <td>
        <input type="text" name="name" size=30 value="<?php p($form->name) ?>">
    </td>
</tr>

<tr valign=top>
    <td align=right><p><b><?php print_string("choicetext","choice") ?>:</b></p>
    <font size="1">
     <?php
        helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
        echo "<br />";
        helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
        echo "<br />";
        if ($usehtmleditor) {
           helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
        } else {
           emoticonhelpbutton("form", "text");
        }   
      ?>
      <br />
    </font>
    </td>
    <td>
    <?php 
       print_textarea($usehtmleditor, 20, 60, 680, 400, "text", $form->text);
    
       echo "<p align=right>";
       helpbutton("textformat", get_string("formattexttype"));
       print_string("formattexttype");
       echo ":&nbsp;";
       if (!$form->format) {
           $form->format = $defaultformat;
       }
       choose_from_menu(format_text_menu(), "format", $form->format, ""); 
       echo "</p>";
    ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><p><b><?php print_string("choice","choice","1") ?>:</b></p></td>
    <td>
        <input type="text" name="answer1" size=60 value="<?php p($form->answer1) ?>">
        <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><p><b><?php print_string("choice","choice","2") ?>:</b></p></td>
    <td>
        <input type="text" name="answer2" size=60 value="<?php p($form->answer2) ?>">
        <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><p><b><?php print_string("choice","choice","3") ?>:</b></p></td>
    <td>
        <input type="text" name="answer3" size=60 value="<?php p($form->answer3) ?>">
        <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("choice","choice","4") ?>:</b></p></td>
    <td>
        <input type="text" name="answer4" size=60 value="<?php p($form->answer4) ?>">
        <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("choice","choice","5") ?>:</b></p></td>
    <td>
        <input type="text" name="answer5" size=60 value="<?php p($form->answer5) ?>">
        <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("choice","choice","6") ?>:</b></p></td>
    <td>
        <input type="text" name="answer6" size=60 value="<?php p($form->answer6) ?>">
        <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><P><B><?php print_string("publish","choice") ?>:</b></p></td>
    <td>
        <?php
        require("$CFG->dirroot/mod/choice/lib.php");
        choose_from_menu($CHOICE_PUBLISH, "publish", "$form->publish", "");
        ?>
        <br />
    </td>
</tr>
<tr valign=top>
    <td align=right><P><B><?php print_string("showunanswered","choice") ?>:</b></p></td>
    <td>
        <?php
        $options[0] = get_string("no");
        $options[1] = get_string("yes");
        choose_from_menu($options, "showunanswered", "$form->showunanswered", "");
        ?>
        <br />
    </td>
</tr>

</table>

<center>
<input type="hidden" name=course     value="<?php p($form->course) ?>">
<input type="hidden" name=coursemodule  value="<?php p($form->coursemodule) ?>">
<input type="hidden" name=section       value="<?php p($form->section) ?>">
<input type="hidden" name=module     value="<?php p($form->module) ?>">
<input type="hidden" name=modulename value="<?php p($form->modulename) ?>">
<input type="hidden" name=instance   value="<?php p($form->instance) ?>">
<input type="hidden" name=mode       value="<?php p($form->mode) ?>">
<input type="submit" value="<?php print_string("savechanges") ?>">
<input type="submit" name=cancel value="<?php print_string("cancel") ?>">
</center>
</form>

<?php
   if ($usehtmleditor) { 
       print_richedit_javascript("form", "text", "yes");
   }
?>