3 => get_string("criterion", "exercise"),
4 => get_string("rubric", "exercise") );
-$EXERCISE_SCALES = array(
+$EXERCISE_SCALES = array(
0 => array( 'name' => get_string("scaleyes", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("yes"), 'end' => get_string("no")),
1 => array( 'name' => get_string("scalepresent", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("present", "exercise"), 'end' => get_string("absent", "exercise")),
- 2 => array( 'name' => get_string("scalecorrect", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("correct", "exercise"), 'end' => get_string("incorrect", "exercise")),
- 3 => array( 'name' => get_string("scalegood3", "exercise"), 'type' => 'radio', 'size' => 3, 'start' => get_string("good", "exercise"), 'end' => get_string("poor", "exercise")),
+ 2 => array( 'name' => get_string("scalecorrect", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("correct", "exercise"), 'end' => get_string("incorrect", "exercise")),
+ 3 => array( 'name' => get_string("scalegood3", "exercise"), 'type' => 'radio', 'size' => 3, 'start' => get_string("good", "exercise"), 'end' => get_string("poor", "exercise")),
4 => array( 'name' => get_string("scaleexcellent4", "exercise"), 'type' => 'radio', 'size' => 4, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")),
5 => array( 'name' => get_string("scaleexcellent5", "exercise"), 'type' => 'radio', 'size' => 5, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")),
6 => array( 'name' => get_string("scaleexcellent7", "exercise"), 'type' => 'radio', 'size' => 7, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")),
7 => array( 'name' => get_string("scale10", "exercise"), 'type' => 'selection', 'size' => 10),
8 => array( 'name' => get_string("scale20", "exercise"), 'type' => 'selection', 'size' => 20),
- 9 => array( 'name' => get_string("scale100", "exercise"), 'type' => 'selection', 'size' => 100));
+ 9 => array( 'name' => get_string("scale100", "exercise"), 'type' => 'selection', 'size' => 100));
-$EXERCISE_EWEIGHTS = array( 0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5, 6 => -0.25,
- 7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0);
+$EXERCISE_EWEIGHTS = array( 0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5, 6 => -0.25,
+ 7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0);
$EXERCISE_ASSESSMENT_COMPS = array (
0 => array('name' => get_string("verylax", "exercise"), 'value' => 1),
4 => array('name' => get_string("verystrict", "exercise"), 'value' => 0.2) );
/*** Standard Moodle functions ******************
-function exercise_add_instance($exercise)
+function exercise_add_instance($exercise)
function exercise_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
-function exercise_cron ()
-function exercise_delete_instance($id)
-function exercise_grades($exerciseid)
-function exercise_print_recent_activity(&$logs, $isteacher=false)
-function exercise_update_instance($exercise)
-function exercise_user_outline($course, $user, $mod, $exercise)
-function exercise_user_complete($course, $user, $mod, $exercise)
+function exercise_cron ()
+function exercise_delete_instance($id)
+function exercise_grades($exerciseid)
+function exercise_print_recent_activity(&$logs, $isteacher=false)
+function exercise_update_instance($exercise)
+function exercise_user_outline($course, $user, $mod, $exercise)
+function exercise_user_complete($course, $user, $mod, $exercise)
**********************************************/
/*******************************************************************/
function exercise_add_instance($exercise) {
-// 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.
$exercise->timemodified = time();
-
- $exercise->deadline = make_timestamp($exercise->deadlineyear,
- $exercise->deadlinemonth, $exercise->deadlineday, $exercise->deadlinehour,
- $exercise->deadlineminute);
// encode password if necessary
if (!empty($exercise->password)) {
function exercise_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
/// Given an array of value, creates a popup menu to be part of a form
/// $options["value"]["label"]
-
+
if ($nothing == "choose") {
$nothing = get_string("choose")."...";
}
// $output .= ">$value</option>\n";
// }
$output .= ">$label</option>\n";
-
+
}
}
$output .= "</select>\n";
} else {
echo $output;
}
-}
+}
/*******************************************************************/
if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
continue; // Not an active participant
}
-
+
// if the submission belongs to a teacher it's a student assessment. No need to email anything.
- if (isteacher($course->id, $submissionowner->id)) {
+ if (isteacher($course->id, $submissionowner->id)) {
continue;
}
$strexercises = get_string("modulenameplural", "exercise");
$strexercise = get_string("modulename", "exercise");
-
+
// it's an assessment, tell the submission owner
$USER->lang = $submissionowner->lang;
$sendto = $submissionowner;
$msg = get_string("mail1", "exercise", $submission->title).' '.fullname($assessmentowner).".\n";
// "The comments and grade can be seen in the exercise assignment '$exercise->name'
$msg .= get_string("mail2", "exercise", format_string($exercise->name,true))."\n\n";
-
+
$postsubject = "$course->shortname: $strexercises: ".format_string($exercise->name,true);
$posttext = "$course->shortname -> $strexercises -> ".format_string($exercise->name,true)."\n";
$posttext .= "---------------------------------------------------------------------\n";
} else {
$posthtml = "";
}
-
+
if (!$teacher = get_teacher($course->id)) {
echo "Error: can not find teacher for course $course->id!\n";
}
-
+
if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
echo "Error: exercise cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n";
}
/*******************************************************************/
function exercise_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 (! $exercise = get_record("exercise", "id", "$id")) {
return false;
}
-
+
// delete all the associated records in the exercise tables, start positive...
$result = true;
if (!$exercise = get_record("exercise", "id", $exerciseid)) {
error("Exercise record not found");
}
-
+
if (! $course = get_record("course", "id", $exercise->course)) {
error("Course is misconfigured");
}
-
+
if (!$return->maxgrade = ($exercise->grade + $exercise->gradinggrade)) {
return NULL;
}
}
}
}
-
+
else { // use mean values
if ($meangrades = exercise_get_mean_submission_grades($exercise)) {
foreach ($meangrades as $grade) {
}
}
- // have a look for new assessment gradings for this user
+ // have a look for new assessment gradings for this user
$gradecontent = false;
if ($logs = exercise_get_grade_logs($course, $timestart)) {
// got some, see if any belong to a visible module
}
}
- // have a look for new assessments for this user
+ // have a look for new assessments for this user
$assesscontent = false;
if (!$isteacher) { // teachers only need to see submissions
if ($logs = exercise_get_assess_logs($course, $timestart)) {
if ($courseid == 0) {
if (! $exercises = get_records("exercise")) {
- return true;
- }
+ return true;
+ }
} else {
if (! $exercises = get_records("exercise", "course", $courseid)) {
return true;
}
}
$moduleid = get_field('modules', 'id', 'name', 'exercise');
-
+
foreach ($exercises as $exercise) {
$event = NULL;
$event->name = addslashes($exercise->name);
if ($event->id = get_field('event', 'id', 'modulename', 'exercise', 'instance', $exercise->id)) {
update_event($event);
-
+
} else {
$event->courseid = $exercise->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'exercise';
- $event->instance = $exercise->id;
+ $event->instance = $exercise->id;
$event->eventtype = 'deadline';
$event->timeduration = 0;
- $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $exercise->id);
+ $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $exercise->id);
add_event($event);
}
}
return true;
-}
+}
/*******************************************************************/
function exercise_update_instance($exercise) {
-// 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.
$exercise->timemodified = time();
- $exercise->deadline = make_timestamp($exercise->deadlineyear,
- $exercise->deadlinemonth, $exercise->deadlineday, $exercise->deadlinehour,
- $exercise->deadlineminute);
-
// encode password if necessary
if (!empty($exercise->password)) {
$exercise->password = md5($exercise->password);
if ($assessments = exercise_get_assessments($submission)) {
// should only be one but we'll loop anyway
foreach ($assessments as $assessment) {
- $table->data[] = array(exercise_print_submission_title($exercise, $submission),
- userdate($submission->timecreated), userdate($assessment->timecreated),
+ $table->data[] = array(exercise_print_submission_title($exercise, $submission),
+ userdate($submission->timecreated), userdate($assessment->timecreated),
$assessment->grade * $exercise->grade / 100.0);
}
} else {
// submission not yet assessed (by teacher)
- $table->data[] = array(exercise_print_submission_title($exercise, $submission),
+ $table->data[] = array(exercise_print_submission_title($exercise, $submission),
userdate($submission->timecreated), get_string("notassessedyet", "exercise"), 0);
}
}
$timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.exerciseid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}exercise e,
- {$CFG->prefix}exercise_submissions s,
- {$CFG->prefix}exercise_assessments a,
+ {$CFG->prefix}exercise e,
+ {$CFG->prefix}exercise_submissions s,
+ {$CFG->prefix}exercise_assessments a,
{$CFG->prefix}user u
- WHERE l.time > $timestart AND l.time < $timethen
+ WHERE l.time > $timestart AND l.time < $timethen
AND l.course = $course->id AND l.module = 'exercise' AND l.action = 'assess'
AND a.id = l.info AND s.id = a.submissionid AND s.userid = $USER->id
AND u.id = a.userid AND e.id = a.exerciseid");
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_assessments($submission) {
- // Return all assessments for this submission provided they are after the editing time,
+ // Return all assessments for this submission provided they are after the editing time,
// ordered oldest first, newest last
global $CFG;
$timenow = time();
- return get_records_select("exercise_assessments", "(submissionid = $submission->id) AND
+ return get_records_select("exercise_assessments", "(submissionid = $submission->id) AND
(timecreated < $timenow - $CFG->maxeditingtime)", "timecreated ASC");
}
function exercise_get_best_grade($submission) {
// Returns the best grade of students' submission (there may, occassionally be more than one assessment)
global $CFG;
-
- return get_record_sql("SELECT MAX(a.grade) AS grade FROM
- {$CFG->prefix}exercise_assessments a
+
+ return get_record_sql("SELECT MAX(a.grade) AS grade FROM
+ {$CFG->prefix}exercise_assessments a
WHERE a.submissionid = $submission->id
GROUP BY a.submissionid");
}
if (empty($USER->id)) {
return false;
}
-
+
$timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.exerciseid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}exercise e,
- {$CFG->prefix}exercise_submissions s,
- {$CFG->prefix}exercise_assessments a,
+ {$CFG->prefix}exercise e,
+ {$CFG->prefix}exercise_submissions s,
+ {$CFG->prefix}exercise_assessments a,
{$CFG->prefix}user u
- WHERE l.time > $timestart AND l.time < $timethen
+ WHERE l.time > $timestart AND l.time < $timethen
AND l.course = $course->id AND l.module = 'exercise' AND l.action = 'grade'
AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
AND u.id = s.userid AND e.id = a.exerciseid");
// Returns the mean grades of students' submissions
// ignores hot assessments
global $CFG;
-
+
$timenow = time();
- $grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) AS grade FROM
- {$CFG->prefix}exercise_submissions s,
+ $grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) AS grade FROM
+ {$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a
- WHERE
+ WHERE
AND s.exerciseid = $exercise->id
AND s.late = 0
AND a.submissionid = s.id
function exercise_get_submit_logs($course, $timestart) {
// get the "submit" entries and add the first and last names...
global $CFG, $USER;
-
+
$timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, l.info as exerciseid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}exercise e,
+ {$CFG->prefix}exercise e,
{$CFG->prefix}user u
- WHERE l.time > $timestart AND l.time < $timethen
+ WHERE l.time > $timestart AND l.time < $timethen
AND l.course = $course->id AND l.module = 'exercise'
AND l.action = 'submit'
- AND e.id = l.info
+ AND e.id = l.info
AND u.id = l.userid");
}
function exercise_get_teacher_submission_assessments($exercise) {
// Return all assessments on the teacher submissions, order by youngest first, oldest last
global $CFG;
-
+
return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a
WHERE s.isexercise = 1
AND s.exerciseid = $exercise->id
global $CFG;
return get_records_sql("SELECT a.*, e.course, e.name
FROM {$CFG->prefix}exercise_assessments a, {$CFG->prefix}exercise e
- WHERE a.mailed = 0
- AND a.timecreated < $cutofftime
+ WHERE a.mailed = 0
+ AND a.timecreated < $cutofftime
AND e.id = a.exerciseid");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_print_submission_title($exercise, $submission) {
global $CFG;
-
+
if (!$submission->timecreated) { // a "no submission"
return $submission->title;
}
+++ /dev/null
-<?php
- require("$CFG->dirroot/mod/exercise/lib.php"); // for parameter arrays
- // ...and fill the form if needed
- if (empty($form->name)) {
- $form->name = "";
- }
- if (!isset($form->gradingstrategy)) {
- $form->gradingstrategy = 1;
- }
- if (empty($form->usemaximum)) {
- $form->usemaximum = 0;
- }
- if (!isset($form->assessmentcomps)) {
- $form->assessmentcomps = 2;
- }
- if (!isset($form->grade)) {
- $form->grade = 100;
- }
- if (!isset($form->gradinggrade)) {
- $form->gradinggrade = 100;
- }
- if (!isset($form->nelements)) {
- $form->nelements = 1;
- }
- if (empty($form->maxbytes)) {
- $form->maxbytes = "";
- }
- if (empty($form->deadline)) {
- $form->deadline = "";
- }
- if (!isset($form->usepassword)) {
- $form->usepassword = 0;
- }
- if (empty($form->showleaguetable)) {
- $form->showleaguetable = "";
- }
- if (empty($form->anonymous)) {
- $form->anonymous = 0;
- }
-
- $nohtmleditorneeded = true;
-?>
-
-<form name="form" method="post" action="mod.php">
-<table cellpadding="5">
-<tr valign="top">
- <td align="right" width="50%"><b><?php print_string("title", "exercise") ?>:</b></td>
- <td width="50%">
- <input type="text" name="name" size="60" value="<?php p($form->name) ?>" alt="<?php print_string("title", "exercise") ?>"/>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("description", "exercise") ?>:</b></td>
- <td>
- <?php
- echo get_string("descriptionofexercise", "exercise", $course->students);
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("gradeforstudentsassessment", "exercise", $course->student) ?>:</b></td>
- <td>
- <?php
- for ($i=100; $i>=0; $i--) {
- $grades[$i] = $i;
- }
- choose_from_menu($grades, "gradinggrade", "$form->gradinggrade", "");
- helpbutton("gradinggrade", get_string("gradinggrade", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("gradeforsubmission", "exercise") ?>:</b></td>
- <td>
- <?php
- choose_from_menu($grades, "grade", "$form->grade", "");
- helpbutton("grade", get_string("gradeforsubmission", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("gradingstrategy", "exercise") ?>:</b></td>
- <td>
- <?php
- choose_from_menu($EXERCISE_TYPE, "gradingstrategy", $form->gradingstrategy, "");
- helpbutton("gradingstrategy", get_string("gradingstrategy", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("handlingofmultiplesubmissions", "exercise") ?>:</b></td>
- <td>
- <?php
- $options[0] = get_string("usemean", "exercise"); $options[1] = get_string("usemaximum", "exercise");
- choose_from_menu($options, "usemaximum", $form->usemaximum, "");
- helpbutton("usemax", get_string("handlingofmultiplesubmissions", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("numberofassessmentelements", "exercise") ?>:</b></td>
- <td valign="middle">
- <?php
- for ($i=20; $i>=0; $i--) {
- $numbers[$i] = $i;
- }
- choose_from_menu($numbers, "nelements", "$form->nelements", "");
- helpbutton("nelements", get_string("numberofassessmentelements", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("comparisonofassessments", "exercise") ?>:</b></td>
- <td>
- <?php
- // set up comparison names
- foreach ($EXERCISE_ASSESSMENT_COMPS as $KEY => $COMPARISON) {
- $COMPARISONS[] = $COMPARISON['name'];
- }
- choose_from_menu($COMPARISONS, "assessmentcomps", $form->assessmentcomps, "");
- helpbutton("comparisonofassessments", get_string("comparisonofassessments", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("usepassword", "exercise"); ?>:</b></td>
- <td>
- <?php
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "usepassword", $form->usepassword, "");
- helpbutton("usepassword", get_string("usepassword", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("password"); ?>:</b></td>
- <td>
- <input type="text" name="password" size="10" value="" alt="<?php print_string("password"); ?>" /> <?php echo " (".get_string("leavetokeep").")"; ?>
- <?php helpbutton("password", get_string("password"), "exercise"); ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("maximumsize", "exercise") ?>:</b></td>
- <td>
- <?php
- $sizelist = array("10Kb", "50Kb", "100Kb", "500Kb", "1Mb", "2Mb", "5Mb", "10Mb", "20Mb", "50Mb");
- $maxsize = get_max_upload_file_size();
- $sizeinlist = false;
- foreach ($sizelist as $size) {
- $sizebytes = get_real_size($size);
- if ($sizebytes < $maxsize) {
- $filesize[$sizebytes] = $size;
- }
- if ($form->maxbytes == $sizebytes) {
- $sizeinlist = true;
- }
- }
- $filesize[$maxsize] = display_size($maxsize);
- if (!$sizeinlist) {
- $form->maxbytes = get_real_size("500K");
- }
- ksort($filesize, SORT_NUMERIC);
- choose_from_menu($filesize, "maxbytes", "$form->maxbytes", "");
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("deadline", "exercise") ?>:</b></td>
- <td><?php
- print_date_selector("deadlineday", "deadlinemonth", "deadlineyear", $form->deadline);
- echo " - ";
- print_time_selector("deadlinehour", "deadlineminute", $form->deadline);
- ?></td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("numberofentriesinleaguetable", "exercise") ?>:</b></td>
- <td><?php
- unset($numbers);
- $numbers[22] = 'All';
- $numbers[21] = 50;
- for ($i=20; $i>=0; $i--) {
- $numbers[$i] = $i;
- }
- choose_from_menu($numbers, "showleaguetable", "$form->showleaguetable", "");
- helpbutton("leaguetable", get_string("numberofentriesinleaguetable", "exercise"), "exercise");
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("hidenamesfromstudents", "exercise", $course->students) ?>:</b></td>
- <td><?php
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "anonymous", $form->anonymous, "");
- helpbutton("leaguetablenames", get_string("hidenamesfromstudents", "exercise", $course->students), "exercise");
- ?>
- </td>
-</tr>
-<?php print_standard_coursemodule_settings($form); ?>
-<tr>
- <td colspan="2">
-
-<center>
-<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") ?>" />
-<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
-</center>
-
- </td>
-</tr>
-
-</table>
-</form>
--- /dev/null
+<?php
+require_once ('moodleform_mod.php');
+
+class exercise_mod_form extends moodleform_mod {
+
+ function definition() {
+
+ global $CFG, $COURSE, $EXERCISE_TYPE, $EXERCISE_ASSESSMENT_COMPS;
+ $mform =& $this->_form;
+ $renderer =& $mform->defaultRenderer();
+
+//-------------------------------------------------------------------------------
+ $mform->addElement('header', 'general', get_string('general', 'form'));
+
+ $mform->addElement('text', 'name', get_string('title', 'exercise'));
+ $mform->setType('name', PARAM_TEXT);
+ $mform->addRule('name', null, 'required', null, 'client');
+
+ $mform->addElement('static', 'description', get_string('description', 'exercise'), get_string('descriptionofexercise', 'exercise', $COURSE->students));
+
+ $filesize = array();
+ $sizelist = array('10Kb', '50Kb', '100Kb', '500Kb', '1Mb', '2Mb', '5Mb', '10Mb', '20Mb', '50Mb');
+ $maxsize = get_max_upload_file_size();
+ foreach ($sizelist as $size) {
+ $sizebytes = get_real_size($size);
+ if ($sizebytes < $maxsize) {
+ $filesize[$sizebytes] = $size;
+ }
+ }
+ $filesize[$maxsize] = display_size($maxsize);
+ ksort($filesize, SORT_NUMERIC);
+ $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'exercise'), $filesize);
+ $mform->setHelpButton('maxbytes', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
+ $mform->setDefault('maxbytes', get_real_size('500K'));
+
+ $mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'exercise'));
+
+ $numbers = array();
+ $numbers[22] = 'All';
+ $numbers[21] = 50;
+ for ($i=20; $i>=0; $i--) {
+ $numbers[$i] = $i;
+ }
+//-------------------------------------------------------------------------------
+ $mform->addElement('header', 'leaguetablehdr', get_string('leaguetable', 'exercise'));
+ $mform->addElement('select', 'showleaguetable', get_string('numberofentriesinleaguetable', 'exercise'), $numbers);
+ $mform->setHelpButton('showleaguetable', array('leaguetable', get_string('numberofentriesinleaguetable', 'exercise'), 'exercise'));
+
+ $mform->addElement('selectyesno', 'anonymous', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), $numbers);
+ $mform->setHelpButton('anonymous', array('leaguetablenames', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), 'exercise'));
+
+//-------------------------------------------------------------------------------
+ $mform->addElement('header', 'gradeshdr', get_string('grades'));
+ $grades = array();
+ for ($i=100; $i>=0; $i--) {
+ $grades[$i] = $i;
+ }
+ $mform->addElement('select', 'gradinggrade', get_string('gradeforstudentsassessment', 'exercise', $COURSE->student), $grades);
+ $mform->setHelpButton('gradinggrade', array('gradinggrade', get_string('gradinggrade', 'exercise'), 'exercise'));
+ $mform->setDefault('gradinggrade', 100);
+
+ $mform->addElement('select', 'grade', get_string('gradeforsubmission', 'exercise'), $grades);
+ $mform->setHelpButton('grade', array('grade', get_string('gradeforsubmission', 'exercise'), 'exercise'));
+ $mform->setDefault('grade', 100);
+
+ $mform->addElement('select', 'gradingstrategy', get_string('gradingstrategy', 'exercise'), $EXERCISE_TYPE);
+ $mform->setHelpButton('gradingstrategy', array('gradingstrategy', get_string('gradingstrategy', 'exercise'), 'exercise'));
+ $mform->setDefault('gradingstrategy', 1);
+
+ $options= array(get_string('usemean', 'exercise'), get_string('usemaximum', 'exercise'));
+ $mform->addElement('select', 'usemaximum', get_string('handlingofmultiplesubmissions', 'exercise'), $options);
+ $mform->setHelpButton('usemaximum', array('usemax', get_string('handlingofmultiplesubmissions', 'exercise'), 'exercise'));
+ $mform->setDefault('usemaximum', 0);
+
+ $options= array();
+ for ($i=20; $i>=0; $i--) {
+ $options[$i] = $i;
+ }
+ $mform->addElement('select', 'nelements', get_string('numberofassessmentelements', 'exercise'), $options);
+ $mform->setHelpButton('nelements', array('nelements', get_string('numberofassessmentelements', 'exercise'), 'exercise'));
+ $mform->setDefault('nelements', 1);
+
+ $COMPARISONS=array();
+ foreach ($EXERCISE_ASSESSMENT_COMPS as $KEY => $COMPARISON) {
+ $COMPARISONS[] = $COMPARISON['name'];
+ }
+ $mform->addElement('select', 'assessmentcomps', get_string('comparisonofassessments', 'exercise'), $options);
+ $mform->setHelpButton('assessmentcomps', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
+ $mform->setDefault('assessmentcomps', 2);
+
+//-------------------------------------------------------------------------------
+ $mform->addElement('header', 'passwordhdr', get_string('password'));
+ $mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'exercise'));
+ $mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
+ $mform->setDefault('usepassword', 0);
+
+ $mform->addElement('text', 'password', get_string('password'));
+ $mform->setHelpButton('password', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
+ $mform->setType('password', PARAM_RAW);
+
+//-------------------------------------------------------------------------------
+ $this->standard_coursemodule_elements();
+//-------------------------------------------------------------------------------
+
+ $buttonarray=array();
+ $buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges'));
+ $buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel'));
+ $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
+ $renderer->addStopFieldsetElements('buttonar');
+ }
+
+
+
+}
+?>
\ No newline at end of file