Skip to content
Browse files

standardized lock/unlock of dates (also name and feedbackurl); added …

…standard "Groups" and "Show" settings at end of form.
  • Loading branch information...
1 parent a8510c5 commit 25d13710edabc61b79f9f498e4da163fa78cd48f gbateson committed Oct 11, 2006
Showing with 25 additions and 49 deletions.
  1. +25 −49 mod/hotpot/mod.html
View
74 mod/hotpot/mod.html
@@ -22,38 +22,37 @@
?>
<script type="text/javascript" language="javascript">
<!--
- var textoffvalues = new Array(0,1,2);
- var namehideitems = new Array('nameSPAN');
- var summaryhideitems = new Array('summarySPAN','summaryhelpSPAN');
+ var nameoffvalues = new Array(0,1,2);
+ var namelockitems = new Array('name');
var timeoffvalues = new Array('0'); // needs to be '0', not just 0
- var timeopenhideitems = new Array('timeopenSPAN');
- var timeclosehideitems = new Array('timecloseSPAN');
var timeopenlockitems = new Array('openday','openmonth','openyear','openhour', 'openminute');
var timecloselockitems = new Array('closeday','closemonth','closeyear','closehour','closeminute');
var feedbackoffvalues = new Array(0,3,4,5);
- var feedbackhideitems = new Array('studentfeedbackurlSPAN');
+ var feedbacklockitems = new Array('studentfeedbackurl');
- function hotpot_showhide(form, master, subitems, offvalues) {
- var style_display = 'inline';
+ function hotpot_lockoptions(form, master, subitems, offvalues) {
+ var disabled = false;
var obj = eval("document."+form+"."+master);
if (obj) {
+ var v = '';
if (obj.type=='select-one') {
var v = obj.options[obj.selectedIndex].value;
for (i=0; i<offvalues.length; i++) {
if (v==offvalues[i]) {
- style_display = 'none';
+ disabled = true;
}
}
+ } else if (obj.type=='checkbox') {
+ if (obj.checked==false) {
+ disabled = true;
+ }
}
}
if (document.getElementById) {
for (i=0; i<subitems.length; i++) {
- var obj = document.getElementById(subitems[i]);
- if (obj) {
- obj.style.display = style_display;
- }
+ eval("document."+form+"."+subitems[i]+".disabled="+disabled);
}
}
return(true);
@@ -69,22 +68,19 @@
if ($form->mode=='add') {
choose_from_menu(
$text_source_options, "namesource", "$form->namesource", "",
- "return hotpot_showhide('form', 'namesource', namehideitems, textoffvalues)"
+ "return hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues)"
);
} else {
print '<input type="hidden" name="namesource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">';
}
- print '<span id="nameSPAN">';
print '<input type="text" name="name" size=40 value="'.$form->name.'">';
- print '</span>';
?></td>
</tr>
<tr valign="top">
<td align="right">
<b><?php
print_string("summary")
?>:</b><br />
- <span id="summaryhelpSPAN">
<font size="1"><?php
helpbutton("summary", get_string("summary"), "resource", true, true);
print '<br />';
@@ -97,7 +93,6 @@
helpbutton("text", get_string("helptext"), "moodle", true, true);
print '<br />';
emoticonhelpbutton("form", "description");
- print '<br />';
}
?></font>
</span>
@@ -107,19 +102,18 @@
choose_from_menu($text_source_options, "summarysource", "$form->summarysource", "");
//choose_from_menu(
// $text_source_options, "summarysource", "$form->summarysource", "",
- // "return hotpot_showhide('form', 'summarysource', summaryhideitems, textoffvalues)"
+ // "return hotpot_lockoptions('form', 'summarysource', summaryhideitems, nameoffvalues)"
//);
} else {
print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">';
}
- print '<span id="summarySPAN">';
+ print '<br />';
if (function_exists("print_textarea") && isset($usehtmleditor)) {
print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary);
} else {
// Moodle 1.1.1 (original size was rows="5" cols="50")
print '<textarea name="summary" rows="10" cols="65" wrap="virtual">'.$form->summary.'</textarea>';
}
- print '</span>';
?></td>
</tr>
<tr valign="top">
@@ -128,20 +122,10 @@
if (!$form->timeopen && $course->format == "weeks") {
$form->timeopen = $course->startdate + (($form->section - 1) * 608400);
}
- //print '<input name="enabletimeopen" type="checkbox" value="1" alt="'.get_string("quizopen", "quiz").'" onclick="'."return lockoptions('form', 'enabletimeopen', timeopenlockitems)".'" '.(empty($form->timeopen) ? '' : 'checked="checked"').' />';
- $options = array(
- HOTPOT_NO => get_string("alwaysopen", "hotpot"),
- HOTPOT_YES => get_string("specifictime", "hotpot")
- );
- choose_from_menu(
- $options, "enabletimeopen", "$form->enabletimeopen", "",
- "return hotpot_showhide('form', 'enabletimeopen', timeopenhideitems, timeoffvalues)"
- );
- print '<span id="timeopenSPAN"> &nbsp; ';
+ print '<input name="enabletimeopen" type="checkbox" value="1" alt="'.get_string("quizopen", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems)".'" '.(empty($form->timeopen) ? '' : 'checked="checked"').' />';
print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
print ' - ';
print_time_selector("openhour", "openminute", $form->timeopen);
- print '</span>';
helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
?></td>
</tr>
@@ -151,20 +135,10 @@
if (!$form->timeclose && $course->format == "weeks") {
$form->timeclose= $course->startdate + (($form->section) * 608400);
}
- //print '<input name="enabletimeclose" type="checkbox" value="1" alt="'.get_string("quizclose", "quiz").'" onclick="'."return lockoptions('form', 'enabletimeclose', timecloselockitems)".'" '.(empty($form->timeclose) ? '' : 'checked="checked"').' />';
- $options = array(
- HOTPOT_NO => get_string("neverclosed", "hotpot"),
- HOTPOT_YES => get_string("specifictime", "hotpot")
- );
- choose_from_menu(
- $options, "enabletimeclose", "$form->enabletimeclose", "",
- "return hotpot_showhide('form', 'enabletimeclose', timeclosehideitems, timeoffvalues)"
- );
- print '<span id="timecloseSPAN"> &nbsp; ';
+ print '<input name="enabletimeclose" type="checkbox" value="1" alt="'.get_string("quizclose", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems)".'" '.(empty($form->timeclose) ? '' : 'checked="checked"').' />';
print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
print ' - ';
print_time_selector("closehour", "closeminute", $form->timeclose);
- print '</span>';
helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
?></td>
</tr>
@@ -270,7 +244,7 @@
<td align="left"><?php
choose_from_menu(
$HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", "",
- "return hotpot_showhide('form', 'studentfeedback', feedbackhideitems, feedbackoffvalues)"
+ "return hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues)"
);
print '<span id="studentfeedbackurlSPAN">';
print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">";
@@ -354,6 +328,9 @@
helpbutton("clickreporting", get_string("clickreporting","hotpot"), "hotpot");
?></td>
</tr>
+<?php
+ print_standard_coursemodule_settings($form);
+?>
<tr valign="top">
<td align="right">&nbsp;</td>
<td align="left">
@@ -390,11 +367,10 @@
</center>
<script type="text/javascript">
<!--
- hotpot_showhide('form', 'namesource', namehideitems, textoffvalues);
- // hotpot_showhide('form', 'summarysource', summaryhideitems, textoffvalues);
- hotpot_showhide('form', 'enabletimeopen', timeopenhideitems, timeoffvalues);
- hotpot_showhide('form', 'enabletimeclose', timeclosehideitems, timeoffvalues);
- hotpot_showhide('form', 'studentfeedback', feedbackhideitems, feedbackoffvalues);
+ hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues);
+ hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems, timeoffvalues);
+ hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems, timeoffvalues);
+ hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues);
// override the standard Moodle "setfocus" function,
// which gives a js error if the "name" field is hidden

0 comments on commit 25d1371

Please sign in to comment.
Something went wrong with that request. Please try again.