migrated mod/lesson/mod.html to formslib
This commit is contained in:
+27
-48
@@ -11,22 +11,15 @@ define("LESSON_MAX_EVENT_LENGTH", "432000"); // 5 days maximum
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_add_instance($lesson) {
|
||||
/// Given an object containing all the necessary data,
|
||||
/// (defined by the form in mod.html) this function
|
||||
/// will create a new instance and return the id number
|
||||
/// Given an object containing all the necessary data,
|
||||
/// (defined by the form in mod.html) this function
|
||||
/// will create a new instance and return the id number
|
||||
/// of the new instance.
|
||||
global $SESSION;
|
||||
|
||||
$lesson->timemodified = time();
|
||||
|
||||
$lesson->available = make_timestamp($lesson->availableyear,
|
||||
$lesson->availablemonth, $lesson->availableday, $lesson->availablehour,
|
||||
$lesson->availableminute);
|
||||
|
||||
$lesson->deadline = make_timestamp($lesson->deadlineyear,
|
||||
$lesson->deadlinemonth, $lesson->deadlineday, $lesson->deadlinehour,
|
||||
$lesson->deadlineminute);
|
||||
|
||||
if(empty($lesson->timespent) or !is_numeric($lesson->timespent) or $lesson->timespent < 0) {
|
||||
$lesson->timespent = 0;
|
||||
}
|
||||
@@ -48,20 +41,12 @@ function lesson_add_instance($lesson) {
|
||||
unset($lesson->completed);
|
||||
unset($lesson->gradebetterthan);
|
||||
|
||||
// sanitize given values a bit
|
||||
$lesson->maxtime = clean_param($lesson->maxtime, PARAM_INT);
|
||||
$lesson->width = clean_param($lesson->width, PARAM_INT);
|
||||
$lesson->height = clean_param($lesson->height, PARAM_INT);
|
||||
$lesson->mediawidth = clean_param($lesson->mediawidth, PARAM_INT);
|
||||
$lesson->mediaheight = clean_param($lesson->mediaheight, PARAM_INT);
|
||||
$lesson->maxhighscores = clean_param($lesson->maxhighscores, PARAM_INT);
|
||||
|
||||
if (!empty($lesson->password)) {
|
||||
$lesson->password = md5($lesson->password);
|
||||
} else {
|
||||
unset($lesson->password);
|
||||
}
|
||||
|
||||
|
||||
if (!$lesson->id = insert_record("lesson", $lesson)) {
|
||||
return false; // bad
|
||||
}
|
||||
@@ -82,7 +67,7 @@ function lesson_add_instance($lesson) {
|
||||
} else {
|
||||
unset($lesson->lessondefault);
|
||||
}
|
||||
|
||||
|
||||
// got this code from quiz, thanks quiz!!!
|
||||
delete_records('event', 'modulename', 'lesson', 'instance', $lesson->id); // Just in case
|
||||
|
||||
@@ -121,17 +106,11 @@ function lesson_add_instance($lesson) {
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_update_instance($lesson) {
|
||||
/// Given an object containing all the necessary data,
|
||||
/// (defined by the form in mod.html) this function
|
||||
/// Given an object containing all the necessary data,
|
||||
/// (defined by the form in mod.html) this function
|
||||
/// will update an existing instance with new data.
|
||||
|
||||
$lesson->timemodified = time();
|
||||
$lesson->available = make_timestamp($lesson->availableyear,
|
||||
$lesson->availablemonth, $lesson->availableday, $lesson->availablehour,
|
||||
$lesson->availableminute);
|
||||
$lesson->deadline = make_timestamp($lesson->deadlineyear,
|
||||
$lesson->deadlinemonth, $lesson->deadlineday, $lesson->deadlinehour,
|
||||
$lesson->deadlineminute);
|
||||
$lesson->id = $lesson->instance;
|
||||
|
||||
if(empty($lesson->timespent) or !is_numeric($lesson->timespent) or $lesson->timespent < 0) {
|
||||
@@ -177,7 +156,7 @@ function lesson_update_instance($lesson) {
|
||||
} else {
|
||||
unset($lesson->lessondefault);
|
||||
}
|
||||
|
||||
|
||||
// update the calendar events (credit goes to quiz module)
|
||||
if ($events = get_records_select('event', "modulename = 'lesson' and instance = '$lesson->id'")) {
|
||||
foreach($events as $event) {
|
||||
@@ -220,9 +199,9 @@ function lesson_update_instance($lesson) {
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_delete_instance($id) {
|
||||
/// Given an ID of an instance of this module,
|
||||
/// this function will permanently delete the instance
|
||||
/// and any data that depends on it.
|
||||
/// Given an ID of an instance of this module,
|
||||
/// this function will permanently delete the instance
|
||||
/// and any data that depends on it.
|
||||
|
||||
if (! $lesson = get_record("lesson", "id", "$id")) {
|
||||
return false;
|
||||
@@ -259,7 +238,7 @@ function lesson_delete_instance($id) {
|
||||
delete_event($event->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -277,18 +256,18 @@ function lesson_delete_course($course, $feedback=true) {
|
||||
|
||||
$count = count_records('lesson_default', 'course', $course->id);
|
||||
delete_records('lesson_default', 'course', $course->id);
|
||||
|
||||
|
||||
//Inform about changes performed if feedback is enabled
|
||||
if ($feedback) {
|
||||
notify(get_string('deletedefaults', 'lesson', $count));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_user_outline($course, $user, $mod, $lesson) {
|
||||
/// Return a small object with summary information about what a
|
||||
/// Return a small object with summary information about what a
|
||||
/// user has done with a given particular instance of this module
|
||||
/// Used for user activity reports.
|
||||
/// $return->time = the time they did it
|
||||
@@ -315,7 +294,7 @@ function lesson_user_outline($course, $user, $mod, $lesson) {
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_user_complete($course, $user, $mod, $lesson) {
|
||||
/// Print a detailed representation of what a user has done with
|
||||
/// Print a detailed representation of what a user has done with
|
||||
/// a given particular instance of this module, for user activity reports.
|
||||
|
||||
if ($attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND userid = $user->id",
|
||||
@@ -332,7 +311,7 @@ function lesson_user_complete($course, $user, $mod, $lesson) {
|
||||
$retry = 0;
|
||||
$npages = 0;
|
||||
$ncorrect = 0;
|
||||
|
||||
|
||||
foreach ($attempts as $attempt) {
|
||||
if ($attempt->retry == $retry) {
|
||||
$npages++;
|
||||
@@ -374,26 +353,26 @@ function lesson_user_complete($course, $user, $mod, $lesson) {
|
||||
echo get_string("no")." ".get_string("attempts", "lesson");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_print_recent_activity($course, $isteacher, $timestart) {
|
||||
/// Given a course and a time, this module should find recent activity
|
||||
/// that has occurred in lesson activities and print it out.
|
||||
/// Given a course and a time, this module should find recent activity
|
||||
/// that has occurred in lesson activities and print it out.
|
||||
/// Return true if there was output, or false is there was none.
|
||||
|
||||
global $CFG;
|
||||
|
||||
return false; // True if anything was printed, otherwise false
|
||||
return false; // True if anything was printed, otherwise false
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_cron () {
|
||||
/// Function to be run periodically according to the moodle cron
|
||||
/// This function searches for things that need to be done, such
|
||||
/// as sending out mail, toggling flags etc ...
|
||||
/// This function searches for things that need to be done, such
|
||||
/// as sending out mail, toggling flags etc ...
|
||||
|
||||
global $CFG;
|
||||
|
||||
@@ -402,7 +381,7 @@ function lesson_cron () {
|
||||
|
||||
/*******************************************************************/
|
||||
function lesson_grades($lessonid) {
|
||||
/// Must return an array of grades for a given instance of this module,
|
||||
/// Must return an array of grades for a given instance of this module,
|
||||
/// indexed by user. It also returns a maximum allowed grade.
|
||||
global $CFG;
|
||||
|
||||
@@ -416,7 +395,7 @@ function lesson_grades($lessonid) {
|
||||
$grades = get_records_sql_menu("SELECT userid,AVG(grade) FROM {$CFG->prefix}lesson_grades WHERE
|
||||
lessonid = $lessonid GROUP BY userid");
|
||||
}
|
||||
|
||||
|
||||
// convert grades from percentages and tidy the numbers
|
||||
if (!$lesson->practice) { // dont display practice lessons
|
||||
if ($grades) {
|
||||
@@ -425,7 +404,7 @@ function lesson_grades($lessonid) {
|
||||
}
|
||||
}
|
||||
$return->maxgrade = $lesson->grade;
|
||||
|
||||
|
||||
return $return;
|
||||
} else {
|
||||
return NULL;
|
||||
@@ -439,7 +418,7 @@ function lesson_get_participants($lessonid) {
|
||||
//in the instance, independient of his role (student, teacher, admin...)
|
||||
|
||||
global $CFG;
|
||||
|
||||
|
||||
//Get students
|
||||
$students = get_records_sql("SELECT DISTINCT u.id, u.id
|
||||
FROM {$CFG->prefix}user u,
|
||||
|
||||
@@ -1,661 +0,0 @@
|
||||
<?php // $Id$
|
||||
/**
|
||||
* Define a new instance of lesson or edit an instance.
|
||||
* It is used from /course/mod.php. The whole instance is available as $form.
|
||||
*
|
||||
* @version $Id$
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package lesson
|
||||
**/
|
||||
|
||||
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->feedback)) {
|
||||
$form->feedback = 1;
|
||||
}
|
||||
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><label for="name"><?php print_string("name") ?>:</label></b></td>
|
||||
<td align="left">
|
||||
<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 align="left">
|
||||
<?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 align="left">
|
||||
<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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?php
|
||||
choose_from_menu($LESSON_NEXTPAGE_ACTION, "nextpagedefault", $form->nextpagedefault, "");
|
||||
helpbutton("nextpageaction", get_string("actionaftercorrectanswer", "lesson"), "lesson");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right"><strong><?php print_string('displaydefaultfeedback', 'lesson'); ?>:</strong></td>
|
||||
<td align="left">
|
||||
<?php
|
||||
$options = array();
|
||||
$options[0] = get_string('no'); $options[1] = get_string('yes');
|
||||
choose_from_menu($options, 'feedback', $form->feedback, '');
|
||||
helpbutton('feedback', get_string('displaydefaultfeedback', 'lesson'), 'lesson');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("minimumnumberofquestions", "lesson") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<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 align="left">
|
||||
<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 align="left">
|
||||
<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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<?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 align="left">
|
||||
<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 align="left">
|
||||
<?php
|
||||
$options = array();
|
||||
if ($lessons = get_all_instances_in_course('lesson', $course)) {
|
||||
foreach($lessons as $lesson) {
|
||||
if ($form->instance != $lesson->id) {
|
||||
$options[$lesson->id] = format_string($lesson->name, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
choose_from_menu($options, 'dependency', $form->dependency, get_string('none'));
|
||||
helpbutton("dependency", get_string("dependency", "lesson"), "lesson");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string("conditionsfordependency", "lesson"); ?>:</b></td>
|
||||
<td align="left">
|
||||
<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 align="left"><?php
|
||||
print_date_selector("availableday", "availablemonth", "availableyear", $form->available);
|
||||
echo " - ";
|
||||
print_time_selector("availablehour", "availableminute", $form->available);
|
||||
?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("deadline", "lesson") ?>:</b></td>
|
||||
<td align="left"><?php
|
||||
print_date_selector("deadlineday", "deadlinemonth", "deadlineyear", $form->deadline);
|
||||
echo " - ";
|
||||
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 align="left">
|
||||
<?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 align="left">
|
||||
<?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, "");
|
||||
?>
|
||||
- <?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 align="left">
|
||||
<?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 align="left">
|
||||
<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 align="left">
|
||||
<?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 -->
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php // $Id$
|
||||
/**
|
||||
* Form to define a new instance of lesson or edit an instance.
|
||||
* It is used from /course/modedit.php.
|
||||
*
|
||||
* @version $Id$
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package lesson
|
||||
**/
|
||||
require_once ($CFG->libdir.'/formslib.php');
|
||||
require_once('locallib.php');
|
||||
class lesson_mod_form extends moodleform_mod {
|
||||
|
||||
function definition() {
|
||||
|
||||
global $LESSON_NEXTPAGE_ACTION, $COURSE;
|
||||
$mform =& $this->_form;
|
||||
$renderer =& $mform->defaultRenderer();
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
|
||||
$mform->addElement('text', 'name', get_string('name'));
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->addRule('name', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('selectyesno', 'timed', get_string('timed', 'lesson'));
|
||||
$mform->setDefault('timed', 0);
|
||||
$mform->setHelpButton('timed', array('timed', get_string('timed', 'lesson'), 'lesson'));
|
||||
|
||||
$mform->addElement('text', 'maxtime', get_string('maxtime', 'lesson'));
|
||||
$mform->setDefault('maxtime', 20);
|
||||
$mform->addRule('maxtime', null, 'required', null, 'client');
|
||||
$mform->addRule('maxtime', null, 'numeric', null, 'client');
|
||||
$mform->setType('maxtime', PARAM_INT);
|
||||
|
||||
$numbers = array();
|
||||
for ($i=20; $i>1; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
$mform->addElement('select', 'maxanswers', get_string('maximumnumberofanswersbranches', 'lesson'), $numbers);
|
||||
$mform->setDefault('maxanswers', 4);
|
||||
$mform->setHelpButton('maxanswers', array('maxanswers', get_string('displayformat', 'lesson'), 'lesson'));
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('gradeoptions', 'lesson'));
|
||||
|
||||
$mform->addElement('selectyesno', 'practice', get_string('practice', 'lesson'));
|
||||
$mform->setHelpButton('practice', array('practice', get_string('practice', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('practice', 0);
|
||||
|
||||
$mform->addElement('selectyesno', 'custom', get_string('customscoring', 'lesson'));
|
||||
$mform->setHelpButton('custom', array('custom', get_string('customscoring', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('custom', 1);
|
||||
|
||||
$grades = array();
|
||||
for ($i=100; $i>=0; $i--) {
|
||||
$grades[$i] = $i;
|
||||
}
|
||||
$mform->addElement('select', 'grade', get_string('maximumgrade'), $grades);
|
||||
$mform->setDefault('grade', 0);
|
||||
$mform->setHelpButton('grade', array('grade', get_string('maximumgrade', 'lesson'), 'lesson'));
|
||||
|
||||
$mform->addElement('selectyesno', 'retake', get_string('canretake', 'lesson', $COURSE->student));
|
||||
$mform->setHelpButton('retake', array('retake', get_string('canretake', 'lesson', $COURSE->student), 'lesson'));
|
||||
$mform->setDefault('retake', 0);
|
||||
|
||||
$options = array();
|
||||
$options[0] = get_string('usemean', 'lesson');
|
||||
$options[1] = get_string('usemaximum', 'lesson');
|
||||
$mform->addElement('select', 'usemaxgrade', get_string('handlingofretakes', 'lesson'), $options);
|
||||
$mform->setHelpButton('usemaxgrade', array('handlingofretakes', get_string('handlingofretakes', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('usemaxgrade', 0);
|
||||
|
||||
$mform->addElement('selectyesno', 'ongoing', get_string('ongoing', 'lesson'));
|
||||
$mform->setHelpButton('ongoing', array('ongoing', get_string('ongoing', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('ongoing', 0);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('flowcontrol', 'lesson'));
|
||||
|
||||
$mform->addElement('selectyesno', 'modattempts', get_string('modattempts', 'lesson'));
|
||||
$mform->setHelpButton('modattempts', array('modattempts', get_string('modattempts', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('modattempts', 0);
|
||||
|
||||
$mform->addElement('selectyesno', 'review', get_string('displayreview', 'lesson'));
|
||||
$mform->setHelpButton('review', array('review', get_string('displayreview', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('review', 0);
|
||||
|
||||
$numbers = array();
|
||||
for ($i=10; $i>0; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
$mform->addElement('select', 'maxattempts', get_string('maximumnumberofattempts', 'lesson'), $numbers);
|
||||
$mform->setHelpButton('maxattempts', array('maxattempts', get_string('maximumnumberofattempts', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('maxattempts', 1);
|
||||
|
||||
$mform->addElement('select', 'nextpagedefault', get_string('actionaftercorrectanswer', 'lesson'), $LESSON_NEXTPAGE_ACTION);
|
||||
$mform->setHelpButton('nextpagedefault', array('nextpageaction', get_string('actionaftercorrectanswer', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('nextpagedefault', 0);
|
||||
|
||||
$mform->addElement('selectyesno', 'feedback', get_string('displaydefaultfeedback', 'lesson'));
|
||||
$mform->setHelpButton('feedback', array('feedback', get_string('displaydefaultfeedback', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('feedback', 0);
|
||||
|
||||
$numbers = array();
|
||||
for ($i = 100; $i >= 0; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
$mform->addElement('select', 'minquestions', get_string('minimumnumberofquestions', 'lesson'), $numbers);
|
||||
$mform->setHelpButton('minquestions', array('minquestions', get_string('minimumnumberofquestions', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('minquestions', 0);
|
||||
|
||||
$numbers = array();
|
||||
for ($i = 100; $i >= 0; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
$mform->addElement('select', 'maxpages', get_string('numberofpagestoshow', 'lesson'), $numbers);
|
||||
$mform->setHelpButton('maxpages', array('maxpages', get_string('numberofpagestoshow', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('maxpages', 0);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('lessonformating', 'lesson'));
|
||||
|
||||
$mform->addElement('selectyesno', 'slideshow', get_string('slideshow', 'lesson'));
|
||||
$mform->setHelpButton('slideshow', array('slideshow', get_string('slideshow', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('slideshow', 0);
|
||||
|
||||
$mform->addElement('text', 'width', get_string('slideshowwidth', 'lesson'));
|
||||
$mform->setDefault('width', 20);
|
||||
$mform->addRule('width', null, 'required', null, 'client');
|
||||
$mform->addRule('width', null, 'numeric', null, 'client');
|
||||
$mform->setHelpButton('width', array('width', get_string('slideshowwidth', 'lesson'), 'lesson'));
|
||||
$mform->setType('width', PARAM_INT);
|
||||
|
||||
$mform->addElement('text', 'height', get_string('slideshowheight', 'lesson'));
|
||||
$mform->setDefault('height', 20);
|
||||
$mform->addRule('height', null, 'required', null, 'client');
|
||||
$mform->addRule('height', null, 'numeric', null, 'client');
|
||||
$mform->setHelpButton('height', array('height', get_string('slideshowheight', 'lesson'), 'lesson'));
|
||||
$mform->setType('height', PARAM_INT);
|
||||
|
||||
$mform->addElement('text', 'bgcolor', get_string('slideshowbgcolor', 'lesson'));
|
||||
$mform->setDefault('bgcolor', '#FFFFFF');
|
||||
$mform->addRule('bgcolor', null, 'required', null, 'client');
|
||||
$mform->setHelpButton('bgcolor', array('bgcolor', get_string('slideshowbgcolor', 'lesson'), 'lesson'));
|
||||
$mform->setType('bgcolor', PARAM_TEXT);
|
||||
|
||||
$mform->addElement('selectyesno', 'displayleft', get_string('displayleftmenu', 'lesson'));
|
||||
$mform->setHelpButton('displayleft', array('displayleft', get_string('displayleftmenu', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('displayleft', 0);
|
||||
|
||||
$options = array();
|
||||
for($i = 100; $i >= 0; $i--) {
|
||||
$options[$i] = $i.'%';
|
||||
}
|
||||
$mform->addElement('select', 'displayleftif', get_string('displayleftif', 'lesson'), $options);
|
||||
$mform->setDefault('displayleftif', 0);
|
||||
|
||||
$mform->addElement('selectyesno', 'progressbar', get_string('progressbar', 'lesson'));
|
||||
$mform->setHelpButton('progressbar', array('progressbar', get_string('progressbar', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('progressbar', 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('accesscontrol', 'lesson'));
|
||||
|
||||
$mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'lesson'));
|
||||
$mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('usepassword', 0);
|
||||
|
||||
$mform->addElement('text', 'password', get_string('password', 'lesson'));
|
||||
$mform->setHelpButton('password', array('password', get_string('password', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('password', '');
|
||||
//never displayed converted to md5
|
||||
$mform->setType('password', PARAM_RAW);
|
||||
|
||||
$mform->addElement('date_time_selector', 'available', get_string('available', 'lesson'));
|
||||
$mform->setDefault('available', 0);
|
||||
|
||||
$mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'lesson'));
|
||||
$mform->setDefault('deadline', 0);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('dependencyon', 'lesson'));
|
||||
|
||||
$options = array(0=>get_string('none'));
|
||||
if ($lessons = get_all_instances_in_course('lesson', $COURSE)) {
|
||||
foreach($lessons as $lesson) {
|
||||
$options[$lesson->id] = format_string($lesson->name, true);
|
||||
}
|
||||
}
|
||||
$mform->addElement('select', 'dependency', get_string('dependencyon', 'lesson'), $options);
|
||||
$mform->setHelpButton('dependency', array('dependency', get_string('dependency', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('dependency', 0);
|
||||
|
||||
$mform->addElement('text', 'timespent', get_string('timespentminutes', 'lesson'));
|
||||
$mform->setDefault('timespent', 0);
|
||||
$mform->setType('timespent', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'completed', get_string('completed', 'lesson'));
|
||||
$mform->setDefault('completed', 0);
|
||||
|
||||
$mform->addElement('text', 'gradebetterthan', get_string('gradebetterthan', 'lesson'));
|
||||
$mform->setDefault('gradebetterthan', 0);
|
||||
$mform->setType('gradebetterthan', PARAM_INT);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('mediafile', 'lesson'));
|
||||
|
||||
// get the modules
|
||||
if ($mods = get_course_mods($COURSE->id)) {
|
||||
$modinstances = array();
|
||||
foreach ($mods as $mod) {
|
||||
|
||||
// get the module name and then store it in a new array
|
||||
if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $COURSE->id)) {
|
||||
$modinstances[$mod->id] = $mod->modname.' - '.$module->name;
|
||||
}
|
||||
}
|
||||
asort($modinstances); // sort by module name
|
||||
$modinstances=array(0=>get_string('none'))+$modinstances;
|
||||
|
||||
$mform->addElement('select', 'activitylink', get_string('activitylink', 'lesson'), $modinstances);
|
||||
$mform->setHelpButton('activitylink', array('activitylink', get_string('activitylink', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('activitylink', 0);
|
||||
|
||||
}
|
||||
|
||||
$mform->addElement('choosecoursefile', 'mediafile', get_string('mediafile', 'lesson'), array('courseid'=>$COURSE->id));
|
||||
$mform->setHelpButton('mediafile', array('mediafile', get_string('mediafile', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('mediafile', '');
|
||||
$mform->setType('mediafile', PARAM_PATH);
|
||||
|
||||
$mform->addElement('selectyesno', 'mediaclose', get_string('mediaclose', 'lesson'));
|
||||
$mform->setDefault('mediaclose', 0);
|
||||
|
||||
$mform->addElement('text', 'mediaheight', get_string('mediaheight', 'lesson'));
|
||||
$mform->setHelpButton('mediaheight', array('mediaheight', get_string('mediaheight', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('mediaheight', 100);
|
||||
$mform->addRule('mediaheight', null, 'required', null, 'client');
|
||||
$mform->addRule('mediaheight', null, 'numeric', null, 'client');
|
||||
$mform->setType('mediaheight', PARAM_INT);
|
||||
|
||||
$mform->addElement('text', 'mediawidth', get_string('mediawidth', 'lesson'));
|
||||
$mform->setHelpButton('mediawidth', array('mediawidth', get_string('mediawidth', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('mediawidth', 650);
|
||||
$mform->addRule('mediawidth', null, 'required', null, 'client');
|
||||
$mform->addRule('mediawidth', null, 'numeric', null, 'client');
|
||||
$mform->setType('mediawidth', PARAM_INT);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('other', 'lesson'));
|
||||
|
||||
$mform->addElement('text', 'maxhighscores', get_string('maxhighscores', 'lesson'));
|
||||
$mform->setHelpButton('maxhighscores', array('maxhighscores', get_string('maxhighscores', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('maxhighscores', 10);
|
||||
$mform->addRule('maxhighscores', null, 'required', null, 'client');
|
||||
$mform->addRule('maxhighscores', null, 'numeric', null, 'client');
|
||||
$mform->setType('maxhighscores', PARAM_INT);
|
||||
|
||||
$mform->addElement('selectyesno', 'lessondefault', get_string('lessondefault', 'lesson'));
|
||||
$mform->setHelpButton('lessondefault', array('lessondefault', get_string('lessondefault', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('lessondefault', 0);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$this->standard_coursemodule_elements(false);
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
$buttonarray=array();
|
||||
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submit', get_string('savechanges'));
|
||||
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel'));
|
||||
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
|
||||
$renderer->addStopFieldsetElements('buttonar');
|
||||
}
|
||||
|
||||
function definition_after_data(){
|
||||
$mform =& $this->_form;
|
||||
$dependencyel =& $mform->getElement('dependency');
|
||||
//unset this option from the dependency drop down :
|
||||
$instance = $mform->getElementValue('instance');
|
||||
if ($instance){
|
||||
$dependencyel->removeOption($instance);
|
||||
}
|
||||
$update = $mform->getElementValue('update');
|
||||
if ($update){
|
||||
$activitylinkel =& $mform->getElement('activitylink');
|
||||
$activitylinkel->removeOption($update);
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Load in existing data as form defaults. Usually new entry defaults are stored directly in
|
||||
* form definition (new entry form); this function is used to load in data where values
|
||||
* already exist and data is being edited (edit entry form).
|
||||
*
|
||||
* Overriding this to add functionality to unserialize some fields before setting deafaults for
|
||||
* this module
|
||||
*
|
||||
* @param mixed $default_values object or array of default values
|
||||
* @param bool $slased true if magic quotes applied to data values
|
||||
*/
|
||||
function set_defaults($default_values, $slashed=false) {
|
||||
if (isset($default_values->conditions)) {
|
||||
$conditions = unserialize($default_values->conditions);
|
||||
$default_values->timespent = $conditions->timespent;
|
||||
$default_values->completed = $conditions->completed;
|
||||
$default_values->gradebetterthan = $conditions->gradebetterthan;
|
||||
}
|
||||
if (isset($default_values->password)) {
|
||||
unset($default_values->password);
|
||||
}
|
||||
parent::set_defaults($default_values, $slashed=false);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user