/** * function which redefines Question::createAnswersForm * @param FormValidator $form */ public function createAnswersForm($form) { $defaults = array(); $nb_matches = $nb_options = 2; $matches = array(); $answer = null; $counter = 1; if (isset($this->id)) { $answer = new Answer($this->id); $answer->read(); if (count($answer->nbrAnswers) > 0) { for ($i = 1; $i <= $answer->nbrAnswers; $i++) { $correct = $answer->isCorrect($i); if (empty($correct)) { $matches[$answer->selectAutoId($i)] = chr(64 + $counter); $counter++; } } } } if ($form->isSubmitted()) { $nb_matches = $form->getSubmitValue('nb_matches'); $nb_options = $form->getSubmitValue('nb_options'); if (isset($_POST['lessOptions'])) { $nb_matches--; $nb_options--; } if (isset($_POST['moreOptions'])) { $nb_matches++; $nb_options++; } } else { if (!empty($this->id)) { if (count($answer->nbrAnswers) > 0) { $nb_matches = $nb_options = 0; for ($i = 1; $i <= $answer->nbrAnswers; $i++) { if ($answer->isCorrect($i)) { $nb_matches++; $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i); $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1); $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i]; } else { $nb_options++; $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i); } } } } else { $defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1'); $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2'); $defaults['matches[2]'] = '2'; $defaults['option[1]'] = get_lang('DefaultMatchingOptA'); $defaults['option[2]'] = get_lang('DefaultMatchingOptB'); } } if (empty($matches)) { for ($i = 1; $i <= $nb_options; ++$i) { // fill the array with A, B, C..... $matches[$i] = chr(64 + $i); } } else { for ($i = $counter; $i <= $nb_options; ++$i) { // fill the array with A, B, C..... $matches[$i] = chr(64 + $i); } } $form->addElement('hidden', 'nb_matches', $nb_matches); $form->addElement('hidden', 'nb_options', $nb_options); // DISPLAY MATCHES $html = '<table class="table table-striped table-hover"> <thead> <tr> <th width="5%">' . get_lang('Number') . '</th> <th width="70%">' . get_lang('Answer') . '</th> <th width="15%">' . get_lang('MatchesTo') . '</th> <th width="10%">' . get_lang('Weighting') . '</th> </tr> </thead> <tbody>'; $form->addHeader(get_lang('MakeCorrespond')); $form->addHtml($html); if ($nb_matches < 1) { $nb_matches = 1; Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); } for ($i = 1; $i <= $nb_matches; ++$i) { $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "answer[{$i}]"); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "matches[{$i}]"); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "weighting[{$i}]"); $form->addHtml('<tr>'); $form->addHtml("<td>{$i}</td>"); $form->addText("answer[{$i}]", null); $form->addSelect("matches[{$i}]", null, $matches); $form->addText("weighting[{$i}]", null, true, ['value' => 10]); $form->addHtml('</tr>'); } $form->addHtml('</tbody></table>'); $group = array(); $form->addGroup($group); // DISPLAY OPTIONS $html = '<table class="table table-striped table-hover"> <thead> <tr> <th width="15%">' . get_lang('Number') . '</th> <th width="85%">' . get_lang('Answer') . '</th> </tr> </thead> <tbody>'; $form->addHtml($html); if ($nb_options < 1) { $nb_options = 1; Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); } for ($i = 1; $i <= $nb_options; ++$i) { $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "option[{$i}]"); $form->addHtml('<tr>'); $form->addHtml('<td>' . chr(64 + $i) . '</td>'); $form->addText("option[{$i}]", null); $form->addHtml('</tr>'); } $form->addHtml('</table>'); $group = array(); global $text; // setting the save button here and not in the question class.php $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true); $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true); $group[] = $form->addButtonSave($text, 'submitQuestion', true); $form->addGroup($group); if (!empty($this->id)) { $form->setDefaults($defaults); } else { if ($this->isContent == 1) { $form->setDefaults($defaults); } } $form->setConstants(array('nb_matches' => $nb_matches, 'nb_options' => $nb_options)); }
echo '</table>'; } else { echo '<div><em>' . get_lang('ThereIsNoAThematicSection') . '</em></div>'; } } elseif ($action == 'thematic_add' || $action == 'thematic_edit') { // Display form $form = new FormValidator('thematic_add', 'POST', 'index.php?action=thematic_add&' . api_get_cidreq()); if ($action == 'thematic_edit') { $form->addElement('header', '', get_lang('EditThematicSection')); } $form->addElement('hidden', 'sec_token', $token); $form->addElement('hidden', 'action', $action); if (!empty($thematic_id)) { $form->addElement('hidden', 'thematic_id', $thematic_id); } $form->addText('title', get_lang('Title'), true, array('size' => '50')); $form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Height' => '150')); $form->addButtonSave(get_lang('Save')); $show_form = true; if (!empty($thematic_data)) { if (api_get_session_id()) { if ($thematic_data['session_id'] != api_get_session_id()) { $show_form = false; Display::display_error_message(get_lang('NotAllowedClickBack'), false); } } // set default values $default['title'] = $thematic_data['title']; $default['content'] = $thematic_data['content']; $form->setDefaults($default); }
} } $allSkills = $objSkill->get_all(); $allGradebooks = $objGradebook->find('all'); $skillList = [0 => get_lang('None')]; $gradebookList = []; foreach ($allSkills as $skill) { $skillList[$skill['id']] = $skill['name']; } foreach ($allGradebooks as $gradebook) { $gradebookList[$gradebook['id']] = $gradebook['name']; } /* Form */ $createForm = new FormValidator('skill_create'); $createForm->addHeader(get_lang('CreateSkill')); $createForm->addText('name', get_lang('Name'), true, ['id' => 'name']); $createForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']); $createForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']); $createForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]); $createForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]); $createForm->addButtonSave(get_lang('Save')); $createForm->addHidden('id', null); $createForm->setDefaults($formDefaultValues); if ($createForm->validate()) { $created = $objSkill->add($createForm->getSubmitValues()); if ($created) { Display::return_message(get_lang('TheSkillHasBeenCreated'), 'success'); } else { Display::return_message(get_lang('CannotCreateSkill'), 'error'); } header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php');
/** * @param int $id * @param string $action * * @return FormValidator */ public static function getCategoryForm($id, $action) { $form = new FormValidator('category', 'post', api_get_self() . '?action=' . $action . '&' . api_get_cidreq()); $defaults = []; if ($action == 'addcategory') { $form->addHeader(get_lang('CategoryAdd')); $my_cat_title = get_lang('CategoryAdd'); } else { $form->addHeader(get_lang('CategoryMod')); $my_cat_title = get_lang('CategoryMod'); $defaults = self::getCategory($id); } $form->addHidden('id', $id); $form->addText('category_title', get_lang('CategoryName')); $form->addTextarea('description', get_lang('Description')); $form->addButtonSave($my_cat_title, 'submitCategory'); $form->setDefaults($defaults); return $form; }
$groups = SystemAnnouncementManager::get_announcement_groups($announcement->id); $values['group'] = isset($groups['group_id']) ? $groups['group_id'] : 0; $action_todo = true; break; } if ($action_todo) { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { $form_title = get_lang('AddNews'); $url = api_get_self(); } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { $form_title = get_lang('EditNews'); $url = api_get_self() . '?id=' . intval($_GET['id']); } $form = new FormValidator('system_announcement', 'post', $url); $form->addElement('header', '', $form_title); $form->addText('title', get_lang('Title'), true); $language_list = api_get_languages(); $language_list_with_keys = array(); $language_list_with_keys['all'] = get_lang('All'); for ($i = 0; $i < count($language_list['name']); $i++) { $language_list_with_keys[$language_list['folder'][$i]] = $language_list['name'][$i]; } $form->addElement('select', 'lang', get_lang('Language'), $language_list_with_keys); $form->addHtmlEditor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300')); $form->addDateRangePicker('range', get_lang('StartTimeWindow'), true, array('id' => 'date_range')); $group = array(); $group[] = $form->createElement('checkbox', 'visible_teacher', null, get_lang('Teacher')); $group[] = $form->createElement('checkbox', 'visible_student', null, get_lang('Student')); $group[] = $form->createElement('checkbox', 'visible_guest', null, get_lang('Guest')); $form->addGroup($group, null, get_lang('Visible'), ''); $form->addElement('hidden', 'id');
/** * Creates form that asks for the directory name. * @return string html-output text for the form */ public static function create_dir_form($dirId) { global $document_id; $form = new FormValidator('create_dir_form', 'post', api_get_self() . '?' . api_get_cidreq()); $form->addElement('hidden', 'create_dir', 1); $form->addElement('hidden', 'dir_id', intval($document_id)); $form->addElement('hidden', 'id', intval($dirId)); $form->addElement('header', get_lang('CreateDir')); $form->addText('dirname', get_lang('NewDir'), array('autofocus' => 'autofocus')); $form->addButtonCreate(get_lang('CreateFolder')); return $form->returnForm(); }
/** * Show the search form * @param string $query the value of the search box * @return string HTML form */ public static function get_search_form($query) { $searchType = isset($_GET['search_type']) ? $_GET['search_type'] : null; $form = new FormValidator('search_user', 'get', api_get_path(WEB_PATH) . 'main/social/search.php', '', array(), FormValidator::LAYOUT_HORIZONTAL); $form->addText('q', get_lang('UsersGroups'), false); $options = array(0 => get_lang('Select'), 1 => get_lang('User'), 2 => get_lang('Group')); $form->addSelect('search_type', get_lang('Type'), $options, array('onchange' => 'javascript: extra_field_toogle();')); // Extra fields $extraFields = UserManager::get_extra_filtrable_fields(); $defaults = []; if (is_array($extraFields) && count($extraFields) > 0) { foreach ($extraFields as $extraField) { $varName = 'field_' . $extraField['variable']; $options = [0 => get_lang('Select')]; foreach ($extraField['data'] as $option) { $checked = ''; if (isset($_GET[$varName])) { if ($_GET[$varName] == $option[1]) { $defaults[$option[1]] = true; } } $options[$option[1]] = $option[1]; } $form->addSelect($varName, $extraField['name'], $options); } } $defaults['search_type'] = intval($searchType); $defaults['q'] = api_htmlentities(Security::remove_XSS($query)); $form->setDefaults($defaults); $form->addButtonSearch(get_lang('Search')); $js = '<script> extra_field_toogle(); function extra_field_toogle() { if (jQuery("select[name=search_type]").val() != "1") { jQuery(".extra_field").hide(); } else { jQuery(".extra_field").show(); } } </script>'; return $js . $form->returnForm(); }
$tpl = Container::getTwig(); $load_user = 0; if (isset($_GET['load_user'])) { $load_user = 1; } $skill_condition = ''; $tpl->addGlobal('skill_id_to_load', ''); if (isset($_GET['skill_id'])) { $skillId = intval($_GET['skill_id']); $skill_condition = '&skill_id=' . $skillId; $tpl->addGlobal('skill_id_to_load', $skillId); } $url = api_get_path(WEB_AJAX_PATH) . "skill.ajax.php?a=get_skills_tree_json&load_user={$load_user}"; $tpl->addGlobal('wheel_url', $url); $url = api_get_path(WEB_AJAX_PATH) . 'skill.ajax.php?1=1'; $tpl->addGlobal('url', $url); $tpl->addGlobal('isAdministration', true); $dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']); $dialogForm->addLabel(get_lang('Name'), Display::tag('p', null, ['id' => 'name', 'class' => 'form-control-static'])); $dialogForm->addLabel(get_lang('ShortCode'), Display::tag('p', null, ['id' => 'short_code', 'class' => 'form-control-static'])); $dialogForm->addLabel(get_lang('Parent'), Display::tag('p', null, ['id' => 'parent', 'class' => 'form-control-static'])); $dialogForm->addLabel([get_lang('Gradebook'), get_lang('WithCertificate')], Display::tag('ul', null, ['id' => 'gradebook', 'class' => 'form-control-static list-unstyled'])); $dialogForm->addLabel(get_lang('Description'), Display::tag('p', null, ['id' => 'description', 'class' => 'form-control-static'])); $tpl->addGlobal('dialogForm', $dialogForm->returnForm()); $saveProfileForm = new FormValidator('form', 'post', null, null, ['id' => 'dialog-form-profile']); $saveProfileForm->addHidden('profile_id', null); $saveProfileForm->addText('name', get_lang('Name'), true, ['id' => 'name_profile']); $saveProfileForm->addTextarea('description', get_lang('Description'), ['id' => 'description_profile', 'rows' => 6]); $tpl->addGlobal('saveProfileForm', $saveProfileForm->returnForm()); echo $tpl->render('@template_style/skill/skill_wheel.html.twig'); Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';
// Create directory if (!$is_certificate_mode) { $actionsLeft .= Display::url(Display::return_icon('new_folder.png', get_lang('CreateDir'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'document/document.php?' . api_get_cidreq() . '&id=' . $document_id . '&createdir=1'); } } require 'document_slideshow.inc.php'; if ($image_present && !isset($_GET['keyword'])) { $actionsLeft .= Display::url(Display::return_icon('slideshow.png', get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'document/slideshow.php?' . api_get_cidreq() . '&curdirpath=' . $curdirpathurl); } if (api_is_allowed_to_edit(null, true)) { $actionsLeft .= Display::url(Display::return_icon('percentage.png', get_lang('DocumentQuota'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'document/document_quota.php?' . api_get_cidreq()); } if (!$is_certificate_mode) { /* BUILD SEARCH FORM */ $form = new FormValidator('search_document', 'get', api_get_self() . '?' . api_get_cidreq(), '', array(), FormValidator::LAYOUT_INLINE); $form->addText('keyword', '', false, array('class' => 'col-md-2')); $form->addElement('hidden', 'cidReq', api_get_course_id()); $form->addElement('hidden', 'id_session', api_get_session_id()); $form->addElement('hidden', 'gidReq', $groupId); $form->addButtonSearch(get_lang('Search')); $actionsRight = $form->returnForm(); } $table_footer = ''; $total_size = 0; $sortable_data = array(); if (isset($documentAndFolders) && is_array($documentAndFolders)) { if ($groupId == 0 || GroupManager::user_has_access($userId, $groupId, GroupManager::GROUP_TOOL_DOCUMENTS)) { $count = 1; $countedPaths = array(); $countedPaths = array(); foreach ($documentAndFolders as $key => $document_data) {
// Filename $form->addElement('hidden', 'title_edited', 'false', 'id="title_edited"'); /** * Check if a document width the chosen filename already exists */ function document_exists($filename) { global $dir; $cleanName = api_replace_dangerous_char($filename); // No "dangerous" files $cleanName = disable_dangerous_file($cleanName); return !DocumentManager::documentExists($dir . $cleanName . '.html', api_get_course_info(), api_get_session_id(), api_get_group_id()); } // Add group to the form if ($is_certificate_mode) { $form->addText('title', get_lang('CertificateName'), true, array('cols-size' => [2, 10, 0], 'autofocus')); } else { $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus')); } // Show read-only box only in groups if (!empty($groupId)) { $group[] = $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly')); } $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists'); $current_session_id = api_get_session_id(); $form->addHtmlEditor('content', '', true, false, $editorConfig); // Comment-field $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit); // If we are not in the certificates creation, display a folder chooser for the // new document created
/** * function which redefines Question::createAnswersForm * @param FormValidator $form */ function createAnswersForm($form) { $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0); $obj_ex = Session::read('objExercise'); $html = '<table class="table table-striped table-hover">'; $html .= '<thead>'; $html .= '<tr>'; $html .= '<th width="10">' . get_lang('Number') . '</th>'; $html .= '<th width="10">' . get_lang('True') . '</th>'; $html .= '<th width="50%">' . get_lang('Comment') . '</th>'; $html .= '<th width="50%">' . get_lang('Answer') . '</th>'; $html .= '</tr>'; $html .= '</thead>'; $html .= '<tbody>'; $form->addHeader(get_lang('Answers')); $form->addHtml($html); $defaults = array(); $correct = 0; $answer = false; if (!empty($this->id)) { $answer = new Answer($this->id); $answer->read(); if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) { $nb_answers = $answer->nbrAnswers; } } $form->addElement('hidden', 'nb_answers'); $boxes_names = array(); if ($nb_answers < 1) { $nb_answers = 1; Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); } for ($i = 1; $i <= $nb_answers; ++$i) { $form->addHtml('<tr>'); if (is_object($answer)) { $defaults['answer[' . $i . ']'] = $answer->answer[$i]; $defaults['comment[' . $i . ']'] = $answer->comment[$i]; $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1); $defaults['correct[' . $i . ']'] = $answer->correct[$i]; } else { $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2'); $defaults['comment[1]'] = get_lang('DefaultMultipleComment2'); $defaults['correct[1]'] = true; $defaults['weighting[1]'] = 10; $defaults['answer[2]'] = get_lang('DefaultMultipleAnswer1'); $defaults['comment[2]'] = get_lang('DefaultMultipleComment1'); $defaults['correct[2]'] = false; } $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']'); $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); $answer_number->freeze(); $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox" style="margin-left: 0em;"'); $boxes_names[] = 'correct[' . $i . ']'; $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')); $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')); $form->addHtml('</tr>'); } $form->addElement('html', '</tbody></table>'); $form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required'); //only 1 answer the all deal ... $form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]); global $text; //ie6 fix if ($obj_ex->edit_exercise_in_lp == true) { // setting the save button here and not in the question class.php $buttonGroup = [$form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true), $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true), $form->addButtonSave($text, 'submitQuestion', true)]; $form->addGroup($buttonGroup); } $defaults['correct'] = $correct; if (!empty($this->id)) { $form->setDefaults($defaults); } else { if ($this->isContent == 1) { $form->setDefaults($defaults); } } $form->setConstants(array('nb_answers' => $nb_answers)); }
if ($form->validate()) { $formValues = $form->getSubmitValues(); if (!$formValues['payment_type']) { Display::addFlash(Display::return_message($plugin->get_lang('NeedToSelectPaymentType'), 'error', false)); header('Location:' . api_get_self() . '?' . $queryString); exit; } $saleId = $plugin->registerSale($item['id'], $formValues['payment_type']); if ($saleId !== false) { $_SESSION['bc_sale_id'] = $saleId; header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/process_confirm.php'); } exit; } $form->addHeader($plugin->get_lang('UserInformation')); $form->addText('name', get_lang('Name'), false, ['cols-size' => [5, 7, 0]]); $form->addText('username', get_lang('Username'), false, ['cols-size' => [5, 7, 0]]); $form->addText('email', get_lang('EmailAddress'), false, ['cols-size' => [5, 7, 0]]); $form->addHeader($plugin->get_lang('PaymentMethods')); $paymentTypesOptions = $plugin->getPaymentTypes(); if (!$paypalEnabled) { unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL]); } if (!$transferEnabled) { unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER]); } $form->addRadio('payment_type', null, $paymentTypesOptions); $form->addHidden('t', intval($_GET['t'])); $form->addHidden('i', intval($_GET['i'])); $form->freeze(['name', 'username', 'email']); $form->setDefaults(['name' => $userInfo['complete_name'], 'username' => $userInfo['username'], 'email' => $userInfo['email']]);
/** * function which redefines Question::createAnswersForm * @param FormValidator $form */ public function createAnswersForm($form) { // Getting the exercise list $obj_ex = Session::read('objExercise'); $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125'); //this line defines how many questions by default appear when creating a choice question // The previous default value was 2. See task #1759. $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4; $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0); /* Types of Feedback $feedback_option[0]=get_lang('Feedback'); $feedback_option[1]=get_lang('DirectFeedback'); $feedback_option[2]=get_lang('NoFeedback'); */ $feedback_title = ''; if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { //Scenario $comment_title = '<th width="20%">' . get_lang('Comment') . '</th>'; $feedback_title = '<th width="20%">' . get_lang('Scenario') . '</th>'; } else { $comment_title = '<th width="40%">' . get_lang('Comment') . '</th>'; } $html = '<table class="table table-striped table-hover"> <thead> <tr style="text-align: center;"> <th width="5%">' . get_lang('Number') . '</th> <th width="5%"> ' . get_lang('True') . '</th> <th width="40%">' . get_lang('Answer') . '</th> ' . $comment_title . ' ' . $feedback_title . ' <th width="10%">' . get_lang('Weighting') . '</th> </tr> </thead> <tbody>'; $form->addHeader(get_lang('Answers')); $form->addHtml($html); $defaults = array(); $correct = 0; if (!empty($this->id)) { $answer = new Answer($this->id); $answer->read(); if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) { $nb_answers = $answer->nbrAnswers; } } $form->addElement('hidden', 'nb_answers'); //Feedback SELECT $question_list = $obj_ex->selectQuestionList(); $select_question = array(); $select_question[0] = get_lang('SelectTargetQuestion'); if (is_array($question_list)) { foreach ($question_list as $key => $questionid) { //To avoid warning messages if (!is_numeric($questionid)) { continue; } $question = Question::read($questionid); $select_question[$questionid] = 'Q' . $key . ' :' . cut($question->selectTitle(), 20); } } $select_question[-1] = get_lang('ExitTest'); $list = new LearnpathList(api_get_user_id()); $flat_list = $list->get_flat_list(); $select_lp_id = array(); $select_lp_id[0] = get_lang('SelectTargetLP'); foreach ($flat_list as $id => $details) { $select_lp_id[$id] = cut($details['lp_name'], 20); } $temp_scenario = array(); if ($nb_answers < 1) { $nb_answers = 1; Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); } for ($i = 1; $i <= $nb_answers; ++$i) { $form->addHtml('<tr>'); if (isset($answer) && is_object($answer)) { if ($answer->correct[$i]) { $correct = $i; } $defaults['answer[' . $i . ']'] = $answer->answer[$i]; $defaults['comment[' . $i . ']'] = $answer->comment[$i]; $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1); $item_list = explode('@@', $answer->destination[$i]); $try = isset($item_list[0]) ? $item_list[0] : ''; $lp = isset($item_list[1]) ? $item_list[1] : ''; $list_dest = isset($item_list[2]) ? $item_list[2] : ''; $url = isset($item_list[3]) ? $item_list[3] : ''; if ($try == 0) { $try_result = 0; } else { $try_result = 1; } if ($url == 0) { $url_result = ''; } else { $url_result = $url; } $temp_scenario['url' . $i] = $url_result; $temp_scenario['try' . $i] = $try_result; $temp_scenario['lp' . $i] = $lp; $temp_scenario['destination' . $i] = $list_dest; } else { $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1'); $defaults['weighting[1]'] = 10; $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2'); $defaults['weighting[2]'] = 0; $temp_scenario['destination' . $i] = array('0'); $temp_scenario['lp' . $i] = array('0'); } $defaults['scenario'] = $temp_scenario; $renderer = $form->defaultRenderer(); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting[' . $i . ']'); $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, ' value = "' . $i . '"'); $answer_number->freeze(); $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox"'); $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editor_config); $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config); // Direct feedback //Adding extra feedback fields $group = array(); $group['try' . $i] = $form->createElement('checkbox', 'try' . $i, null, get_lang('TryAgain')); $group['lp' . $i] = $form->createElement('select', 'lp' . $i, get_lang('SeeTheory') . ': ', $select_lp_id); $group['destination' . $i] = $form->createElement('select', 'destination' . $i, get_lang('GoToQuestion') . ': ', $select_question); $group['url' . $i] = $form->createElement('text', 'url' . $i, get_lang('Other') . ': ', array('class' => 'col-md-2', 'placeholder' => get_lang('Other'))); $form->addGroup($group, 'scenario'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}', 'scenario'); } else { $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config); } $form->addText('weighting[' . $i . ']', null, null, array('value' => '0')); $form->addHtml('</tr>'); } $form->addHtml('</tbody>'); $form->addHtml('</table>'); global $text; $buttonGroup = []; //ie6 fix if ($obj_ex->edit_exercise_in_lp == true) { //setting the save button here and not in the question class.php $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); $form->addGroup($buttonGroup); } // We check the first radio button to be sure a radio button will be check if ($correct == 0) { $correct = 1; } $defaults['correct'] = $correct; if (!empty($this->id)) { $form->setDefaults($defaults); } else { if ($this->isContent == 1) { // Default sample content. $form->setDefaults($defaults); } else { $form->setDefaults(array('correct' => 1)); } } $form->setConstants(array('nb_answers' => $nb_answers)); }
<?php /* For licensing terms, see /license.txt */ /** * View (MVC patter) for creating course category * @author Christian Fasanando <*****@*****.**> - Beeznest * @package chamilo.auth */ // Acces rights: anonymous users can't do anything usefull here. api_block_anonymous_users(); $stok = Security::get_token(); ?> <!-- Actions: The menu with the different options in cathe course management --> <div id="actions" class="actions"> <a href="<?php echo api_get_self(); ?> ?action=sortmycourses"> <?php echo Display::return_icon('back.png', get_lang('Back'), '', '32'); ?> </a> </div> <?php $form = new FormValidator('create_course_category', 'post', api_get_self() . '?createcoursecategory'); $form->addHidden('sec_token', $stok); $form->addText('title_course_category', get_lang('Name')); $form->addButtonSave(get_lang('AddCategory'), 'create_course_category'); $form->display();
$sql = "SELECT user_id,lastname,firstname FROM {$table_user} WHERE status=1" . $order_clause; // Filtering teachers when creating a course. if (api_is_multiple_url_enabled()) { $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $sql = "SELECT u.user_id,lastname,firstname FROM {$table_user} as u\n INNER JOIN {$access_url_rel_user_table} url_rel_user\n ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=" . api_get_current_access_url_id() . " AND status=1" . $order_clause; } $res = Database::query($sql); $teachers = array(); while ($obj = Database::fetch_object($res)) { $teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname); } // Build the form. $form = new FormValidator('update_course'); $form->addElement('header', $tool_name); // Title $form->addText('title', get_lang('Title'), true); $form->applyFilter('title', 'html_filter'); $form->applyFilter('title', 'trim'); // Code $form->addText('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')), false, ['maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE, 'pattern' => '[a-zA-Z0-9]+', 'title' => get_lang('OnlyLettersAndNumbers')]); $form->applyFilter('visual_code', 'api_strtoupper'); $form->applyFilter('visual_code', 'html_filter'); $form->addRule('visual_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE); $form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select" style="width:350px" multiple="multiple" '); $form->applyFilter('course_teachers', 'html_filter'); // Category code $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category'; $form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url)); // Course department $form->addText('department_name', get_lang('CourseDepartment'), false, array('size' => '60')); $form->applyFilter('department_name', 'html_filter');
use Chamilo\CoreBundle\Entity\Sequence; $cidReset = true; require_once '../inc/global.inc.php'; api_protect_global_admin_script(); // setting breadcrumbs $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $tpl = new Template(get_lang('ResourcesSequencing')); $sessionListFromDatabase = SessionManager::get_sessions_list(); $sessionList = []; if (!empty($sessionListFromDatabase)) { foreach ($sessionListFromDatabase as $sessionItem) { $sessionList[$sessionItem['id']] = $sessionItem['name'] . ' (' . $sessionItem['id'] . ')'; } } $formSequence = new FormValidator('sequence_form', 'post', api_get_self(), null, null, 'inline'); $formSequence->addText('name', get_lang('Sequence'), true, ['cols-size' => [3, 8, 1]]); $formSequence->addButtonCreate(get_lang('AddSequence'), 'submit_sequence', false, ['cols-size' => [3, 8, 1]]); $em = Database::getManager(); // Add sequence if ($formSequence->validate()) { $values = $formSequence->exportValues(); $sequence = new Sequence(); $sequence->setName($values['name']); $em->persist($sequence); $em->flush(); header('Location: ' . api_get_self()); exit; } $selectSequence = new FormValidator(''); $selectSequence->addHidden('sequence_type', 'session'); $em = Database::getManager();
/** * Creates the form to create / edit an exercise * @param FormValidator $form */ 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('id' => 'exercise_title')); $form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters')); $form->addElement('html', '<div id="advanced_params_options" style="display:none">'); $editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150'); if (is_array($type)) { $editor_config = array_merge($editor_config, $type); } $form->addHtmlEditor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config); 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('exercise.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('exercise.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(); } } // number of random question $max = $this->id > 0 ? $this->selectNbrQuestions() : 10; $option = range(0, $max); $option[0] = get_lang('No'); $option[-1] = get_lang('AllQuestionsShort'); $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id' => 'randomQuestions')); // Random answers $radios_random_answers = array(); $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1'); $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0'); $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), ''); // Random by category $form->addElement('html', '<div class="clear"> </div>'); $radiocat = array(); $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1'); $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2'); $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0'); $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), ''); $form->addElement('html', '<div class="clear"> </div>'); // add the radio display the category name for student $radio_display_cat_name = array(); $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('Yes'), '1'); $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('No'), '0'); $form->addGroup($radio_display_cat_name, null, get_lang('QuestionDisplayCategoryName'), ''); // Attempts $attempt_option = range(0, 10); $attempt_option[0] = get_lang('Infinite'); $form->addElement('select', 'exerciseAttempts', get_lang('ExerciseAttempts'), $attempt_option, ['id' => 'exerciseAttempts']); // Exercise time limit $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); $var = Exercise::selectTimeLimit(); if ($this->start_time != '0000-00-00 00:00:00') { $form->addElement('html', '<div id="start_date_div" style="display:block;">'); } else { $form->addElement('html', '<div id="start_date_div" style="display:none;">'); } $form->addElement('date_time_picker', 'start_time'); $form->addElement('html', '</div>'); $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); if ($this->end_time != '0000-00-00 00:00:00') { $form->addElement('html', '<div id="end_date_div" style="display:block;">'); } else { $form->addElement('html', '<div id="end_date_div" style="display:none;">'); } $form->addElement('date_time_picker', 'end_time'); $form->addElement('html', '</div>'); //$check_option=$this->selectType(); $diplay = 'block'; $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults')); $form->addElement('html', '<div class="clear"> </div>'); $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); $form->addElement('html', '<div id="divtimecontrol" style="display:' . $diplay . ';">'); //Timer control //$time_hours_option = range(0,12); //$time_minutes_option = range(0,59); $form->addElement('checkbox', 'enabletimercontrol', null, get_lang('EnableTimerControl'), array('onclick' => 'option_time_expired()', 'id' => 'enabletimercontrol', 'onload' => 'check_load_time()')); $expired_date = (int) $this->selectExpiredTime(); if ($expired_date != '0') { $form->addElement('html', '<div id="timercontrol" style="display:block;">'); } else { $form->addElement('html', '<div id="timercontrol" style="display:none;">'); } $form->addText('enabletimercontroltotalminutes', get_lang('ExerciseTotalDurationInMinutes'), false, ['id' => 'enabletimercontroltotalminutes', 'cols-size' => [2, 2, 8]]); $form->addElement('html', '</div>'); $form->addElement('text', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), array('id' => 'pass_percentage')); $form->addRule('pass_percentage', get_lang('Numeric'), 'numeric'); // add the text_when_finished textbox $form->addHtmlEditor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config); $defaults = array(); if (api_get_setting('search.search_enabled') === 'true') { require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument')); $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); $specific_fields = get_specific_field_list(); foreach ($specific_fields as $specific_field) { $form->addElement('text', $specific_field['code'], $specific_field['name']); $filter = array('c_id' => "'" . api_get_course_int_id() . "'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\'' . TOOL_QUIZ . '\''); $values = get_specific_field_values_list($filter, array('value')); if (!empty($values)) { $arr_str_values = array(); foreach ($values as $value) { $arr_str_values[] = $value['value']; } $defaults[$specific_field['code']] = implode(', ', $arr_str_values); } } //$form->addElement ('html','</div>'); } $form->addElement('html', '</div>'); //End advanced setting $form->addElement('html', '</div>'); } // submit if (isset($_GET['exerciseId'])) { $form->addButtonSave(get_lang('ModifyExercise'), 'submitExercise'); } else { $form->addButtonUpdate(get_lang('ProcedToQuestions'), 'submitExercise'); } $form->addRule('exerciseTitle', get_lang('GiveExerciseName'), 'required'); if ($type == 'full') { // rules $form->addRule('exerciseAttempts', get_lang('Numeric'), 'numeric'); $form->addRule('start_time', get_lang('InvalidDate'), 'datetime'); $form->addRule('end_time', get_lang('InvalidDate'), 'datetime'); } // defaults if ($type == 'full') { if ($this->id > 0) { if ($this->random > $this->selectNbrQuestions()) { $defaults['randomQuestions'] = $this->selectNbrQuestions(); } else { $defaults['randomQuestions'] = $this->random; } $defaults['randomAnswers'] = $this->selectRandomAnswers(); $defaults['exerciseType'] = $this->selectType(); $defaults['exerciseTitle'] = $this->get_formated_title(); $defaults['exerciseDescription'] = $this->selectDescription(); $defaults['exerciseAttempts'] = $this->selectAttempts(); $defaults['exerciseFeedbackType'] = $this->selectFeedbackType(); $defaults['results_disabled'] = $this->selectResultsDisabled(); $defaults['propagate_neg'] = $this->selectPropagateNeg(); $defaults['review_answers'] = $this->review_answers; $defaults['randomByCat'] = $this->selectRandomByCat(); $defaults['text_when_finished'] = $this->selectTextWhenFinished(); $defaults['display_category_name'] = $this->selectDisplayCategoryName(); $defaults['pass_percentage'] = $this->selectPassPercentage(); if ($this->start_time != '0000-00-00 00:00:00') { $defaults['activate_start_date_check'] = 1; } if ($this->end_time != '0000-00-00 00:00:00') { $defaults['activate_end_date_check'] = 1; } $defaults['start_time'] = $this->start_time != '0000-00-00 00:00:00' ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); $defaults['end_time'] = $this->end_time != '0000-00-00 00:00:00' ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600); // Get expired time if ($this->expired_time != '0') { $defaults['enabletimercontrol'] = 1; $defaults['enabletimercontroltotalminutes'] = $this->expired_time; } else { $defaults['enabletimercontroltotalminutes'] = 0; } } else { $defaults['exerciseType'] = 2; $defaults['exerciseAttempts'] = 0; $defaults['randomQuestions'] = 0; $defaults['randomAnswers'] = 0; $defaults['exerciseDescription'] = ''; $defaults['exerciseFeedbackType'] = 0; $defaults['results_disabled'] = 0; $defaults['randomByCat'] = 0; $defaults['text_when_finished'] = ""; $defaults['start_time'] = date('Y-m-d 12:00:00'); $defaults['display_category_name'] = 1; $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600); $defaults['pass_percentage'] = ''; } } else { $defaults['exerciseTitle'] = $this->selectTitle(); $defaults['exerciseDescription'] = $this->selectDescription(); } if (api_get_setting('search.search_enabled') === 'true') { $defaults['index_document'] = 'checked="checked"'; } $form->setDefaults($defaults); // Freeze some elements. if ($this->id != 0 && $this->edit_exercise_in_lp == false) { $elementsToFreeze = array('randomQuestions', 'exerciseAttempts', 'propagate_neg', 'enabletimercontrol', 'review_answers'); foreach ($elementsToFreeze as $elementName) { /** @var HTML_QuickForm_element $element */ $element = $form->getElement($elementName); $element->freeze(); } $radioCatGroup->freeze(); } }
/** * This is the main function that displays the list or the table with all * the glossary terms * @param string View ('table' or 'list'). Optional parameter. * Defaults to 'table' and prefers glossary_view from the session by default. * @return void * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version januari 2009, dokeos 1.8.6 */ public static function display_glossary($view = 'table') { // This function should always be called with the corresponding // parameter for view type. Meanwhile, use this cheap trick. $glossaryView = Session::read('glossary_view'); if (empty($glossaryView)) { Session::write('glossary_view', $view); } // action links //echo '<div class="actions">'; $actionsLeft = ''; if (api_is_allowed_to_edit(null, true)) { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=addglossary&msg=add?' . api_get_cidreq() . '">' . Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM) . '</a>'; } $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=export">' . Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM) . '</a>'; if (api_is_allowed_to_edit(null, true)) { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM) . '</a>'; } $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=export_to_pdf">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a>'; if (isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table' or !isset($_SESSION['glossary_view'])) { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=list">' . Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM) . '</a>'; } else { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=table">' . Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM) . '</a>'; } /* BUILD SEARCH FORM */ $form = new FormValidator('search', 'get', api_get_self() . '?' . api_get_cidreq(), '', array(), FormValidator::LAYOUT_INLINE); $form->addText('keyword', '', false, array('class' => 'col-md-2')); $form->addElement('hidden', 'cidReq', api_get_course_id()); $form->addElement('hidden', 'id_session', api_get_session_id()); $form->addButtonSearch(get_lang('Search')); $actionsRight = $form->returnForm(); $toolbar = Display::toolbarAction('toolbar-document', array(0 => $actionsLeft, 1 => $actionsRight)); echo $toolbar; if ($glossaryView == 'table') { $table = new SortableTable('glossary', array('GlossaryManager', 'get_number_glossary_terms'), array('GlossaryManager', 'get_glossary_data'), 0); //$table->set_header(0, '', false); $table->set_header(0, get_lang('TermName'), true); $table->set_header(1, get_lang('TermDefinition'), true); if (api_is_allowed_to_edit(null, true)) { $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions')); $table->set_column_filter(2, array('GlossaryManager', 'actions_filter')); } $table->display(); } if ($glossaryView == 'list') { GlossaryManager::display_glossary_list(); } }
/** * @param $id * @param array $params * @return string */ public static function generate_message_form($id, $params = array()) { $form = new FormValidator('send_message'); $form->addText('subject', get_lang('Subject'), false, ['id' => 'subject_id']); $form->addTextarea('content', get_lang('Message'), ['id' => 'content_id', 'rows' => '5']); return $form->returnForm(); }
/** * function which redifines Question::createAnswersForm * @param FormValidator $form * @param the answers number to display */ function createAnswersForm($form) { // getting the exercise list $obj_ex = Session::read('objExercise'); $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125'); //this line define how many question by default appear when creating a choice question $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3; // The previous default value was 2. See task #1759. $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0); /* Types of Feedback $feedback_option[0]=get_lang('Feedback'); $feedback_option[1]=get_lang('DirectFeedback'); $feedback_option[2]=get_lang('NoFeedback'); */ $feedback_title = ''; $comment_title = ''; if ($obj_ex->selectFeedbackType() == 1) { $editor_config['Width'] = '250'; $editor_config['Height'] = '110'; $comment_title = '<th width="50%" >' . get_lang('Comment') . '</th>'; $feedback_title = '<th width="50%" >' . get_lang('Scenario') . '</th>'; } else { $comment_title = '<th width="50%">' . get_lang('Comment') . '</th>'; } $html = '<table class="table table-striped table-hover">'; $html .= '<thead>'; $html .= '<tr>'; $html .= '<th>' . get_lang('Number') . '</th>'; $html .= '<th>' . get_lang('True') . '</th>'; $html .= '<th width="50%">' . get_lang('Answer') . '</th>'; $html .= $comment_title . $feedback_title; $html .= '<th>' . get_lang('Weighting') . '</th>'; $html .= '</tr>'; $html .= '</thead>'; $html .= '<tbody>'; $form->addHeader(get_lang('Answers')); $form->addHtml($html); $defaults = array(); $correct = 0; $answer = false; if (!empty($this->id)) { $answer = new Answer($this->id); $answer->read(); if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) { $nb_answers = $answer->nbrAnswers; } } $temp_scenario = array(); if ($nb_answers < 1) { $nb_answers = 1; Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); } $editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : false; if ($editQuestion) { //fixing $nb_answers $new_list = array(); $count = 1; if (isset($_POST['lessAnswers'])) { $lessFromSession = Session::read('less_answer'); if (!isset($lessFromSession)) { Session::write('less_answer', $this->id); $nb_answers--; } } for ($k = 1; $k <= $nb_answers; ++$k) { if ($answer->position[$k] != '666') { $new_list[$count] = $count; $count++; } } } else { for ($k = 1; $k <= $nb_answers; ++$k) { $new_list[$k] = $k; } } $i = 1; //for ($k = 1 ; $k <= $real_nb_answers; $k++) { foreach ($new_list as $key) { $i = $key; $form->addElement('html', '<tr>'); if (is_object($answer)) { if ($answer->position[$i] == 666) { //we set nothing } else { if ($answer->correct[$i]) { $correct = $i; } $answer_result = $answer->answer[$i]; $weight_result = float_format($answer->weighting[$i], 1); if ($nb_answers == $i) { $weight_result = '0'; } $defaults['answer[' . $i . ']'] = $answer_result; $defaults['comment[' . $i . ']'] = $answer->comment[$i]; $defaults['weighting[' . $i . ']'] = $weight_result; $item_list = explode('@@', $answer->destination[$i]); $try = $item_list[0]; $lp = $item_list[1]; $list_dest = $item_list[2]; $url = $item_list[3]; if ($try == 0) { $try_result = 0; } else { $try_result = 1; } if ($url == 0) { $url_result = ''; } else { $url_result = $url; } $temp_scenario['url' . $i] = $url_result; $temp_scenario['try' . $i] = $try_result; $temp_scenario['lp' . $i] = $lp; $temp_scenario['destination' . $i] = $list_dest; } } $defaults['scenario'] = $temp_scenario; $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting[' . $i . ']'); $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); $answer_number->freeze(); $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"'); $form->addHtmlEditor('answer[' . $i . ']', null, array(), false, $editor_config); $form->addHtmlEditor('comment[' . $i . ']', null, array(), false, $editor_config); $form->addElement('text', 'weighting[' . $i . ']', null, array('style' => 'width: 60px;', 'value' => '0')); $form->addElement('html', '</tr>'); $i++; } if (empty($this->id)) { $form->addElement('hidden', 'new_question', 1); } //Adding the "I don't know" question answer //if (empty($this -> id)) { $i = 666; $form->addHtml('<tr>'); $defaults['answer[' . $i . ']'] = get_lang('DontKnow'); $defaults['weighting[' . $i . ']'] = 0; $defaults['scenario'] = $temp_scenario; $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting[' . $i . ']'); $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="-"'); $answer_number->freeze(); $form->addElement('hidden', 'position[' . $i . ']', '666'); $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"'); $form->addHtmlEditor('answer[' . $i . ']', null, array(), false, $editor_config); $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); $form->addHtmlEditor('comment[' . $i . ']', null, array(), false, $editor_config); //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple'); $form->addText("weighting[{$i}]", null, false, ['style' => 'width: 60px;', 'value' => 0, 'readonly' => 'readonly']); $form->addHTml('</tr>'); $form->addHtml('</tbody></table>'); $buttonGroup = []; global $text, $class; //ie6 fix if ($obj_ex->edit_exercise_in_lp == true) { //setting the save button here and not in the question class.php $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); $form->addGroup($buttonGroup); } //We check the first radio button to be sure a radio button will be check if ($correct == 0) { $correct = 1; } $defaults['correct'] = $correct; if (!empty($this->id)) { $form->setDefaults($defaults); } else { $form->setDefaults($defaults); } $form->addElement('hidden', 'nb_answers'); $form->setConstants(array('nb_answers' => $nb_answers)); }
/** * Displays the form to create a new post * @author Toon Keppens * * @param Integer $blog_id */ public static function display_new_comment_form($blog_id, $post_id, $title) { $form = new FormValidator('add_post', 'post', api_get_path(WEB_CODE_PATH) . "blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=" . intval($post_id) . "&" . api_get_cidreq(), null, array('enctype' => 'multipart/form-data')); $header = get_lang('AddNewComment'); if (isset($_GET['task_id'])) { $header = get_lang('ExecuteThisTask'); } $form->addHeader($header); $form->addText('title', get_lang('Title')); $config = array(); if (!api_is_allowed_to_edit()) { $config['ToolbarSet'] = 'ProjectComment'; } else { $config['ToolbarSet'] = 'ProjectCommentStudent'; } $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); $form->addFile('user_upload', get_lang('AddAnAttachment')); $form->addTextarea('post_file_comment', get_lang('FileComment')); $form->addHidden('action', null); $form->addHidden('comment_parent_id', 0); if (isset($_GET['task_id'])) { $form->addHidden('new_task_execution_submit', 'true'); $form->addHidden('task_id', intval($_GET['task_id'])); } else { $form->addHidden('new_comment_submit', 'true'); } $form->addButton('save', get_lang('Save')); $form->display(); }
} // Create a sortable table with user-data $parameters['sec_token'] = Security::get_token(); // get the list of all admins to mark them in the users list $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); $sql_admin = "SELECT user_id FROM {$admin_table}"; $res_admin = Database::query($sql_admin); $_admins_list = array(); while ($row_admin = Database::fetch_row($res_admin)) { $_admins_list[] = $row_admin[0]; } // Display Advanced search form. $form = new FormValidator('advanced_search', 'get', '', '', array(), FormValidator::LAYOUT_HORIZONTAL); $form->addElement('html', '<div id="advanced_search_form" style="display:none;">'); $form->addElement('header', get_lang('AdvancedSearch')); $form->addText('keyword_firstname', get_lang('FirstName'), false); $form->addText('keyword_lastname', get_lang('LastName'), false); $form->addText('keyword_username', get_lang('LoginName'), false); $form->addText('keyword_email', get_lang('Email'), false); $form->addText('keyword_officialcode', get_lang('OfficialCode'), false); $status_options = array(); $status_options['%'] = get_lang('All'); $status_options[STUDENT] = get_lang('Student'); $status_options[COURSEMANAGER] = get_lang('Teacher'); $status_options[DRH] = get_lang('Drh'); $status_options[SESSIONADMIN] = get_lang('SessionsAdmin'); $status_options[PLATFORM_ADMIN] = get_lang('Administrator'); $form->addElement('select', 'keyword_status', get_lang('Profile'), $status_options); $active_group = array(); $active_group[] = $form->createElement('checkbox', 'keyword_active', '', get_lang('Active')); $active_group[] = $form->createElement('checkbox', 'keyword_inactive', '', get_lang('Inactive'));
if (api_is_allowed_to_edit(null, true)) { echo '<div class="actions">'; switch ($type) { case STUDENT: $selectedTab = 1; $url = api_get_path(WEB_CODE_PATH) . 'user/subscribe_user.php?' . api_get_cidreq() . '&type=' . STUDENT; break; case COURSEMANAGER: $selectedTab = 2; $url = api_get_path(WEB_CODE_PATH) . 'user/subscribe_user.php?' . api_get_cidreq() . '&type=' . COURSEMANAGER; break; } echo Display::url(Display::return_icon('add.png', get_lang('Add'), '', ICON_SIZE_MEDIUM), $url); // Build search-form $form = new FormValidator('search_user', 'get', '', '', null, FormValidator::LAYOUT_INLINE); $form->addText('keyword', '', false); $form->addButtonSearch(get_lang('SearchButton')); $form->display(); $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&type=csv">' . Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM) . '</a> '; $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&type=xls">' . Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM) . '</a> '; if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' || api_is_platform_admin()) { $actions .= '<a href="user_import.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM) . '</a> '; } $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&type=pdf">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a> '; $allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session'); if (api_is_allowed_to_edit() && $allowTutors == 'true') { $actions .= ' <a class="btn btn-default" href="session_list.php?' . api_get_cidreq() . '">' . get_lang('Sessions') . '</a>'; } echo $actions; echo '</div>'; }
$chat->startSession(); break; case 'set_status': $status = isset($_REQUEST['status']) ? intval($_REQUEST['status']) : 0; $chat->setUserStatus($status); break; case 'start_video': $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id); if ($room !== false) { $videoChatLink = Display::url(Display::tag('i', null, ['class' => 'fa fa-video-camera']) . " " . get_lang('StartVideoChat'), api_get_path(WEB_LIBRARY_JS_PATH) . "chat/video.php?room={$room['room_name']}"); $chat->send(api_get_user_id(), $to_user_id, $videoChatLink, false); echo Display::tag('p', $videoChatLink, ['class' => 'lead']); break; } $form = new FormValidator('start_video_chat'); $form->addText('chat_room_name', get_lang('ChatRoomName'), false); $form->addHidden('to', $to_user_id); $form->addButtonSend(get_lang('Create')); $template = new Template(); $template->assign('form', $form->returnForm()); echo $template->fetch('default/javascript/chat/start_video.tpl'); break; case 'create_room': $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id); $createdRoom = false; if ($room === false) { $roomName = isset($_REQUEST['room_name']) ? Security::remove_XSS($_REQUEST['room_name']) : null; if (VideoChat::nameExists($roomName)) { echo Display::return_message(get_lang('TheVideoChatRoomXNameAlreadyExists'), 'error'); break; }
/** * Shows statistics about the time of last visit to each course. */ public static function printCourseLastVisit() { $access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $current_url_id = api_get_current_access_url_id(); $columns[0] = 'c_id'; $columns[1] = 'access_date'; $sql_order[SORT_ASC] = 'ASC'; $sql_order[SORT_DESC] = 'DESC'; $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10; $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1; $column = isset($_GET['column']) ? intval($_GET['column']) : 0; $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60; $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC; if (!in_array($direction, array(SORT_ASC, SORT_DESC))) { $direction = SORT_ASC; } $form = new FormValidator('courselastvisit', 'get'); $form->addElement('hidden', 'report', 'courselastvisit'); $form->addText('date_diff', get_lang('Days'), true); $form->addRule('date_diff', 'InvalidNumber', 'numeric'); $form->addButtonSearch(get_lang('Search'), 'submit'); if (!isset($_GET['date_diff'])) { $defaults['date_diff'] = 60; } else { $defaults['date_diff'] = Security::remove_XSS($_GET['date_diff']); } $form->setDefaults($defaults); $form->display(); $values = $form->exportValues(); $date_diff = $values['date_diff']; $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); if (api_is_multiple_url_enabled()) { $sql = "SELECT * FROM {$table} t , {$access_url_rel_course_table} a\n WHERE\n t.c_id = a.c_id AND\n access_url_id='" . $current_url_id . "'\n GROUP BY c_id\n HAVING c_id <> ''\n AND DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff; } else { $sql = "SELECT * FROM {$table}\n GROUP BY c_id\n HAVING c_id <> ''\n AND DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff; } $sql .= ' ORDER BY ' . $columns[$column] . ' ' . $sql_order[$direction]; $from = ($page_nr - 1) * $per_page; $sql .= ' LIMIT ' . $from . ',' . $per_page; echo '<p>' . get_lang('LastAccess') . ' >= ' . $date_diff . ' ' . get_lang('Days') . '</p>'; $res = Database::query($sql); if (Database::num_rows($res) > 0) { $courses = array(); while ($obj = Database::fetch_object($res)) { $courseInfo = api_get_course_info_by_id($obj->c_id); if (empty($courseInfo)) { continue; } $course = array(); $course[] = '<a href="' . api_get_path(WEB_COURSE_PATH) . $courseInfo['code'] . '">' . $courseInfo['code'] . ' <a>'; // Allow sort by date hiding the numerical date $course[] = '<span style="display:none;">' . $obj->access_date . '</span>' . api_convert_and_format_date($obj->access_date); $courses[] = $course; } $parameters['date_diff'] = $date_diff; $parameters['report'] = 'courselastvisit'; $table_header[] = array(get_lang("CourseCode"), true); $table_header[] = array(get_lang("LastAccess"), true); Display::display_sortable_table($table_header, $courses, array('column' => $column, 'direction' => $direction), array(), $parameters); } else { echo get_lang('NoSearchResults'); } }
$form = new FormValidator('add_course', 'post', 'course_request_edit.php?id=' . $id . '&caller=' . $caller); // Form title. $form->addElement('header', $tool_name); // Title. $form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title')); $form->applyFilter('title', 'html_filter'); $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); // Course category. $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category'; $courseSelect = $form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url)); if (!empty($course_request_info['category_code'])) { $data = CourseCategory::getCategory($course_request_info['category_code']); $courseSelect->addOption($data['name'], $data['code'], ['selected' => 'selected']); } // Course code. $form->addText('wanted_code', get_lang('Code'), false, array('size' => '$maxlength', 'maxlength' => $maxlength)); $form->applyFilter('wanted_code', 'html_filter'); $form->addRule('wanted_code', get_lang('Max'), 'maxlength', $maxlength); $form->addRule('wanted_code', get_lang('ThisFieldIsRequired'), 'required'); // The teacher. $titular = $form->addText('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled')); // Description of the requested course. $form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116')); $form->addRule('description', get_lang('ThisFieldIsRequired'), 'required'); // Objectives of the requested course. $form->addElement('textarea', 'objetives', get_lang('Objectives'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116')); $form->addRule('objetives', get_lang('ThisFieldIsRequired'), 'required'); // Target audience of the requested course. $form->addElement('textarea', 'target_audience', get_lang('TargetAudience'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116')); $form->addRule('target_audience', get_lang('ThisFieldIsRequired'), 'required'); // Course language.
*/ /** * Code */ // Resetting the course id. $cidReset = true; // Including some necessary dokeos files. //require_once '../inc/global.inc.php'; // Setting the section (for the tabs). $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions. api_protect_admin_script(); // Setting breadcrumbs. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'class_list.php', 'name' => get_lang('Classes')); // Setting the name of the tool. $tool_name = get_lang("AddClasses"); $form = new FormValidator('add_class'); $form->addText('name', get_lang('ClassName')); $form->addButtonCreate(get_lang('Ok')); if ($form->validate()) { $values = $form->exportValues(); ClassManager::create_class($values['name']); header('Location: class_list.php'); } // Displaying the header. Display::display_header($tool_name); // Displaying the form. $form->display(); // Displaying the footer. Display::display_footer();
/** * @return string */ public function displayLoginForm() { $form = new FormValidator('formLogin', 'POST', null, null, null, FormValidator::LAYOUT_BOX_NO_LABEL); $form->addText('login', get_lang('UserName'), true, array('id' => 'login', 'autofocus' => 'autofocus', 'icon' => 'user fa-fw', 'placeholder' => get_lang('UserName'))); $form->addElement('password', 'password', get_lang('Pass'), array('id' => 'password', 'icon' => 'lock fa-fw', 'placeholder' => get_lang('Pass'))); // Captcha $captcha = api_get_setting('allow_captcha'); $allowCaptcha = $captcha == 'true'; if ($allowCaptcha) { $useCaptcha = isset($_SESSION['loginFailed']) ? $_SESSION['loginFailed'] : null; if ($useCaptcha) { $ajax = api_get_path(WEB_AJAX_PATH) . 'form.ajax.php?a=get_captcha'; $options = array('width' => 250, 'height' => 90, 'callback' => $ajax . '&var=' . basename(__FILE__, '.php'), 'sessionVar' => basename(__FILE__, '.php'), 'imageOptions' => array('font_size' => 20, 'font_path' => api_get_path(SYS_FONTS_PATH) . 'opensans/', 'font_file' => 'OpenSans-Regular.ttf')); // Minimum options using all defaults (including defaults for Image_Text): //$options = array('callback' => 'qfcaptcha_image.php'); $captcha_question = $form->addElement('CAPTCHA_Image', 'captcha_question', '', $options); $form->addHtml(get_lang('ClickOnTheImageForANewOne')); $form->addElement('text', 'captcha', get_lang('EnterTheLettersYouSee')); $form->addRule('captcha', get_lang('EnterTheCharactersYouReadInTheImage'), 'required', null, 'client'); $form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question); } } $form->addButton('submitAuth', get_lang('LoginEnter'), null, 'primary', null, 'btn-block'); $html = $form->returnForm(); if (api_get_setting('openid_authentication') == 'true') { include_once 'main/auth/openid/login.php'; $html .= '<div>' . openid_form() . '</div>'; } return $html; }
function manage_form($default, $select_from_user_list = null, $sent_to = null) { $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null; $param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null; $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data')); if (empty($group_id)) { if (isset($select_from_user_list)) { $form->addText('id_text_name', get_lang('SendMessageTo'), true, array('id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off')); $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" > </div>'); $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list')); } else { if (!empty($sent_to)) { $form->addLabel(get_lang('SendMessageTo'), $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select_ajax', 'users', get_lang('SendMessageTo'), array(), ['multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH) . 'message.ajax.php?a=find_users']); } else { $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user')); } } } else { $userGroup = new UserGroup(); $group_info = $userGroup->get($group_id); $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name'])); $form->addElement('hidden', 'group_id', $group_id); $form->addElement('hidden', 'parent_id', $message_id); } $form->addText('title', get_lang('Subject'), true); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250')); if (isset($_GET['re_id'])) { $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title']; $form->addElement('hidden', 're_id', intval($_GET['re_id'])); $form->addElement('hidden', 'save_form', 'save_form'); //adding reply mail $user_reply_info = api_get_user_info($message_reply_info['user_sender_id']); $default['content'] = '<p><br/></p>' . sprintf(get_lang('XWroteY'), $user_reply_info['complete_name'], Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('label', '', '<div id="filepaths" class="form-group"> <div id="filepath_1"> <label>' . get_lang('FilesAttachment') . '</label> <input type="file" name="attach_1"/> <label>' . get_lang('Description') . '</label> <input id="file-descrtiption" type="text" name="legend[]" class="form-control"/> </div> </div>'); $form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))) . ')'); } $form->addButtonSend(get_lang('SendMessage'), 'compose'); $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); if (!empty($group_id) && !empty($message_id)) { $message_info = MessageManager::get_message_by_id($message_id); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title']; } $form->setDefaults($default); $html = ''; if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $user_list = $default['users']; $file_comments = $_POST['legend']; $title = $default['title']; $content = $default['content']; $group_id = isset($default['group_id']) ? $default['group_id'] : null; $parent_id = isset($default['parent_id']) ? $default['parent_id'] : null; if (is_array($user_list) && count($user_list) > 0) { //all is well, send the message foreach ($user_list as $user) { $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id); if ($res) { $html .= MessageManager::display_success_message($user); } } } else { Display::display_error_message('ErrorSendingMessage'); } } Security::clear_token(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $html .= $form->returnForm(); } return $html; }
$userId = Request::get('id'); $this_section = SECTION_CAMPUS; $tool_name = get_lang('LostPassword'); if ($reset && $userId) { $messageText = Login::reset_password($reset, $userId, true); if (CustomPages::enabled() && CustomPages::exists(CustomPages::INDEX_UNLOGGED)) { CustomPages::display(CustomPages::INDEX_UNLOGGED, ['info' => $messageText]); exit; } Display::addFlash(Display::return_message($messageText)); header('Location: ' . api_get_path(WEB_PATH)); exit; } $form = new FormValidator('lost_password'); $form->addHeader($tool_name); $form->addText('user', [get_lang('LoginOrEmailAddress'), get_lang('EnterEmailUserAndWellSendYouPassword')], true); $form->addButtonSend(get_lang('Send')); if ($form->validate()) { $values = $form->exportValues(); $user = Login::get_user_accounts_by_username($values['user']); if (!$user) { $messageText = get_lang('NoUserAccountWithThisEmailAddress'); if (CustomPages::enabled() && CustomPages::exists(CustomPages::LOST_PASSWORD)) { CustomPages::display(CustomPages::LOST_PASSWORD, ['info' => $messageText]); exit; } Display::addFlash(Display::return_message($messageText, 'error')); header('Location: ' . api_get_self()); exit; } $passwordEncryption = api_get_configuration_value('password_encryption');