if (!empty($add)){
$modname=$add;
if (file_exists("../mod/$modname/mod_form.php")) {
- $id = required_param('id', PARAM_INT);
- $section = required_param('section', PARAM_INT);
+ $id = required_param('id', PARAM_INT);
+ $section = required_param('section', PARAM_INT);
+ $type = optional_param('type', '', PARAM_ALPHA);
$returntomod = optional_param('return', 0, PARAM_BOOL);
- redirect("modedit.php?add=$add&course=$id§ion=$section&return=$returntomod");
+ redirect("modedit.php?add=$add&type=$type&course=$id§ion=$section&return=$returntomod");
}
}elseif (!empty($update)){
if (!$modname=get_field_sql("SELECT md.name
}
+ function setup_elements(&$mform) {
+
+ }
+
/**
* Print the setup form for the current assignment type
*
+++ /dev/null
-<?php
- require_once("$CFG->dirroot/mod/assignment/lib.php");
-
- if (empty($form->name)) {
- $form->name = "";
- }
- if (empty($form->description)) {
- $form->description = "";
- }
- if (empty($form->format)) {
- $form->format = "";
- }
- if (empty($form->assignmenttype)) {
- $form->assignmenttype = "uploadsingle";
- }
- if (!isset($form->grade)) {
- $form->grade = 100;
- }
- if (!isset($form->timedue)) {
- $form->timedue = time()+7*24*3600;
- }
- if (!isset($form->timeavailable)) {
- $form->timeavailable = time();
- }
- if (!isset($form->preventlate)) {
- $form->preventlate = 0;
- }
- if (empty($form->maxbytes)) {
- $form->maxbytes = $CFG->assignment_maxbytes;
- }
-
-?>
-<script type="text/javascript">
-//<![CDATA[
- var dueitems = ['dueday','duemonth','dueyear','duehour', 'dueminute', 'preventlate'];
- var availableitems = ['availableday','availablemonth','availableyear','availablehour', 'availableminute'];
-//]]>
-</script>
-
-<form id="form" method="post" action="../mod/assignment/details.php">
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("assignmentname", "assignment") ?>:</b></td>
- <td>
- <input type="text" name="name" size="60" value="<?php p($form->name) ?>" />
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string("description", "assignment") ?>:</b>
- <br /><br />
- <?php
- helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
- echo "<br />";
- helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
- echo "<br />";
- if ($usehtmleditor) {
- helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
- } else {
- emoticonhelpbutton("form", "description");
- }
- ?>
- </td>
- <td>
- <?php
- print_textarea($usehtmleditor, 20, 60, 680, 400, "description", $form->description);
-
- if ($usehtmleditor) {
- echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
- } else {
- echo '<div align="right">';
- helpbutton("textformat", get_string("formattexttype"));
- print_string("formattexttype");
- echo ': ';
- if (!$form->format) {
- $form->format = $defaultformat;
- }
- choose_from_menu(format_text_menu(), "format", $form->format, "");
- echo '</div>';
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
-<td align="right"><b><?php print_string("grade") ?>:</b></td>
- <td>
- <?php
- print_grade_menu($course->id, "grade", "$form->grade");
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("availabledate","assignment") ?>:</b></td>
- <td>
- <input name="availableenable" type="checkbox" value="1" alt="<?php print_string('availabledate', 'assignment') ?>" onclick="return lockoptions('form', 'availableenable', availableitems)" <?php if ($form->timeavailable) echo 'checked="checked"' ?> />
- <?php
- print_date_selector("availableday", "availablemonth", "availableyear", $form->timeavailable);
- echo " - ";
- print_time_selector("availablehour", "availableminute", $form->timeavailable);
- ?>
- <input type="hidden" name="havailableday" value="0" />
- <input type="hidden" name="havailablemonth" value="0" />
- <input type="hidden" name="havailableyear" value="0" />
- <input type="hidden" name="havailablehour" value="0" />
- <input type="hidden" name="havailableminute" value="0" />
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("duedate", "assignment") ?>:</b></td>
- <td>
- <input name="dueenable" type="checkbox" value="1" alt="<?php print_string('duedate', 'assignment') ?>" onclick="return lockoptions('form', 'dueenable', dueitems)" <?php if ($form->timedue) echo 'checked="checked"' ?> />
- <?php
- print_date_selector("dueday", "duemonth", "dueyear", $form->timedue);
- echo " - ";
- print_time_selector("duehour", "dueminute", $form->timedue);
- ?>
- <input type="hidden" name="hdueday" value="0" />
- <input type="hidden" name="hduemonth" value="0" />
- <input type="hidden" name="hdueyear" value="0" />
- <input type="hidden" name="hduehour" value="0" />
- <input type="hidden" name="hdueminute" value="0" />
- </td>
-</tr>
-
-<tr valign="top">
- <td> </td>
- <td><?php print_string('preventlate', 'assignment') ?>:
- <?php
- $options[0] = get_string('no'); $options[1] = get_string('yes');
- choose_from_menu($options, 'preventlate', $form->preventlate, '');
- ?>
- <input type="hidden" name="hpreventlate" value="0" />
- </td>
-</tr>
-
-<tr valign="top">
- <td colspan="2"> </td>
-</tr>
-
-<tr valign="top">
- <td align="right"><b><?php print_string("assignmenttype", "assignment") ?>:</b></td>
- <td>
- <?php
- $ASSIGNMENT_TYPES = assignment_types();
- choose_from_menu($ASSIGNMENT_TYPES, 'assignmenttype', $form->assignmenttype, '');
- helpbutton('types', get_string('assignmenttype', 'assignment'), 'assignment');
- ?>
- </td>
-</tr>
-
-<?php print_standard_coursemodule_settings($form); ?>
-
-</table>
-<br />
-<center>
-<?php
- // Add hidden fields for all the ones not defined on this page
- $assvars = array('course','coursemodule','section','module','modulename','instance','mode',
- 'resubmit','emailteachers','maxbytes', 'var1','var2','var3','var4','var5');
-
- foreach ($assvars as $assname) {
- if (isset($form->$assname)) {
- echo '<input type="hidden" name="'.$assname.'" value="'.s($form->$assname).'" />'."\n";
- }
- }
-?>
-<input type="submit" value="<?php print_string('next') ?> »" />
-<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
-</center>
-</form>
-
-<script type="text/javascript">
-<?php
- if (!$form->timedue) echo "lockoptions('form','dueenable', dueitems);";
- if (!$form->timeavailable) echo "lockoptions('form','availableenable', availableitems);";
-?>
-</script>
-
--- /dev/null
+<?php
+require_once ('moodleform_mod.php');
+
+class mod_assignment_mod_form extends moodleform_mod {
+
+ function definition() {
+ global $CFG;
+ $mform =& $this->_form;
+
+ // this hack is needed for different settings of each subtype
+ if (!empty($this->_instance)) {
+ if($ass = get_record('assignment', 'id', (int)$this->_instance)) {
+ $type = $ass->assignmenttype;
+ } else {
+ error('incorrect assignment');
+ }
+ } else {
+ $type = required_param('type', PARAM_ALPHA);
+ }
+ $mform->addElement('hidden', 'assignmenttype', $type);
+ $mform->setDefault('assignmenttype', $type);
+ $mform->addElement('hidden', 'type', $type);
+ $mform->setDefault('type', $type);
+
+ require($CFG->dirroot.'/mod/assignment/type/'.$type.'/assignment.class.php');
+ $assignmentclass = 'assignment_'.$type;
+ $assignmentinstance = new $assignmentclass();
+
+//-------------------------------------------------------------------------------
+ $mform->addElement('header', 'general', get_string('general', 'form'));
+
+// $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment'));
+
+ $mform->addElement('text', 'name', get_string('chatname', 'chat'));
+ $mform->setType('name', PARAM_TEXT);
+ $mform->addRule('name', null, 'required', null, 'client');
+
+ $mform->addElement('htmleditor', 'description', get_string('chatintro', 'chat'));
+ $mform->setType('description', PARAM_RAW);
+ $mform->setHelpButton('description', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
+ $mform->addRule('description', get_string('required'), 'required', null, 'client');
+
+ $mform->addElement('modgrade', 'grade', get_string('grade'));
+ $mform->setDefault('grade', 100);
+
+ $mform->addElement('date_time_selector', 'timeavailable', get_string('availabledate', 'assignment'), array('optional'=>true));
+ $mform->setDefault('timeavailable', time());
+ $mform->addElement('date_time_selector', 'timedue', get_string('duedate', 'assignment'), array('optional'=>true));
+ $mform->setDefault('timedue', time()+7*24*3600);
+
+ $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
+
+ $mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions);
+ $mform->setDefault('preventlate', 0);
+
+ $mform->addElement('header', 'typedesc', get_string('type'.$type,'assignment'));
+ $assignmentinstance->setup_elements($mform);
+
+ $this->standard_coursemodule_elements();
+
+ $this->add_action_buttons();
+ }
+
+
+
+}
+?>
\ No newline at end of file
+++ /dev/null
-<div class="modform">
-<input type="submit" value="<?php print_string("continue") ?>" />
-</div>
}
}
+ function setup_elements(&$mform) {
+ global $CFG, $COURSE;
+
+ $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
+
+ $mform->addElement('select', 'resubmit', get_string("allowresubmit", "assignment"), $ynoptions);
+ $mform->setHelpButton('resubmit', array('resubmit', get_string('allowresubmit', 'assignment'), 'assignment'));
+ $mform->setDefault('resubmit', 0);
+
+ $mform->addElement('select', 'emailteachers', get_string("emailteachers", "assignment"), $ynoptions);
+ $mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment'));
+ $mform->setDefault('emailteachers', 0);
+
+ $mform->addElement('select', 'var1', get_string("commentinline", "assignment"), $ynoptions);
+ $mform->setHelpButton('var1', array('commentinline', get_string('commentinline', 'assignment'), 'assignment'));
+ $mform->setDefault('var1', 0);
+
+ }
+
}
class mod_assignment_online_edit_form extends moodleform {
+++ /dev/null
-<?php
- if (!isset($form->resubmit)) {
- $form->resubmit = 1;
- }
- if (empty($form->emailteachers)) {
- $form->emailteachers = 0;
- }
- if (empty($form->var1)) {
- $form->var1 = 0;
- }
-?>
-
-<table class="modform" cellpadding="5" cellspacing="0">
-
-<tr>
- <td align="right"><b><?php print_string("allowresubmit", "assignment") ?>:</b></td>
- <td>
- <?php
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "resubmit", $form->resubmit, "");
- helpbutton("resubmit", get_string("allowresubmit", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("emailteachers", "assignment") ?>:</b></td>
- <td>
- <?php
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "emailteachers", $form->emailteachers, "");
- helpbutton("emailteachers", get_string("emailteachers", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("commentinline", "assignment") ?>:</b></td>
- <td>
- <?php
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "var1", $form->var1, "");
- helpbutton("commentinline", get_string("commentinline", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-
-</table>
-
-<div class="modform">
-<br />
-<input type="submit" value="<?php print_string("continue") ?>" />
-</div>
return 0;
}
+ function setup_elements(&$mform) {
+ global $CFG, $COURSE;
+
+ $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
+
+ $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
+ $choices[1] = get_string('uploadnotallowed');
+ $choices[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
+ $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $choices);
+ $mform->setDefault('maxbytes', $CFG->assignment_maxbytes);
+
+ $mform->addElement('select', 'resubmit', get_string("allowdeleting", "assignment"), $ynoptions);
+ $mform->setHelpButton('resubmit', array('allowdeleting', get_string('allowdeleting', 'assignment'), 'assignment'));
+ $mform->setDefault('resubmit', 1);
+
+ $options = array();
+ for($i = 1; $i <= 20; $i++) {
+ $options[$i] = $i;
+ }
+ $mform->addElement('select', 'var1', get_string("allowmaxfiles", "assignment"), $options);
+ $mform->setHelpButton('var1', array('allowmaxfiles', get_string('allowmaxfiles', 'assignment'), 'assignment'));
+ $mform->setDefault('var1', 3);
+
+ $mform->addElement('select', 'var2', get_string("allownotes", "assignment"), $ynoptions);
+ $mform->setHelpButton('var2', array('allownotes', get_string('allownotes', 'assignment'), 'assignment'));
+ $mform->setDefault('var2', 0);
+
+ $mform->addElement('select', 'var3', get_string("hideintro", "assignment"), $ynoptions);
+ $mform->setHelpButton('var3', array('hideintro', get_string('hideintro', 'assignment'), 'assignment'));
+ $mform->setDefault('var3', 0);
+
+ $mform->addElement('select', 'emailteachers', get_string("emailteachers", "assignment"), $ynoptions);
+ $mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment'));
+ $mform->setDefault('emailteachers', 0);
+
+
+ }
+
}
class mod_assignment_upload_notes_form extends moodleform {
+++ /dev/null
-<?php
- if (empty($form->var1)) {
- $form->var1 = 3; // max number of uploaded files
- }
- if (empty($form->var2)) {
- $form->var2 = 0; // enable notes
- }
- if (empty($form->var3)) {
- $form->var3 = 0; // force intro hiding before available date
- }
- if (empty($form->resubmit)) {
- $form->resubmit = 1; // allow deleting
- }
- if (empty($form->maxbytes)) {
- $form->maxbytes = $CFG->assignment_maxbytes;
- }
- if (empty($form->emailteachers)) {
- $form->emailteachers = 0;
- }
-?>
-
-<table class="modform" cellpadding="5" cellspacing="0">
-
-<tr valign="top">
- <td align="right"><b><?php print_string("maximumsize", "assignment") ?>:</b></td>
- <td>
- <?php
- $choices = get_max_upload_sizes($CFG->maxbytes, $this->course->maxbytes);
- choose_from_menu ($choices, "maxbytes", $form->maxbytes, "");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("allowdeleting", "assignment") ?>:</b></td>
- <td>
- <?php
- $options = array(0=>get_string("no"), 1=>get_string("yes"));
- choose_from_menu($options, "resubmit", $form->resubmit, "");
- helpbutton("allowdeleting", get_string("allowdeleting", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("allowmaxfiles", "assignment") ?>:</b></td>
- <td>
- <?php
- $options = array();
- for($i = 1; $i <= 20; $i++) {
- $options[$i] = $i;
- }
- choose_from_menu($options, "var1", $form->var1, "");
- helpbutton("allowmaxfiles", get_string("allowmaxfiles", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("allownotes", "assignment") ?>:</b></td>
- <td>
- <?php
- $options = array(0=>get_string("no"), 1=>get_string("yes"));
- choose_from_menu($options, "var2", $form->var2, "");
- helpbutton("allownotes", get_string("allownotes", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("hideintro", "assignment") ?>:</b></td>
- <td>
- <?php
- $options = array(0=>get_string("no"), 1=>get_string("yes"));
- choose_from_menu($options, "var3", $form->var3, "");
- helpbutton("hideintro", get_string("hideintro", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("emailteachers", "assignment") ?>:</b></td>
- <td>
- <?php
- $options = array(0=>get_string("no"), 1=>get_string("yes"));
- choose_from_menu($options, "emailteachers", $form->emailteachers, "");
- helpbutton("emailteachers", get_string("emailteachers", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-</table>
-
-<div class="modform">
-<br />
-<input type="submit" value="<?php print_string("continue") ?>" />
-</div>
$this->view_footer();
}
+ function setup_elements(&$mform) {
+ global $CFG, $COURSE;
+ $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
+ $mform->addElement('select', 'resubmit', get_string("allowresubmit", "assignment"), $ynoptions);
+ $mform->setHelpButton('resubmit', array('resubmit', get_string('allowresubmit', 'assignment'), 'assignment'));
+ $mform->setDefault('resubmit', 0);
+
+ $mform->addElement('select', 'emailteachers', get_string("emailteachers", "assignment"), $ynoptions);
+ $mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment'));
+ $mform->setDefault('emailteachers', 0);
+
+ $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
+ $choices[1] = get_string('uploadnotallowed');
+ $choices[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
+ $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $choices);
+ $mform->setDefault('maxbytes', $CFG->assignment_maxbytes);
+
+ }
}
+++ /dev/null
-<?php
- if (empty($form->resubmit)) {
- $form->resubmit = 0;
- }
- if (empty($form->maxbytes)) {
- $form->maxbytes = $CFG->assignment_maxbytes;
- }
- if (empty($form->emailteachers)) {
- $form->emailteachers = '';
- }
-?>
-
-<table class="modform" cellpadding="5" cellspacing="0">
-
-<tr valign="top">
- <td align="right"><b><?php print_string("maximumsize", "assignment") ?>:</b></td>
- <td>
- <?php
- $choices = get_max_upload_sizes($CFG->maxbytes, $this->course->maxbytes);
- choose_from_menu ($choices, "maxbytes", $form->maxbytes, "");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("allowresubmit", "assignment") ?>:</b></td>
- <td>
- <?php
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "resubmit", $form->resubmit, "");
- helpbutton("resubmit", get_string("allowresubmit", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-<tr>
- <td align="right"><b><?php print_string("emailteachers", "assignment") ?>:</b></td>
- <td>
- <?php
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "emailteachers", $form->emailteachers, "");
- helpbutton("emailteachers", get_string("emailteachers", "assignment"), "assignment");
- ?>
- </td>
-</tr>
-
-</table>
-
-<div class="modform">
-<br />
-<input type="submit" value="<?php print_string("continue") ?>" />
-</div>