mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
simplified the javascript to hide "name", "studentfeedbackurl" and dates when not required
This commit is contained in:
parent
dd00dbd799
commit
c0e19266db
@ -1,10 +1,9 @@
|
||||
<!-- 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. -->
|
||||
|
||||
<?PHP
|
||||
<?php
|
||||
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
require_once("$CFG->dirroot{$ds}mod{$ds}hotpot{$ds}lib.php");
|
||||
require_once("$CFG->dirroot/mod/hotpot/lib.php");
|
||||
|
||||
// set default values in form fields, if necessary
|
||||
set_form_fields($form);
|
||||
@ -21,28 +20,72 @@ $text_source_options = array(
|
||||
HOTPOT_TEXTSOURCE_SPECIFIC => get_string("textsourcespecific", "hotpot")
|
||||
);
|
||||
?>
|
||||
<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 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');
|
||||
|
||||
function hotpot_showhide(form, master, subitems, offvalues) {
|
||||
var style_display = 'inline';
|
||||
var obj = eval("document."+form+"."+master);
|
||||
if (obj) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (document.getElementById) {
|
||||
for (i=0; i<subitems.length; i++) {
|
||||
var obj = document.getElementById(subitems[i]);
|
||||
if (obj) {
|
||||
obj.style.display = style_display;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<center>
|
||||
<form name="form" method="post" action="mod.php">
|
||||
<table cellpadding="5">
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("name") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("name") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
if ($form->mode=='add') {
|
||||
choose_from_menu($text_source_options, "namesource", "$form->namesource", "");
|
||||
choose_from_menu(
|
||||
$text_source_options, "namesource", "$form->namesource", "",
|
||||
"return hotpot_showhide('form', 'namesource', namehideitems, textoffvalues)"
|
||||
);
|
||||
} else {
|
||||
print '<input type="hidden" name="namesource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">';
|
||||
}
|
||||
print '<span id="nameSPAN">';
|
||||
print '<span id="nameSPAN">';
|
||||
print '<input type="text" name="name" size=40 value="'.$form->name.'">';
|
||||
print '</span>';
|
||||
print '</span>';
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<b><?PHP
|
||||
<b><?php
|
||||
print_string("summary")
|
||||
?>:</b><br />
|
||||
<FONT size="1"><?PHP
|
||||
<span id="summaryhelpSPAN">
|
||||
<font size="1"><?php
|
||||
helpbutton("summary", get_string("summary"), "resource", true, true);
|
||||
print '<br />';
|
||||
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
|
||||
@ -56,69 +99,80 @@ $text_source_options = array(
|
||||
emoticonhelpbutton("form", "description");
|
||||
print '<br />';
|
||||
}
|
||||
?></FONT>
|
||||
?></font>
|
||||
</span>
|
||||
</td>
|
||||
<td align="left"><?PHP
|
||||
<td align="left"><?php
|
||||
if ($form->mode=='add') {
|
||||
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)"
|
||||
//);
|
||||
} else {
|
||||
print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">';
|
||||
}
|
||||
print '<span id="summarySPAN">';
|
||||
print '<span id="summarySPAN">';
|
||||
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>';
|
||||
print '</span>';
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("quizopen", "quiz") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
$options = array(
|
||||
HOTPOT_NO => get_string("alwaysopen", "hotpot"),
|
||||
HOTPOT_YES => get_string("specifictime", "hotpot")
|
||||
);
|
||||
choose_from_menu($options, "enabletimeopen", "$form->enabletimeopen", "");
|
||||
print '<span id="timeopenSPAN">';
|
||||
print ' ';
|
||||
<td align="right"><b><?php print_string("quizopen", "quiz") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
if (!$form->timeopen && $course->format == "weeks") {
|
||||
$form->timeopen= $course->startdate + (($form->section - 1) * 608400);
|
||||
$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"> ';
|
||||
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");
|
||||
print '</span>';
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("quizclose", "quiz") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
$options = array(
|
||||
HOTPOT_NO => get_string("neverclosed", "hotpot"),
|
||||
HOTPOT_YES => get_string("specifictime", "hotpot")
|
||||
);
|
||||
choose_from_menu($options, "enabletimeclose", "$form->enabletimeclose", "");
|
||||
print '<span id="timecloseSPAN">';
|
||||
print ' ';
|
||||
<td align="right"><b><?php print_string("quizclose", "quiz") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
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"> ';
|
||||
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");
|
||||
print '</span>';
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap>
|
||||
<b><?PHP print get_string("location","hotpot") ?>:</b>
|
||||
<b><?php print get_string("location","hotpot") ?>:</b>
|
||||
</td>
|
||||
<td align="left"><?PHP
|
||||
<td align="left"><?php
|
||||
|
||||
if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
$site = get_site();
|
||||
@ -164,9 +218,9 @@ $text_source_options = array(
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap>
|
||||
<b><?PHP print_string("filename", "resource") ?>:</b>
|
||||
<b><?php print_string("filename", "resource") ?>:</b>
|
||||
</td>
|
||||
<td align="left"><?PHP
|
||||
<td align="left"><?php
|
||||
if (function_exists("button_to_popup_window")) {
|
||||
print '<input name="reference" size="50" value="'.$form->reference.'"> ';
|
||||
|
||||
@ -188,61 +242,66 @@ $text_source_options = array(
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP
|
||||
<td align="right"><b><?php
|
||||
$quizchain = "{$form->mode}quizchain";
|
||||
print_string($quizchain, "hotpot");
|
||||
?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="left"><?php
|
||||
choose_from_menu($yes_no_options, "quizchain", $form->quizchain, "");
|
||||
helpbutton($quizchain, get_string($quizchain,"hotpot"), "hotpot");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("outputformat", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("outputformat", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu($HOTPOT_OUTPUTFORMAT, "outputformat", "$form->outputformat", "");
|
||||
helpbutton("outputformat", get_string("outputformat","hotpot"), "hotpot");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("navigation", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("navigation", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu($HOTPOT_NAVIGATION, "navigation", "$form->navigation", "");
|
||||
helpbutton("navigation", get_string("navigation","hotpot"), "hotpot");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("studentfeedback", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
choose_from_menu($HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", "");
|
||||
<td align="right"><b><?php print_string("studentfeedback", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu(
|
||||
$HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", "",
|
||||
"return hotpot_showhide('form', 'studentfeedback', feedbackhideitems, feedbackoffvalues)"
|
||||
);
|
||||
print '<span id="studentfeedbackurlSPAN">';
|
||||
print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">";
|
||||
print '</span>';
|
||||
helpbutton("studentfeedback", get_string("studentfeedback","hotpot"), "hotpot");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("forceplugins", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("forceplugins", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu($yes_no_options, "forceplugins", "$form->forceplugins", "");
|
||||
helpbutton("forceplugins", get_string("forceplugins","hotpot"), "hotpot");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("shownextquiz", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("shownextquiz", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu($yes_no_options, "shownextquiz", "$form->shownextquiz", "");
|
||||
helpbutton("shownextquiz", get_string("shownextquiz","hotpot"), "hotpot");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("allowreview", "quiz") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu($yes_no_options, "review", "$form->review", "");
|
||||
helpbutton("review", get_string("allowreview","quiz"), "quiz");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("maximumgrade") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
$options = array();
|
||||
for ($i=100; $i>=1; $i--) {
|
||||
$options[$i] = $i;
|
||||
@ -254,15 +313,15 @@ $text_source_options = array(
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("grademethod", "quiz") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu($HOTPOT_GRADEMETHOD, "grademethod", "$form->grademethod", "");
|
||||
helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("attemptsallowed", "quiz") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
$options = array(
|
||||
0 => get_string("attemptsunlimited", "quiz"),
|
||||
1 => '1 '.strtolower(get_string("attempt", "quiz"))
|
||||
@ -275,22 +334,22 @@ $text_source_options = array(
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("requirepassword", "quiz") ?>:</b></td>
|
||||
<td align="right"><b><?php print_string("requirepassword", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="password" size=40 value="<?PHP p($form->password) ?>">
|
||||
<?PHP helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
|
||||
<input type="text" name="password" size=40 value="<?php p($form->password) ?>">
|
||||
<?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("requiresubnet", "quiz") ?>:</b></td>
|
||||
<td align="right"><b><?php print_string("requiresubnet", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<input type="text" name="subnet" size=40 value="<?PHP p($form->subnet) ?>">
|
||||
<?PHP helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
|
||||
<input type="text" name="subnet" size=40 value="<?php p($form->subnet) ?>">
|
||||
<?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?PHP print_string("clickreporting", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?PHP
|
||||
<td align="right"><b><?php print_string("clickreporting", "hotpot") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu($yes_no_options, "clickreporting", "$form->clickreporting", "");
|
||||
helpbutton("clickreporting", get_string("clickreporting","hotpot"), "hotpot");
|
||||
?></td>
|
||||
@ -299,9 +358,9 @@ $text_source_options = array(
|
||||
<td align="right"> </td>
|
||||
<td align="left">
|
||||
<!-- buttons -->
|
||||
<input type="submit" value="<?PHP print_string("savechanges") ?>">
|
||||
<input type="submit" name="cancel" value="<?PHP print_string("cancel") ?>" /><br />
|
||||
<?PHP
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>">
|
||||
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" /><br />
|
||||
<?php
|
||||
if (isset($CFG->release) && substr($CFG->release, 0, 3)>=1.5) {
|
||||
$options = array(
|
||||
HOTPOT_DISPLAYNEXT_QUIZ => get_string("displayhotpotnext", "hotpot"),
|
||||
@ -316,96 +375,46 @@ $text_source_options = array(
|
||||
</table>
|
||||
|
||||
<!-- hidden fields -->
|
||||
<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) ?>">
|
||||
<?PHP if (isset($USER->sesskey)) { ?>
|
||||
<input type="hidden" name="sesskey" value="<?PHP p($USER->sesskey) ?>">
|
||||
<?PHP } ?>
|
||||
<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) ?>">
|
||||
<?php if (isset($USER->sesskey)) { ?>
|
||||
<input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>">
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function hpShowHideStudentFeedbackUrl() {
|
||||
var frm = document.forms['form'];
|
||||
if (frm) {
|
||||
var obj = frm.elements['studentfeedback'];
|
||||
var url = frm.elements['studentfeedbackurl'];
|
||||
if (obj && obj.type=='select-one' && url && url.style) {
|
||||
if (obj.onchange==null) {
|
||||
obj.onchange = hpShowHideStudentFeedbackUrl;
|
||||
}
|
||||
var v = obj.options[obj.selectedIndex].value;
|
||||
url.style.display = (v==1 || v==2) ? 'inline' : 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
hpShowHideStudentFeedbackUrl();
|
||||
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);
|
||||
|
||||
function hpShowHideTime(s) {
|
||||
var frm = document.forms['form'];
|
||||
if (frm) {
|
||||
var obj = frm.elements['enabletime'+s];
|
||||
if (obj && obj.type=='select-one' && document.getElementById) {
|
||||
if (obj.onchange==null) {
|
||||
obj.onchange = new Function("hpShowHideTime('"+s+"')");
|
||||
}
|
||||
var v = obj.options[obj.selectedIndex].value;
|
||||
var obj = document.getElementById('time'+s+'SPAN');
|
||||
if (obj && obj.style) {
|
||||
obj.style.display = (v==0) ? 'none' : 'inline';
|
||||
}
|
||||
}
|
||||
}
|
||||
// override the standard Moodle "setfocus" function,
|
||||
// which gives a js error if the "name" field is hidden
|
||||
function setfocus() {
|
||||
var f = document.form;
|
||||
if (f) {
|
||||
if (canfocus(f, 'namesource')) {
|
||||
f.namesource.focus();
|
||||
} else if (canfocus(f, 'name')) {
|
||||
f.name.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
hpShowHideTime('open');
|
||||
hpShowHideTime('close');
|
||||
|
||||
function hpShowHideTextSource(s) {
|
||||
var frm = document.forms['form'];
|
||||
if (frm) {
|
||||
var obj = frm.elements[s+'source'];
|
||||
if (obj && obj.type=='select-one' && document.getElementById) {
|
||||
if (obj.onchange==null) {
|
||||
obj.onchange = new Function("hpShowHideTextSource('"+s+"')");
|
||||
}
|
||||
var v = obj.options[obj.selectedIndex].value;
|
||||
var obj = document.getElementById(s+'SPAN');
|
||||
if (obj && obj.style) {
|
||||
obj.style.display = (v==0 || v==1 || v==2) ? 'none' : 'inline';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
function canfocus(f, name) {
|
||||
var obj = eval('f.'+name);
|
||||
return (obj==null || obj.type=='hidden' || obj.focus==null || (obj.style && obj.style.display=='none')) ? false : true;
|
||||
}
|
||||
hpShowHideTextSource('name');
|
||||
//hpShowHideTextSource('summary');
|
||||
|
||||
// override the standard Moodle "setfocus" function,
|
||||
// which gives a js error if the "name" field is hidden
|
||||
function setfocus() {
|
||||
var f = document.form;
|
||||
if (f) {
|
||||
if (canfocus(f, 'namesource')) {
|
||||
f.namesource.focus();
|
||||
} else if (canfocus(f, 'name')) {
|
||||
f.name.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
function canfocus(f, name) {
|
||||
var obj = eval('f.'+name);
|
||||
return (obj==null || obj.type=='hidden' || obj.focus==null || (obj.style && obj.style.display=='none')) ? false : true;
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<?PHP
|
||||
<?php
|
||||
|
||||
// ======================
|
||||
// functions
|
||||
@ -448,5 +457,4 @@ function set_form_field(&$form, $fieldname, $defaultvalue='') {
|
||||
$form->$fieldname = $defaultvalue;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user