<?php  // $Id: mod.html,v 1.11 2006/03/22 08:07:25 moodler Exp $

    require_once($CFG->dirroot.'/mod/data/lib.php');

    if (!isset($form->name)) {
        $form->name = '';
    }
    if (!isset($form->intro)) {
        $form->intro = '';
    }
    if (!isset($form->keepdays)) {
        $form->keepdays = 30;
    }
    if (!isset($form->studentlogs)) {
        $form->studentlogs = 0;
    }
    if (!isset($form->timeavailablefrom)) {
        $form->timeavailablefrom = 0;
    }
    if (!isset($form->timeavailableto)) {
        $form->timeavailableto = 0;
    }
    if (!isset($form->timeviewfrom)) {
        $form->timeviewfrom = 0;
    }
    if (!isset($form->timeviewto)) {
        $form->timeviewto = 0;
    }
    if (!isset($form->schedule)) {
        $form->schedule = 0;
    }
    if (!isset($form->participants)) {
        $form->participants = DATA_TEACHERS_AND_STUDENTS;
    }
    if (!isset($form->requiredentries)) {
        $form->requiredentries = 0;
    }
    if (!isset($form->requiredentriestoview)) {
        $form->requiredentriestoview = 0;
    }
    if (!isset($form->maxentries)) {
        $form->maxentries = 0;
    }
    if (!isset($form->rssarticles)) {
        $form->rssarticles = 0;
    }
    if (!isset($form->comments)) {
        $form->comments = 0;
    }
    if (!isset($form->ratings)) {
        $form->ratings = 0;
    }
    if (!isset($form->approval)) {
        $form->approval = 0;
    }
    if (!isset($form->scale)) {
        $form->scale = 0;
    }
    if (!isset($form->assessed)) {
        $form->assessed = 1;
    }
    if (!isset($form->assesspublic)) {
        $form->assesspublic = 1;
    }
?>

<script type="text/javascript" language="javascript">
    var availablefromitems = ['availablefromday','availablefrommonth','availablefromyear','availablefromhour', 'availablefromminute'];
    var availabletoitems = ['availabletoday','availabletomonth','availabletoyear','availabletohour', 'availabletominute'];
    var viewfromitems = ['viewfromday','viewfrommonth','viewfromyear','viewfromhour', 'viewfromminute'];
    var viewtoitems = ['viewtoday','viewtomonth','viewtoyear','viewtohour', 'viewtominute'];
</script>



<form name="form" method="post" action="mod.php">
<table cellpadding="5">
<tr valign="top">
    <td align="right"><?php print_string('name')?>:</b></td>
    <td>
        <input type="text" name="name" size="30" value="<?php p($form->name) ?>" alt="<?php print_string('name') ?>" />
    </td>
</tr>
<tr valign="top">
    <td align="right"><?php print_string('intro', 'data')?>:</b><br /><br />
     <?php
        helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
        echo '<br />';
        helpbutton('questions', get_string('helpquestions'), 'moodle', true, true);
        echo '<br />';
        emoticonhelpbutton('form', 'intro');
        echo '<br />';
      ?>
    </td>
    <td>
        <?php print_textarea($usehtmleditor, 20, 50, 680, 400, 'intro', $form->intro); ?>
    </td>
</tr>

<tr valign="top">
   <td align="right"><b><?php print_string('availablefromdate','data') ?>:</b></td>
    <td>
        <input name="availablefromenable" type="checkbox" value="1" alt="<?php print_string('availablefromdate', 'data') ?>" onclick="return lockoptions('form', 'availablefromenable', availablefromitems)" <?php if ($form->timeavailablefrom) echo 'checked="checked"' ?> />
    <?php
           print_date_selector("availablefromday", "availablefrommonth", "availablefromyear", $form->timeavailablefrom);
           echo "&nbsp;-&nbsp;";
           print_time_selector("availablefromhour", "availablefromminute", $form->timeavailablefrom);
    ?>
        <input type="hidden" name="havailablefromday"    value="0" />
        <input type="hidden" name="havailablefrommonth"  value="0" />
        <input type="hidden" name="havailablefromyear"   value="0" />
        <input type="hidden" name="havailablefromhour"   value="0" />
        <input type="hidden" name="havailablefromminute" value="0" />
    </td>
</tr>


<tr valign="top">
   <td align="right"><b><?php print_string('availabletodate','data') ?>:</b></td>
    <td>
        <input name="availabletoenable" type="checkbox" value="1" alt="<?php print_string('availabletodate', 'data') ?>" onclick="return lockoptions('form', 'availabletoenable', availabletoitems)" <?php if ($form->timeavailableto) echo 'checked="checked"' ?> />
    <?php
           print_date_selector("availabletoday", "availabletomonth", "availabletoyear", $form->timeavailableto);
           echo "&nbsp;-&nbsp;";
           print_time_selector("availabletohour", "availabletominute", $form->timeavailableto);
    ?>
        <input type="hidden" name="havailabletoday"    value="0" />
        <input type="hidden" name="havailabletomonth"  value="0" />
        <input type="hidden" name="havailabletoyear"   value="0" />
        <input type="hidden" name="havailabletohour"   value="0" />
        <input type="hidden" name="havailabletominute" value="0" />
    </td>
</tr>

<tr valign="top">
   <td align="right"><b><?php print_string('viewfromdate','data') ?>:</b></td>
    <td>
        <input name="viewfromenable" type="checkbox" value="1" alt="<?php print_string('viewfromdate', 'data') ?>" onclick="return lockoptions('form', 'viewfromenable', viewfromitems)" <?php if ($form->timeviewfrom) echo 'checked="checked"' ?> />
    <?php
           print_date_selector("viewfromday", "viewfrommonth", "viewfromyear", $form->timeviewfrom);
           echo "&nbsp;-&nbsp;";
           print_time_selector("viewfromhour", "viewfromminute", $form->timeviewfrom);
    ?>
        <input type="hidden" name="hviewfromday"    value="0" />
        <input type="hidden" name="hviewfrommonth"  value="0" />
        <input type="hidden" name="hviewfromyear"   value="0" />
        <input type="hidden" name="hviewfromhour"   value="0" />
        <input type="hidden" name="hviewfromminute" value="0" />
    </td>
</tr>


<tr valign="top">
   <td align="right"><b><?php print_string('viewtodate','data') ?>:</b></td>
    <td>
        <input name="viewtoenable" type="checkbox" value="1" alt="<?php print_string('viewtodate', 'data') ?>" onclick="return lockoptions('form', 'viewtoenable', viewtoitems)" <?php if ($form->timeviewto) echo 'checked="checked"' ?> />
    <?php
           print_date_selector("viewtoday", "viewtomonth", "viewtoyear", $form->timeviewto);
           echo "&nbsp;-&nbsp;";
           print_time_selector("viewtohour", "viewtominute", $form->timeviewto);
    ?>
        <input type="hidden" name="hviewtoday"    value="0" />
        <input type="hidden" name="hviewtomonth"  value="0" />
        <input type="hidden" name="hviewtoyear"   value="0" />
        <input type="hidden" name="hviewtohour"   value="0" />
        <input type="hidden" name="hviewtominute" value="0" />
    </td>
</tr>


<tr valign="top">
    <td align="right"><b><?php print_string('participants', 'data') ?>:</b></td>
    <td>
    <?php
        $a->teachers = $course->teachers;
        $a->students = $course->students;
        $options = array(DATA_TEACHERS_ONLY => $a->teachers,
                         DATA_TEACHERS_AND_STUDENTS => get_string('teachersandstudents', 'data', $a));
        choose_from_menu($options, 'participants', $form->participants, '');
        helpbutton('participants', get_string('participants', 'data'), 'data');
    ?>
    </td>
</tr>


<tr valign="top">
    <td align="right"><b><?php print_string('requiredentries', 'data') ?>:</b></td>
    <td>
    <?php
        $countoptions = array();
        for($count=1;$count<=DATA_MAX_ENTRIES;$count++) $countoptions[$count] = $count;
        choose_from_menu($countoptions, 'requiredentries', $form->requiredentries, get_string('none'));
        helpbutton('requiredentries', get_string('requiredentries', 'data'), 'data');
    ?>
    </td>
</tr>

<tr valign="top">
    <td>&nbsp;</td>
    <td><b><?php print_string('requiredentriestoview', 'data') ?>: </b>
        <?php
            choose_from_menu($countoptions, 'requiredentriestoview', $form->requiredentriestoview, get_string('none'));
            helpbutton('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data');
        ?>
    </td>
</tr>

<tr valign="top">
    <td align="right"><b><?php print_string('maxentries', 'data') ?>:</b></td>
    <td>
        <?php
            choose_from_menu($countoptions, 'maxentries', $form->maxentries, get_string('nomaximum', 'data'));
            helpbutton('maxentries', get_string('maxentries', 'data'), 'data');
        ?>
    </td>
</tr>


<tr valign="top">
    <td align="right"><b><?php print_string('comments', 'data') ?>:</b></td>
    <td>
    <?php
        $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
        choose_from_menu($ynoptions, 'comments', $form->comments, '');
        helpbutton('comments', get_string('allowcomments', 'data'), 'data');
   ?>
   </td>
</tr>

<tr valign="top">
    <td align="right"><b><?php print_string('requireapproval', 'data') ?>:</b></td>
    <td>
    <?php
        $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
        choose_from_menu($ynoptions, 'approval', $form->approval, '');
        helpbutton('requireapproval', get_string('requireapproval', 'data'), 'data');
   ?>
   </td>
</tr>

<?php if (!empty($CFG->data_enablerssfeeds) and !empty($CFG->enablerssfeeds)) { ?>
<tr valign="top">
    <td align="right"><b><?php print_string('numberrssarticles', 'data') ?>:</b></td>
    <td>
        <?php
            choose_from_menu($countoptions, 'rssarticles', $form->rssarticles, get_string('none'));
            echo ' ' . get_string('rsshowmany', 'data');
        ?>
    </td>
</tr>
<?php } ?>

<tr>
    <td align="right" valign="top"><b><?php print_string("allowratings", "data") ?>:</b></td>
    <td>
        <table cellpadding="1">
        <tr>
            <td colspan="2">
        <?php
            echo '<script type="text/javascript">';
            echo "  var subitemsall = ['assessed', 'assesspublic', 'scale'];";
            echo '</script>';

            echo '<input name="ratings" type="checkbox" alt="'.get_string('ratingsuse', 'data').'" value="1" ';
            echo " onclick=\"return lockoptions('form','ratings', subitemsall)\" ";
            if ($form->ratings) {
                echo ' checked="checked" ';
            }
            echo ' />';
            echo '&nbsp;'.get_string('ratingsuse', 'data').':';
            echo '</td></tr>';

            echo '<tr><td>';
            // The odd order below was to maintain backward compatibility
            unset($options);
            $options[2] = get_string('ratingonlyteachers', 'data', moodle_strtolower($course->teachers));
            $options[1] = get_string('ratingeveryone', 'data');
            echo get_string('users').': ';
            echo '</td><td>';
            choose_from_menu($options, 'assessed', $form->assessed, '');
            echo '</td></tr>';

            echo '<tr><td>';
            unset($options);
            $options[0] = get_string('ratingpublicnot', 'data', $course->students);
            $options[1] = get_string('ratingpublic', 'data', $course->students);
            echo get_string('view').': ';
            echo '</td><td>';
            choose_from_menu($options, 'assesspublic', $form->assesspublic, '');
            echo '</td></tr>';

            echo '<tr><td>';
            echo get_string('grade').': ';
            echo '</td><td>';
            print_grade_menu($course->id, 'scale', $form->scale, false);
            echo '</td></tr>';

            echo '</td></tr></table>';

            echo '<input type="hidden" name="hassessed"     value="0" />';
            echo '<input type="hidden" name="hassesspublic" value="0" />';
            echo '<input type="hidden" name="hscale"        value="0" />';

            echo '<script type="text/javascript">';
            echo "lockoptions('form','ratings', subitemsall);";
            echo '</script>';

        ?>
    </td>
</tr>
<?php print_standard_coursemodule_settings($form); ?>

</table>
<center>
<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') ?>" />
<input type="submit" name="cancel" value="<?php  print_string('cancel') ?>" />
</center>
</form>

<script type="text/javascript">
<?php
    if (!$form->timeavailablefrom) echo "lockoptions('form','availablefromenable', availablefromitems);";
    if (!$form->timeavailableto) echo "lockoptions('form','availabletoenable', availabletoitems);";
    if (!$form->timeviewfrom) echo "lockoptions('form','viewfromenable', viewfromitems);";
    if (!$form->timeviewto) echo "lockoptions('form','viewtoenable', viewtoitems);";
?>
</script>

