/** * @param FormValidator $form * @param array $questionData * @param array $answers */ public function render(FormValidator $form, $questionData = array(), $answers = '') { $name = 'question' . $questionData['question_id']; $form->addSelect($name, null, $questionData['options']); if (!empty($answers)) { $form->setDefaults([$name => $answers]); } }
/** * @param FormValidator $form * @param array $questionData * @param array $answers */ public function render(FormValidator $form, $questionData = array(), $answers = '') { $options = array('--' => '--'); foreach ($questionData['options'] as $key => &$value) { $options[$key] = $value; } $name = 'question' . $questionData['question_id']; $form->addSelect($name, null, $options); if (!empty($answers)) { $form->setDefaults([$name => $answers]); } }
/** * @param FormValidator $form * @param array $questionData * @param array $answers */ public function render(FormValidator $form, $questionData = array(), $answers = array()) { $defaults = []; foreach ($questionData['options'] as $key => &$value) { $options = array(); for ($i = 1; $i <= $questionData['maximum_score']; $i++) { $options[$i] = $i; } $name = 'question' . $questionData['question_id'] . '[' . $key . ']'; $form->addSelect($name, $value, $options); if (!empty($answers)) { if (in_array($key, array_keys($answers))) { $defaults[$name] = $answers[$key]; } } } if (!empty($defaults)) { $form->setDefaults($defaults); } }
$currentUserId = api_get_user_id(); $currentUser = $entityManager->find('ChamiloUserBundle:User', $currentUserId); $allowExport = $currentUser ? $currentUser->getId() === $skillIssue->getUser()->getId() : false; $allowComment = $currentUser ? Skill::userCanAddFeedbackToUser($currentUser, $skillIssue->getUser()) : false; $skillIssueDate = api_get_local_time($skillIssue->getAcquiredSkillAt()); $skillIssueInfo = ['id' => $skillIssue->getId(), 'datetime' => api_format_date($skillIssueDate, DATE_TIME_FORMAT_SHORT), 'argumentation' => $skillIssue->getArgumentation(), 'source_name' => $skillIssue->getSourceName(), 'user_id' => $skillIssue->getUser()->getId(), 'user_complete_name' => $skillIssue->getUser()->getCompleteName(), 'skill_badge_image' => $skillIssue->getSkill()->getWebIconPath(), 'skill_name' => $skillIssue->getSkill()->getName(), 'skill_short_code' => $skillIssue->getSkill()->getShortCode(), 'skill_description' => $skillIssue->getSkill()->getDescription(), 'skill_criteria' => $skillIssue->getSkill()->getCriteria(), 'badge_asserion' => [$skillIssue->getAssertionUrl()], 'comments' => [], 'feedback_average' => $skillIssue->getAverage()]; $skillIssueComments = $skillIssue->getComments(true); foreach ($skillIssueComments as $comment) { $commentDate = api_get_local_time($comment->getFeedbackDateTime()); $skillIssueInfo['comments'][] = ['text' => $comment->getFeedbackText(), 'value' => $comment->getFeedbackValue(), 'giver_complete_name' => $comment->getFeedbackGiver()->getCompleteName(), 'datetime' => api_format_date($commentDate, DATE_TIME_FORMAT_SHORT)]; } $form = new FormValidator('comment'); $form->addTextarea('comment', get_lang('NewComment'), ['rows' => 4]); $form->applyFilter('comment', 'trim'); $form->addRule('comment', get_lang('ThisFieldIsRequired'), 'required'); $form->addSelect('value', [get_lang('Value'), get_lang('RateTheSkillInPractice')], ['-', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); $form->addHidden('user', $skillIssue->getUser()->getId()); $form->addHidden('issue', $skillIssue->getId()); $form->addButtonSend(get_lang('Send')); if ($form->validate() && $allowComment) { $values = $form->exportValues(); $skillUserComment = new Chamilo\CoreBundle\Entity\SkillRelUserComment(); $skillUserComment->setFeedbackDateTime(new DateTime())->setFeedbackGiver($currentUser)->setFeedbackText($values['comment'])->setFeedbackValue($values['value'] ? $values['value'] : null)->setSkillRelUser($skillIssue); $entityManager->persist($skillUserComment); $entityManager->flush(); header("Location: " . $skillIssue->getIssueUrl()); exit; } if ($allowExport) { $backpack = 'https://backpack.openbadges.org/'; $configBackpack = api_get_setting('openbadges_backpack');
/** * @param FormValidator $form * * @return array */ public static function setForm(FormValidator &$form, $sessionId = 0) { $categoriesList = SessionManager::get_all_session_category(); $userInfo = api_get_user_info(); $categoriesOptions = array('0' => get_lang('None')); if ($categoriesList != false) { foreach ($categoriesList as $categoryItem) { $categoriesOptions[$categoryItem['id']] = $categoryItem['name']; } } // Database Table Definitions $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $form->addElement('text', 'name', get_lang('SessionName'), array('maxlength' => 50)); $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('name', get_lang('SessionNameAlreadyExists'), 'callback', 'check_session_name'); if (!api_is_platform_admin() && api_is_teacher()) { $form->addElement('select', 'coach_username', get_lang('CoachName'), [api_get_user_id() => $userInfo['complete_name']], array('id' => 'coach_username', 'class' => 'chzn-select', 'style' => 'width:370px;')); } else { $sql = "SELECT COUNT(1) FROM {$tbl_user} WHERE status = 1"; $rs = Database::query($sql); $countUsers = Database::result($rs, 0, 0); if (intval($countUsers) < 50) { $orderClause = "ORDER BY "; $orderClause .= api_sort_by_first_name() ? "firstname, lastname, username" : "lastname, firstname, username"; $sql = "SELECT user_id, lastname, firstname, username\n FROM {$tbl_user}\n WHERE status = '1' " . $orderClause; if (api_is_multiple_url_enabled()) { $userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $accessUrlId = api_get_current_access_url_id(); if ($accessUrlId != -1) { $sql = "SELECT user.user_id, username, lastname, firstname\n FROM {$tbl_user} user\n INNER JOIN {$userRelAccessUrlTable} url_user\n ON (url_user.user_id = user.user_id)\n WHERE\n access_url_id = {$accessUrlId} AND\n status = 1 " . $orderClause; } } $result = Database::query($sql); $coachesList = Database::store_result($result); $coachesOptions = array(); foreach ($coachesList as $coachItem) { $coachesOptions[$coachItem['user_id']] = api_get_person_name($coachItem['firstname'], $coachItem['lastname']) . ' (' . $coachItem['username'] . ')'; } $form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions); } else { $form->addElement('select_ajax', 'coach_username', get_lang('CoachName'), null, ['url' => api_get_path(WEB_AJAX_PATH) . 'session.ajax.php?a=search_general_coach', 'width' => '100%']); } } $form->addRule('coach_username', get_lang('ThisFieldIsRequired'), 'required'); $form->addHtml('<div id="ajax_list_coachs"></div>'); $form->addButtonAdvancedSettings('advanced_params'); $form->addElement('html', '<div id="advanced_params_options" style="display:none">'); $form->addSelect('session_category', get_lang('SessionCategory'), $categoriesOptions, array('id' => 'session_category', 'class' => 'chzn-select', 'style' => 'width:370px;')); $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Minimal')); $form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription')); $visibilityGroup = array(); $visibilityGroup[] = $form->createElement('select', 'session_visibility', null, array(SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'), SESSION_VISIBLE => get_lang('SessionAccessible'), SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible')))); $form->addGroup($visibilityGroup, 'visibility_group', get_lang('SessionVisibility'), null, false); $options = [0 => get_lang('ByDuration'), 1 => get_lang('ByDates')]; $form->addSelect('access', get_lang('Access'), $options, array('onchange' => 'accessSwitcher()', 'id' => 'access')); $form->addElement('html', '<div id="duration" style="display:none">'); $form->addElement('number', 'duration', array(get_lang('SessionDurationTitle'), get_lang('SessionDurationDescription')), array('maxlength' => 50)); $form->addElement('html', '</div>'); $form->addElement('html', '<div id="date_fields" style="display:none">'); // Dates $form->addDateTimePicker('access_start_date', array(get_lang('SessionStartDate'), get_lang('SessionStartDateComment')), array('id' => 'access_start_date')); $form->addDateTimePicker('access_end_date', array(get_lang('SessionEndDate'), get_lang('SessionEndDateComment')), array('id' => 'access_end_date')); $form->addRule(array('access_start_date', 'access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty'); $form->addDateTimePicker('display_start_date', array(get_lang('SessionDisplayStartDate'), get_lang('SessionDisplayStartDateComment')), array('id' => 'display_start_date')); $form->addDateTimePicker('display_end_date', array(get_lang('SessionDisplayEndDate'), get_lang('SessionDisplayEndDateComment')), array('id' => 'display_end_date')); $form->addRule(array('display_start_date', 'display_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty'); $form->addDateTimePicker('coach_access_start_date', array(get_lang('SessionCoachStartDate'), get_lang('SessionCoachStartDateComment')), array('id' => 'coach_access_start_date')); $form->addDateTimePicker('coach_access_end_date', array(get_lang('SessionCoachEndDate'), get_lang('SessionCoachEndDateComment')), array('id' => 'coach_access_end_date')); $form->addRule(array('coach_access_start_date', 'coach_access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty'); $form->addElement('html', '</div>'); $form->addCheckBox('send_subscription_notification', [get_lang('SendSubscriptionNotification'), get_lang('SendAnEmailWhenAUserBeingSubscribed')]); // Extra fields $extra_field = new ExtraField('session'); $extra = $extra_field->addElements($form, $sessionId); $form->addElement('html', '</div>'); $js = $extra['jquery_ready_content']; return ['js' => $js]; }
/** * @param $blog_id * @return FormValidator */ public static function getTaskForm($blog_id) { // Init $tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $course_id = api_get_course_int_id(); // Get users in this blog / make select list of it $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username\n\t\t\t\tFROM {$tbl_users} user\n\t\t\t\tINNER JOIN {$tbl_blogs_rel_user} blogs_rel_user\n\t\t\t\tON user.user_id = blogs_rel_user.user_id\n\t\t\t\tWHERE blogs_rel_user.c_id = {$course_id} AND blogs_rel_user.blog_id = '" . (int) $blog_id . "'"; $result = Database::query($sql); $options = array(); while ($user = Database::fetch_array($result)) { $username = api_htmlentities(sprintf(get_lang('LoginX'), $user['username']), ENT_QUOTES); $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); } // Get tasks in this blog / make select list of it $sql = "\n\t\t\tSELECT\n\t\t\t\tblog_id,\n\t\t\t\ttask_id,\n\t\t\t\tblog_id,\n\t\t\t\ttitle,\n\t\t\t\tdescription,\n\t\t\t\tcolor,\n\t\t\t\tsystem_task\n\t\t\tFROM " . $tbl_blogs_tasks . "\n\t\t\tWHERE c_id = {$course_id} AND blog_id = " . (int) $blog_id . "\n\t\t\tORDER BY system_task, title"; $result = Database::query($sql); $taskOptions = array(); while ($task = Database::fetch_array($result)) { $taskOptions[$task['task_id']] = stripslashes($task['title']); } $form = new FormValidator('assign_task', 'post', api_get_path(WEB_CODE_PATH) . 'blog/blog.php?action=manage_tasks&blog_id=' . $blog_id); $form->addHeader(get_lang('AssignTask')); $form->addSelect('task_user_id', get_lang('SelectUser'), $options); $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); $form->addDatePicker('task_day', get_lang('SelectTargetDate')); $form->addHidden('action', ''); $form->addButtonSave(get_lang('Ok')); return $form; }
$condition = array('status = ?' => 1); if ($form->validate()) { $data = $form->getSubmitValues(); $filter = intval($data['filter']); if (!empty($filter)) { $condition = array('status = ? AND id = ? ' => array(1, $filter)); } } $careers = $career->get_all(array('status = ?' => 1)); //only status =1 $career_select_list = array(); $career_select_list[0] = ' -- ' . get_lang('Select') . ' --'; foreach ($careers as $item) { $career_select_list[$item['id']] = $item['name']; } $form->addSelect('filter', get_lang('Career'), $career_select_list, array('id' => 'filter_1')); $form->addButtonSearch(get_lang('Filter')); // action links echo '<div class="actions" style="margin-bottom:20px">'; echo '<a href="../admin/index.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="careers.php">' . Display::return_icon('career.png', get_lang('Careers'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="promotions.php">' . Display::return_icon('promotion.png', get_lang('Promotions'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '</div>'; $form->display(); $careers = $career->get_all($condition); //only status =1 $column_count = 3; $i = 0; $grid_js = ''; $career_array = array(); if (!empty($careers)) {
$("#group_filter").change(function() { window.location = "class.php?' . api_get_cidreq() . '&type=' . $type . '" +"&group_filter=" + $(this).val(); }); }); </script>'; $actions = ''; $usergroup = new UserGroup(); if (api_is_allowed_to_edit()) { $actions .= '<div class="actions">'; if ($type == 'registered') { $actions .= '<a href="class.php?' . api_get_cidreq() . '&type=not_registered">' . Display::return_icon('add-class.png', get_lang("AddClassesToACourse"), array(), ICON_SIZE_MEDIUM) . '</a>'; } else { $actions .= '<a href="class.php?' . api_get_cidreq() . '&type=registered">' . Display::return_icon('back.png', get_lang("Classes"), array(), ICON_SIZE_MEDIUM) . '</a>'; $form = new FormValidator('groups', 'post', api_get_self(), '', '', FormValidator::LAYOUT_INLINE); $options = [-1 => get_lang('All'), 1 => get_lang('SocialGroups'), 0 => get_lang('Classes')]; $form->addSelect('group_filter', get_lang('Groups'), $options, ['id' => 'group_filter']); $form->setDefaults(['group_filter' => $groupFilter]); $actions .= $form->returnForm(); } $actions .= '</div>'; } if (api_is_allowed_to_edit()) { $action = isset($_GET['action']) ? $_GET['action'] : null; switch ($action) { case 'add_class_to_course': $id = $_GET['id']; if (!empty($id)) { $usergroup->subscribe_courses_to_usergroup($id, array(api_get_course_int_id()), false); Display::addFlash(Display::return_message(get_lang('Added'))); } break;
/** * 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(); }
/* View */ $template = new Template(get_lang('GradebookListOfStudentsCertificates')); if (Session::has('reportErrorMessage')) { $template->assign('errorMessage', Session::read('reportErrorMessage')); } $searchBySessionCourseDateForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php'); $searchBySessionCourseDateForm->addSelect('session', get_lang('Sessions'), $sessions, ['id' => 'session']); $searchBySessionCourseDateForm->addSelect('course', get_lang('Courses'), $courses, ['id' => 'course']); $searchBySessionCourseDateForm->addGroup([$searchBySessionCourseDateForm->createElement('select', 'month', null, $months, ['id' => 'month']), $searchBySessionCourseDateForm->createElement('text', 'year', null, ['id' => 'year', 'placeholder' => get_lang('Year')])], null, get_lang('Date')); $searchBySessionCourseDateForm->addButtonSearch(); $searchBySessionCourseDateForm->setDefaults(['session' => $selectedSession, 'course' => $selectedCourse, 'month' => $selectedMonth, 'year' => $selectedYear]); if (api_is_student_boss()) { foreach ($userList as $studentId) { $students[$studentId] = api_get_user_info($studentId)['complete_name_with_username']; } $searchByStudentForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php'); $searchByStudentForm->addSelect('student', get_lang('Students'), $students, ['id' => 'student']); $searchByStudentForm->addButtonSearch(); $searchByStudentForm->setDefaults(['student' => $selectedStudent]); $template->assign('searchByStudentForm', $searchByStudentForm->returnForm()); } $template->assign('searchBySessionCourseDateForm', $searchBySessionCourseDateForm->returnForm()); $template->assign('sessions', $sessions); $template->assign('courses', $courses); $template->assign('months', $months); $template->assign('exportAllLink', $exportAllLink); $template->assign('certificateStudents', $certificateStudents); $content = $template->fetch("default/gradebook/certificate_report.tpl"); $template->assign('content', $content); $template->display_one_col_template(); Session::erase('reportErrorMessage');
/** * @param FormValidator $form * @param array $extraData * @param bool $admin_permissions * @param int $user_id * @param array $extra * @param int $itemId * @param array $exclude variables of extra field to exclude * @return array */ public function set_extra_fields_in_form($form, $extraData, $admin_permissions = false, $extra = array(), $itemId = null, $exclude = []) { $type = $this->type; $jquery_ready_content = null; if (!empty($extra)) { foreach ($extra as $field_details) { // Getting default value id if is set $defaultValueId = null; if (isset($field_details['options']) && !empty($field_details['options'])) { $valueToFind = null; if (isset($field_details['field_default_value'])) { $valueToFind = $field_details['field_default_value']; } // If a value is found we override the default value if (isset($extraData['extra_' . $field_details['variable']])) { $valueToFind = $extraData['extra_' . $field_details['variable']]; } foreach ($field_details['options'] as $option) { if ($option['option_value'] == $valueToFind) { $defaultValueId = $option['id']; } } } if (!$admin_permissions) { if ($field_details['visible'] == 0) { continue; } if (in_array($field_details['variable'], $exclude)) { continue; } } switch ($field_details['field_type']) { case ExtraField::FIELD_TYPE_TEXT: $form->addElement('text', 'extra_' . $field_details['variable'], $field_details['display_text'], array()); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['variable'], 'trim'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_TEXTAREA: $form->addHtmlEditor('extra_' . $field_details['variable'], $field_details['display_text'], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['variable'], 'trim'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_RADIO: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['display_text']; $group[] = $form->createElement('radio', 'extra_' . $field_details['variable'], $option_details['option_value'], $option_details['display_text'] . '<br />', $option_details['option_value']); } } $form->addGroup($group, 'extra_' . $field_details['variable'], $field_details['display_text'], ''); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_CHECKBOX: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['display_text']; $group[] = $form->createElement('checkbox', 'extra_' . $field_details['variable'], $option_details['option_value'], $option_details['display_text'] . '<br />', $option_details['option_value']); } } else { $fieldVariable = "extra_{$field_details['variable']}"; $checkboxAttributes = array(); if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) { $checkboxAttributes['checked'] = true; } // We assume that is a switch on/off with 1 and 0 as values $group[] = $form->createElement('checkbox', 'extra_' . $field_details['variable'], null, get_lang('Yes'), $checkboxAttributes); } $form->addGroup($group, 'extra_' . $field_details['variable'], $field_details['display_text'], ''); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_SELECT: $get_lang_variables = false; if (in_array($field_details['variable'], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) { $get_lang_variables = true; } // Get extra field workflow $userInfo = api_get_user_info(); $addOptions = array(); $optionsExists = false; global $app; // Check if exist $app['orm.em'] object if (isset($app['orm.em']) && is_object($app['orm.em'])) { $optionsExists = $app['orm.em']->getRepository('ChamiloLMS\\Entity\\ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_details['id'])); } if ($optionsExists) { if (isset($userInfo['status']) && !empty($userInfo['status'])) { $fieldWorkFlow = $app['orm.em']->getRepository('ChamiloLMS\\Entity\\ExtraFieldOptionRelFieldOption')->findBy(array('fieldId' => $field_details['id'], 'relatedFieldOptionId' => $defaultValueId, 'roleId' => $userInfo['status'])); foreach ($fieldWorkFlow as $item) { $addOptions[] = $item->getFieldOptionId(); } } } $options = array(); if (empty($defaultValueId)) { $options[''] = get_lang('SelectAnOption'); } $optionList = array(); if (!empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $optionList[$option_details['id']] = $option_details; if ($get_lang_variables) { $options[$option_details['option_value']] = get_lang($option_details['display_text']); } else { if ($optionsExists) { // Adding always the default value if ($option_details['id'] == $defaultValueId) { $options[$option_details['option_value']] = $option_details['display_text']; } else { if (isset($addOptions) && !empty($addOptions)) { // Parsing filters if (in_array($option_details['id'], $addOptions)) { $options[$option_details['option_value']] = $option_details['display_text']; } } } } else { // Normal behaviour $options[$option_details['option_value']] = $option_details['display_text']; } } } if (isset($optionList[$defaultValueId])) { if (isset($optionList[$defaultValueId]['option_value']) && $optionList[$defaultValueId]['option_value'] == 'aprobada') { // @todo function don't exists api_is_question_manager /*if (api_is_question_manager() == false) { $form->freeze(); }*/ } } // Setting priority message if (isset($optionList[$defaultValueId]) && isset($optionList[$defaultValueId]['priority'])) { if (!empty($optionList[$defaultValueId]['priority'])) { $priorityId = $optionList[$defaultValueId]['priority']; $option = new ExtraFieldOption($this->type); $messageType = $option->getPriorityMessageType($priorityId); $form->addElement('label', null, Display::return_message($optionList[$defaultValueId]['priority_message'], $messageType)); } } } if ($get_lang_variables) { $field_details['display_text'] = get_lang($field_details['display_text']); } // chzn-select doesn't work for sessions?? $form->addElement('select', 'extra_' . $field_details['variable'], $field_details['display_text'], $options, array('id' => 'extra_' . $field_details['variable'])); /* Enable this when field_loggeable is introduced as a table field (2.0) if ($optionsExists && $field_details['field_loggeable'] && !empty($defaultValueId)) { $form->addElement( 'textarea', 'extra_' . $field_details['variable'] . '_comment', $field_details['display_text'] . ' ' . get_lang('Comment') ); $extraFieldValue = new ExtraFieldValue($this->type); $repo = $app['orm.em']->getRepository($extraFieldValue->entityName); $repoLog = $app['orm.em']->getRepository('Gedmo\Loggable\Entity\LogEntry'); $newEntity = $repo->findOneBy( array( $this->handlerEntityId => $itemId, 'fieldId' => $field_details['id'] ) ); // @todo move this in a function inside the class if ($newEntity) { $logs = $repoLog->getLogEntries($newEntity); if (!empty($logs)) { $html = '<b>' . get_lang('LatestChanges') . '</b><br /><br />'; $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Value')); $table->setHeaderContents(0, 1, get_lang('Comment')); $table->setHeaderContents(0, 2, get_lang('ModifyDate')); $table->setHeaderContents(0, 3, get_lang('Username')); $row = 1; foreach ($logs as $log) { $column = 0; $data = $log->getData(); $fieldValue = isset($data['fieldValue']) ? $data['fieldValue'] : null; $comment = isset($data['comment']) ? $data['comment'] : null; $table->setCellContents($row, $column, $fieldValue); $column++; $table->setCellContents($row, $column, $comment); $column++; $table->setCellContents($row, $column, api_get_local_time($log->getLoggedAt()->format('Y-m-d H:i:s'))); $column++; $table->setCellContents($row, $column, $log->getUsername()); $row++; } $form->addElement('label', null, $html.$table->toHtml()); } } } */ if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: $options = array(); foreach ($field_details['options'] as $option_id => $option_details) { $options[$option_details['option_value']] = $option_details['display_text']; } $form->addElement('select', 'extra_' . $field_details['variable'], $field_details['display_text'], $options, array('multiple' => 'multiple')); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_DATE: $form->addDatePicker('extra_' . $field_details['variable'], $field_details['display_text']); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DATETIME: $form->addDateTimePicker('extra_' . $field_details['variable'], $field_details['display_text']); $defaults['extra_' . $field_details['variable']] = api_get_local_time(); if (!isset($form->_defaultValues['extra_' . $field_details['variable']])) { $form->setDefaults($defaults); } if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DOUBLE_SELECT: $first_select_id = 'first_extra_' . $field_details['variable']; $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php?1=1'; $jquery_ready_content .= ' $("#' . $first_select_id . '").on("change", function() { var id = $(this).val(); if (id) { $.ajax({ url: "' . $url . '&a=get_second_select_options", dataType: "json", data: "type=' . $type . '&field_id=' . $field_details['id'] . '&option_value_id="+id, success: function(data) { $("#second_extra_' . $field_details['variable'] . '").empty(); $.each(data, function(index, value) { $("#second_extra_' . $field_details['variable'] . '").append($("<option/>", { value: index, text: value })); }); }, }); } else { $("#second_extra_' . $field_details['variable'] . '").empty(); } });'; $first_id = null; $second_id = null; if (!empty($extraData)) { $first_id = $extraData['extra_' . $field_details['variable']]['extra_' . $field_details['variable']]; $second_id = $extraData['extra_' . $field_details['variable']]['extra_' . $field_details['variable'] . '_second']; } $options = ExtraField::extra_field_double_select_convert_array_to_ordered_array($field_details['options']); $values = array('' => get_lang('Select')); $second_values = array(); if (!empty($options)) { foreach ($options as $option) { foreach ($option as $sub_option) { if ($sub_option['option_value'] == '0') { $values[$sub_option['id']] = $sub_option['display_text']; } else { if ($first_id === $sub_option['option_value']) { $second_values[$sub_option['id']] = $sub_option['display_text']; } } } } } $group = array(); $group[] = $form->createElement('select', 'extra_' . $field_details['variable'], null, $values, array('id' => $first_select_id)); $group[] = $form->createElement('select', 'extra_' . $field_details['variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['variable'])); $form->addGroup($group, 'extra_' . $field_details['variable'], $field_details['display_text'], ' '); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_DIVIDER: $form->addElement('static', $field_details['variable'], '<br /><strong>' . $field_details['display_text'] . '</strong>'); break; case ExtraField::FIELD_TYPE_TAG: $variable = $field_details['variable']; $field_id = $field_details['id']; //Added for correctly translate the extra_field $get_lang_variables = false; if (in_array($variable, ['tags'])) { $get_lang_variables = true; } if ($get_lang_variables) { $field_details['display_text'] = get_lang($field_details['display_text']); } $tagsSelect = $form->addSelect("extra_{$field_details['variable']}", $field_details['display_text']); $tagsSelect->setAttribute('class', null); $tagsSelect->setAttribute('id', "extra_{$field_details['variable']}"); $tagsSelect->setMultiple(true); if ($this->type == 'user') { /* //the magic should be here $user_tags = UserManager::get_user_tags($user_id, $field_details[0]); $tag_list = ''; if (is_array($user_tags) && count($user_tags) > 0) { foreach ($user_tags as $tag) { $tag_list .= '<option value="'.$tag['tag'].'" class="selected">'.$tag['tag'].'</option>'; } } $multi_select = '<select id="extra_'.$field_details[1].'" name="extra_'.$field_details[1].'"> '.$tag_list.' </select>'; $form->addElement('label', $field_details[3], $multi_select); $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php'; $complete_text = get_lang('StartToType'); //if cache is set to true the jquery will be called 1 time $jquery_ready_content = <<<EOF $("#extra_$field_details[1]").fcbkcomplete({ json_url: "$url?a=search_tags&field_id=$field_details[0]", cache: false, filter_case: true, filter_hide: true, complete_text:"$complete_text", firstselected: true, //onremove: "testme", //onselect: "testme", filter_selected: true, newel: true }); EOF; break;*/ // The magic should be here $user_tags = UserManager::get_user_tags($itemId, $field_details['id']); if (is_array($user_tags) && count($user_tags) > 0) { foreach ($user_tags as $tag) { $tagsSelect->addOption($tag['tag'], $tag['tag'], ['selected' => 'selected', 'class' => 'selected']); } } $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php'; } else { $em = Database::getManager(); $fieldTags = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag')->findBy(['fieldId' => $field_id, 'itemId' => $itemId]); foreach ($fieldTags as $fieldTag) { $tag = $em->find('ChamiloCoreBundle:Tag', $fieldTag->getTagId()); if (empty($tag)) { continue; } $tagsSelect->addOption($tag->getTag(), $tag->getTag(), ['selected' => 'selected', 'class' => 'selected']); } $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php'; } $complete_text = get_lang('StartToType'); //if cache is set to true the jquery will be called 1 time $jquery_ready_content .= <<<EOF \$("#extra_{$variable}").fcbkcomplete({ json_url: "{$url}?a=search_tags&field_id={$field_id}&type={$this->type}", cache: false, filter_case: true, filter_hide: true, complete_text:"{$complete_text}", firstselected: false, filter_selected: true, newel: true }); EOF; break; case ExtraField::FIELD_TYPE_TIMEZONE: $form->addElement('select', 'extra_' . $field_details['variable'], $field_details['display_text'], api_get_timezones(), ''); if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } break; case ExtraField::FIELD_TYPE_SOCIAL_PROFILE: // get the social network's favicon $extra_data_variable = isset($extraData['extra_' . $field_details['variable']]) ? $extraData['extra_' . $field_details['variable']] : null; $field_default_value = isset($field_details['field_default_value']) ? $field_details['field_default_value'] : null; $icon_path = UserManager::get_favicon_from_url($extra_data_variable, $field_default_value); // special hack for hi5 $leftpad = '1.7'; $top = '0.4'; $domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $leftpad = '3'; $top = '0'; } // print the input field $form->addElement('text', 'extra_' . $field_details['variable'], $field_details['display_text'], array('size' => 60, 'style' => 'background-image: url(\'' . $icon_path . '\'); background-repeat: no-repeat; background-position: 0.4em ' . $top . 'em; padding-left: ' . $leftpad . 'em; ')); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['variable'], 'trim'); if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } break; case ExtraField::FIELD_TYPE_MOBILE_PHONE_NUMBER: $form->addElement('text', 'extra_' . $field_details[1], $field_details[3] . " (" . get_lang('CountryDialCode') . ")", array('size' => 40, 'placeholder' => '(xx)xxxxxxxxx')); $form->applyFilter('extra_' . $field_details[1], 'stripslashes'); $form->applyFilter('extra_' . $field_details[1], 'trim'); $form->applyFilter('extra_' . $field_details[1], 'mobile_phone_number_filter'); $form->addRule('extra_' . $field_details[1], get_lang('MobilePhoneNumberWrong'), 'mobile_phone_number'); if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } break; case ExtraField::FIELD_TYPE_INTEGER: $form->addElement('number', 'extra_' . $field_details['variable'], $field_details['display_text'], array('class' => 'span1', 'step' => 1)); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['variable'], 'trim'); $form->applyFilter('extra_' . $field_details['variable'], 'intval'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_FILE_IMAGE: $fieldVariable = "extra_{$field_details['variable']}"; $fieldTexts = array($field_details['display_text']); if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) { if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { $fieldTexts[] = Display::img(api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], $field_details['display_text'], array('width' => '300')); } } $form->addElement('file', $fieldVariable, $fieldTexts, array('accept' => 'image/*')); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['variable'], 'trim'); $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); $form->addRule('extra_' . $field_details['variable'], get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_FLOAT: $form->addElement('number', 'extra_' . $field_details['variable'], $field_details['display_text'], array('class' => 'span1', 'step' => '0.01')); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['variable'], 'trim'); $form->applyFilter('extra_' . $field_details['variable'], 'floatval'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_FILE: $fieldVariable = "extra_{$field_details['variable']}"; $fieldTexts = array($field_details['display_text']); if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) { if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { $fieldTexts[] = Display::url(api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], array('title' => $field_details['display_text'], 'target' => '_blank')); } } $form->addElement('file', $fieldVariable, $fieldTexts, array()); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['variable'], 'trim'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_VIDEO_URL: //Added for correctly translate the extra_field $get_lang_variables = false; if (in_array($field_details['variable'], ['video_url'])) { $get_lang_variables = true; } if ($get_lang_variables) { $field_details['display_text'] = get_lang($field_details['display_text']); } $form->addUrl("extra_{$field_details['variable']}", $field_details['display_text'], false, ['placeholder' => 'https://']); break; case ExtraField::FIELD_TYPE_LETTERS_ONLY: $form->addTextLettersOnly("extra_{$field_details['variable']}", $field_details['display_text']); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_ALPHANUMERIC: $form->addTextAlphanumeric("extra_{$field_details['variable']}", $field_details['display_text']); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_LETTERS_SPACE: $form->addTextLettersAndSpaces("extra_{$field_details['variable']}", $field_details['display_text']); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; case ExtraField::FIELD_TYPE_ALPHANUMERIC_SPACE: $form->addTextAlphanumericAndSpaces("extra_{$field_details['variable']}", $field_details['display_text']); $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); if (!$admin_permissions) { if ($field_details['visible'] == 0) { $form->freeze('extra_' . $field_details['variable']); } } break; } } } $return = array(); $return['jquery_ready_content'] = $jquery_ready_content; return $return; }
$condition = array('status = ?' => 1); if ($form->validate()) { $data = $form->getSubmitValues(); $filter = intval($data['filter']); if (!empty($filter)) { $condition = array('status = ? AND id = ? ' => array(1, $filter)); } } $careers = $career->get_all(array('status = ?' => 1)); //only status =1 $career_select_list = array(); $career_select_list[0] = ' -- ' . get_lang('Select') . ' --'; foreach ($careers as $item) { $career_select_list[$item['id']] = $item['name']; } $form->addSelect('filter', get_lang('Career'), $career_select_list, array('id' => 'filter_1', 'class' => 'chzn-select')); $form->addButtonSearch(get_lang('Filter')); // action links echo '<div class="actions" style="margin-bottom:20px">'; echo '<a href="../admin/index.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="careers.php">' . Display::return_icon('career.png', get_lang('Careers'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="promotions.php">' . Display::return_icon('promotion.png', get_lang('Promotions'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '</div>'; $form->display(); $careers = $career->get_all($condition); //only status =1 $column_count = 3; $i = 0; $grid_js = ''; $career_array = array(); if (!empty($careers)) {
Export::arrayToCsv($listToExport, $archiveFile); case 'xls': Export::arrayToXls($listToExport, $archiveFile); break; } } else { Display::addFlash(Display::return_message(get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty'))); } } Display::display_header($tool_name); $form = new FormValidator('export', 'post', api_get_self()); $form->addHeader($tool_name); $form->addHidden('formSent', 1); $form->addElement('radio', 'select_type', get_lang('Option'), get_lang('ExportAllCoursesList'), '1', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='none';}"]); $form->addElement('radio', 'select_type', '', get_lang('ExportSelectedCoursesFromCoursesList'), '2', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='block';}"]); if (!empty($course_list)) { $form->addHtml('<div id="div-course-list" style="display:none">'); $coursesInList = []; foreach ($course_list as $course) { $coursesInList[$course['code']] = $course['title'] . ' (' . $course['code'] . ')'; } $form->addSelect('course_code', get_lang('WhichCoursesToExport'), $coursesInList, ['multiple' => 'multiple']); $form->addHtml('</div>'); } $form->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV', 'csv', null); $form->addElement('radio', 'file_type', '', 'XLS', 'xls', null); $form->addElement('radio', 'file_type', null, 'XML', 'xml', null, array('id' => 'file_type_xml')); $form->setDefaults(['select_type' => '1', 'file_type' => 'csv']); $form->addButtonExport(get_lang('ExportCourses')); $form->display(); Display::display_footer();
$searchTerm = ''; $form = new FormValidator('search', 'get'); if ($form->validate()) { $selectedFilterType = $form->getSubmitValue('filter_type'); $selectedStatus = $form->getSubmitValue('status'); $searchTerm = $form->getSubmitValue('user'); if ($selectedStatus === false) { $selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING; } if ($selectedFilterType === false) { $selectedFilterType = '0'; } } $form->addRadio('filter_type', get_lang('Filter'), [$plugin->get_lang('ByStatus'), $plugin->get_lang('ByUser')]); $form->addHtml('<div id="report-by-status" ' . ($selectedFilterType !== '0' ? 'style="display:none"' : '') . '>'); $form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses); $form->addHtml('</div>'); $form->addHtml('<div id="report-by-user" ' . ($selectedFilterType !== '1' ? 'style="display:none"' : '') . '>'); $form->addText('user', get_lang('UserName'), false); $form->addHtml('</div>'); $form->addButtonFilter(get_lang('Search')); $form->setDefaults(['filter_type' => $selectedFilterType, 'status' => $selectedStatus]); switch ($selectedFilterType) { case '0': $sales = $plugin->getSaleListByStatus($selectedStatus); break; case '1': $sales = $plugin->getSaleListByUser($searchTerm); break; } $saleList = [];
/** * Function which redefines Question::createAnswersForm * @param FormValidator $form */ public function createAnswersForm($form) { $defaults = array(); $nb_matches = $nb_options = 2; $matches = array(); $answer = null; if ($form->isSubmitted()) { $nb_matches = $form->getSubmitValue('nb_matches'); $nb_options = $form->getSubmitValue('nb_options'); if (isset($_POST['lessMatches'])) { $nb_matches--; } if (isset($_POST['moreMatches'])) { $nb_matches++; } if (isset($_POST['lessOptions'])) { $nb_options--; } if (isset($_POST['moreOptions'])) { $nb_options++; } } else { if (!empty($this->id)) { $answer = new Answer($this->id); $answer->read(); 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); $answerInfo = $answer->getAnswerByAutoId($answer->correct[$i]); $defaults['matches[' . $nb_matches . ']'] = isset($answerInfo['answer']) ? $answerInfo['answer'] : ''; } 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'); } } for ($i = 1; $i <= $nb_matches; ++$i) { $matches[$i] = $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="85%">' . 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->addText("answer[{$i}]", null); $form->addSelect("matches[{$i}]", null, $matches); $form->addText("weighting[{$i}]", null, true, ['value' => 10, 'style' => 'width: 60px;']); $form->addHtml('</tr>'); } $form->addHtml('</tbody></table>'); $renderer->setElementTemplate('<div class="form-group"><div class="col-sm-offset-2">{element}', 'lessMatches'); $renderer->setElementTemplate('{element}</div></div>', 'moreMatches'); global $text; $group = [$form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true), $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true), $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(['nb_matches' => $nb_matches, 'nb_options' => $nb_options]); }
$tool = CourseHome::getTool($id); if (empty($tool)) { api_not_allowed(true); } $interbreadcrumb[] = array('url' => api_get_self() . '?' . api_get_cidreq(), 'name' => get_lang('CustomizeIcons')); $toolName = $tool['name']; $currentUrl = api_get_self() . '?action=edit_icon&id=' . $id . '&' . api_get_cidreq(); $form = new FormValidator('icon_edit', 'post', $currentUrl); $form->addHeader(get_lang('EditIcon')); $form->addHtml('<div class="col-md-7">'); $form->addText('name', get_lang('Name')); $form->addText('link', get_lang('Links')); $allowed_picture_types = array('jpg', 'jpeg', 'png'); $form->addFile('icon', get_lang('CustomIcon')); $form->addRule('icon', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types); $form->addSelect('target', get_lang('LinkTarget'), ['_self' => get_lang('LinkOpenSelf'), '_blank' => get_lang('LinkOpenBlank')]); $form->addSelect('visibility', get_lang('Visibility'), array(1 => get_lang('Visible'), 0 => get_lang('Invisible'))); $form->addTextarea('description', get_lang('Description'), array('rows' => '3', 'cols' => '40')); $form->addButtonUpdate(get_lang('Update')); $form->addHtml('</div>'); $form->addHtml('<div class="col-md-5">'); if (isset($tool['custom_icon']) && !empty($tool['custom_icon'])) { $form->addLabel(get_lang('CurrentIcon'), Display::img(CourseHome::getCustomWebIconPath() . $tool['custom_icon'])); $form->addCheckBox('delete_icon', null, get_lang('DeletePicture')); } $form->addHtml('</div>'); $form->setDefaults($tool); $content = $form->returnForm(); if ($form->validate()) { $data = $form->getSubmitValues(); CourseHome::updateTool($id, $data);
$form->addElement('date_time_picker', 'date_time'); $defaults['date_time'] = date('Y-m-d H:i', api_strtotime(api_get_local_time())); $form->addElement('checkbox', 'repeat', null, get_lang('RepeatDate'), array('onclick' => "javascript: if(this.checked){document.getElementById('repeat-date-attendance').style.display='block';}else{document.getElementById('repeat-date-attendance').style.display='none';}")); $defaults['repeat'] = isset($repeat) ? $repeat : null; if ($defaults['repeat']) { $form->addElement('html', '<div id="repeat-date-attendance" style="display:block">'); } else { $form->addElement('html', '<div id="repeat-date-attendance" style="display:none">'); } $a_repeat_type = array('daily' => get_lang('RepeatDaily'), 'weekly' => get_lang('RepeatWeekly'), 'monthlyByDate' => get_lang('RepeatMonthlyByDate')); $form->addElement('select', 'repeat_type', get_lang('RepeatType'), $a_repeat_type); $form->addElement('date_picker', 'end_date_time', get_lang('RepeatEnd'), array('form_name' => 'attendance_calendar_add')); $defaults['end_date_time'] = date('Y-m-d'); $form->addElement('html', '</div>'); $defaults['repeat_type'] = 'weekly'; $form->addSelect('groups', get_lang('Group'), $groupIdList); $form->addButtonCreate(get_lang('Save')); $form->setDefaults($defaults); $form->display(); } else { // Calendar list $groupList = GroupManager::get_group_list(); $groupIdList = array('--'); foreach ($groupList as $group) { $groupIdList[$group['id']] = $group['name']; } echo Display::page_subheader(get_lang('CalendarList')); echo '<div class="attendance-calendar-list">'; if (!empty($attendance_calendar)) { foreach ($attendance_calendar as $calendar) { echo '<div class="attendance-calendar-row">';
$dataToExport = $timeReport->prepareDataToExport($withFilter); $fileName = get_lang('TeacherTimeReport') . ' ' . api_get_local_time(); switch ($_GET['export']) { case 'pdf': $params = array('add_signatures' => false, 'filename' => $fileName, 'pdf_title' => "{$reportTitle} - {$reportSubTitle}", 'pdf_description' => get_lang('TeacherTimeReport'), 'format' => 'A4-L', 'orientation' => 'L'); $pdfContent = Export::convert_array_to_html($dataToExport); Export::export_html_to_pdf($pdfContent, $params); break; case 'xls': array_unshift($dataToExport, array($reportTitle), array($reportSubTitle), array()); Export::export_table_xls_html($dataToExport, $fileName); break; } die; } $form->addSelect('course', get_lang('Course'), $optionsCourses, ['id' => 'courses']); $form->addSelect('session', get_lang('Session'), $optionsSessions, ['id' => 'session']); $form->addSelect('teacher', get_lang('Teacher'), $optionsTeachers, ['id' => 'teacher']); $form->addDateRangePicker('daterange', get_lang('Date'), false, ['id' => 'daterange', 'maxDate' => $limitDate->format('Y-m-d'), 'format' => 'YYYY-MM-DD', 'timePicker' => 'false', 'value' => "{$selectedFrom} / {$selectedUntil}"]); $form->addButtonFilter(get_lang('Filter')); $form->addHidden('from', ''); $form->addHidden('until', ''); $form->setDefaults(['course' => $selectedCourse, 'session' => $selectedSession, 'teacher' => $selectedTeacher, 'date_range' => "{$selectedFrom} / {$selectedUntil}", 'from' => $selectedFrom, 'until' => $selectedUntil]); $tpl = new Template($toolName); $tpl->assign('reportTitle', $reportTitle); $tpl->assign('reportSubTitle', $reportSubTitle); $tpl->assign('selectedCourse', $selectedCourse); $tpl->assign('selectedSession', $selectedSession); $tpl->assign('selectedTeacher', $selectedTeacher); $tpl->assign('selectedFrom', $selectedFrom); $tpl->assign('selectedUntil', $selectedUntil);
$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(); $sequenceList = $em->getRepository('ChamiloCoreBundle:Sequence')->findAll(); $selectSequence->addSelect('sequence', get_lang('Sequence'), $sequenceList, ['id' => 'sequence_id', 'cols-size' => [3, 7, 2]]); $form = new FormValidator(''); $form->addHtml("<div class='col-md-6'>"); $form->addHidden('sequence_type', 'session'); $form->addSelect('sessions', get_lang('Sessions'), $sessionList, ['id' => 'item', 'cols-size' => [4, 7, 1]]); $form->addButtonNext(get_lang('UseAsReference'), 'use_as_reference', ['cols-size' => [4, 7, 1]]); $form->addHtml("</div>"); $form->addHtml("<div class='col-md-6'>"); $form->addSelect('requirements', get_lang('Requirements'), $sessionList, ['id' => 'requirements', 'cols-size' => [3, 7, 2]]); $form->addButtonCreate(get_lang('SetAsRequirement'), 'set_requirement', false, ['cols-size' => [3, 7, 2]]); $form->addHtml("</div>"); $formSave = new FormValidator(''); $formSave->addHidden('sequence_type', 'session'); $formSave->addButton('save_resource', get_lang('SaveSettings'), 'floppy-o', 'success', null, null, ['cols-size' => [1, 10, 1]]); $tpl->assign('create_sequence', $formSequence->returnForm()); $tpl->assign('select_sequence', $selectSequence->returnForm()); $tpl->assign('configure_sequence', $form->returnForm()); $tpl->assign('save_sequence', $formSave->returnForm()); $layout = $tpl->get_template('admin/resource_sequence.tpl'); $tpl->display($layout);
/** * 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)); }
/** * @param int $filter * @param string $view * @return string */ public function displayActions($view, $filter = 0) { $courseInfo = api_get_course_info(); $actionsLeft = ''; $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php?type={$this->type}'>" . Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM) . "</a>"; $courseCondition = ''; if (!empty($courseInfo)) { $courseCondition = api_get_cidreq(); } $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_list.php?type={$this->type}&" . $courseCondition . "'>" . Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM) . "</a>"; $form = ''; if (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true) || GroupManager::user_has_access(api_get_user_id(), api_get_group_id(), GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())) { $actionsLeft .= Display::url(Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=add&type=" . $this->type); $actionsLeft .= Display::url(Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=importical&type=" . $this->type); if ($this->type == 'course') { if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'post', '', '', array(), FormValidator::LAYOUT_INLINE); $attributes = array('multiple' => false, 'id' => 'select_form_id_search'); $selectedValues = $this->parseAgendaFilter($filter); $this->showToForm($form, $selectedValues, $attributes); $form = $form->returnForm(); } } } if (api_is_platform_admin() || api_is_teacher() || api_is_student_boss() || api_is_drh() || api_is_session_admin() || api_is_coach()) { if ($this->type == 'personal') { $form = null; if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'get', api_get_self() . '?type=personal&', '', array(), FormValidator::LAYOUT_INLINE); $sessions = SessionManager::get_sessions_by_user(api_get_user_id()); $form->addHidden('type', 'personal'); $sessions = array_column($sessions, 'session_name', 'session_id'); $sessions = ['0' => get_lang('SelectAnOption')] + $sessions; $form->addSelect('session_id', get_lang('Session'), $sessions, ['id' => 'session_id', 'onchange' => 'submit();']); //$form->addButtonFilter(get_lang('Filter')); //$renderer = $form->defaultRenderer(); //$renderer->setCustomElementTemplate('<div class="col-md-6">{element}</div>'); $form->addButtonReset(get_lang('Reset')); $form = $form->returnForm(); } } } $actionsRight = ''; if ($view == 'calendar') { $actionsRight .= $form; } $toolbar = Display::toolbarAction('toolbar-agenda', array(0 => $actionsLeft, 1 => $actionsRight), 2, false); return $toolbar; }
// 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 if (!$is_certificate_mode && !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)) { $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit); //$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory'))); $parent_select = $form->addSelect('curdirpath', get_lang('DestinationDirectory'), null, array('cols-size' => [2, 10, 0])); // Following two conditions copied from document.inc.php::build_directory_selector() $folder_titles = array(); if (is_array($folders)) { $escaped_folders = array(); foreach ($folders as $key => &$val) { // Hide some folders if ($val == '/HotPotatoes_files' || $val == '/certificates' || basename($val) == 'css') { continue; } // Admin setting for Hide/Show the folders of all users if (api_get_setting('document.show_users_folders') == 'false' && (strstr($val, '/shared_folder') || strstr($val, 'shared_folder_session_'))) { continue; } // Admin setting for Hide/Show Default folders to all users if (api_get_setting('document.show_default_folders') == 'false' && ($val == '/images' || $val == '/flash' || $val == '/audio' || $val == '/video' || strstr($val, '/images/gallery') || $val == '/video/flv')) {
/** * Builds the form that enables the user to * select a directory to browse/upload in * * @param array An array containing the folders we want to be able to select * @param string The current folder (path inside of the "document" directory, including the prefix "/") * @param string Group directory, if empty, prevents documents to be uploaded (because group documents cannot be uploaded in root) * @param boolean Whether to change the renderer (this will add a template <span> to the QuickForm object displaying the form) * @todo this funcionality is really bad : jmontoya * @return string html form */ public static function build_directory_selector($folders, $document_id, $group_dir = '', $change_renderer = false) { $doc_table = Database::get_course_table(TABLE_DOCUMENT); $course_id = api_get_course_int_id(); $folder_titles = array(); if (is_array($folders)) { $escaped_folders = array(); foreach ($folders as $key => &$val) { $escaped_folders[$key] = Database::escape_string($val); } $folder_sql = implode("','", $escaped_folders); $sql = "SELECT * FROM {$doc_table}\n WHERE filetype = 'folder' AND c_id = {$course_id} AND path IN ('" . $folder_sql . "')"; $res = Database::query($sql); $folder_titles = array(); while ($obj = Database::fetch_object($res)) { $folder_titles[$obj->path] = $obj->title; } } $form = new FormValidator('selector', 'GET', api_get_self() . '?' . api_get_cidreq()); $form->addElement('hidden', 'cidReq', api_get_course_id()); $parent_select = $form->addSelect('id', get_lang('CurrentDirectory'), '', array('onchange' => 'javascript: document.selector.submit();')); if ($change_renderer) { $renderer = $form->defaultRenderer(); $renderer->setElementTemplate('<span>{label} : {element}</span> ', 'curdirpath'); } // Group documents cannot be uploaded in the root if (empty($group_dir)) { $parent_select->addOption(get_lang('Documents'), '/'); if (is_array($folders)) { foreach ($folders as $folder_id => &$folder) { $selected = $document_id == $folder_id ? ' selected="selected"' : ''; $path_parts = explode('/', $folder); $folder_titles[$folder] = cut($folder_titles[$folder], 80); $counter = count($path_parts) - 2; if ($counter > 0) { $label = str_repeat(' ', $counter) . ' — ' . $folder_titles[$folder]; } else { $label = ' — ' . $folder_titles[$folder]; } $parent_select->addOption($label, $folder_id); if ($selected != '') { $parent_select->setSelected($folder_id); } } } } else { if (!empty($folders)) { foreach ($folders as $folder_id => &$folder) { $selected = $document_id == $folder_id ? ' selected="selected"' : ''; $label = $folder_titles[$folder]; if ($folder == $group_dir) { $label = get_lang('Documents'); } else { $path_parts = explode('/', str_replace($group_dir, '', $folder)); $label = cut($label, 80); $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; } $parent_select->addOption($label, $folder_id); if ($selected != '') { $parent_select->setSelected($folder_id); } } } } $html = $form->toHtml(); return $html; }
$iconCourse = Display::return_icon('course.png', null, null, ICON_SIZE_TINY); $html .= '<ul class="session-list">'; foreach ($sessionList as $session) { $url = api_get_path(WEB_CODE_PATH) . 'mySpace/course.php?session_id=' . $session['id'] . '&cidReq=' . $courseInfo['code']; $html .= Display::tag('li', $iconCourse . ' ' . Display::url($session['name'], $url)); } $html .= '</ul>'; } $html .= Display::page_subheader2(get_lang('StudentList')); // PERSON_NAME_DATA_EXPORT is buggy $is_western_name_order = api_is_western_name_order(); if (count($a_students) > 0) { $getLangXDays = get_lang('XDays'); $form = new FormValidator('reminder_form', 'get', api_get_path(WEB_CODE_PATH) . 'announcements/announcements.php?' . api_get_cidreq(), null, ['style' => 'margin-bottom: 10px'], FormValidator::LAYOUT_INLINE); $options = array(2 => sprintf($getLangXDays, 2), 3 => sprintf($getLangXDays, 3), 4 => sprintf($getLangXDays, 4), 5 => sprintf($getLangXDays, 5), 6 => sprintf($getLangXDays, 6), 7 => sprintf($getLangXDays, 7), 15 => sprintf($getLangXDays, 15), 30 => sprintf($getLangXDays, 30), 'never' => get_lang('Never')); $el = $form->addSelect('since', Display::returnFontAwesomeIcon('warning') . get_lang('RemindInactivesLearnersSince'), $options, ['class' => 'col-sm-3']); $el->setSelected(7); $form->addElement('hidden', 'action', 'add'); $form->addElement('hidden', 'remindallinactives', 'true'); $form->addElement('hidden', 'cidReq', $courseInfo['code']); $form->addElement('hidden', 'id_session', api_get_session_id()); $form->addButtonSend(get_lang('SendNotification')); $extra_field_select = TrackingCourseLog::display_additional_profile_fields(); if (!empty($extra_field_select)) { $html .= $extra_field_select; } $html .= $form->return_form(); if ($export_csv) { $csv_content = array(); //override the SortableTable "per page" limit if CSV $_GET['users_tracking_per_page'] = 1000000;
$includeCalendar = false; } } } if ($today == $attendance_date['date']) { $exists_attendance_today = true; } if ($includeCalendar) { $values[$attendance_date['id']] = $attendance_date['date_time']; } } } if (!$exists_attendance_today) { Display::display_warning_message(get_lang('ThereIsNoClassScheduledTodayTryPickingAnotherDay')); } $form->addSelect('filter', get_lang('Filter'), $values, ['id' => 'filter_id', 'onchange' => 'submit();']); //$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id')); $groupList = GroupManager::get_group_list(null, null, 1); $groupIdList = array('--'); foreach ($groupList as $group) { $groupIdList[$group['id']] = $group['name']; } if (!empty($groupList)) { $form->addSelect('group_id', get_lang('Group'), $groupIdList); } if (isset($_REQUEST['filter'])) { if (in_array($_REQUEST['filter'], array_keys($values))) { $default_filter = $_REQUEST['filter']; } } else { $default_filter = 'today';
/** * this function displays the form to upload a new item to the dropbox. * * @author Patrick Cool <*****@*****.**>, Ghent University * @version march 2006 */ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view) { $course_info = api_get_course_info(); $_user = api_get_user_info(); $is_courseAdmin = api_is_course_admin(); $is_courseTutor = api_is_course_tutor(); $origin = isset($_GET['origin']) ? $_GET['origin'] : null; $token = Security::get_token(); $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); $form = new FormValidator('sent_form', 'post', api_get_self() . '?view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&' . api_get_cidreq(), null, array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);')); $form->addElement('header', get_lang('UploadNewFile')); $form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize')); $form->addElement('hidden', 'dropbox_unid', $dropbox_unid); $form->addElement('hidden', 'sec_token', $token); $form->addElement('hidden', 'origin', $origin); $form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);')); if (dropbox_cnf('allowOverwrite')) { $form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite')); } // List of all users in this course and all virtual courses combined with it if (api_get_session_id()) { $complete_user_list_for_dropbox = array(); if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) { $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id(), null, null, 0); } $complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id()); $generalCoachList = array(); $courseCoachList = array(); foreach ($complete_user_list2 as $coach) { if ($coach['type'] == 'general_coach') { $generalCoachList[] = $coach; } else { $courseCoachList[] = $coach; } } $hideCourseCoach = api_get_setting('dropbox_hide_course_coach'); if ($hideCourseCoach == 'false') { $complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $courseCoachList); } $hideGeneralCoach = api_get_setting('dropbox_hide_general_coach'); if ($hideGeneralCoach == 'false') { $complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $generalCoachList); } } else { if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) { $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id()); } else { $complete_user_list_for_dropbox = CourseManager::get_teacher_list_from_course_code($course_info['code'], false); } } if (!empty($complete_user_list_for_dropbox)) { foreach ($complete_user_list_for_dropbox as $k => $e) { $complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname'])); } $complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst'); } /* Create the options inside the select box: List all selected users their user id as value and a name string as display */ $current_user_id = ''; $options = array(); $userGroup = new UserGroup(); foreach ($complete_user_list_for_dropbox as $current_user) { if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['is_tutor'] == 1) && $current_user['user_id'] != $_user['user_id']) { // Don't include yourself. if ($current_user['user_id'] == $current_user_id) { continue; } $userId = $current_user['user_id']; $userInfo = api_get_user_info($userId); $groupNameListToString = ''; if (!empty($groups)) { $groupNameList = array_column($groups, 'name'); $groupNameListToString = ' - [' . implode(', ', $groupNameList) . ']'; } $groups = $userGroup->getUserGroupListByUser($userId); $full_name = $userInfo['complete_name'] . $groupNameListToString; $current_user_id = $current_user['user_id']; $options['user_' . $current_user_id] = $full_name; } } /* * Show groups */ if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) { $complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId')); if (count($complete_group_list_for_dropbox) > 0) { foreach ($complete_group_list_for_dropbox as $current_group) { if ($current_group['number_of_members'] > 0) { $options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users'); } } } } if (dropbox_cnf('allowJustUpload')) { $options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect'); } $form->addSelect('recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10')); $form->addButtonUpload(get_lang('Upload'), 'submitWork'); $form->display(); }
/** * @param int $linkId * @param $action * @param null $urlview * @param null $token * @return FormValidator */ public static function getLinkForm($linkId, $action, $token = null) { $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); $linkInfo = Link::get_link_info($linkId); $categoryId = isset($linkInfo['category_id']) ? $linkInfo['category_id'] : ''; $lpId = isset($_GET['lp_id']) ? Security::remove_XSS($_GET['lp_id']) : null; $category = 0; $form = new FormValidator('link', 'post', api_get_self() . '?action=' . $action . '&category_id=' . $categoryId . '&' . api_get_cidreq() . '&id=' . $linkId . '&sec_token=' . $token); if ($action == 'addlink') { $form->addHeader(get_lang('LinkAdd')); } else { $form->addHeader(get_lang('LinkMod')); } $target_link = "_blank"; $title = ''; $category = ''; $onhomepage = ''; $description = ''; if (!empty($linkInfo)) { $urllink = $linkInfo['url']; $title = $linkInfo['title']; $description = $linkInfo['description']; $category = $linkInfo['category_id']; if ($linkInfo['on_homepage'] != 0) { $onhomepage = 1; } $target_link = $linkInfo['target']; } $form->addHidden('id', $linkId); $form->addText('url', 'URL'); $form->addRule('url', get_lang('GiveURL'), 'url'); $form->addText('title', get_lang('LinkName')); $form->addTextarea('description', get_lang('Description')); $resultcategories = Link::getLinkCategories($course_id, $session_id); $options = ['0' => '--']; if (!empty($resultcategories)) { foreach ($resultcategories as $myrow) { $options[$myrow['id']] = $myrow['category_title']; } } $form->addSelect('category_id', get_lang('Category'), $options); $form->addCheckBox('on_homepage', null, get_lang('OnHomepage')); $targets = array('_self' => get_lang('LinkOpenSelf'), '_blank' => get_lang('LinkOpenBlank'), '_parent' => get_lang('LinkOpenParent'), '_top' => get_lang('LinkOpenTop')); $form->addSelect('target', array(get_lang('LinkTarget'), get_lang('AddTargetOfLinkOnHomepage')), $targets); $defaults = array('url' => empty($urllink) ? 'http://' : Security::remove_XSS($urllink), 'title' => Security::remove_XSS($title), 'category_id' => $category, 'on_homepage' => $onhomepage, 'description' => $description, 'target' => $target_link); if (api_get_setting('search_enabled') == 'true') { require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; $specific_fields = get_specific_field_list(); $form->addCheckBox('index_document', get_lang('SearchFeatureDoIndexLink'), get_lang('Yes')); foreach ($specific_fields as $specific_field) { $default_values = ''; if ($action == 'editlink') { $filter = array('field_id' => $specific_field['id'], 'ref_id' => intval($_GET['id']), 'tool_id' => '\'' . TOOL_LINK . '\''); $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']; } $default_values = implode(', ', $arr_str_values); } } $form->addText($specific_field['name'], $specific_field['code']); $defaults[$specific_field['name']] = $default_values; } } $form->addHidden('lp_id', $lpId); $form->addButtonSave(get_lang('SaveLink'), 'submitLink'); $form->setDefaults($defaults); return $form; }
public static function displayTrackingAccessOverView($courseId, $sessionId, $studentId) { $courseId = intval($courseId); $sessionId = intval($sessionId); $studentId = intval($studentId); $em = Database::getManager(); $sessionRepo = $em->getRepository('ChamiloCoreBundle:Session'); $courseList = []; $sessionList = []; $studentList = []; if (!empty($courseId)) { $course = $em->find('ChamiloCoreBundle:Course', $courseId); $courseList[$course->getId()] = $course->getTitle(); } if (!empty($sessionId)) { $session = $em->find('ChamiloCoreBundle:Session', $sessionId); $sessionList[$session->getId()] = $session->getName(); } if (!empty($studentId)) { $student = $em->find('ChamiloUserBundle:User', $studentId); $studentList[$student->getId()] = $student->getCompleteName(); } $form = new FormValidator('access_overview', 'GET'); $form->addElement('select_ajax', 'course_id', get_lang('SearchCourse'), $courseList, ['url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query(['a' => 'search_course_by_session_all', 'session_id' => $sessionId])]); $form->addElement('select_ajax', 'session_id', get_lang('SearchSession'), $sessionList, ['url_function' => "\n function () {\n var params = \$.param({\n a: 'search_session_by_course',\n course_id: \$('#course_id').val() || 0\n });\n\n return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params;\n }\n "]); $form->addSelect('profile', get_lang('Profile'), ['' => get_lang('Select'), STUDENT => get_lang('Student'), COURSEMANAGER => get_lang('CourseManager'), DRH => get_lang('Drh')], ['id' => 'profile']); $form->addElement('select_ajax', 'student_id', get_lang('SearchUsers'), $studentList, ['placeholder' => get_lang('All'), 'url_function' => "\n function () {\n var params = \$.param({\n a: 'search_user_by_course',\n session_id: \$('#session_id').val(),\n course_id: \$('#course_id').val()\n });\n\n return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params;\n }\n "]); $form->addDateRangePicker('date', get_lang('DateRange'), true, ['id' => 'date_range', 'format' => 'YYYY-MM-DD', 'timePicker' => 'false', 'validate_format' => 'Y-m-d']); $form->addHidden('display', 'accessoverview'); $form->addRule('course_id', get_lang('Required'), 'required'); $form->addRule('profile', get_lang('Required'), 'required'); $form->addButton('submit', get_lang('Generate'), 'gear', 'primary'); $table = null; if ($form->validate()) { $table = new SortableTable('tracking_access_overview', ['MySpace', 'getNumberOfRrackingAccessOverview'], ['MySpace', 'getUserDataAccessTrackingOverview'], 0); $table->additional_parameters = $form->exportValues(); $table->set_header(0, get_lang('LoginDate'), true); $table->set_header(1, get_lang('Username'), true); if (api_is_western_name_order()) { $table->set_header(2, get_lang('FirstName'), true); $table->set_header(3, get_lang('LastName'), true); } else { $table->set_header(2, get_lang('LastName'), true); $table->set_header(3, get_lang('FirstName'), true); } $table->set_header(4, get_lang('Clicks'), false); $table->set_header(5, get_lang('IP'), false); $table->set_header(6, get_lang('TimeLoggedIn'), false); } $template = new Template(null, false, false, false, false, false, false); $template->assign('form', $form->returnForm()); $template->assign('table', $table ? $table->return_table() : null); echo $template->fetch($template->get_template('my_space/accessoverview.tpl')); }
$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'); exit; }
/** * Return HTML form to add/edit a student publication (work) * @param string Action (add/edit) * @param integer Item ID if already exists * @param mixed Extra info (work ID if integer) * @return string HTML form */ public function display_student_publication_form($action = 'add', $id = 0, $extra_info = '') { $course_id = api_get_course_int_id(); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION); if ($id != 0 && is_array($extra_info)) { $item_title = stripslashes($extra_info['title']); $item_description = stripslashes($extra_info['description']); } elseif (is_numeric($extra_info)) { $extra_info = intval($extra_info); $sql = "SELECT title, description\n FROM " . $tbl_publication . "\n WHERE c_id = " . $course_id . " AND id = " . $extra_info; $result = Database::query($sql); $row = Database::fetch_array($result); $item_title = $row['title']; } else { $item_title = get_lang('Student_publication'); } if ($id != 0 && is_array($extra_info)) { $parent = $extra_info['parent_item_id']; } else { $parent = 0; } $sql = "SELECT * FROM " . $tbl_lp_item . "\n WHERE c_id = " . $course_id . " AND lp_id = " . $this->lp_id; $result = Database::query($sql); $arrLP = array(); while ($row = Database::fetch_array($result)) { $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], 'path' => $row['path'], 'description' => $row['description'], 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'display_order' => $row['display_order'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite']); } $this->tree_array($arrLP); $arrLP = isset($this->arrMenu) ? $this->arrMenu : null; unset($this->arrMenu); $form = new FormValidator('frm_student_publication', 'post', '#'); if ($action == 'add') { $form->addHeader(get_lang('Student_publication')); } elseif ($action == 'move') { $form->addHeader(get_lang('MoveCurrentStudentPublication')); } else { $form->addHeader(get_lang('EditCurrentStudentPublication')); } if ($action != 'move') { $form->addText('title', get_lang('Title'), true, ['class' => 'learnpath_item_form', 'id' => 'idTitle']); } $parentSelect = $form->addSelect('parent', get_lang('Parent'), ['0' => $this->name], ['onchange' => 'javascript: load_cbo(this.value);', 'class' => 'learnpath_item_form', 'id' => 'idParent']); $arrHide = array($id); for ($i = 0; $i < count($arrLP); $i++) { if ($action != 'add') { if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) { $parentSelect->addOption($arrLP[$i]['title'], $arrLP[$i]['id'], ['style' => 'padding-left: ' . ($arrLP[$i]['depth'] * 10 + 20) . 'px;']); if ($parent == $arrLP[$i]['id']) { $parentSelect->setSelected($arrLP[$i]['id']); } } else { $arrHide[] = $arrLP[$i]['id']; } } else { if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') { $parentSelect->addOption($arrLP[$i]['title'], $arrLP[$i]['id'], ['style' => 'padding-left: ' . ($arrLP[$i]['depth'] * 10 + 20) . 'px;']); if ($parent == $arrLP[$i]['id']) { $parentSelect->setSelected($arrLP[$i]['id']); } } } } if (is_array($arrLP)) { reset($arrLP); } $previousSelect = $form->addSelect('previous', get_lang('Position'), ['0' => get_lang('FirstPosition')], ['id' => 'previous', 'class' => 'learnpath_item_form']); for ($i = 0; $i < count($arrLP); $i++) { if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { $previousSelect->addOption(get_lang('After') . ' "' . $arrLP[$i]['title'] . '"', $arrLP[$i]['id']); if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { $previousSelect->setSelected($arrLP[$i]['id']); } elseif ($action == 'add') { $previousSelect->setSelected($arrLP[$i]['id']); } } } if ($action != 'move') { $id_prerequisite = 0; if (is_array($arrLP)) { foreach ($arrLP as $key => $value) { if ($value['id'] == $id) { $id_prerequisite = $value['prerequisite']; break; } } } $arrHide = array(); for ($i = 0; $i < count($arrLP); $i++) { if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { $s_selected_position = $arrLP[$i]['id']; } elseif ($action == 'add') { $s_selected_position = 0; } $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; } } } if ($action == 'add') { $form->addButtonCreate(get_lang('AddAssignmentToCourse'), 'submit_button'); } else { $form->addButtonCreate(get_lang('EditCurrentStudentPublication'), 'submit_button'); } if ($action == 'move') { $form->addHidden('title', $item_title); $form->addHidden('description', $item_description); } if (is_numeric($extra_info)) { $form->addHidden('path', $extra_info); } elseif (is_array($extra_info)) { $form->addHidden('path', $extra_info['path']); } $form->addHidden('type', TOOL_STUDENTPUBLICATION); $form->addHidden('post_time', time()); $form->setDefaults(['title' => $item_title]); $return = '<div class="sectioncomment">'; $return .= $form->returnForm(); $return .= '</div>'; return $return; }