本文整理汇总了PHP中FormValidator::add_html_editor方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::add_html_editor方法的具体用法?PHP FormValidator::add_html_editor怎么用?PHP FormValidator::add_html_editor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::add_html_editor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create a form validator based on an array of form data:
*
* array(
* 'name' => 'zombie_report_parameters', //optional
* 'method' => 'GET', //optional
* 'items' => array(
* array(
* 'name' => 'ceiling',
* 'label' => 'Ceiling', //optional
* 'type' => 'date',
* 'default' => date() //optional
* ),
* array(
* 'name' => 'active_only',
* 'label' => 'ActiveOnly',
* 'type' => 'checkbox',
* 'default' => true
* ),
* array(
* 'name' => 'submit_button',
* 'type' => 'style_submit_button',
* 'value' => get_lang('Search'),
* 'attributes' => array('class' => 'search')
* )
* )
* );
*
* @param array $form_data
*
* @return FormValidator
*/
public static function create($form_data)
{
if (empty($form_data)) {
return null;
}
$form_name = isset($form_data['name']) ? $form_data['name'] : 'form';
$form_method = isset($form_data['method']) ? $form_data['method'] : 'POST';
$form_action = isset($form_data['action']) ? $form_data['action'] : '';
$form_target = isset($form_data['target']) ? $form_data['target'] : '';
$form_attributes = isset($form_data['attributes']) ? $form_data['attributes'] : null;
$form_track_submit = isset($form_data['track_submit']) ? $form_data['track_submit'] : true;
$result = new FormValidator($form_name, $form_method, $form_action, $form_target, $form_attributes, $form_track_submit);
$defaults = array();
foreach ($form_data['items'] as $item) {
$name = $item['name'];
$type = isset($item['type']) ? $item['type'] : 'text';
$label = isset($item['label']) ? $item['label'] : '';
if ($type == 'wysiwyg') {
$element = $result->add_html_editor($name, $label);
} else {
$element = $result->addElement($type, $name, $label);
}
if (isset($item['attributes'])) {
$attributes = $item['attributes'];
$element->setAttributes($attributes);
}
if (isset($item['value'])) {
$value = $item['value'];
$element->setValue($value);
}
if (isset($item['default'])) {
$defaults[$name] = $item['default'];
}
if (isset($item['rules'])) {
$rules = $item['rules'];
foreach ($rules as $rule) {
$message = $rule['message'];
$type = $rule['type'];
$format = isset($rule['format']) ? $rule['format'] : null;
$validation = isset($rule['validation']) ? $rule['validation'] : 'server';
$force = isset($rule['force']) ? $rule['force'] : false;
$result->addRule($name, $message, $type, $format, $validation, $reset, $force);
}
}
}
$result->setDefaults($defaults);
return $result;
}
示例2: return_form
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
*/
public function return_form($url, $action)
{
$oFCKeditor = new FCKeditor('description');
$oFCKeditor->ToolbarSet = 'careers';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '';
$oFCKeditor->CreateHtml();
$form = new FormValidator('career', 'post', $url);
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers', 'Width' => '100%', 'Height' => '250'));
$status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list);
if ($action == 'edit') {
$form->addElement('text', 'created_at', get_lang('CreatedAt'));
$form->freeze('created_at');
}
if ($action == 'edit') {
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
} else {
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
}
// Setting the defaults
$defaults = $this->get($id);
if (!empty($defaults['created_at'])) {
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
}
if (!empty($defaults['updated_at'])) {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
示例3: createForm
//.........这里部分代码省略.........
if (document.getElementById(in_id).style.display == "none") {
document.getElementById(in_id).style.display = "block";
if (document.getElementById(in_id+"Img")) {
document.getElementById(in_id+"Img").html = "' . addslashes(Display::return_icon('div_hide.gif')) . '";
}
} else {
document.getElementById(in_id).style.display = "none";
if (document.getElementById(in_id+"Img")) {
document.getElementById(in_id+"Img").html = "dsdsds' . addslashes(Display::return_icon('div_show.gif')) . '";
}
}
}
}
</script>';
$form->addElement('html', $js);
}
// question name
$form->addElement('text', 'questionName', get_lang('Question'), array('class' => 'span6'));
$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
// Default content.
$isContent = isset($_REQUEST['isContent']) ? intval($_REQUEST['isContent']) : null;
// Question type
$answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : $this->selectType();
$form->addElement('hidden', 'answerType', $answerType);
// html editor
$editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
if (is_array($fck_config)) {
$editor_config = array_merge($editor_config, $fck_config);
}
if (!api_is_allowed_to_edit(null, true)) {
$editor_config['UserStatus'] = 'student';
}
$form->add_html_editor('questionDescription', get_lang('QuestionDescription'), false, false, $editor_config);
// hidden values
$my_id = isset($_REQUEST['myid']) ? intval($_REQUEST['myid']) : null;
$form->addElement('hidden', 'myid', $my_id);
if ($this->type != MEDIA_QUESTION) {
if ($this->exercise->fastEdition == false) {
// Advanced parameters
$form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="advanced_params_options" style="display:none;">');
}
// Level (difficulty).
$select_level = Question::get_default_levels();
$form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);
// Media question.
$course_medias = Question::prepare_course_media_select(api_get_course_int_id());
$form->addElement('select', 'parent_id', get_lang('AttachToMedia'), $course_medias, array('id' => 'parent_id'));
// Categories.
$categoryJS = null;
if (!empty($this->category_list)) {
$trigger = '';
foreach ($this->category_list as $category_id) {
if (!empty($category_id)) {
$cat = new Testcategory($category_id);
if ($cat->id) {
$trigger .= '$("#category_id").trigger("addItem",[{"title": "' . $cat->parent_path . '", "value": "' . $cat->id . '"}]);';
}
}
}
$categoryJS .= '<script>$(function() { ' . $trigger . ' });</script>';
}
$form->addElement('html', $categoryJS);
$form->addElement('select', 'questionCategory', get_lang('Category'), array(), array('id' => 'category_id'));
// Extra fields. (Injecting question extra fields!)
示例4: floatval
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook=' . Security::remove_XSS($_SESSION['gradebook']);
}
if (!$error) {
$token = Security::get_token();
}
$attendance_weight = floatval($attendance_weight);
// display form
$form = new FormValidator('attendance_edit', 'POST', 'index.php?action=attendance_edit&' . api_get_cidreq() . '&attendance_id=' . $attendance_id . $param_gradebook);
$form->addElement('header', '', get_lang('Edit'));
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'attendance_id', $attendance_id);
$form->add_textfield('title', get_lang('Title'), true, array('size' => '50'));
$form->applyFilter('title', 'html_filter');
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
// Adavanced Parameters
if (Gradebook::is_active()) {
if (!empty($attendance_qualify_title) || !empty($attendance_weight)) {
$form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="id_qualify_options" style="display:block">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), array('checked' => 'true', 'onclick' => 'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}'));
$form->addElement('html', '<div id="options_field" style="display:block">');
} else {
$form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="id_qualify_options" style="display:none">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$form->addElement('html', '<div id="options_field" style="display:none">');
}
load_gradebook_select_in_tool($form);
$form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook'));
示例5: array
} else {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:block">');
}
if (count($attendance_select) > 1) {
$form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)'));
} else {
$form->addElement('label', get_lang('Attendances'), '<strong><em>' . get_lang('ThereAreNoAttendancesInsideCourse') . '</em></strong>');
}
$form->addElement('html', '<div id="div_datetime_attendance">');
if (!empty($calendar_select)) {
$form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select, array('id' => 'start_date_select_calendar'));
}
$form->addElement('html', '</div>');
$form->addElement('html', '</div>');
$form->add_textfield('duration_in_hours', get_lang('DurationInHours'), false, array('size' => '3', 'id' => 'duration_in_hours_element', 'autofocus' => 'autofocus'));
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded' => 'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
//$form->addElement('textarea', 'content', get_lang('Content'));
if ($action == 'thematic_advance_add') {
$form->addElement('style_submit_button', null, get_lang('Save'), 'id="add_button" class="save"');
} else {
$form->addElement('style_submit_button', null, get_lang('Save'), 'id="update_button" class="save"');
}
//$form->addElement('html', '<a href="#" id="save_button" onclick="save();">Save</a>');
$attendance_select_item_id = null;
if (count($attendance_select) > 1) {
$i = 1;
foreach ($attendance_select as $key => $attendance_select_item) {
if ($i == 2) {
$attendance_select_item_id = $key;
break;
}
示例6: add_category_form
function add_category_form($in_action, $type = 'simple')
{
$in_action = Security::remove_XSS($in_action);
// Initiate the object
$form = new FormValidator('note', 'post', api_get_self() . '?' . api_get_cidreq() . '&action=' . $in_action . "&type=" . $type);
// Setting the form elements
$form->addElement('header', get_lang('AddACategory'));
$form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
$form->addElement('select', 'parent_id', get_lang('Parent'), array(), array('id' => 'parent_id'));
$form->addElement('style_submit_button', 'SubmitNote', get_lang('AddTestCategory'), 'class="add"');
// Setting the rules
$form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->getSubmitValues();
$parent_id = isset($values['parent_id']) && isset($values['parent_id'][0]) ? $values['parent_id'][0] : null;
$objcat = new Testcategory(0, $values['category_name'], $values['category_description'], $parent_id, $type, api_get_course_int_id());
if ($objcat->addCategoryInBDD()) {
Display::display_confirmation_message(get_lang('AddCategoryDone'));
} else {
Display::display_confirmation_message(get_lang('AddCategoryNameAlreadyExists'));
}
}
Security::clear_token();
display_add_category($type);
display_categories($type);
} else {
display_goback($type);
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
}
示例7: FormValidator
}
break;
case 'create_dir':
case 'add':
//$check = Security::check_token('post');
//show them the form for the directory name
if ($is_allowed_to_edit && in_array($action, array('create_dir', 'add'))) {
//create the form that asks for the directory name
$form = new FormValidator('form1', 'post', api_get_self() . '?action=create_dir&' . api_get_cidreq());
$form->addElement('header', get_lang('CreateAssignment') . $token);
$form->addElement('hidden', 'action', 'add');
$form->addElement('hidden', 'curdirpath', Security::remove_XSS($curdirpath));
// $form->addElement('hidden', 'sec_token', $token);
$form->addElement('text', 'new_dir', get_lang('AssignmentName'));
$form->addRule('new_dir', get_lang('ThisFieldIsRequired'), 'required');
$form->add_html_editor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
$form->addElement('advanced_settings', '<a href="javascript: void(0);" onclick="javascript: return plus();"><span id="plus">' . Display::return_icon('div_show.gif', get_lang('AdvancedParameters'), array('style' => 'vertical-align:center')) . ' ' . get_lang('AdvancedParameters') . '</span></a>');
$form->addElement('html', '<div id="options" style="display: none;">');
//QualificationOfAssignment
$form->addElement('text', 'qualification_value', get_lang('QualificationNumeric'));
if (Gradebook::is_active()) {
$form->addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), array('id' => 'make_calification_id', 'onclick' => "javascript: if(this.checked){document.getElementById('option1').style.display='block';}else{document.getElementById('option1').style.display='none';}"));
} else {
//QualificationOfAssignment
//$form->addElement('hidden', 'qualification_value',0);
$form->addElement('hidden', 'make_calification', false);
}
$form->addElement('html', '<div id="option1" style="display: none;">');
//Loading gradebook select
load_gradebook_select_in_tool($form);
$form->addElement('text', 'weight', get_lang('WeightInTheGradebook'));
示例8: array
$form->addElement('text', 'phone', get_lang('Phone'), array('size' => 20));
if (api_get_setting('registration', 'phone') == 'true') {
$form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
}
// LANGUAGE
if (api_get_setting('registration', 'language') == 'true') {
$form->addElement('select_language', 'language', get_lang('Language'));
}
// STUDENT/TEACHER
if (api_get_setting('allow_registration_as_teacher') != 'false') {
$form->addElement('radio', 'status', get_lang('Profile'), get_lang('RegStudent'), STUDENT);
$form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER);
}
// EXTENDED FIELDS
if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true') {
$form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130'));
}
if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true') {
$form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130'));
}
if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'myteach') == 'true') {
$form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130'));
}
if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true') {
$form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130'));
}
if (api_get_setting('extended_profile') == 'true') {
if (api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true' && api_get_setting('extendedprofile_registrationrequired', 'mycomptetences') == 'true') {
$form->addRule('competences', get_lang('ThisFieldIsRequired'), 'required');
}
if (api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true' && api_get_setting('extendedprofile_registrationrequired', 'mydiplomas') == 'true') {
示例9: elseif
echo '<a href="' . api_get_self() . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
} elseif (isset($_GET['action']) && $_GET['action'] == 'edit' && is_numeric($_GET['id'])) {
// Action handling: Editing a note
// Initialize the object
$form = new FormValidator('career', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&id=' . Security::remove_XSS($_GET['id']));
// Setting the form elements
$form->addElement('header', '', get_lang('Modify'));
$form->addElement('hidden', 'id', intval($_GET['id']));
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('Width' => '95%', 'Height' => '250'));
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
// Setting the defaults
$defaults = $usergroup->get($_GET['id']);
$form->setDefaults($defaults);
// Setting the rules.
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
// The validation or display.
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
$res = $usergroup->update($values);
if ($res) {
Display::display_confirmation_message(get_lang('Updated'));
} else {
示例10: createForm
/**
* Creates the form to create / edit an exercise
* @param FormValidator $form
*/
public function createForm($form, $type = 'full')
{
global $id;
if (empty($type)) {
$type = 'full';
}
// form title
if (!empty($_GET['exerciseId'])) {
$form_title = get_lang('ModifyExercise');
} else {
$form_title = get_lang('NewEx');
}
$form->addElement('header', $form_title);
// Title.
$form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), array('class' => 'span6', 'id' => 'exercise_title'));
$form->addElement('advanced_settings', '<a href="javascript://" onclick=" return show_media()">
<span id="media_icon">
<img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" />' . addslashes(api_htmlentities(get_lang('ExerciseDescription'))) . '
</span>
</a>
');
$editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
if (is_array($type)) {
$editor_config = array_merge($editor_config, $type);
}
$form->addElement('html', '<div class="HideFCKEditor" id="HiddenFCKexerciseDescription" >');
$form->add_html_editor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config);
$form->addElement('html', '</div>');
$form->addElement('advanced_settings', '<a href="javascript://" onclick=" return advanced_parameters()"><span id="img_plus_and_minus"><div style="vertical-align:top;" >
<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> ' . addslashes(api_htmlentities(get_lang('AdvancedParameters'))) . '</div></span></a>');
// Random questions
// style="" and not "display:none" to avoid #4029 Random and number of attempt menu empty
$form->addElement('html', '<div id="options" style="">');
if ($type == 'full') {
//Can't modify a DirectFeedback question
if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) {
// feedback type
$radios_feedback = array();
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
if (api_get_setting('enable_quiz_scenario') == 'true') {
//Can't convert a question from one feedback to another if there is more than 1 question already added
if ($this->selectNbrQuestions() == 0) {
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
}
}
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
$form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), '');
// Type of results display on the final page
$radios_results_disabled = array();
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2'));
//$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'), '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()'));
$form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
// Type of questions disposition on page
$radios = array();
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all'));
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one'));
$form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
} else {
// if is Directfeedback but has not questions we can allow to modify the question type
if ($this->selectNbrQuestions() == 0) {
// feedback type
$radios_feedback = array();
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
if (api_get_setting('enable_quiz_scenario') == 'true') {
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
}
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
$form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
//$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
$radios_results_disabled = array();
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
$form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
// Type of questions disposition on page
$radios = array();
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
$form->addGroup($radios, null, get_lang('ExerciseType'));
} else {
//Show options freeze
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
$result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
$result_disable_group->freeze();
//we force the options to the DirectFeedback exercisetype
$form->addElement('hidden', 'exerciseFeedbackType', EXERCISE_FEEDBACK_TYPE_DIRECT);
$form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
// Type of questions disposition on page
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all'));
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one'));
$type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
$type_group->freeze();
//.........这里部分代码省略.........
示例11: getForm
/**
*
* @param $url
* @param string
* @return \FormValidator
*/
private function getForm($url, $tool)
{
$toolbar_set = 'IntroductionTool';
$width = '100%';
$height = '300';
$editor_config = array('ToolbarSet' => $toolbar_set, 'Width' => $width, 'Height' => $height);
$form = new \FormValidator('form', 'post', $url);
$form->add_html_editor('content', null, null, false, $editor_config);
if ($tool == 'course_homepage') {
$form->addElement('label', get_lang('YouCanUseAllTheseTags'), '((' . implode(')) <br /> ((', \CourseHome::availableTools()) . '))');
}
$form->addElement('button', 'submit', get_lang('SaveIntroText'));
return $form;
}
示例12: createForm
/**
* Creates the form to create / edit a question
* A subclass can redifine this function to add fields...
* @param FormValidator $form the formvalidator instance (by reference)
*/
function createForm(&$form, $fck_config = 0)
{
echo '<style>
.media { display:none;}
</style>';
echo '<script>
// hack to hide http://cksource.com/forums/viewtopic.php?f=6&t=8700
function FCKeditor_OnComplete( editorInstance ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name )) {
HideFCKEditorByInstanceName (editorInstance.Name);
}
}
function HideFCKEditorByInstanceName ( editorInstanceName ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className == "HideFCKEditor" ) {
document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className = "media";
}
}
function show_media(){
var my_display = document.getElementById(\'HiddenFCKquestionDescription\').style.display;
if(my_display== \'none\' || my_display == \'\') {
document.getElementById(\'HiddenFCKquestionDescription\').style.display = \'block\';
document.getElementById(\'media_icon\').innerHTML=\' <img style="vertical-align: middle;" src="../img/looknfeelna.png" alt="" /> ' . get_lang('EnrichQuestion') . '\';
} else {
document.getElementById(\'HiddenFCKquestionDescription\').style.display = \'none\';
document.getElementById(\'media_icon\').innerHTML=\' <img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" /> ' . get_lang('EnrichQuestion') . '\';
}
}
// hub 13-12-2010
function visiblerDevisibler(in_id) {
if (document.getElementById(in_id)) {
if (document.getElementById(in_id).style.display == "none") {
document.getElementById(in_id).style.display = "block";
if (document.getElementById(in_id+"Img")) {
document.getElementById(in_id+"Img").src = "../img/div_hide.gif";
}
}
else {
document.getElementById(in_id).style.display = "none";
if (document.getElementById(in_id+"Img")) {
document.getElementById(in_id+"Img").src = "../img/div_show.gif";
}
}
}
}
</script>';
// question name
$form->addElement('text', 'questionName', get_lang('Question'), array('class' => 'span6'));
$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
// default content
$isContent = isset($_REQUEST['isContent']) ? intval($_REQUEST['isContent']) : null;
// Question type
$answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null;
$form->addElement('hidden', 'answerType', $answerType);
// html editor
$editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
if (is_array($fck_config)) {
$editor_config = array_merge($editor_config, $fck_config);
}
if (!api_is_allowed_to_edit(null, true)) {
$editor_config['UserStatus'] = 'student';
}
$form->addElement('advanced_settings', '
<a href="javascript://" onclick=" return show_media()"><span id="media_icon"><img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" /> ' . get_lang('EnrichQuestion') . '</span></a>
');
$form->addElement('html', '<div class="HideFCKEditor" id="HiddenFCKquestionDescription" >');
$form->add_html_editor('questionDescription', get_lang('QuestionDescription'), false, false, $editor_config);
$form->addElement('html', '</div>');
// hidden values
$my_id = isset($_REQUEST['myid']) ? intval($_REQUEST['myid']) : null;
$form->addElement('hidden', 'myid', $my_id);
if ($this->type != MEDIA_QUESTION) {
// Advanced parameters
$form->addElement('advanced_settings', '<a href="javascript:void(0)" onclick="visiblerDevisibler(\'id_advancedOption\')"><img id="id_advancedOptionImg" style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> ' . get_lang("AdvancedParameters") . '</a>');
$form->addElement('html', '<div id="id_advancedOption" style="display:none;">');
$select_level = Question::get_default_levels();
$form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);
// Categories
//$category_list = Testcategory::getCategoriesIdAndName();
//$form->addElement('select', 'questionCategory', get_lang('Category'), $category_list, array('multiple' => 'multiple'));
// Categories
$tabCat = Testcategory::getCategoriesIdAndName();
$form->addElement('select', 'questionCategory', get_lang('Category'), $tabCat);
//Medias
//$course_medias = Question::prepare_course_media_select(api_get_course_int_id());
//$form->addElement('select', 'parent_id', get_lang('AttachToMedia'), $course_medias);
$form->addElement('html', '</div>');
}
if (!isset($_GET['fromExercise'])) {
switch ($answerType) {
case 1:
$this->question = get_lang('DefaultUniqueQuestion');
//.........这里部分代码省略.........
示例13: array
}
//THEME
if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') {
$form->addElement('select_theme', 'theme', get_lang('Theme'));
if (api_get_setting('profile', 'theme') !== 'true') {
$form->freeze('theme');
}
$form->applyFilter('theme', 'trim');
}
// EXTENDED PROFILE this make the page very slow!
if (api_get_setting('extended_profile') == 'true') {
$width_extended_profile = 500;
//$form->addElement('html', '<a href="javascript: void(0);" onclick="javascript: show_extend();"> show_extend_profile</a>');
//$form->addElement('static', null, '<em>'.get_lang('OptionalTextFields').'</em>');
// MY COMPETENCES
$form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130'));
// MY DIPLOMAS
$form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130'));
// WHAT I AM ABLE TO TEACH
$form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130'));
// MY PRODUCTIONS
$form->addElement('file', 'production', get_lang('MyProductions'));
if ($production_list = UserManager::build_production_list(api_get_user_id(), '', true)) {
$form->addElement('static', 'productions_list', null, $production_list);
}
// MY PERSONAL OPEN AREA
$form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '350'));
$form->applyFilter(array('competences', 'diplomas', 'teach', 'openarea'), 'stripslashes');
$form->applyFilter(array('competences', 'diplomas', 'teach'), 'trim');
// openarea is untrimmed for maximum openness
}
示例14: setForm
/**
* @param FormValidator $form
* @param array $row
*/
public function setForm($form, $row = array())
{
$toolBar = api_is_allowed_to_edit(null, true) ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400') : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student');
$form->add_html_editor('content', get_lang('Content'), false, false, $toolBar);
//$content
$form->addElement('text', 'comment', get_lang('Comments'));
$progress = array('', 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
$form->addElement('select', 'progress', get_lang('Progress'), $progress);
if ((api_is_allowed_to_edit(false, true) || api_is_platform_admin()) && isset($row['reflink']) && $row['reflink'] != 'index') {
/* $advanced = '<a href="javascript://" onclick="advanced_parameters()" >
<div id="plus_minus"> '.
Display::return_icon(
'div_show.gif',
get_lang('Show'),
array('style'=>'vertical-align:middle')
).' '.get_lang('AdvancedParameters').'</div></a>';
*/
$form->addElement('advanced_settings', 'settings', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="settings_options" style="display:none">');
$form->add_html_editor('task', get_lang('DescriptionOfTheTask'), false, false, array('ToolbarSet' => 'wiki_task', 'Width' => '100%', 'Height' => '200'));
$form->addElement('label', null, get_lang('AddFeedback'));
$form->addElement('textarea', 'feedback1', get_lang('Feedback1'));
$form->addElement('select', 'fprogress1', get_lang('FProgress'), $progress);
$form->addElement('textarea', 'feedback2', get_lang('Feedback2'));
$form->addElement('select', 'fprogress2', get_lang('FProgress'), $progress);
$form->addElement('textarea', 'feedback3', get_lang('Feedback3'));
$form->addElement('select', 'fprogress3', get_lang('FProgress'), $progress);
$form->addElement('checkbox', 'initstartdate', null, get_lang('StartDate'), array('id' => 'start_date_toggle'));
$style = "display:block";
$row['initstartdate'] = 1;
if ($row['startdate_assig'] == '0000-00-00 00:00:00') {
$style = "display:none";
$row['initstartdate'] = null;
}
$form->addElement('html', '<div id="start_date" style="' . $style . '">');
$form->addElement('datepicker', 'startdate_assig');
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'initenddate', null, get_lang('EndDate'), array('id' => 'end_date_toggle'));
$style = "display:block";
$row['initenddate'] = 1;
if ($row['enddate_assig'] == '0000-00-00 00:00:00') {
$style = "display:none";
$row['initenddate'] = null;
}
$form->addElement('html', '<div id="end_date" style="' . $style . '">');
$form->addElement('datepicker', 'enddate_assig');
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'delayedsubmit', null, get_lang('AllowLaterSends'));
$form->addElement('text', 'max_text', get_lang('NMaxWords'));
$form->addElement('text', 'max_version', get_lang('NMaxVersion'));
$form->addElement('checkbox', 'assignment', null, get_lang('CreateAssignmentPage'));
$form->addElement('html', '</div>');
}
$form->addElement('hidden', 'page_id');
$form->addElement('hidden', 'reflink');
// $form->addElement('hidden', 'assignment');
$form->addElement('hidden', 'version');
$form->addElement('hidden', 'wpost_id', api_get_unique_id());
}
示例15: createForm
/**
* Creates the form to create / edit an exercise
* @param FormValidator $form the formvalidator instance (by reference)
* @param string
*/
public function createForm($form, $type = 'full')
{
if (empty($type)) {
$type = 'full';
}
// form title
if (!empty($_GET['exerciseId'])) {
$form_title = get_lang('ModifyExercise');
} else {
$form_title = get_lang('NewEx');
}
$form->addElement('header', $form_title);
// title
$form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), array('class' => 'span6', 'id' => 'exercise_title'));
$editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
if (is_array($type)) {
$editor_config = array_merge($editor_config, $type);
}
$form->add_html_editor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config);
$form->addElement('advanced_settings', '<a href="javascript://" onclick=" return advanced_parameters()">
<span id="img_plus_and_minus">
<div style="vertical-align:top;" >
' . Display::return_icon('div_show.gif') . ' ' . addslashes(get_lang('AdvancedParameters')) . '</div>
</span>
</a>');
$form->addElement('html', '<div id="options" style="">');
// Model type
$radio = array($form->createElement('radio', 'model_type', null, get_lang('Normal'), EXERCISE_MODEL_TYPE_NORMAL), $form->createElement('radio', 'model_type', null, get_lang('Committee'), EXERCISE_MODEL_TYPE_COMMITTEE));
$form->addGroup($radio, null, get_lang('ModelType'), '');
$modelType = $this->getModelType();
$scoreTypeDisplay = 'display:none';
if ($modelType == EXERCISE_MODEL_TYPE_COMMITTEE) {
$scoreTypeDisplay = null;
}
$form->addElement('html', '<div id="score_type" style="' . $scoreTypeDisplay . '">');
// QuestionScoreType
global $app;
$em = $app['orm.em'];
$types = $em->getRepository('Entity\\QuestionScore')->findAll();
$options = array('0' => get_lang('SelectAnOption'));
foreach ($types as $questionType) {
$options[$questionType->getId()] = $questionType->getName();
}
$form->addElement('select', 'score_type_model', array(get_lang('QuestionScoreType')), $options, array('id' => 'score_type_model'));
$form->addElement('html', '</div>');
if ($type == 'full') {
//Can't modify a DirectFeedback question
if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) {
// feedback type
$radios_feedback = array();
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
if (api_get_setting('enable_quiz_scenario') == 'true') {
/* Can't convert a question from one feedback to another if there
is more than 1 question already added */
if ($this->selectNbrQuestions() == 0) {
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
}
}
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
$form->addGroup($radios_feedback, null, get_lang('FeedbackType'), '');
// question
$radios = array($form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), ALL_ON_ONE_PAGE, array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all')), $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), ONE_PER_PAGE, array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one')));
$form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
$radios_results_disabled = array();
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
$form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
} else {
// if is Directfeedback but has not questions we can allow to modify the question type
if ($this->selectNbrQuestions() == 0) {
// feedback type
$radios_feedback = array();
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
if (api_get_setting('enable_quiz_scenario') == 'true') {
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
}
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
$form->addGroup($radios_feedback, null, get_lang('FeedbackType'));
// Exercise type
$radios = array($form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'), $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2'), $form->createElement('radio', 'exerciseType', null, get_lang('Committee'), '3'));
$form->addGroup($radios, null, get_lang('ExerciseType'));
$radios_results_disabled = array();
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
$form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
} else {
//Show options freeze
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
$result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
$result_disable_group->freeze();
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all'));
//.........这里部分代码省略.........