<!-- 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. -->
<!-- Register module written by Domenico Pontari -->
<!-- Modified by Lorenzo Nicora -->

<?php

global $CFG;

// Include module lib.php for defined constants
require_once("../mod/register/lib.php");

/// First we check that form variables have been initialised
if (!isset($form->name)) {
    $form->name = '';
}

if (!isset($form->type)) {
    $form->type = 'normal';
}

if (!isset($form->toleranceevaluation)) 
	$form->toleranceevaluation = false;
if (!isset($form->offlinesessions)) 
	$form->offlinesessions = true;

if (!isset($form->sessiontimeout)) 
	$form->sessiontimeout = REGISTER_DEFAULT_SESSION_TIMEOUT;
if (!isset($form->dayscertificable)) 
	$form->dayscertificable = REGISTER_DEFAULT_DAYS_CERTIFICABLE;
if (!isset($form->offlinecomments)) 
	$form->offlinecomments = true;
if (!isset($form->mandatoryofflinecomments)) 
	$form->mandatoryofflinecomments = false;
if (!isset($form->offlinespecifycourse)) 
	$form->offlinespecifycourse = true;
if (!isset($form->mandatoryofflinespecifycourse)) 
	$form->mandatoryofflinespecifycourse = false;
if (!isset($form->showtolerance)) 
	$form->showtolerance = false;



// More similar blocks go here...
?>

<form name="form" method="post" action="mod.php">
<div style="text-align:center">
<table summary="Instance module preferences" cellpadding="5">
<tr valign="top">
    <td style="text-align:right"><b><?php  print_string("name") ?>:</b></td>
    <td style="text-align:left"><input type="text" name="name" size="30" value="<?php  p($form->name) ?>" /></td>
</tr>
<tr valign="top">
    <td style="text-align:right"><b><?php  print_string("type", "register") ?>:</b></td>
    <td align="left">
        <?php
            $course = get_record("course", "id", $form->course);
            $isinmetacourse = $course->metacourse;
            unset($choices);
            $choices["normal"] = get_string("normal", "register");
            if ($isinmetacourse) $choices["meta"] = get_string("meta", "register");
            $choices["category"] = get_string("category", "register");
            choose_from_menu ($choices, "type", $form->type, 'choose', '', 'normal');
        ?>
        <br />
        <input type="hidden" name="toleranceevaluation" value="0" />
        <input type="hidden" name="offlinesessions" value="0" />
        
        <input type="hidden" name="offlinecomments" value="0" />
        <input type="hidden" name="mandatoryofflinecomments" value="0" />
        <input type="hidden" name="offlinespecifycourse" value="0" />
        <input type="hidden" name="mandatoryofflinespecifycourse" value="0" />
        <input type="hidden" name="showtolerance" value="0" />
        <br />
        
        <input type="checkbox" name="toleranceevaluation" value="1"
        <?PHP if ($form->toleranceevaluation == true) echo 'checked = "checked"';
            echo ' />';
            print_string("toleranceevaluation","register");
            helpbutton ("tolerance", get_string ("toleranceevaluation"), "register");
        ?><br />
        
        <input type="checkbox" name="showtolerance" value="1" 
        <?PHP  if ($form->showtolerance == true) echo 'checked = "checked"';
            echo ' />';
            print_string("showtolerance","register");
        ?><br /><br />
        
        <input type="checkbox" name="offlinesessions" value="1" 
        <?PHP  if ($form->offlinesessions == true) echo 'checked = "checked"';
            echo ' />';
            print_string("offlinesessions","register");
        ?><br /><br />
        
        <input type="checkbox" name="offlinecomments" value="1"
        <?PHP if ($form->offlinecomments == true) echo 'checked = "checked"';
            echo ' />';
            print_string("allowofflinecomments","register");
        ?><br />
        
        <input type="checkbox" name="mandatoryofflinecomments" value="1"
        <?PHP if ($form->mandatoryofflinecomments == true) echo 'checked = "checked"';
            echo ' />';
            print_string("offlinecommentsmandatory","register");
        ?><br /><br />
        

        <input type="checkbox" name="offlinespecifycourse" value="1"
        <?PHP if ($form->offlinespecifycourse == true) echo 'checked = "checked"';
            echo ' />';
            print_string("offlinemetacoursespecifycourse","register");
        ?><br />
        
        <input type="checkbox" name="mandatoryofflinespecifycourse" value="1"
        <?PHP if ($form->mandatoryofflinespecifycourse == true) echo 'checked = "checked"';
            echo ' />';
            print_string("specifycoursemandatory","register");
        ?><br />
        
    </td>
</tr>

<!-- Session Timeout -->
<tr valign="top">
    <td style="text-align:right"><b><?php  print_string("sessiontimeout", "register"); ?>:</b></td>
    <td align="left">
        <input type="text" name="sessiontimeout" size="3" maxlength="3" value="<?php echo $form->sessiontimeout; ?>" />
        <font size="2"><?php  print_string("minutes", "register"); ?></font> 
    </td>
</tr>

<!-- Days Certificable -->
<tr valign="top">
    <td style="text-align:right"><b><?php  print_string("dayscertificable", "register"); ?>:</b></td>
    <td align="left">
        <input type="text" name="dayscertificable" size="2" maxlength="2" value="<?php echo $form->dayscertificable; ?>" />
        <font size="2"><?php  print_string("days", "register"); ?></font> 
    </td>
</tr>



<!-- More rows go in here... -->

<!-- The following line for Moodle 1.5 prints the visibility setting form element -->
<?php print_visible_setting($form); ?>
<!-- and if your module uses groups you would also have -->
<?php print_groupmode_setting($form); ?>

</table>
<!-- These hidden variables are always the same -->
<input type="hidden" name="course"          value="<?php  p($form->course) ?>" />
<input type="hidden" name="sesskey"         value="<?php  p($form->sesskey) ?>" />
<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") ?>" />
</div>
</form>
