<!-- This page defines the form to create or edit an instance of this module -->
<!-- It is used from /course/mod.php.  The whole instance is available as $form. -->

<?php 
    require_once("$CFG->dirroot/mod/quiz/lib.php");

    if (!isset($form->name)) {
        $form->name = "";
    }
    if (!isset($form->intro)) {
        $form->intro = "";
    }
    if (!isset($form->timeopen)) {
        $form->timeopen = "";
    }
    if (!isset($form->timeclose)) {
        $form->timeclose = "";
    }
    if (!isset($form->attempts)) {
        $form->attempts = 0;
    }
    if (!isset($form->grademethod)) {
        $form->grademethod = "";
    }
    if (!isset($form->feedback)) {
        $form->feedback = "";
    }
    if (!isset($form->correctanswers)) {
        $form->correctanswers = "";
    }
    if (!isset($form->review)) {
        $form->review = 0;
    }
    if (!isset($form->shufflequestions)) {
        $form->shufflequestions = 0;
    }
    if (!isset($form->shuffleanswers)) {
        $form->shuffleanswers = 1;
    }
    if (!isset($form->grade)) {
        $form->grade = "";
    }
    if (!isset($form->questions)) {
        $form->questions = "";
    }
?>



<form name="form" method="post" action="../mod/quiz/edit.php">
<center>
<table cellpadding=5>
<tr valign=top>
    <td align=right><p><b><?php print_string("name") ?>:</b></p></td>
    <td>
        <input type="text" name="name" size=40 value="<?php p($form->name) ?>">
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("introduction", "quiz") ?>:</b></p></td>
    <td>
        <textarea name="intro" rows=4 cols=50 wrap="virtual"><?php p($form->intro) ?></textarea>
        <?php 
           helpbutton("text", get_string("helptext")); 
        ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("quizopen", "quiz") ?>:</b></p></td>
    <td>
    <?php
        if (!$form->timeopen and $course->format == "weeks") {
            $form->timeopen  = $course->startdate + (($form->section - 1) * 608400);
        }
        print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
        print_time_selector("openhour", "openminute", $form->timeopen);
        helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("quizclose", "quiz") ?>:</b></p></td>
    <td>
    <?php
        if (!$form->timeclose and $course->format == "weeks") {
            $form->timeclose  = $course->startdate + (($form->section) * 608400);
        }
        print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
        print_time_selector("closehour", "closeminute", $form->timeclose);
        helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("shufflequestions", "quiz") ?>:</b></p></td>
    <td>
    <?php
        $options = array();
        $options[0] = get_string("no");
        $options[1] = get_string("yes");
        choose_from_menu($options, "shufflequestions", "$form->shufflequestions", "");
        helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("shuffleanswers", "quiz") ?>:</b></p></td>
    <td>
    <?php
        $options = array();
        $options[0] = get_string("no");
        $options[1] = get_string("yes");
        choose_from_menu($options, "shuffleanswers", "$form->shuffleanswers", "");
        helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("attemptsallowed", "quiz") ?>:</b></p></td>
    <td>
    <?php
        $options = array();
        $options[0] = get_string("attemptsunlimited", "quiz");
        $options[1] = "1 ".strtolower(get_string("attempt", "quiz"));
        for ($i=2;$i<=6;$i++) {
            $options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
        }
        choose_from_menu($options, "attempts", "$form->attempts", "");
        helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("grademethod", "quiz") ?>:</b></p></td>
    <td>
    <?php
        $options = array();
        $options[1] = get_string("gradehighest", "quiz");
        $options[2] = get_string("gradeaverage", "quiz");
        $options[3] = get_string("attemptfirst", "quiz");
        $options[4] = get_string("attemptlast", "quiz");
        choose_from_menu($QUIZ_GRADE_METHOD, "grademethod", "$form->grademethod", "");
        helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("showfeedback", "quiz") ?>:</b></p></td>
    <td>
    <?php
        $options = array();
        $options[0] = get_string("no");
        $options[1] = get_string("yes");
        choose_from_menu($options, "feedback", "$form->feedback", "");
        helpbutton("feedback", get_string("showfeedback","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("showcorrectanswer", "quiz") ?>:</b></p></td>
    <td>
    <?php
        $options = array();
        $options[0] = get_string("no");
        $options[1] = get_string("yes");
        choose_from_menu($options, "correctanswers", "$form->correctanswers", "");
        helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("allowreview", "quiz") ?>:</b></p></td>
    <td>
    <?php
        $options = array();
        $options[0] = get_string("no");
        $options[1] = get_string("yes");
        choose_from_menu($options, "review", "$form->review", "");
        helpbutton("review", get_string("allowreview","quiz"), "quiz");
     ?>
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php print_string("maximumgrade") ?>:</b></p></td>
    <td>
    <?php
        for ($i=100; $i>=1; $i--) {
            $grades[$i] = $i;
        }
        choose_from_menu($grades, "grade", "$form->grade", "");
        helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
     ?>
    </td>
</tr>
</table>
<input type="hidden" name=questions     value="<?php p($form->questions) ?>">
<!-- these hidden variables are always the same -->
<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="hidden" name=destination   value="<?php echo "$CFG->wwwroot/course/mod.php" ?>">
<input type="submit" value="<?php print_string("continue") ?>">
</center>
</form>
