moodle/mod/choice/mod.html

320 lines
11 KiB
HTML
Raw Normal View History

<?php
if (empty($form->name)) {
$form->name = "";
}
if (empty($form->text)) {
$form->text = "";
}
if (empty($form->format)) {
$form->format = 0;
}
if (empty($form->display)) {
$form->display = 0;
}
if (empty($form->timeopen)) {
$form->timeopen = "";
$form->timerestrict = 0;
} else {
$form->timerestrict = 1;
}
if (empty($form->timeclose)) {
$form->timeclose = "";
}
if (empty($form->publish)) {
$form->publish = 0;
}
if (empty($form->release)) {
$form->release = 0;
}
if (empty($form->allowupdate)) {
$form->allowupdate = 0;
}
if (empty($form->showunanswered)) {
$form->showunanswered = 0;
}
2005-04-14 21:10:39 +00:00
if (empty($form->limitanswers)) {
$form->limitanswers = 0;
}
?>
2005-04-14 21:10:39 +00:00
<script type="text/javascript">
function lockselects(form, master, subitems) {
// subitems is an array of names of sub items
// requires that each item in subitems has a
// companion hidden item in the form with the
// same name but prefixed by "h"
// master is the name of the selct
// x is the option that is selcted to enforce the lock.
if (eval("document."+form+"."+master+".selected")) {
for (i=0; i<subitems.length; i++) {
lockoption(form, subitems[i]);
}
} else {
for (i=0; i<subitems.length; i++) {
unlockoption(form, subitems[i]);
}
}
return(true);
}
</script>
<form name="form" method="post" action="mod.php">
2001-11-22 06:23:56 +00:00
<table cellpadding="5">
2001-11-22 06:23:56 +00:00
<tr valign="top">
<td align="right"><strong><?php print_string("choicename","choice") ?>:</strong></td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<input type="text" name="name" size="30" alt="<?php print_string("choicename","choice") ?>" value="<?php p($form->name) ?>" />
2001-11-22 06:23:56 +00:00
</td>
</tr>
<tr valign="top">
<td align="right"><strong><?php print_string("choicetext","choice") ?>:</strong><br /><br />
<?php
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
echo "<br />";
helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
echo "<br />";
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
emoticonhelpbutton("form", "text");
}
echo "<br />";
?>
</td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<?php
print_textarea($usehtmleditor, 20, 60, 680, 400, "text", $form->text);
if ($usehtmleditor) {
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
} else {
echo "<div 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 "</div>";
}
?>
2001-11-22 06:23:56 +00:00
</td>
</tr>
<?php
$standardblanks = 10;
2005-03-30 18:47:57 +00:00
$count = 0;
2005-04-15 12:54:25 +00:00
$limitfieldlist = '';
2005-04-14 21:10:39 +00:00
if (($options = get_records_menu('choice_options','choiceid', $form->instance, 'id', 'id,text')) && ($options2 = get_records_menu('choice_options','choiceid', $form->instance, 'id', 'id,maxanswers')) ) {
foreach ($options as $id => $text) {
$count++;
?>
<tr valign=top>
<td align="right"><strong><?php echo get_string("choice","choice").' '.$count; ?>:</strong></td>
<td>
<input type="text" name="oldoption<?php p($id) ?>" size="60" value="<?php p($text) ?>" id="oldoption<?php p($id) ?>" />
<?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
</td>
2005-04-15 12:54:25 +00:00
<td align="right"><strong><?php p(get_string("limit","choice")) ?>:</strong>
2005-04-14 21:10:39 +00:00
<input type="text" name="oldlimit<?php p($id) ?>" size="4" value="<?php p($options2[$id]) ?>" id="oldlimit<?php p($id) ?>" />
<input type="hidden" name="holdlimit<?php p($id) ?>" value="0"/>
</td>
</tr>
<?php
2005-04-15 12:54:25 +00:00
$limitfieldlist .= "'oldlimit".$id."',";
}
$standardblanks = 2;
}
for ($i=1; $i<=$standardblanks; $i++) {
$count++;
?>
<tr valign=top>
<td align="right"><strong><?php echo get_string("choice","choice").' '.$count; ?>:</strong></td>
<td>
<input type="text" name="newoption<?php p($i) ?>" size="60" value="" id="newoption<?php p($i) ?>">
<?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
</td>
2005-04-15 12:54:25 +00:00
<td align="right"><strong><?php p(get_string("limit","choice")) ?>:</strong>
<input type="text" name="newlimit<?php p($i)?>" size="4" value="0" id="newlimit<?php p($i) ?>" />
2005-04-14 21:10:39 +00:00
<input type="hidden" name="hnewlimit<?php p($i) ?>" value="0" />
</td>
</tr>
<?php
2005-04-15 12:54:25 +00:00
$limitfieldlist .= "'newlimit".$i."',";
}
2005-04-20 20:59:20 +00:00
$limitfieldlist = trim($limitfieldlist, ",");
?>
2005-04-14 21:10:39 +00:00
<script type="text/javascript">
2005-04-15 12:54:25 +00:00
limititems = [<?php p($limitfieldlist); ?>];
2005-04-14 21:10:39 +00:00
</script>
<tr valign="top">
2005-04-15 12:54:25 +00:00
<td align="right" colspan="2"><strong><?php print_string("limitanswers", "choice") ?>:</strong></td>
<td align="right">
2005-04-14 21:10:39 +00:00
<?php
2005-04-15 12:54:25 +00:00
$menuoptions[0] = get_string("disable");
$menuoptions[1] = get_string("enable");
helpbutton("limit", get_string("limit", "choice"), "choice");
echo '&nbsp;';
2005-04-14 21:10:39 +00:00
choose_from_menu($menuoptions, "limitanswers", "$form->limitanswers", "", "return lockselects('form','limitanswers.options[0]', limititems)");
?>
</td>
</tr>
<?php if ($form->limitanswers == 0) { //lock the limit fields if limit isn't used. ?>
<script type="text/javascript">
lockoptions('form','limitanswers', limititems);
</script>
<?php }?>
<tr valign="top">
<td align="right"><strong><?php print_string("timerestrict", "choice") ?>:</strong></td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<script type="text/javascript">
var timeitems = ['openday','openmonth','openyear','openhour', 'openminute', 'closeday','closemonth','closeyear','closehour','closeminute'];
</script>
<input name="timerestrict" type="checkbox" value="1" alt="<?php print_string("timerestrict", "choice") ?>" onclick="return lockoptions('form','timerestrict', timeitems)" <?php if ($form->timerestrict) echo 'checked="checked"'; ?> />
<?php
helpbutton("timerestrict", get_string("timerestrict","choice"), "choice");
?>
</td>
</tr>
<tr valign="top">
2004-10-22 07:45:58 +00:00
<td>&nbsp;</td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<table>
<tr>
<td align="right"><strong><?php print_string("choiceopen", "choice") ?>:</strong></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);
?>
2004-09-12 22:23:51 +00:00
<input type="hidden" name="hopenday" value="0" />
<input type="hidden" name="hopenmonth" value="0" />
<input type="hidden" name="hopenyear" value="0" />
<input type="hidden" name="hopenhour" value="0" />
<input type="hidden" name="hopenminute" value="0" />
</td>
</tr>
<tr>
<td align="right"><strong><?php print_string("choiceclose", "choice") ?>:</strong></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);
?>
2004-09-12 22:23:51 +00:00
<input type="hidden" name="hcloseday" value="0" />
<input type="hidden" name="hclosemonth" value="0" />
<input type="hidden" name="hcloseyear" value="0" />
<input type="hidden" name="hclosehour" value="0" />
<input type="hidden" name="hcloseminute" value="0" />
<?php
if (! $form->timerestrict) {
echo "<script type=\"text/javascript\">";
echo "lockoptions('form','timerestrict', timeitems);";
echo "</script>\n";
}
?>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td align="right"><strong><?php print_string("displaymode","choice") ?>:</strong></td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<?php
require_once("$CFG->dirroot/mod/choice/lib.php");
choose_from_menu($CHOICE_DISPLAY, "display", "$form->display", "");
?>
<br />
</td>
</tr>
<tr valign="top">
<td align="right"><strong><?php print_string("publish","choice") ?>:</strong></td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<?php
require_once("$CFG->dirroot/mod/choice/lib.php");
2005-04-14 21:10:39 +00:00
choose_from_menu($CHOICE_RELEASE, "release", "$form->release", "", "return lockselects('form','release.options[0]',['publish'])");
?>
<br />
</td>
</tr>
<tr valign="top">
<td align="right"><strong><?php print_string("privacy","choice") ?>:</strong></td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<?php
require_once("$CFG->dirroot/mod/choice/lib.php");
choose_from_menu($CHOICE_PUBLISH, "publish", "$form->publish", "");
?>
<br />
<input type="hidden" name="hpublish" value="0" />
</td>
</tr>
2005-04-14 21:10:39 +00:00
<script type="text/javascript">
lockselects('form','release.options[0]',['publish']);
</script>
<tr valign="top">
<td align="right"><strong><?php print_string("allowupdate","choice") ?>:</strong></td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<?php
2005-04-01 03:30:12 +00:00
$menuoptions[0] = get_string("no");
$menuoptions[1] = get_string("yes");
choose_from_menu($menuoptions, "allowupdate", "$form->allowupdate", "");
?>
<br />
</td>
</tr>
<tr valign="top">
<td align="right"><strong><?php print_string("showunanswered","choice") ?>:</strong></td>
2005-04-15 12:54:25 +00:00
<td colspan="2">
<?php
2005-04-01 03:30:12 +00:00
$menuoptions[0] = get_string("no");
$menuoptions[1] = get_string("yes");
choose_from_menu($menuoptions, "showunanswered", "$form->showunanswered", "");
?>
<br />
</td>
</tr>
<?php print_standard_coursemodule_settings($form); ?>
2001-11-22 06:23:56 +00:00
</table>
<center>
2004-09-12 22:23:51 +00:00
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
2005-01-22 18:53:44 +00:00
<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
2004-09-12 22:23:51 +00:00
<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
2005-01-22 18:53:44 +00:00
<input type="hidden" name="section" value="<?php p($form->section) ?>" />
2004-09-12 22:23:51 +00:00
<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>