Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

644 lines (593 sloc) 21.554 kb
<!-- define a new instance of lesson -->
<!-- It is used from /course/mod.php. The whole instance is available as $form. -->
<?php
require("$CFG->dirroot/mod/lesson/locallib.php"); // for parameter array
if ($form->mode == "add") {
if ($defaults = get_record("lesson_default", "course", $form->course)) {
foreach ($defaults as $name => $value) {
if (!is_numeric($name)) {
$form->$name = $value;
}
}
}
}
// set the defaults
if (empty($form->name)) {
$form->name = "";
}
if (!isset($form->grade)) {
$form->grade = 0;
}
if (!isset($form->usemaxgrade)) {
$form->usemaxgrade = 0;
}
if (!isset($form->maxanswers)) {
$form->maxanswers = 4;
}
if (!isset($form->maxattempts)) {
$form->maxattempts = 1;
}
if (!isset($form->nextpagedefault)) {
$form->nextpagedefault = 0;
}
if (!isset($form->minquestions)) {
$form->minquestions = 0;
}
if (!isset($form->maxpages)) {
$form->maxpages = 0;
}
if (!isset($form->retake)) {
$form->retake = 0;
}
if (!isset($form->available)) {
$form->available = 0;
}
if (!isset($form->deadline)) {
$currentdate = usergetdate(time());
$form->deadline = gmmktime($currentdate["hours"], $currentdate["minutes"], $currentdate["seconds"], $currentdate["mon"]+1, $currentdate["mday"], $currentdate["year"]);
}
if (!isset($form->usepassword)) {
$form->usepassword = 0;
}
if (!isset($form->custom)) {
$form->custom = 1;
}
if (!isset($form->ongoing)) {
$form->ongoing = 0;
}
if (!isset($form->timed)) {
$form->timed = 0;
}
if (!isset($form->maxtime)) {
$form->maxtime = 20;
}
if (!isset($form->slideshow)) {
$form->slideshow = 0;
}
if (!isset($form->width)) {
$form->width = 640;
}
if (!isset($form->height)) {
$form->height = 400;
}
if (!isset($form->bgcolor)) {
$form->bgcolor = "#FFFFFF";
}
if (!isset($form->displayleft)) {
$form->displayleft = 0;
}
if (!isset($form->displayleftif)) {
$form->displayleftif = 0;
}
if (!isset($form->progressbar)) {
$form->progressbar = 0;
}
if (!isset($form->highscores)) {
$form->highscores = 0;
}
if (!isset($form->maxhighscores)) {
$form->maxhighscores = 10;
}
if (!isset($form->practice)) {
$form->practice = 0;
}
if (!isset($form->review)) {
$form->review = 0;
}
if (!isset($form->lessondefault)) {
$form->lessondefault = 0;
}
if (!isset($form->modattempts)) {
$form->modattempts = 0;
}
if (!isset($form->mediafile)) {
$form->mediafile = '';
}
if (!isset($form->mediaheight)) {
$form->mediaheight = 100;
}
if (!isset($form->mediawidth)) {
$form->mediawidth = 650;
}
if (!isset($form->mediaclose)) {
$form->mediaclose = 0;
}
if (!isset($form->dependency)) {
$form->dependency = 0;
}
if (!isset($form->conditions)) {
$form->timespent = 0;
$form->completed = 0;
$form->gradebetterthan = 0;
} else {
$conditions = unserialize($form->conditions);
$form->timespent = $conditions->timespent;
$form->completed = $conditions->completed;
$form->gradebetterthan = $conditions->gradebetterthan;
}
if (!isset($form->activitylink)) {
$form->activitylink = 0;
}
$form->deleteattempts = "";
?>
<div class="mod-lesson">
<form name="form" method="post" action="mod.php">
<center>
<table cellpadding="5">
<tr>
<td>
<?php print_heading(get_string("general", "lesson"), "left", 4); ?>
</td><td></td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("name") ?>:</b></td>
<td>
<!-- hidden label added. --><label for="name" class="hidden-label">Name</label><input type="text" id="name" name="name" size="30" value="<?php p($form->name) ?>" />
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("timed", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "timed", $form->timed, "");
helpbutton("timed", get_string("timed", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("maxtime", "lesson"); ?>:</b></td>
<td>
<input type="text" name="maxtime" maxlength="7" size="7" value="<?php p($form->maxtime) ?>" />
<?php helpbutton("maxtime", get_string("maxtime", "lesson"), "lesson"); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("maximumnumberofanswersbranches", "lesson") ?>:</b></td>
<td>
<?php
$numbers = array();
for ($i=20; $i>1; $i--) {
$numbers[$i] = $i;
}
choose_from_menu($numbers, "maxanswers", "$form->maxanswers", "");
helpbutton("maxanswers", get_string("maximumnumberofanswersbranches", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td>
<br/><?php print_heading(get_string("gradeoptions", "lesson"), "left", 4); ?>
</td><td></td>
</tr>
<tr>
<td align="right"><b><?php print_string("practice", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "practice", $form->practice, "");
helpbutton("practice", get_string("practice", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("customscoring", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "custom", $form->custom, "");
helpbutton("custom", get_string("customscoring", "lesson"), "lesson");
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
<td>
<?php
$grades = array();
for ($i=100; $i>=0; $i--) {
$grades[$i] = $i;
}
choose_from_menu($grades, "grade", "$form->grade", "");
helpbutton("grade", get_string("maximumgrade", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("canretake", "lesson", $course->student) ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "retake", $form->retake, "");
helpbutton("retake", get_string("canretake", "lesson", $course->student), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("handlingofretakes", "lesson") ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("usemean", "lesson"); $options[1] = get_string("usemaximum", "lesson");
choose_from_menu($options, "usemaxgrade", $form->usemaxgrade, "");
helpbutton("handlingofretakes", get_string("handlingofretakes", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("ongoing", "lesson"); ?>:</b></td>
<td>
<?php
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "ongoing", $form->ongoing, "");
helpbutton("ongoing", get_string("ongoing", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td>
<br/><?php print_heading(get_string("flowcontrol", "lesson"), "left", 4); ?>
</td><td></td>
</tr>
<tr>
<td align="right"><b><?php print_string("modattempts", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "modattempts", $form->modattempts, "");
helpbutton("modattempts", get_string("modattempts", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("displayreview", "lesson"); ?>:</b></td>
<td>
<?php
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "review", $form->review, "");
helpbutton("review", get_string("displayreview", "lesson"), "lesson");
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("maximumnumberofattempts", "lesson") ?>:</b></td>
<td>
<?php
$numbers = array();
for ($i=10; $i>0; $i--) {
$numbers[$i] = $i;
}
choose_from_menu($numbers, "maxattempts", "$form->maxattempts", "");
helpbutton("maxattempts", get_string("maximumnumberofattempts", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("actionaftercorrectanswer", "lesson") ?>:</b></td>
<td>
<?php
choose_from_menu($LESSON_NEXTPAGE_ACTION, "nextpagedefault", $form->nextpagedefault, "");
helpbutton("nextpageaction", get_string("actionaftercorrectanswer", "lesson"), "lesson");
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("minimumnumberofquestions", "lesson") ?>:</b></td>
<td>
<?php
$numbers = array();
for ($i=100; $i>=0; $i--) {
$numbers[$i] = $i;
}
choose_from_menu($numbers, "minquestions", "$form->minquestions", "");
helpbutton("minquestions", get_string("minimumnumberofquestions", "lesson"), "lesson");
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("numberofpagestoshow", "lesson") ?>:</b></td>
<td>
<?php
$numbers = array();
for ($i=100; $i>=0; $i--) {
$numbers[$i] = $i;
}
choose_from_menu($numbers, "maxpages", "$form->maxpages", "");
helpbutton("maxpages", get_string("numberofpagestoshow", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td>
<br/><?php print_heading(get_string("lessonformating", "lesson"), "left", 4); ?>
</td><td></td>
</tr>
<tr>
<td align="right"><b><?php print_string("slideshow", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "slideshow", $form->slideshow, "");
helpbutton("slideshow", get_string("slideshow", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("slideshowwidth", "lesson"); ?>:</b></td>
<td>
<input type="text" name="width" maxlength="7" size="7" value="<?php p($form->width) ?>" />px
<?php helpbutton("width", get_string("slideshowwidth", "lesson"), "lesson"); ?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("slideshowheight", "lesson"); ?>:</b></td>
<td>
<input type="text" name="height" maxlength="7" size="7" value="<?php p($form->height) ?>" />px
<?php helpbutton("height", get_string("slideshowheight", "lesson"), "lesson"); ?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("slideshowbgcolor", "lesson"); ?>:</b></td>
<td>
<input type="text" name="bgcolor" maxlength="7" size="7" value="<?php p($form->bgcolor) ?>" />
<?php helpbutton("bgcolor", get_string("slideshowbgcolor", "lesson"), "lesson"); ?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("displayleftmenu", "lesson"); ?>:</b></td>
<td>
<?php
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "displayleft", $form->displayleft, "");
echo ' ';
print_string("displayleftif", "lesson", $course->student);
$options = array();
for($i = 100; $i >= 0; $i--) {
$options[$i] = $i.'%';
}
choose_from_menu($options, "displayleftif", $form->displayleftif, "");
helpbutton("displayleft", get_string("displayleftmenu", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("progressbar", "lesson"); ?>:</b></td>
<td>
<?php
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "progressbar", $form->progressbar, "");
helpbutton("progressbar", get_string("progressbar", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td>
<br/><?php print_heading(get_string("accesscontrol", "lesson"), "left", 4); ?>
</td><td></td>
</tr>
<tr>
<td align="right"><b><?php print_string("usepassword", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "usepassword", $form->usepassword, "");
helpbutton("usepassword", get_string("usepassword", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("password", "lesson"); ?>:</b></td>
<td>
<input type="text" name="password" size="7" value="" /> <?php echo " (".get_string("leavetokeep").")"; ?>
<?php helpbutton("password", get_string("password", "lesson"), "lesson"); ?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("dependencyon", "lesson"); ?>:</b></td>
<td>
<?php
$options = array();
$options[0] = get_string("none");
if (empty($form->instance)) {
$select = "course = $course->id";
} else {
$select = "course = $course->id AND id != $form->instance";
}
if ($lessons = get_records_select('lesson', $select, 'name ASC')) {
foreach($lessons as $lesson) {
$options[$lesson->id] = $lesson->name;
}
}
choose_from_menu($options, "dependency", $form->dependency, "");
?>
<?php helpbutton("dependency", get_string("dependency", "lesson"), "lesson"); ?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("conditionsfordependency", "lesson"); ?>:</b></td>
<td>
<table cellpadding="5">
<tr align="center">
<td><?php print_string("timespentminutes", "lesson"); ?></td>
<td><?php print_string("completed", "lesson"); ?></td>
<td><?php print_string("gradebetterthan", "lesson"); ?></td>
</tr>
<tr align="center">
<td><input type="text" name="timespent" maxlength="7" size="7" value="<?php p($form->timespent) ?>" /></td>
<td>
<?php
if ($form->completed) {
$checked = 'checked="checked"';
} else {
$checked = '';
}
?>
<input type="checkbox" name="completed" value="1" <?php echo $checked; ?> />
</td>
<td><input type="text" name="gradebetterthan" maxlength="7" size="7" value="<?php p($form->gradebetterthan) ?>" /></td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("available", "lesson") ?>:</b></td>
<td><?php
print_date_selector("availableday", "availablemonth", "availableyear", $form->available);
echo "&nbsp;-&nbsp;";
print_time_selector("availablehour", "availableminute", $form->available);
?></td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("deadline", "lesson") ?>:</b></td>
<td><?php
print_date_selector("deadlineday", "deadlinemonth", "deadlineyear", $form->deadline);
echo "&nbsp;-&nbsp;";
print_time_selector("deadlinehour", "deadlineminute", $form->deadline);
?></td>
</tr>
<tr>
<td>
<br/><?php print_heading(get_string("other", "lesson"), "left", 4); ?>
</td><td></td>
</tr>
<tr>
<td align="right"><b><?php print_string("activitylink", "lesson"); ?>:</b></td>
<td>
<?php
// get the modules
if ($mods = get_course_mods($form->course)) {
$modinstances = array();
foreach ($mods as $mod) {
if ($mod->instance == $form->instance and $mod->module == $form->module) { // don't add this lesson
continue;
}
// get the module name and then store it in a new array
if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $form->course)) {
$modinstances[$mod->modname][$mod->id] = $module->name;
}
}
ksort($modinstances); // sort by module name
// print out a select dropdown with optgroups
echo '<select id="menuactivitylink" name="activitylink">';
if ($form->activitylink == 0) {
echo '<option selected="selected" value="0">'.get_string('none')."</option>\n";
} else {
echo '<option value="0">'.get_string('none')."</option>\n";
}
foreach ($modinstances as $module => $instances) {
echo '<optgroup label="'.get_string('modulename', $module).'">'."\n";
asort($instances);
foreach ($instances as $modid => $instance) {
if ($form->activitylink == $modid) { // check for being selected
echo '<option selected="selected" value="'.$modid.'">'.$instance."</option>\n";
} else {
echo '<option value="'.$modid.'">'.$instance."</option>\n";
}
}
echo "</optgroup>\n";
}
echo "</select>\n";
} else {
print_string('nocoursemods', 'lesson');
}
helpbutton("activitylink", get_string("activitylink", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("mediafile", "lesson"); ?>:</b></td>
<td>
<?PHP
$strchooseafile = get_string("chooseafile", "resource");
echo "<input name=\"mediafile\" size=\"50\" value=\"$form->mediafile\" /><br />";
button_to_popup_window ("/files/index.php?id=$course->id&choose=form.mediafile", "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
helpbutton("mediafile", get_string("mediafile", "lesson"), "lesson");
?>
<br /><br />
<?php
print_string("mediaclose", "lesson");
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "mediaclose", $form->mediaclose, "");
?>
-&nbsp;<?php print_string("mediaheight", "lesson"); ?>
<input type="text" name="mediaheight" maxlength="7" size="4" value="<?php p($form->mediaheight) ?>" />px,
<?php print_string("mediawidth", "lesson"); ?>
<input type="text" name="mediawidth" maxlength="7" size="4" value="<?php p($form->mediawidth) ?>" />px
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("displayhighscores", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "highscores", $form->highscores, "");
helpbutton("highscores", get_string("displayhighscores", "lesson"), "lesson");
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("maxhighscores", "lesson"); ?>:</b></td>
<td>
<input type="text" name="maxhighscores" maxlength="7" size="7" value="<?php p($form->maxhighscores) ?>" />
<?php helpbutton("maxhighscores", get_string("maxhighscores", "lesson"), "lesson"); ?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("lessondefault", "lesson"); ?>:</b></td>
<td>
<?PHP
$options = array();
$options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu($options, "lessondefault", $form->lessondefault, "");
helpbutton("lessondefault", get_string("lessondefault", "lesson"), "lesson");
?>
</td>
</tr>
<?php print_visible_setting($form); ?>
</table>
<!-- These hidden variables are always the same -->
<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") ?>" />
</center>
</form>
</div> <!-- ends class mod-lesson -->
Jump to Line
Something went wrong with that request. Please try again.