<!-- define a new instance of lesson -->
<!-- It is used from /course/mod.php.  The whole instance is available as $form. -->
<?php

    require_once("$CFG->dirroot/mod/lesson/lib.php");  // for parameter array
    $nohtmleditorneeded = true;

// set the defaults
    if (empty($form->name)) {
        $form->name = "";
    }
    if (!isset($form->grade)) {
        $form->grade = 0;
    }
    if (!isset($form->usemaxgrade)) {
        $form->usemaxgrade = 0;
    }
    if (!isset($form->maxanswers)) {
        $form->maxanswers = 4;
    }
    if (!isset($form->maxattempts)) {
        $form->maxattempts = 5;
    }
    if (!isset($form->nextpagedefault)) {
        $form->nextpagedefault = 0;
    }
    if (!isset($form->minquestions)) {
        $form->minquestions = 0;
    }
    if (!isset($form->maxpages)) {
        $form->maxpages = 0;
    }
    if (!isset($form->retake)) {
        $form->retake = 1;
    }
    if (!isset($form->available)) {
        $form->available = 0;
    }
    if (!isset($form->deadline)) {
        $form->deadline = 0;
    }

?>

<FORM name="form" method="post" action="<?php echo $ME ?>">
<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=30 value="<?php  p($form->name) ?>">
    </TD>
</TR>

<tr valign=top>
    <td align=right><P><B><?php  print_string("maximumgrade") ?>:</B></P></TD>
    <td>
        <?php
        for ($i=100; $i>=0; $i--) {
            $grades[$i] = $i;
        }
        choose_from_menu($grades, "grade", "$form->grade", "");
       helpbutton("grade", get_string("maximumgrade", "lesson"), "lesson");
        ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("maximumnumberofanswersbranches", "lesson") ?>:</B></P></TD>
    <td>
        <?php
        for ($i=10; $i>1; $i--) {
            $numbers[$i] = $i;
        }
        choose_from_menu($numbers, "maxanswers", "$form->maxanswers", "");
       helpbutton("maxanswers", get_string("maximumnumberofanswersbranches", "lesson"), "lesson");
        ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("maximumnumberofattempts", "lesson") ?>:</B></P></TD>
    <td>
        <?php
        unset($numbers);
        for ($i=10; $i>0; $i--) {
            $numbers[$i] = $i;
        }
        choose_from_menu($numbers, "maxattempts", "$form->maxattempts", "");
       helpbutton("maxattempts", get_string("maximumnumberofattempts", "lesson"), "lesson");
        ?>
    </td>
</tr>

<tr>
    <td align=right><P><B><?php  print_string("actionaftercorrectanswer", "lesson") ?>:</B></P></TD>
    <td>
    <?PHP 
        choose_from_menu($LESSON_NEXTPAGE_ACTION, "nextpagedefault", $form->nextpagedefault, "");
        helpbutton("nextpageaction", get_string("actionaftercorrectanswer", "lesson"), "lesson");
    ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("minimumnumberofquestions", "lesson") ?>:</B></P></TD>
    <td>
        <?php
        unset($numbers);
        for ($i=100; $i>=0; $i--) {
            $numbers[$i] = $i;
        }
        choose_from_menu($numbers, "minquestions", "$form->minquestions", "");
        helpbutton("minquestions", get_string("minimumnumberofquestions", "lesson"), "lesson");
        ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("numberofpagestoshow", "lesson") ?>:</B></P></TD>
    <td>
        <?php
        unset($numbers);
        for ($i=100; $i>=0; $i--) {
            $numbers[$i] = $i;
        }
        choose_from_menu($numbers, "maxpages", "$form->maxpages", "");
        helpbutton("maxpages", get_string("numberofpagestoshow", "lesson"), "lesson");
        ?>
    </td>
</tr>

<tr>
    <td align=right><P><B><?php  print_string("canretake", "lesson", $course->student) ?>:</B></P></TD>
    <td>
    <?PHP 
        $options[0] = get_string("no"); $options[1] = get_string("yes");
        choose_from_menu($options, "retake", $form->retake, "");
        helpbutton("retake", get_string("canretake", "lesson", $course->student), "lesson");
    ?>
    </td>
</tr>

<tr>
    <td align=right><P><B><?php  print_string("handlingofretakes", "lesson") ?>:</B></P></TD>
    <td>
    <?PHP 
        $options[0] = get_string("usemean", "lesson"); $options[1] = get_string("usemaximum", "lesson");
        choose_from_menu($options, "usemaxgrade", $form->usemaxgrade, "");
        helpbutton("handlingofretakes", get_string("handlingofretakes", "lesson"), "lesson");
    ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("available", "lesson") ?>:</B></td>
    <td><?php
           print_date_selector("availableday", "availablemonth", "availableyear", $form->available);
           echo "&nbsp;-&nbsp;";
           print_time_selector("availablehour", "availableminute", $form->available);
    ?></td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("deadline", "lesson") ?>:</B></td>
    <td><?php
           print_date_selector("deadlineday", "deadlinemonth", "deadlineyear", $form->deadline);
           echo "&nbsp;-&nbsp;";
           print_time_selector("deadlinehour", "deadlineminute", $form->deadline);
    ?></td>
</tr>

</TABLE>
<!-- 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="submit" value="<?php  print_string("savechanges") ?>">
</CENTER>
</FORM>
