<?php
	// ...and fill the form if needed
    if (empty($form->name)) {
        $form->name = "";
    }
    if (empty($form->description)) {
        $form->description = "";
    }
    if (empty($form->format)) {
        $form->format = "";
    }
    if (!isset($form->grade)) {
        $form->grade = 100;
    }
    if (!isset($form->nelements)) {
        $form->nelements = 1;
    }
    if (empty($form->resubmit)) {
        $form->resubmit = "";
    }
    if (!isset($form->ntassessments)) {
        $form->ntassessments = 0;
    }
    if (!isset($form->nsassessments)) {
        $form->nsassessments = 0;
    }
    if (empty($form->includeself)) {
        $form->includeself = "";
    }
    if (empty($form->agreeassessments)) {
        $form->agreeassessments = "";
    }
    if (empty($form->hidegrades)) {
        $form->hidegrades = "";
    }
    if (empty($form->maxbytes)) {
        $form->maxbytes = "";
    }
    if (empty($form->deadline)) {
        $form->deadline = "";
    }
?>

<form name="form" method="post" action="mod.php">
<table cellpadding=5>
<tr valign=top>
    <td align=right><P><B><?php  print_string("title", "workshop") ?>:</B></P></TD>
    <td>
        <input type="text" name="name" size=60 value="<?php  p($form->name) ?>">
    </td>
</tr>
<tr valign=top>
    <td align=right><p><b><?php  print_string("description", "workshop") ?>:</b></p>
    <font size="1">
     <?php
        helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
        echo "<br />";
        if ($usehtmleditor) {
           helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
        } else {
           helpbutton("text", get_string("helptext"), "moodle", true, true);
           echo "<br />";
           emoticonhelpbutton("form", "description", "moodle", true, true);
           echo "<br />";
        } 
      ?>
      <br />
    </font>
    <td>
    <?php  
       print_textarea($usehtmleditor, 20, 60, 595, 400, "description", $form->description);
    
       if ($usehtmleditor) {
           echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
       } else {
           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("maximumgrade") ?>:</B></P></TD>
    <td>
        <?php
        for ($i=100; $i>=0; $i--) {
            $grades[$i] = $i;
        }
        choose_from_menu($grades, "grade", "$form->grade", "");
        ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("gradingstrategy", "workshop") ?>:</B></P></TD>
    <td>
    <?PHP
       require("$CFG->dirroot/mod/workshop/lib.php");
	   if (!isset($form->gradingstrategy)) {
		   $form->gradingstrategy = 1;  // default
		   }
       choose_from_menu($WORKSHOP_TYPE, "gradingstrategy", $form->gradingstrategy, "");
       helpbutton("gradingstrategy", get_string("gradingstrategy", "workshop"), "workshop");
    ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("numberofassessmentelements", "workshop") ?>:</B></P></TD>
    <td valign="middle">
        <?php
        for ($i=20; $i>=0; $i--) {
            $numbers[$i] = $i;
        }
        choose_from_menu($numbers, "nelements", "$form->nelements", "");
       helpbutton("nelements", get_string("numberofassessmentelements", "workshop"), "workshop");
        ?>
    </td>
</tr>

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

<tr valign=top>
    <td align=right><P><B><?php  print_string("numberofassessmentsofteachersexamples", "workshop") ?>:</B></P></TD>
    <td>
		<?PHP
		for ($i=20; $i>=0; $i--) {
			$numbers[$i] = $i;
		}
		choose_from_menu($numbers, "ntassessments", $form->ntassessments, "");
       helpbutton("nassessmentsofteachersexamples", get_string("numberofassessmentsofteachersexamples", "workshop"), "workshop");
		?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("numberofassessmentsofstudentsubmissions", "workshop") ?>:</B></P></TD>
    <td>
		<?PHP
		for ($i=20; $i>=0; $i--) {
			$numbers[$i] = $i;
		}
		choose_from_menu($numbers, "nsassessments", $form->nsassessments, "");
       helpbutton("nassessmentsofstudentsubmissions", get_string("numberofassessmentsofstudentsubmissions", "workshop"), "workshop");
		?>
    </td>
</tr>

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

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

<tr>
    <td align=right><P><B><?php  print_string("hidegradesbeforeagreement", "workshop") ?>:</B></P></TD>
    <td>
    <?PHP 
        $options[0] = get_string("no"); $options[1] = get_string("yes");
        choose_from_menu($options, "hidegrades", $form->hidegrades, "");
        helpbutton("showinggrades", get_string("hidegradesbeforeagreement", "workshop"), "workshop");
    ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("maximumsize", "workshop") ?>:</B></P></TD>
    <td>
        <?php
        $sizelist = array("10Kb", "50Kb", "100Kb", "500Kb", "1Mb", "2Mb", "5Mb", "10Mb", "20Mb", "50Mb");
        $maxsize = get_max_upload_file_size();
        $sizeinlist = false;
        foreach ($sizelist as $size) {
            $sizebytes = get_real_size($size);
            if ($sizebytes < $maxsize) {
                $filesize[$sizebytes] = $size;
            }
            if ($form->maxbytes == $sizebytes) {
                $sizeinlist = true;
            }
        }
        $filesize[$maxsize] = display_size($maxsize);
        if (!$sizeinlist) {
            $form->maxbytes = get_real_size("500K");
        }
        ksort($filesize, SORT_NUMERIC);
        choose_from_menu($filesize, "maxbytes", "$form->maxbytes", "");
        ?>
    </td>
</tr>

<tr valign=top>
    <td align=right><P><B><?php  print_string("deadline", "workshop") ?>:</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>
<BR>
<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") ?>">
<p>
<p><?PHP notify(get_string("noteonassessmentelements", "workshop")); ?>

</CENTER>
</FORM>
