function definition() { global $CFG; $mform =& $this->_form; $helplink = get_string('mossexplain', 'plagiarism_moss'); $mform->addElement('html', $helplink); $mform->addElement('checkbox', 'mossenabled', get_string('mossenabled', 'plagiarism_moss')); $mform->setDefault('mossenabled', false); $mform->addElement('text', 'mossuserid', get_string('mossuserid', 'plagiarism_moss')); $mform->addHelpButton('mossuserid', 'mossuserid', 'plagiarism_moss'); $mform->setDefault('mossuserid', ''); $mform->disabledIf('mossuserid', 'mossenabled'); $choices = moss_get_supported_languages(); $mform->addElement('select', 'defaultlanguage', get_string('defaultlanguage', 'plagiarism_moss'), $choices); $mform->disabledIf('defaultlanguage', 'mossenabled'); $mform->addElement('checkbox', 'showidnumber', get_string('showidnumber', 'plagiarism_moss')); $mform->setDefault('showidnumber', false); $mform->disabledIf('showidnumber', 'mossenabled'); if ($CFG->ostype == 'WINDOWS') { $mform->addElement('text', 'cygwinpath', get_string('cygwinpath', 'plagiarism_moss')); $mform->setDefault('cygwinpath', 'C:\cygwin'); $mform->setType('cygwinpath', PARAM_RAW); $mform->disabledIf('cygwinpath', 'mossenabled'); } $this->add_action_buttons(false); }
/** * (non-PHPdoc) * @see plagiarism_plugin::get_form_elements_module() */ public function get_form_elements_module($mform, $context) { global $DB; if (!moss_enabled()) { return; } // Construct the form $mform->addElement('header', 'mossdesc', get_string('moss', 'plagiarism_moss')); $mform->addHelpButton('mossdesc', 'moss', 'plagiarism_moss'); $mform->addElement('checkbox', 'enabled', get_string('mossenabled', 'plagiarism_moss')); $mform->addElement('date_time_selector', 'timetomeasure', get_string('timetomeasure', 'plagiarism_moss'), array('optional' => true)); $mform->addHelpButton('timetomeasure', 'timetomeasure', 'plagiarism_moss'); $mform->disabledIf('timetomeasure', 'enabled'); $mform->addElement('text', 'tag', get_string('tag', 'plagiarism_moss')); $mform->addHelpButton('tag', 'tag', 'plagiarism_moss'); $mform->setType('tag', PARAM_TEXT); $mform->disabledIf('tag', 'enabled'); $mform->addElement('text', 'sensitivity', get_string('sensitivity', 'plagiarism_moss'), 'size = "10"'); $mform->addHelpButton('sensitivity', 'sensitivity', 'plagiarism_moss'); $mform->setType('sensitivity', PARAM_NUMBER); $mform->addRule('sensitivity', null, 'numeric', null, 'client'); $mform->disabledIf('sensitivity', 'enabled'); // multi configs for ($index = 0; $index < MOSS_MAX_PATTERNS; $index++) { if ($index == 0) { $subheader = get_string('configrequired', 'plagiarism_moss', $index + 1); } else { $subheader = get_string('configoptional', 'plagiarism_moss', $index + 1); } $subheader = html_writer::tag('strong', $subheader); $mform->addElement('static', 'subheader' . $index, $subheader); $mform->addElement('text', 'filepatterns' . $index, get_string('filepatterns', 'plagiarism_moss')); $mform->addHelpButton('filepatterns' . $index, 'filepatterns', 'plagiarism_moss'); $mform->setType('filepatterns' . $index, PARAM_TEXT); $mform->disabledIf('filepatterns' . $index, 'enabled'); $choices = moss_get_supported_languages(); $mform->addElement('select', 'language' . $index, get_string('language', 'plagiarism_moss'), $choices); $mform->disabledIf('language' . $index, 'enabled'); $mform->setDefault('language' . $index, get_config('plagiarism_moss', 'defaultlanguage')); $mform->addElement('filemanager', 'basefile' . $index, get_string('basefile', 'plagiarism_moss'), null, array('subdirs' => 0)); $mform->addHelpButton('basefile' . $index, 'basefile', 'plagiarism_moss'); $mform->disabledIf('basefile' . $index, 'enabled'); if ($index != 0) { $mform->setAdvanced('subheader' . $index); $mform->setAdvanced('filepatterns' . $index); $mform->setAdvanced('language' . $index); $mform->setAdvanced('basefile' . $index); } } // set config values $cmid = optional_param('update', 0, PARAM_INT); //there doesn't seem to be a way to obtain the current cm a better way - $this->_cm is not available here. if ($cmid != 0 and $moss = $DB->get_record('plagiarism_moss', array('cmid' => $cmid))) { // configed $mform->setDefault('enabled', $moss->enabled); $mform->setDefault('timetomeasure', $moss->timetomeasure); $mform->setDefault('tag', $DB->get_field('plagiarism_moss_tags', 'name', array('id' => $moss->tag))); if (!empty($moss->sensitivity)) { $mform->setDefault('sensitivity', $moss->sensitivity); } $mform->addElement('hidden', 'mossid', $moss->id); $subconfigs = $DB->get_records('plagiarism_moss_configs', array('moss' => $moss->id)); $index = 0; foreach ($subconfigs as $subconfig) { $mform->setDefault('filepatterns' . $index, $subconfig->filepatterns); $mform->setDefault('language' . $index, $subconfig->language); $mform->addElement('hidden', 'configid' . $index, $subconfig->id); $context = get_system_context(); $draftitemid = 0; file_prepare_draft_area($draftitemid, $context->id, 'plagiarism_moss', 'basefiles', $subconfig->id); $mform->setDefault('basefile' . $index, $draftitemid); $index++; } } else { // new config $mform->setDefault('enabled', 0); $mform->setDefault('tag', ''); $mform->setDefault('filepatterns0', '*'); // leave other subconfig empty } }