moodle/mod/hotpot/mod.html

453 lines
20 KiB
HTML

<!-- 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
$ds = DIRECTORY_SEPARATOR;
require_once("$CFG->dirroot{$ds}mod{$ds}hotpot{$ds}lib.php");
// set default values in form fields, if necessary
set_form_fields($form);
// commonly used array of <select> options
$yes_no_options = array(
HOTPOT_NO => get_string("no"),
HOTPOT_YES => get_string("yes")
);
$text_source_options = array(
HOTPOT_TEXTSOURCE_QUIZ => get_string("textsourcequiz", "hotpot"),
HOTPOT_TEXTSOURCE_FILENAME => get_string("textsourcefilename", "hotpot"),
HOTPOT_TEXTSOURCE_FILEPATH => get_string("textsourcefilepath", "hotpot"),
HOTPOT_TEXTSOURCE_SPECIFIC => get_string("textsourcespecific", "hotpot")
);
?>
<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
if ($form->mode=='add') {
choose_from_menu($text_source_options, "namesource", "$form->namesource", "");
} 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 />
<FONT size="1"><?PHP
helpbutton("summary", get_string("summary"), "resource", true, true);
print '<br />';
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
print '<br />';
if (isset($usehtmleditor) && $usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
print '<br />';
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
print '<br />';
emoticonhelpbutton("form", "description");
print '<br />';
}
?></FONT>
</td>
<td align="left"><?PHP
if ($form->mode=='add') {
choose_from_menu($text_source_options, "summarysource", "$form->summarysource", "");
} else {
print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">';
}
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>';
?></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 ' &nbsp; ';
if (!$form->timeopen && $course->format == "weeks") {
$form->timeopen= $course->startdate + (($form->section - 1) * 608400);
}
print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
print ' - ';
print_time_selector("openhour", "openminute", $form->timeopen);
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 ' &nbsp; ';
if (!$form->timeclose && $course->format == "weeks") {
$form->timeclose= $course->startdate + (($form->section) * 608400);
}
print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
print ' - ';
print_time_selector("closehour", "closeminute", $form->timeclose);
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>
</td>
<td align="left"><?PHP
if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
$site = get_site();
if ($course->id==$site->id) {
$id = $site->id;
$location = HOTPOT_LOCATION_SITEFILES;
} else {
$id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES."?".$site->id.":".$course->id.")+'";
$location = '';
}
} else { // ordinary teacher or content creator
$id = $course->id;
$location = HOTPOT_LOCATION_COURSEFILES;
}
if (array_key_exists($location, $HOTPOT_LOCATION)) {
print '<input type="hidden" name="location" value="'.$location.'" />';
print '<i><font size="-1">'.$HOTPOT_LOCATION[$location].'</font></i> &nbsp; ';
} else { // admin can select from "site" or "course" files
choose_from_menu($HOTPOT_LOCATION, "location", "$form->location", "");
}
if (function_exists("button_to_popup_window")) {
// use javascript to extract wdir from the reference field
$wdir = "'+getDir(getObjValue(this.form.reference))+'";
// set button url depending on Moodle version
if ($CFG->version < 2004083125) { // version may need refining
// up to and including Moodle 1.4.1
$url = "/mod/resource/coursefiles.php?id=$id&wdir=$wdir";
} else {
// Moodle 1.4.2 and beyond
$url = "/files/index.php?id=$id&wdir=$wdir&choose=form.reference";
}
$strchooseafile = get_string("chooseafile", "resource");
button_to_popup_window ($url, 'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
}
?></td>
</tr>
<tr valign="top">
<td align="right" nowrap>
<b><?PHP print_string("filename", "resource") ?>:</b>
</td>
<td align="left"><?PHP
if (function_exists("button_to_popup_window")) {
print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
} else if (function_exists("get_directory_list")) {
// Moodle 1.1 (and perhaps some others)
$dirs = get_directory_list("$CFG->dataroot/$course->id");
$options = array();
foreach ($dirs as $dir) {
$options["$dir"] = $dir;
}
choose_from_menu ($options, "reference", $form->reference);
} else {
// a very old Moodle (may be none left :-)
print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
}
print '<br />';
hotpot_print_show_links($form->course, $form->location, $form->reference, '', ' &nbsp; ', true);
?></td>
</tr>
<tr valign="top">
<td align="right"><b><?PHP
$quizchain = "{$form->mode}quizchain";
print_string($quizchain, "hotpot");
?>:</b></td>
<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
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
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", "");
print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">";
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
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
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
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
$options = array();
for ($i=100; $i>=1; $i--) {
$options[$i] = $i;
}
$options[0] = get_string("nograde");
choose_from_menu($options, "grade", "$form->grade", "");
helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
?></td>
</tr>
<tr valign="top">
<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
$options = array(
0 => get_string("attemptsunlimited", "quiz"),
1 => '1 '.strtolower(get_string("attempt", "quiz"))
);
for ($i=2; $i<=10; $i++) {
$options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
}
choose_from_menu($options, "attempts", "$form->attempts", "");
helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
?></td>
</tr>
<tr valign="top">
<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"); ?>
</td>
</tr>
<tr valign="top">
<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"); ?>
</td>
</tr>
<tr valign="top">
<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>
</tr>
<tr valign="top">
<td align="right">&nbsp;</td>
<td align="left">
<!-- buttons -->
<input type="submit" value="<?PHP print_string("savechanges") ?>"> &nbsp; &nbsp;
<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"),
HOTPOT_DISPLAYNEXT_COURSE => get_string("displaycoursenext", "hotpot"),
HOTPOT_DISPLAYNEXT_INDEX => get_string("displayindexnext", "hotpot")
);
choose_from_menu($options, "displaynext", "$form->displaynext", "");
} else {
print '<input type="hidden" name="displaynext" value="'.HOTPOT_NO.'">'."\n";
}
?>
</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 } ?>
</form>
</center>
<script type="text/javascript" language="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();
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';
}
}
}
}
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;
}
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
// ======================
// functions
// ======================
function set_form_fields(&$form) {
set_form_field($form, 'name');
set_form_field($form, 'summary');
set_form_field($form, 'timeopen', get_user_preferences('hotpot_timeopen', 0));
set_form_field($form, 'enabletimeopen', empty($form->timeopen) ? HOTPOT_NO : HOTPOT_YES);
set_form_field($form, 'timeclose', get_user_preferences('hotpot_timeclose', 0));
set_form_field($form, 'enabletimeclose', empty($form->timeclose) ? HOTPOT_NO : HOTPOT_YES);
set_form_field($form, 'location', HOTPOT_LOCATION_COURSEFILES);
set_form_field($form, 'reference');
set_form_field($form, 'navigation', get_user_preferences('hotpot_navigation', HOTPOT_NAVIGATION_BAR));
set_form_field($form, 'outputformat', get_user_preferences('hotpot_outputformat', HOTPOT_OUTPUTFORMAT_BEST));
set_form_field($form, 'studentfeedback', get_user_preferences('hotpot_studentfeedback', HOTPOT_FEEDBACK_NONE));
set_form_field($form, 'studentfeedbackurl', get_user_preferences('hotpot_studentfeedbackurl', 'http://'));
set_form_field($form, 'forceplugins', get_user_preferences('hotpot_forceplugins', HOTPOT_NO));
if ($form->mode=='add') {
set_form_field($form, 'namesource', get_user_preferences('hotpot_namesource', HOTPOT_TEXTSOURCE_QUIZ));
set_form_field($form, 'summarysource', get_user_preferences('hotpot_summarysource', HOTPOT_TEXTSOURCE_QUIZ));
$quizchain = get_user_preferences('hotpot_quizchain', HOTPOT_NO);
} else {
$quizchain = empty($form->quizchain) ? HOTPOT_NO : HOTPOT_YES;
}
set_form_field($form, 'quizchain', $quizchain);
set_form_field($form, 'shownextquiz', get_user_preferences('hotpot_shownextquiz', HOTPOT_NO));
set_form_field($form, 'review', get_user_preferences('hotpot_review', HOTPOT_YES));
set_form_field($form, 'grade', get_user_preferences('hotpot_grade', 100));
set_form_field($form, 'grademethod', get_user_preferences('hotpot_grademethod', HOTPOT_GRADEMETHOD_HIGHEST));
set_form_field($form, 'attempts', get_user_preferences('hotpot_attempts', 0)); // 0=unlimited
set_form_field($form, 'password');
set_form_field($form, 'subnet', get_user_preferences('hotpot_subnet'));
set_form_field($form, 'clickreporting', HOTPOT_NO);
set_form_field($form, 'displaynext', get_user_preferences('hotpot_displaynext', HOTPOT_DISPLAYNEXT_QUIZ));
}
function set_form_field(&$form, $fieldname, $defaultvalue='') {
if (!isset($form->$fieldname)) {
$form->$fieldname = $defaultvalue;
}
}
?>