';
$mform->addElement('html', $html_div);
//Applies only iLM iGeom
$mform->addElement('selectyesno', 'special_param1', get_string('special_param', 'iassign')); //$ynoptions
$mform->setDefault('special_param1', 0);
$mform->addHelpButton('special_param1', 'helpspecial_param', 'iassign');
//-----------------------------------------------------------------------------
//Applies only when the iLM is automatic evaluate.
$mform->addElement('header', 'id_automatic_evaluate', get_string('only_automatic_evaluate', 'iassign'));
// Using automatic evaluation activity? 0 - no / 1 – yes
$mform->addElement('selectyesno', 'automatic_evaluate', get_string('automatic_evaluate', 'iassign'), array('onChange' => 'disable_answer(this.value);'));
$mform->disabledIf('automatic_evaluate', 'type_iassign', 'eq', 1); //activity does not display if the type example
$mform->setDefault('automatic_evaluate', 0);
// @todo Ver código comentado
//$mform->addHelpButton('automatic_evaluate', 'helpautomatic_evaluate', 'iassign');
//Show automatic evaluation results to students? 0 - no / 1 - yes
$mform->addElement('selectyesno', 'show_answer', get_string('show_answer', 'iassign'));
$mform->disabledIf('show_answer', 'type_iassign', 'eq', 1); //activity does not display if the type example
// $mform->disabledIf('show_answer', 'automatic_evaluate', 'neq', 0);
$mform->setDefault('show_answer', 0);
//$mform->addHelpButton('show_answer', 'helpshow_answer', 'iassign');
//-----------------------------------------------------------------------------
// Adding the "duration_activity" fieldset, where all the common settings are showed
$mform->addElement('header', 'duration_activity', get_string('duration_activity', 'iassign'));
$mform->addElement('date_time_selector', 'timeavailable', get_string('availabledate', 'iassign'));
$mform->setDefault('timeavailable', time());
$mform->disabledIf('timeavailable', 'type_iassign', 'eq', 1); // activity does not display if the type example
$mform->addElement('date_time_selector', 'timedue', get_string('duedate', 'iassign'));
$mform->setDefault('timedue', time() + 7 * 24 * 3600);
$mform->disabledIf('timedue', 'type_iassign', 'eq', 1); //activity does not display if the type example
//Allow sending late? 0 - no or unlocked / 1 - yes or locked
$mform->addElement('selectyesno', 'preventlate', get_string('preventlate', 'iassign'));
$mform->setDefault('preventlate', 0);
$mform->addHelpButton('preventlate', 'helppreventlate', 'iassign');
$mform->disabledIf('preventlate', 'type_iassign', 'eq', 1); //activity does not display if the type example
$mform->disabledIf('preventlate', 'type_iassign', 'eq', 2); //activity does not display if the type test
//Allow test after delivery? 0 - no or unlocked / 1 - yes or locked
$mform->addElement('selectyesno', 'test', get_string('permission_test', 'iassign'));
$mform->setDefault('test', 0);
$mform->addHelpButton('test', 'helptest', 'iassign');
$mform->disabledIf('test', 'type_iassign', 'eq', 1); //activity does not display if the type example
$mform->disabledIf('test', 'type_iassign', 'eq', 2); //activity does not display if the type test
//--------------
$mform->addElement('header', 'op_val', get_string('op_val', 'iassign'));
$mform->addElement('modgrade', 'grade', get_string('grade', 'iassign'));
$mform->setDefault('grade', 100);
$mform->disabledIf('grade', 'type_iassign', 'eq', 1); //activity does not display if the type example
$mform->disabledIf('grade', 'type_iassign', 'eq', 2); //activity does not display if the type test
$max_experiment_options = array(0 => get_string('ilimit', 'iassign'));
for ($i = 1; $i <= 20; $i++)
$max_experiment_options[$i] = $i;
$mform->addElement('select', 'max_experiment', get_string('experiment', 'iassign'), $max_experiment_options);
$mform->setDefault('max_experiment', 0);
$mform->addHelpButton('max_experiment', 'helpexperiment', 'iassign');
$mform->disabledIf('max_experiment', 'type_iassign', 'eq', 1); //activity does not display if the type example
$mform->disabledIf('max_experiment', 'type_iassign', 'eq', 2); //activity does not display if the type test
if ($COURSE->iassign_list) {
//-------------- dependency
$mform->addElement('header', 'headerdependency', get_string('dependency', 'iassign'));
$mform->addHelpButton('headerdependency', 'helpdependency', 'iassign');
foreach ($COURSE->iassign_list as $iassign) {
$tmp = 'iassign_list[' . $iassign->id . ']';
if ($iassign->enable == 1)
$mform->addElement('checkbox', $tmp, $iassign->name);
} //foreach ($COURSE->iassign_list as $iassign)
} //if ($COURSE->iassign_list)
$mform->addElement('hidden', 'dependency');
$mform->setType('dependency', PARAM_RAW);
//-------------- config
$mform->addElement('header', 'config', get_string('general', 'iassign'));
$visibleoptions = array(1 => get_string('show'), 0 => get_string('hide'));
$mform->addElement('select', 'visible', get_string('visible', 'iassign'), $visibleoptions);
$mform->setDefault('visible', 0);
//-------------------------------------------------------------------------------
// Hidden fields
$mform->addElement('hidden', 'action');
$mform->setType('action', PARAM_TEXT);
$mform->addElement('hidden', 'oldname');
$mform->setType('oldname', PARAM_TEXT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_TEXT);
$mform->addElement('hidden', 'iassign_id');
$mform->setType('iassign_id', PARAM_TEXT);
$mform->addElement('hidden', 'file', '0');
$mform->setType('file', PARAM_INT);
$mform->addElement('hidden', 'filename');
$mform->setType('filename', PARAM_TEXT);
$mform->addElement('hidden', 'fileold');
$mform->setType('fileold', PARAM_TEXT);
$mform->addElement('hidden', 'iassignid');
$mform->setType('iassignid', PARAM_TEXT);
$mform->addElement('hidden', 'author_name');
$mform->setType('author_name', PARAM_TEXT);
$mform->addElement('hidden', 'author_modified_name');
$mform->setType('author_modified_name', PARAM_TEXT);
$mform->addElement('hidden', 'timecreated');
$mform->setType('timecreated', PARAM_TEXT);
$mform->addElement('hidden', 'position');
$mform->setType('position', PARAM_TEXT);
$mform->addElement('html', $code_javascript);
// add standard elements, common to all modules
$this->add_action_buttons();
} // function definition()
function validation ($data, $files) {
global $COURSE, $DB;
$errors = parent::validation($data, $files);
$mform = & $this->_form;
$errors = array();
if ($mform->elementExists('name')) {
$value = trim($data['name']);
if ($value == '') {
$errors['name'] = get_string('required', 'iassign');
}
}
if ($mform->elementExists('proposition')) {
$value = trim($data['proposition']);
if ($value == '') {
$errors['proposition'] = get_string('required', 'iassign');
}
}
if ($mform->elementExists('file')) {
$value = trim($data['file']);
if ($value == 0) {
$errors['iassign_ilmid'] = get_string('required_iassign_file', 'iassign');
}
}
return $errors;
} // function validation($data, $files)
} // class mod_iassign_form extends moodleform