function openid_form() { $form = new FormValidator('openid_login', 'post', null, null, array('class' => 'form-vertical form_login')); $form->addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input')); $form->addElement('button', 'submit', get_lang('Login')); return $form->return_form(); }
/** * This function displays the form for import of the zip file with qti2 */ function ch_qti2_display_form() { $name_tools = get_lang('ImportQtiQuiz'); $form = '<div class="actions">'; $form .= '<a href="exercice.php?show=test">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>'; $form .= '</div>'; $form_validator = new FormValidator('qti_upload', 'post', api_get_self() . "?" . api_get_cidreq(), null, array('enctype' => 'multipart/form-data')); $form_validator->addElement('header', $name_tools); $form_validator->addElement('file', 'userFile', get_lang('DownloadFile')); $form_validator->addElement('style_submit_button', 'submit', get_lang('Send'), 'class="upload"'); $form .= $form_validator->return_form(); echo $form; }
function openid_form() { //get_lang('OpenIdAuthentication') $form = new FormValidator('openid_login', 'post', null, null, array('class' => 'form-vertical form_login')); $form->addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input')); $form->addElement('button', 'submit', get_lang('Login')); return $form->return_form(); /* return '<label for="openid_url">'.get_lang('OpenIDURL').' <a href="main/auth/openid/whatis.php" title="'.get_lang('OpenIDWhatIs').'">'.Display::return_icon('info3.gif',get_lang('Info')).'</a></label> <input type="text" id="openid_url" name="openid_url" style="background: url(main/img/openid_small_logo.png) no-repeat; background-color: #fff; background-position: 0 50%; padding-left:18px;" value="http://"></input> * <input type="submit" name="openid_login" value="'.get_lang('Enter').'" /><br /><br /></form></div>'; * */ }
/** * This function displays the form for import of the zip file with qti2 * @param string Report message to show in case of error */ function aiken_display_form($msg = '') { $name_tools = get_lang('ImportAikenQuiz'); $form = '<div class="actions">'; $form .= '<a href="exercice.php?show=test">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>'; $form .= '</div>'; $form .= $msg; $form_validator = new FormValidator('aiken_upload', 'post', api_get_self() . "?" . api_get_cidreq(), null, array('enctype' => 'multipart/form-data')); $form_validator->addElement('header', $name_tools); $form_validator->addElement('text', 'total_weight', get_lang('TotalWeight')); $form_validator->addElement('file', 'userFile', get_lang('DownloadFile')); $form_validator->addElement('style_submit_button', 'submit', get_lang('Send'), 'class="upload"'); $form .= $form_validator->return_form(); $form .= '<blockquote>' . get_lang('ImportAikenQuizExplanation') . '<br /><pre>' . get_lang('ImportAikenQuizExplanationExample') . '</pre></blockquote>'; echo $form; }
/** * @param array $work * @return string */ function getWorkCommentForm($work) { if (ADD_DOCUMENT_TO_WORK == false) { return null; } $form = new FormValidator( 'work_comment', 'post', api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&action=send_comment&'.api_get_cidreq() ); $form->addElement('file', 'file', get_lang('Attachment')); $form->addElement('textarea', 'comment', get_lang('Comment'), array('class' => 'span5', 'rows' => '8')); $form->addElement('hidden', 'id', $work['id']); if (api_is_allowed_to_edit()) { $form->addElement('checkbox', 'send_mail', null, get_lang('SendMail')); } $form->addElement('button', 'button', get_lang('Send')); return $form->return_form(); }
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']) ? Security::remove_XSS($_GET['f']) : ''; $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->add_textfield('id_text_name', get_lang('SendMessageTo'), true, array('class' => 'span4', '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->addElement('html', $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select', 'users', get_lang('SendMessageTo'), array(), array('id' => '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->add_textfield('title', get_lang('Subject'), true, array('class' => 'span4')); $form->add_html_editor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '95%', '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 = UserManager::get_user_info_by_id($message_reply_info['user_sender_id']); $default['content'] = '<br />' . sprintf(get_lang('XWroteY'), api_get_person_name($user_reply_info['firstname'], $user_reply_info['lastname']), Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('advanced_settings', get_lang('FilesAttachment') . '<span id="filepaths"> <div id="filepath_1"> <input type="file" name="attach_1"/><br /> ' . get_lang('Description') . ' <input type="text" name="legend[]" /><br /><br /> </div> </span>'); $form->addElement('advanced_settings', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); } $form->addElement('style_submit_button', 'compose', api_xml_http_response_encode(get_lang('SendMessage')), 'class="save"'); $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 = $default['parent_id']; 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, null, null, api_get_user_id()); if ($res) { if (is_string($res)) { $html .= Display::return_message($res, 'error'); } else { $user_info = api_get_user_info($user); $html .= Display::return_message(get_lang('MessageSentTo') . " <b>" . $user_info['complete_name'] . "</b>", 'confirmation', false); } } } } 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->return_form(); } return $html; }
$form->addElement('button', 'submit', get_lang('Confirm'), array('class' => 'btn btn-primary')); $formHtml = $form->return_form(); if ($form->validate()) { $result = $form->getSubmitValues(); if (isset($result['left']) && $result['left']) { $_SESSION['before_login_accepted'] = 1; header('Location: ' . $urlOption1); exit; } } $form2 = new FormValidator('form'); if (!empty($option2) && !empty($urlOption2)) { $renderer =& $form2->defaultRenderer(); $renderer->setHeaderTemplate(''); $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>'); $renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>'); $form2->addElement('html', $option2); $form2->addElement('checkbox', 'right', null, get_lang('Yes')); $form2->addElement('button', 'submit', get_lang('Send')); $formHtml2 = $form2->return_form(); if ($form2->validate()) { $result = $form2->getSubmitValues(); if (isset($result['right']) && $result['right']) { header('Location: ' . $urlOption2); exit; } } } $_template['form_option1'] = $formHtml; $_template['form_option2'] = $formHtml2; }
} }); $( "#dialog-confirm" ).dialog("open"); return false; }); }); </script>'; $extra .= '<div id="dialog-confirm" title="' . get_lang("ConfirmYourChoice") . '">'; $form = new FormValidator('report', 'post', null, null, array('class' => 'form-vertical')); $form->addElement('radio', 'export_format', null, get_lang('ExportAsCSV'), 'csv', array('id' => 'export_format_csv_label')); $form->addElement('radio', 'export_format', null, get_lang('ExportAsXLS'), 'xls', array('id' => 'export_format_xls_label')); $form->addElement('checkbox', 'load_extra_data', null, get_lang('LoadExtraData'), '0', array('id' => 'export_format_xls_label')); $form->addElement('checkbox', 'include_all_users', null, get_lang('IncludeAllUsers'), '0'); $form->addElement('checkbox', 'only_best_attempts', null, get_lang('OnlyBestAttempts'), '0'); $form->setDefaults(array('export_format' => 'csv')); $extra .= $form->return_form(); $extra .= '</div>'; if ($is_allowedToEdit) { echo $extra; } echo $actions; $url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_results&exerciseId=' . $exercise_id . '&filter_by_user='******'&' . api_get_cidreq(); $action_links = ''; //Generating group list $group_list = GroupManager::get_group_list(); $group_parameters = array('group_all:' . get_lang('All'), 'group_none:' . get_lang('None')); foreach ($group_list as $group) { $group_parameters[] = $group['id'] . ':' . $group['name']; } if (!empty($group_parameters)) { $group_parameters = implode(';', $group_parameters);
api_set_firstpage_parameter($firstpage); $tpl = new Template(null, 1, 1); $action = api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']); $action = str_replace('&', '&', $action); $form = new FormValidator('formLogin', 'post', $action, null, array('class' => 'form-stacked')); $form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'span3 autocapitalize_off')); //new $form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'), 'class' => 'span3')); //new $form->addElement('style_submit_button', 'submitAuth', get_lang('LoginEnter'), array('class' => 'btn span3')); // see same text in main_api.lib.php function api_not_allowed if (api_is_cas_activated()) { $msg .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false); $msg .= Display::div("<br/><a href='" . get_cas_direct_URL(api_get_course_id()) . "'>" . getCASLogoHTML() . " " . sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution")) . "</a><br/><br/>", array('align' => 'center')); $msg .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount')); $msg .= "<p style='text-align:center'><a href='#' onclick='\$(this).parent().next().toggle()'>" . get_lang('LoginWithExternalAccount') . "</a></p>"; $msg .= "<div style='display:none;'>"; } $msg .= '<div class="well_login">'; $msg .= $form->return_form(); $msg .= '</div>'; if (api_is_cas_activated()) { $msg .= "</div>"; } $msg .= '<hr/><p style="text-align:center"><a href="' . api_get_path(WEB_PATH) . '">' . get_lang('ReturnToCourseHomepage') . '</a></p>'; $tpl->assign('content', '<h4>' . get_lang('LoginToGoToThisCourse') . '</h4>' . $msg); $tpl->display_one_col_template(); } else { api_delete_firstpage_parameter(); Header('Location: ' . api_get_path(WEB_PATH) . 'index.php'); }
/** * @param $id * @param array $params * @param string $display * @return string */ public static function generate_invitation_form($id, $params = array()) { $form = new FormValidator('send_invitation'); $form->addTextarea('content', get_lang('AddPersonalMessage'), ['id' => 'content_invitation_id', 'rows' => 5]); return $form->return_form(); }
<script> $(function() { $("#session_name").on("change", function() { var sessionId = $(this).val(); window.location = "' . $courseListUrl . '?session_id="+sessionId; }); }); </script>'; $actions .= '<div class="pull-right">'; $actions .= '<a href="course_add.php">' . Display::return_icon('new_course.png', get_lang('AddCourse'), '', ICON_SIZE_MEDIUM) . '</a> '; if (api_get_setting('course_validation') == 'true') { $actions .= '<a href="course_request_review.php">' . Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests'), '', ICON_SIZE_MEDIUM) . '</a>'; } $actions .= '</div>'; $actions .= '<div class="pull-right">'; $actions .= $sessionFilter->return_form(); $actions .= '</div>'; $actions .= $form->return_form(); if (isset($_GET['session_id']) && !empty($_GET['session_id'])) { // Create a sortable table with the course data filtered by session $table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data_by_session', 2); } else { // Create a sortable table with the course data $table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2); } $parameters = array(); if (isset($_GET['keyword'])) { $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); } elseif (isset($_GET['keyword_code'])) { $parameters['keyword_code'] = Security::remove_XSS($_GET['keyword_code']); $parameters['keyword_title'] = Security::remove_XSS($_GET['keyword_title']);
/** * Displays message "You are not allowed here..." and exits the entire script. * @param bool $print_headers Whether or not to print headers (default = false -> does not print them) * @param string $message */ function api_not_allowed($print_headers = false, $message = null) { $message = get_lang('NotAllowed'); throw new Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException($message); if (api_get_setting('sso_authentication') === 'true') { global $osso; if ($osso) { $osso->logout(); } } $home_url = api_get_path(WEB_PATH); $user_id = api_get_user_id(); $course = api_get_course_id(); global $this_section; if (CustomPages::enabled() && !isset($user_id)) { if (empty($user_id)) { // Why the CustomPages::enabled() need to be to set the request_uri $_SESSION['request_uri'] = $_SERVER['REQUEST_URI']; } CustomPages::display(CustomPages::INDEX_UNLOGGED); } $origin = isset($_GET['origin']) ? $_GET['origin'] : ''; $msg = null; if (isset($message)) { $msg = $message; } else { $msg = Display::return_message(get_lang('NotAllowedClickBack') . '<br/><br/><a href="' . $home_url . '">' . get_lang('ReturnToCourseHomepage') . '</a>', 'error', false); } $msg = Display::div($msg, array('align' => 'center')); $show_headers = 0; if ($print_headers && $origin != 'learnpath') { $show_headers = 1; } $tpl = new Template(null, $show_headers, $show_headers); $tpl->assign('hide_login_link', 1); $tpl->assign('content', $msg); if ($user_id != 0 && !api_is_anonymous() && (!isset($course) || $course == -1) && empty($_GET['cidReq'])) { // if the access is not authorized and there is some login information // but the cidReq is not found, assume we are missing course data and send the user // to the user_portal $tpl->display_one_col_template(); exit; } if (!empty($_SERVER['REQUEST_URI']) && (!empty($_GET['cidReq']) || $this_section == SECTION_MYPROFILE || $this_section == SECTION_PLATFORM_ADMIN)) { $courseCode = api_get_course_id(); // Only display form and return to the previous URL if there was a course ID included if ($user_id != 0 && !api_is_anonymous()) { //if there is a user ID, then the user is not allowed but the session is still there. Say so and exit $tpl->assign('content', $msg); $tpl->display_one_col_template(); exit; } if (!is_null($courseCode)) { api_set_firstpage_parameter($courseCode); } // If the user has no user ID, then his session has expired $action = api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']); $action = str_replace('&', '&', $action); $form = new FormValidator('formLogin', 'post', $action, null, array(), FormValidator::LAYOUT_BOX_NO_LABEL); $form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'autocapitalize_off')); $form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'))); $form->addButton('submitAuth', get_lang('LoginEnter'), '', 'primary'); // see same text in auth/gotocourse.php and main_api.lib.php function api_not_allowed (above) $content = Display::return_message(get_lang('NotAllowed'), 'error', false); if (!empty($courseCode)) { $content .= '<h4>' . get_lang('LoginToGoToThisCourse') . '</h4>'; } if (api_is_cas_activated()) { $content .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false); $content .= Display::div("<br/><a href='" . get_cas_direct_URL(api_get_course_id()) . "'>" . sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution")) . "</a><br/><br/>", array('align' => 'center')); $content .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount')); $content .= "<p style='text-align:center'><a href='#' onclick='\$(this).parent().next().toggle()'>" . get_lang('LoginWithExternalAccount') . "</a></p>"; $content .= "<div style='display:none;'>"; } $content .= '<div class="well_login">'; $content .= $form->return_form(); $content .= '</div>'; if (api_is_cas_activated()) { $content .= "</div>"; } if (!empty($courseCode)) { $content .= '<hr/><p style="text-align:center"><a href="' . $home_url . '">' . get_lang('ReturnToCourseHomepage') . '</a></p>'; } else { $content .= '<hr/><p style="text-align:center"><a href="' . $home_url . '">' . get_lang('CampusHomepage') . '</a></p>'; } $tpl->setLoginBodyClass(); $tpl->assign('content', $content); $tpl->display_one_col_template(); exit; } if ($user_id != 0 && !api_is_anonymous()) { $tpl->display_one_col_template(); exit; } $msg = null; // The session is over and we were not in a course, // or we try to get directly to a private course without being logged if (!is_null(api_get_course_int_id())) { api_set_firstpage_parameter(api_get_course_id()); $tpl->setLoginBodyClass(); $action = api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']); $action = str_replace('&', '&', $action); $form = new FormValidator('formLogin', 'post', $action, null, array('class' => 'form-stacked')); $form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'col-md-3 autocapitalize_off')); //new $form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'), 'class' => 'col-md-3')); //new $form->addButtonNext(get_lang('LoginEnter'), 'submitAuth'); // see same text in auth/gotocourse.php and main_api.lib.php function api_not_allowed (bellow) $msg = Display::return_message(get_lang('NotAllowed'), 'error', false); $msg .= '<h4>' . get_lang('LoginToGoToThisCourse') . '</h4>'; if (api_is_cas_activated()) { $msg .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false); $msg .= Display::div("<br/><a href='" . get_cas_direct_URL(api_get_course_int_id()) . "'>" . getCASLogoHTML() . " " . sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution")) . "</a><br/><br/>", array('align' => 'center')); $msg .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount')); $msg .= "<p style='text-align:center'><a href='#' onclick='\$(this).parent().next().toggle()'>" . get_lang('LoginWithExternalAccount') . "</a></p>"; $msg .= "<div style='display:none;'>"; } $msg .= '<div class="well">'; $msg .= $form->return_form(); $msg .= '</div>'; if (api_is_cas_activated()) { $msg .= "</div>"; } $msg .= '<hr/><p style="text-align:center"><a href="' . $home_url . '">' . get_lang('ReturnToCourseHomepage') . '</a></p>'; } else { // we were not in a course, return to home page $msg = Display::return_message(get_lang('NotAllowed') . '<br/><br/><a href="' . $home_url . '">' . get_lang('ReturnToCourseHomepage') . '</a><br />', 'error', false); } $tpl->assign('content', $msg); $tpl->display_one_col_template(); exit; }
/** * Adds a form to let users login * @version 1.1 */ function display_login_form() { $form = new FormValidator('formLogin', 'POST', null, null, array('class'=>'form-vertical')); $form->addElement('text', 'login', get_lang('UserName'), array('id' => 'login', 'class' => 'span2 user_login_icon autocapitalize_off', 'autofocus' => 'autofocus')); $form->addElement('password', 'password', get_lang('Pass'), array('id' => 'password', 'class' => 'span2 user_password_icon')); global $_configuration; // Captcha $allowCaptcha = isset($_configuration['allow_captcha']) ? $_configuration['allow_captcha'] : false; 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(LIBRARY_PATH).'pchart/fonts/', 'font_file' => 'tahoma.ttf', //'output' => 'gif' ) ); // 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->addElement('static', null, null, 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->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn')); $html = $form->return_form(); // The validation is located in the local.inc /*if ($form->validate()) { // Prevent re-use of the same CAPTCHA phrase $captcha_question->destroy(); }*/ if (api_get_setting('openid_authentication') == 'true') { include_once 'main/auth/openid/login.php'; $html .= '<div>'.openid_form().'</div>'; } return $html; }
$form_data['button'] = Display::button('next', get_lang('Go', null, $_user['language']), array('class' => 'btn btn-primary btn-large')); } if (!empty($form_data['action'])) { header('Location: ' . $form_data['action']); exit; } } } } } $form_register = new FormValidator('form_register', 'post', $form_data['action']); if (!empty($form_data['message'])) { $form_register->addElement('html', $form_data['message'] . '<br /><br />'); } $form_register->addElement('html', $form_data['button']); $text_after_registration .= $form_register->return_form(); //Just in case Session::erase('course_redirect'); Session::erase('exercise_redirect'); Display::display_header($tool_name); echo Display::page_header($tool_name); echo $content; echo $text_after_registration; if (CustomPages::enabled()) { CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $text_after_registration)); } } else { Display::display_header($tool_name); echo Display::page_header($tool_name); echo $content; // Custom pages
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; } $all_datas = array(); $course_code = $_course['id']; $user_ids = array_keys($a_students); $table = new SortableTable('users_tracking', array('TrackingCourseLog', 'get_number_of_users'), array('TrackingCourseLog', 'get_user_data'), (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2); $parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']); $parameters['id_session'] = $session_id; $parameters['from'] = isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null; $table->set_additional_parameters($parameters); $headers = array(); // tab of header texts
/** * Shows a question * @param Question $objQuestionTmp * @param bool $only_questions if true only show the questions, no exercise title * @param bool $origin origin i.e = learnpath * @param string $current_item current item from the list of questions * @param bool $show_title * @param bool $freeze * @param array $user_choice * @param bool $show_comment * @param null $exercise_feedback * @param bool $show_answers * @param null $modelType * @param bool $categoryMinusOne * @return bool|null|string */ public function showQuestion(Question $objQuestionTmp, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false, $modelType = null, $categoryMinusOne = true) { // Text direction for the current language //$is_ltr_text_direction = api_get_text_direction() != 'rtl'; // Change false to true in the following line to enable answer hinting $debug_mark_answer = $show_answers; //api_is_allowed_to_edit() && false; // Reads question information if (!$objQuestionTmp) { // Question not found return false; } $html = null; $questionId = $objQuestionTmp->id; if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) { $show_comment = false; } $answerType = $objQuestionTmp->selectType(); $pictureName = $objQuestionTmp->selectPicture(); $s = null; $form = new FormValidator('question'); $renderer = $form->defaultRenderer(); $form_template = '{content}'; $renderer->setFormTemplate($form_template); if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) { // Question is not a hotspot if (!$only_questions) { $questionDescription = $objQuestionTmp->selectDescription(); if ($show_title) { $categoryName = TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id, null, true, $categoryMinusOne); $html .= $categoryName; $html .= Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title')); if (!empty($questionDescription)) { $html .= Display::div($questionDescription, array('class' => 'question_description')); } } else { $html .= '<div class="media">'; $html .= '<div class="pull-left">'; $html .= '<div class="media-object">'; $html .= Display::div($current_item, array('class' => 'question_no_title')); $html .= '</div>'; $html .= '</div>'; $html .= '<div class="media-body">'; if (!empty($questionDescription)) { $html .= Display::div($questionDescription, array('class' => 'question_description')); } $html .= '</div>'; $html .= '</div>'; } } if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) { return null; } $html .= '<div class="question_options">'; // construction of the Answer object (also gets all answers details) $objAnswerTmp = new Answer($questionId, null, $this); $nbrAnswers = $objAnswerTmp->selectNbrAnswers(); $course_id = api_get_course_int_id(); $quiz_question_options = Question::readQuestionOption($questionId, $course_id); // For "matching" type here, we need something a little bit special // because the match between the suggestions and the answers cannot be // done easily (suggestions and answers are in the same table), so we // have to go through answers first (elems with "correct" value to 0). $select_items = array(); //This will contain the number of answers on the left side. We call them // suggestions here, for the sake of comprehensions, while the ones // on the right side are called answers $num_suggestions = 0; if ($answerType == MATCHING || $answerType == DRAGGABLE) { if ($answerType == DRAGGABLE) { $s .= '<div class="ui-widget ui-helper-clearfix"> <ul class="drag_question ui-helper-reset ui-helper-clearfix">'; } else { $s .= '<div id="drag' . $questionId . '_question" class="drag_question">'; $s .= '<table class="data_table">'; } $j = 1; //iterate through answers $letter = 'A'; //mark letters for each answer $answer_matching = array(); $capital_letter = array(); //for ($answerId=1; $answerId <= $nbrAnswers; $answerId++) { foreach ($objAnswerTmp->answer as $answerId => $answer_item) { $answerCorrect = $objAnswerTmp->isCorrect($answerId); $answer = $objAnswerTmp->selectAnswer($answerId); if ($answerCorrect == 0) { // options (A, B, C, ...) that will be put into the list-box // have the "correct" field set to 0 because they are answer $capital_letter[$j] = $letter; //$answer_matching[$j]=$objAnswerTmp->selectAnswerByAutoId($numAnswer); $answer_matching[$j] = array('id' => $answerId, 'answer' => $answer); $j++; $letter++; } } $i = 1; $select_items[0]['id'] = 0; $select_items[0]['letter'] = '--'; $select_items[0]['answer'] = ''; foreach ($answer_matching as $id => $value) { $select_items[$i]['id'] = $value['id']; $select_items[$i]['letter'] = $capital_letter[$id]; $select_items[$i]['answer'] = $value['answer']; $i++; } $num_suggestions = $nbrAnswers - $j + 1; } elseif ($answerType == FREE_ANSWER) { $content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer'] : null; $toolBar = 'TestFreeAnswer'; if ($modelType == EXERCISE_MODEL_TYPE_COMMITTEE) { $toolBar = 'TestFreeAnswerStrict'; } $form->addElement('html_editor', "choice[" . $questionId . "]", null, array('id' => "choice[" . $questionId . "]"), array('ToolbarSet' => $toolBar)); $form->setDefaults(array("choice[" . $questionId . "]" => $content)); $s .= $form->return_form(); } elseif ($answerType == ORAL_EXPRESSION) { // Add nanogong if (api_get_setting('document.enable_nanogong') == 'true') { //@todo pass this as a parameter global $exercise_stat_info, $exerciseId; if (!empty($exercise_stat_info)) { $params = array('exercise_id' => $exercise_stat_info['exe_exo_id'], 'exe_id' => $exercise_stat_info['exe_id'], 'question_id' => $questionId); } else { $params = array('exercise_id' => $exerciseId, 'exe_id' => 'temp_exe', 'question_id' => $questionId); } $nano = new Nanogong($params); $s .= $nano->show_button(); } $form->addElement('html_editor', "choice[" . $questionId . "]", null, array('id' => "choice[" . $questionId . "]"), array('ToolbarSet' => 'TestFreeAnswer')); //$form->setDefaults(array("choice[".$questionId."]" => $content)); $s .= $form->return_form(); } // Now navigate through the possible answers, using the max number of // answers for the question as a limiter $lines_count = 1; // a counter for matching-type answers if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { $header = Display::tag('th', get_lang('Options')); foreach ($objQuestionTmp->options as $item) { $header .= Display::tag('th', $item); } if ($show_comment) { $header .= Display::tag('th', get_lang('Feedback')); } $s .= '<table class="data_table">'; $s .= Display::tag('tr', $header, array('style' => 'text-align:left;')); } if ($show_comment) { if (in_array($answerType, array(MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, GLOBAL_MULTIPLE_ANSWER))) { $header = Display::tag('th', get_lang('Options')); if ($exercise_feedback == EXERCISE_FEEDBACK_TYPE_END) { $header .= Display::tag('th', get_lang('Feedback')); } $s .= '<table class="data_table">'; $s .= Display::tag('tr', $header, array('style' => 'text-align:left;')); } } $matching_correct_answer = 0; $user_choice_array = array(); if (!empty($user_choice)) { foreach ($user_choice as $item) { $user_choice_array[] = $item['answer']; } } foreach ($objAnswerTmp->answer as $answerId => $answer_item) { $answer = $objAnswerTmp->selectAnswer($answerId); $answerCorrect = $objAnswerTmp->isCorrect($answerId); $comment = $objAnswerTmp->selectComment($answerId); //$numAnswer = $objAnswerTmp->selectAutoId($answerId); $numAnswer = $answerId; $attributes = array(); // Unique answer if (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_IMAGE, UNIQUE_ANSWER_NO_OPTION))) { $input_id = 'choice-' . $questionId . '-' . $answerId; if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1); } else { $attributes = array('id' => $input_id); } if ($debug_mark_answer) { if ($answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } $answer = Security::remove_XSS($answer); $s .= Display::input('hidden', 'choice2[' . $questionId . ']', '0'); $answer_input = null; if ($answerType == UNIQUE_ANSWER_IMAGE) { $attributes['style'] = 'display:none'; $answer_input .= '<div id="answer' . $questionId . $numAnswer . '" style="float:left" class="highlight_image_default highlight_image">'; } $answer_input .= '<label class="radio">'; $answer_input .= Display::input('radio', 'choice[' . $questionId . ']', $numAnswer, $attributes); $answer_input .= $answer; $answer_input .= '</label>'; if ($answerType == UNIQUE_ANSWER_IMAGE) { $answer_input .= "</div>"; } if ($show_comment) { $s .= '<tr><td>'; $s .= $answer_input; $s .= '</td>'; $s .= '<td>'; $s .= $comment; $s .= '</td>'; $s .= '</tr>'; } else { $s .= $answer_input; } } elseif (in_array($answerType, array(MULTIPLE_ANSWER, MULTIPLE_ANSWER_TRUE_FALSE, GLOBAL_MULTIPLE_ANSWER))) { $input_id = 'choice-' . $questionId . '-' . $answerId; $answer = Security::remove_XSS($answer); if (in_array($numAnswer, $user_choice_array)) { $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1); } else { $attributes = array('id' => $input_id); } if ($debug_mark_answer) { if ($answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; $answer_input = '<label class="checkbox">'; $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', $numAnswer, $attributes); $answer_input .= $answer; $answer_input .= '</label>'; if ($show_comment) { $s .= '<tr><td>'; $s .= $answer_input; $s .= '</td>'; $s .= '<td>'; $s .= $comment; $s .= '</td>'; $s .= '</tr>'; } else { $s .= $answer_input; } } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) { $my_choice = array(); if (!empty($user_choice_array)) { foreach ($user_choice_array as $item) { $item = explode(':', $item); $my_choice[$item[0]] = $item[1]; } } $s .= '<tr>'; $s .= Display::tag('td', $answer); if (!empty($quiz_question_options)) { foreach ($quiz_question_options as $id => $item) { $id = $item['iid']; if (isset($my_choice[$numAnswer]) && $id == $my_choice[$numAnswer]) { $attributes = array('checked' => 1, 'selected' => 1); } else { $attributes = array(); } if ($debug_mark_answer) { if ($id == $answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $id, $attributes), array('style' => '')); } } if ($show_comment) { $s .= '<td>'; $s .= $comment; $s .= '</td>'; } $s .= '</tr>'; } } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { // multiple answers $input_id = 'choice-' . $questionId . '-' . $answerId; if (in_array($numAnswer, $user_choice_array)) { $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1); } else { $attributes = array('id' => $input_id); } if ($debug_mark_answer) { if ($answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } $answer = Security::remove_XSS($answer); $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; $answer_input .= '<label class="checkbox">'; $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', 1, $attributes); $answer_input .= $answer; $answer_input .= '</label>'; if ($show_comment) { $s .= '<tr>'; $s .= '<td>'; $s .= $answer_input; $s .= '</td>'; $s .= '<td>'; $s .= $comment; $s .= '</td>'; $s .= '</tr>'; } else { $s .= $answer_input; } } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; $my_choice = array(); if (!empty($user_choice_array)) { foreach ($user_choice_array as $item) { $item = explode(':', $item); $my_choice[$item[0]] = $item[1]; } } $answer = Security::remove_XSS($answer); $s .= '<tr>'; $s .= Display::tag('td', $answer); foreach ($objQuestionTmp->options as $key => $item) { if (isset($my_choice[$numAnswer]) && $key == $my_choice[$numAnswer]) { $attributes = array('checked' => 1, 'selected' => 1); } else { $attributes = array(); } if ($debug_mark_answer) { if ($key == $answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $key, $attributes)); } if ($show_comment) { $s .= '<td>'; $s .= $comment; $s .= '</td>'; } $s .= '</tr>'; } elseif ($answerType == FILL_IN_BLANKS) { list($answer) = explode('::', $answer); //Correct answer api_preg_match_all('/\\[[^]]+\\]/', $answer, $correct_answer_list); //Student's answezr if (isset($user_choice[0]['answer'])) { api_preg_match_all('/\\[[^]]+\\]/', $user_choice[0]['answer'], $student_answer_list); $student_answer_list = $student_answer_list[0]; } //If debug if ($debug_mark_answer) { $student_answer_list = $correct_answer_list[0]; } if (!empty($correct_answer_list) && !empty($student_answer_list)) { $correct_answer_list = $correct_answer_list[0]; $i = 0; foreach ($correct_answer_list as $correct_item) { $value = null; if (isset($student_answer_list[$i]) && !empty($student_answer_list[$i])) { //Cleaning student answer list $value = strip_tags($student_answer_list[$i]); $value = api_substr($value, 1, api_strlen($value) - 2); $value = explode('/', $value); if (!empty($value[0])) { $value = str_replace(' ', '', trim($value[0])); } $correct_item = preg_quote($correct_item); $correct_item = api_preg_replace('|/|', '\\/', $correct_item); // to prevent error if there is a / in the text to find $answer = api_preg_replace('/' . $correct_item . '/', Display::input('text', "choice[{$questionId}][]", $value), $answer, 1); } $i++; } } else { $answer = api_preg_replace('/\\[[^]]+\\]/', Display::input('text', "choice[{$questionId}][]", '', $attributes), $answer); } $s .= $answer; } elseif ($answerType == MATCHING) { // matching type, showing suggestions and answers // TODO: replace $answerId by $numAnswer if ($lines_count == 1) { $s .= $objAnswerTmp->getJs(); } if ($answerCorrect != 0) { // only show elements to be answered (not the contents of // the select boxes, who are correct = 0) $s .= '<tr><td width="45%">'; $parsed_answer = $answer; $windowId = $questionId . '_' . $lines_count; //left part questions $s .= ' <div id="window_' . $windowId . '" class="window window_left_question window' . $questionId . '_question"> <b>' . $lines_count . '</b>. ' . $parsed_answer . ' </div> </td>'; // middle part (matches selects) $s .= '<td width="10%" align="center"> '; $s .= '<div style="display:block">'; $s .= '<select id="window_' . $windowId . '_select" name="choice[' . $questionId . '][' . $numAnswer . ']">'; $selectedValue = 0; // fills the list-box $item = 0; foreach ($select_items as $val) { // set $debug_mark_answer to true at public static function start to // show the correct answer with a suffix '-x' $selected = ''; if ($debug_mark_answer) { if ($val['id'] == $answerCorrect) { $selected = 'selected="selected"'; $selectedValue = $val['id']; } } if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) { $selected = 'selected="selected"'; $selectedValue = $val['id']; } //$s .= '<option value="'.$val['id'].'" '.$selected.'>'.$val['letter'].'</option>'; $s .= '<option value="' . $item . '" ' . $selected . '>' . $val['letter'] . '</option>'; $item++; } if (!empty($answerCorrect) && !empty($selectedValue)) { $s .= '<script> jsPlumb.ready(function() { jsPlumb.connect({ source: "window_' . $windowId . '", target: "window_' . $questionId . '_' . $selectedValue . '_answer", endpoint:["Blank", { radius:15 }], anchor:["RightMiddle","LeftMiddle"], paintStyle:{ strokeStyle:"#8a8888" , lineWidth:8 }, connector: [connectorType, { curviness: curvinessValue } ], }) }); </script>'; } $s .= '</select></div></td>'; $s .= '<td width="45%" valign="top" >'; if (isset($select_items[$lines_count])) { $s .= '<div id="window_' . $windowId . '_answer" class="window window_right_question"> <b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer'] . ' </div>'; } else { $s .= ' '; } $s .= '</td>'; $s .= '</tr>'; $lines_count++; //if the left side of the "matching" has been completely // shown but the right side still has values to show... if ($lines_count - 1 == $num_suggestions) { // if it remains answers to shown at the right side while (isset($select_items[$lines_count])) { $s .= '<tr> <td colspan="2"></td> <td valign="top">'; $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b>'; $s .= $select_items[$lines_count]['answer']; $s .= "</td>\n </tr>"; $lines_count++; } // end while() } // end if() $matching_correct_answer++; } } elseif ($answerType == DRAGGABLE) { // matching type, showing suggestions and answers // TODO: replace $answerId by $numAnswer if ($answerCorrect != 0) { // only show elements to be answered (not the contents of // the select boxes, who are correct = 0) $s .= '<td>'; $parsed_answer = $answer; $windowId = $questionId . '_' . $numAnswer; //67_293 - 67_294 //left part questions $s .= '<li class="ui-state-default" id="' . $windowId . '">'; $s .= ' <div id="window_' . $windowId . '" class="window' . $questionId . '_question_draggable question_draggable"> ' . $parsed_answer . ' </div>'; $s .= '<div style="display:none">'; $s .= '<select id="window_' . $windowId . '_select" name="choice[' . $questionId . '][' . $numAnswer . ']" class="select_option">'; $selectedValue = 0; // fills the list-box $item = 0; foreach ($select_items as $val) { // set $debug_mark_answer to true at function start to // show the correct answer with a suffix '-x' $selected = ''; if ($debug_mark_answer) { if ($val['id'] == $answerCorrect) { $selected = 'selected="selected"'; $selectedValue = $val['id']; } } if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) { $selected = 'selected="selected"'; $selectedValue = $val['id']; } //$s .= '<option value="'.$val['id'].'" '.$selected.'>'.$val['letter'].'</option>'; $s .= '<option value="' . $item . '" ' . $selected . '>' . $val['letter'] . '</option>'; $item++; } $s .= '</select>'; if (!empty($answerCorrect) && !empty($selectedValue)) { $s .= '<script> $(function() { deleteItem($("#' . $questionId . '_' . $selectedValue . '"), $("#drop_' . $windowId . '")); }); </script>'; } if (isset($select_items[$lines_count])) { $s .= '<div id="window_' . $windowId . '_answer" class=""> <b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer'] . ' </div>'; } else { $s .= ' '; } $lines_count++; //if the left side of the "matching" has been completely // shown but the right side still has values to show... if ($lines_count - 1 == $num_suggestions) { // if it remains answers to shown at the right side while (isset($select_items[$lines_count])) { $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b>'; $s .= $select_items[$lines_count]['answer']; $lines_count++; } } $s .= '</div>'; $matching_correct_answer++; $s .= '</li>'; } } } // end for() if ($show_comment) { $s .= '</table>'; } else { if ($answerType == MATCHING || $answerType == UNIQUE_ANSWER_NO_OPTION || $answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { $s .= '</table>'; } } if ($answerType == DRAGGABLE) { $s .= '</ul><div class="clear"></div>'; $counterAnswer = 1; foreach ($objAnswerTmp->answer as $answerId => $answer_item) { $answerCorrect = $objAnswerTmp->isCorrect($answerId); $windowId = $questionId . '_' . $counterAnswer; if ($answerCorrect == 0) { $s .= '<div id="drop_' . $windowId . '" class="droppable ui-state-default">' . $counterAnswer . '</div>'; $counterAnswer++; } } } if ($answerType == MATCHING) { $s .= '</div>'; } $s .= '</div>'; // destruction of the Answer object unset($objAnswerTmp); // destruction of the Question object unset($objQuestionTmp); $html .= $s; return $html; } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) { // Question is a HOT_SPOT //checking document/images visibility if (api_is_platform_admin() || api_is_course_admin()) { $course = api_get_course_info(); $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName); if (is_numeric($doc_id)) { $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id()); if (!$images_folder_visibility) { //This message is shown only to the course/platform admin if the image is set to visibility = false Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage')); } } } $questionName = $objQuestionTmp->selectTitle(); $questionDescription = $objQuestionTmp->selectDescription(); if ($freeze) { $s .= Display::img($objQuestionTmp->selectPicturePath()); $html .= $s; return $html; } // Get the answers, make a list $objAnswerTmp = new Answer($questionId); // get answers of hotpost $answers_hotspot = array(); foreach ($objAnswerTmp->answer as $answerId => $answer_item) { //$answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId)); $answers_hotspot[$answerId] = $objAnswerTmp->selectAnswer($answerId); } // display answers of hotpost order by id $answer_list = '<div style="padding: 10px; margin-left: 0px; border: 1px solid #A4A4A4; height: 408px; width: 200px;"><b>' . get_lang('HotspotZones') . '</b><dl>'; if (!empty($answers_hotspot)) { ksort($answers_hotspot); foreach ($answers_hotspot as $key => $value) { $answer_list .= '<dt>' . $key . '.- ' . $value . '</dt><br />'; } } $answer_list .= '</dl></div>'; if ($answerType == HOT_SPOT_DELINEATION) { $answer_list = ''; $swf_file = 'hotspot_delineation_user'; $swf_height = 405; } else { $swf_file = 'hotspot_user'; $swf_height = 436; } if (!$only_questions) { if ($show_title) { $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id); $html .= '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>'; $html .= $questionDescription; } else { $html .= '<div class="media">'; $html .= '<div class="pull-left">'; $html .= '<div class="media-object">'; $html .= Display::div($current_item . '. ', array('class' => 'question_no_title')); $html .= '</div>'; $html .= '</div>'; $html .= '<div class="media-body">'; if (!empty($questionDescription)) { $html .= Display::div($questionDescription, array('class' => 'question_description')); } $html .= '</div>'; $html .= '</div>'; } //@todo I need to the get the feedback type $html .= '<input type="hidden" name="hidden_hotspot_id" value="' . $questionId . '" />'; $html .= '<table class="exercise_questions"> <tr> <td valign="top" colspan="2">'; $html .= '</td></tr>'; } $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); $s .= ' <script type="text/javascript" src="../plugin/hotspot/JavaScriptFlashGateway.js"></script> <script src="../plugin/hotspot/hotspot.js" type="text/javascript" ></script> <script type="text/javascript"> <!-- // Globals // Major version of Flash required var requiredMajorVersion = 7; // Minor version of Flash required var requiredMinorVersion = 0; // Minor version of Flash required var requiredRevision = 0; // the version of javascript supported var jsVersion = 1.0; // --> </script> <script language="VBScript" type="text/vbscript"> <!-- // Visual basic helper required to detect Flash Player ActiveX control version information Function VBGetSwfVer(i) on error resume next Dim swControl, swVersion swVersion = 0 set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i)) if (IsObject(swControl)) then swVersion = swControl.GetVariable("$version") end if VBGetSwfVer = swVersion End Function // --> </script> <script language="JavaScript1.1" type="text/javascript"> <!-- // Detect Client Browser type var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; jsVersion = 1.1; // JavaScript helper required to detect Flash Player PlugIn version information function JSGetSwfVer(i) { // NS/Opera version >= 3 check for Flash plugin in plugin array if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; descArray = flashDescription.split(" "); tempArrayMajor = descArray[2].split("."); versionMajor = tempArrayMajor[0]; versionMinor = tempArrayMajor[1]; if ( descArray[3] != "" ) { tempArrayMinor = descArray[3].split("r"); } else { tempArrayMinor = descArray[4].split("r"); } versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } else { flashVer = -1; } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; // Can\'t detect in all other cases else { flashVer = -1; } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { reqVer = parseFloat(reqMajorVer + "." + reqRevision); // loop backwards through the versions until we find the newest version for (i=25;i>0;i--) { if (isIE && isWin && !isOpera) { versionStr = VBGetSwfVer(i); } else { versionStr = JSGetSwfVer(i); } if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { tempArray = versionStr.split(" "); tempString = tempArray[1]; versionArray = tempString .split(","); } else { versionArray = versionStr.split("."); } versionMajor = versionArray[0]; versionMinor = versionArray[1]; versionRevision = versionArray[2]; versionString = versionMajor + "." + versionRevision; // 7.0r24 == 7.24 versionNum = parseFloat(versionString); // is the major.revision >= requested major.revision AND the minor version >= requested minor if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) { return true; } else { return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false ); } } } } // --> </script>'; $s .= '<tr><td valign="top" colspan="2" width="520"><table><tr><td width="520"> <script> // Version check based upon the values entered above in "Globals" var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); // Check to see if the version meets the requirements for playback if (hasReqestedVersion) { // if we\'ve detected an acceptable version var oeTags = \'<object type="application/x-shockwave-flash" data="../plugin/hotspot/' . $swf_file . '.swf?modifyAnswers=' . $questionId . '&canClick:' . $canClick . '" width="600" height="' . $swf_height . '">\' + \'<param name="wmode" value="transparent">\' + \'<param name="movie" value="../plugin/hotspot/' . $swf_file . '.swf?modifyAnswers=' . $questionId . '&canClick:' . $canClick . '" />\' + \'<\\/object>\'; document.write(oeTags); // embed the Flash Content SWF when all tests are passed } else { // flash is too old or we can\'t detect the plugin var alternateContent = "Error<br \\/>" + "Hotspots requires Macromedia Flash 7.<br \\/>" + "<a href=\\"http://www.macromedia.com/go/getflash/\\">Get Flash<\\/a>"; document.write(alternateContent); // insert non-flash content } </script> </td> <td valign="top" align="left">' . $answer_list . '</td></tr> </table> </td></tr>'; $html .= $s; $html .= '</table>'; return $html; } return $nbrAnswers; }
public static function generate_invitation_form($id, $params = array()) { $form = new FormValidator('send_invitation', null, 'post', null, array('id' => $id . '_form', 'class' => 'form-vertical')); //$form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject_id')); $form->addElement('textarea', 'content', get_lang('AddPersonalMessage'), array('id' => 'content_invitation_id', 'rows' => '5', 'class' => 'span5')); $div = Display::div($form->return_form(), array('id' => $id . '_div', 'style' => 'display:none')); return $div; }
} else { $intro_dispDefault = true; $intro_dispForm = false; if ($intro_editAllowed) { $intro_dispCommand = true; } else { $intro_dispCommand = false; } } /* Executes the display */ // display thematic advance inside a postit if ($intro_dispForm) { $default['intro_content'] = $intro_content; $form->setDefaults($default); $introduction_section .= '<div id="courseintro" style="width: 98%">'; $introduction_section .= $form->return_form(); $introduction_section .= '</div>'; } $thematic_description_html = ''; if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) { // Only show this if we're on the course homepage and we're not currently editing $thematic = new Thematic(); $displayMode = api_get_course_setting('display_info_advance_inside_homecourse'); $class1 = ''; if ($displayMode == '1') { // Show only the current course progress step // $information_title = get_lang('InfoAboutLastDoneAdvance'); $last_done_advance = $thematic->get_last_done_thematic_advance(); $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance); $subTitle1 = get_lang('CurrentTopic'); $class1 = ' current';
/** * Shows a question * * @param int $questionId question id * @param bool $only_questions if true only show the questions, no exercise title * @param bool $origin i.e = learnpath * @param string $current_item current item from the list of questions * @param bool $show_title * @param bool $freeze * @param array $user_choice * @param bool $show_comment * @param bool $exercise_feedback * @param bool $show_answers * */ public static function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false) { $course_id = api_get_course_int_id(); // Change false to true in the following line to enable answer hinting $debug_mark_answer = $show_answers; // Reads question information if (!($objQuestionTmp = Question::read($questionId))) { // Question not found return false; } if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) { $show_comment = false; } $answerType = $objQuestionTmp->selectType(); $pictureName = $objQuestionTmp->selectPicture(); $s = ''; if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) { // Question is not a hotspot if (!$only_questions) { $questionDescription = $objQuestionTmp->selectDescription(); if ($show_title) { TestCategory::displayCategoryAndTitle($objQuestionTmp->id); echo Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title')); } if (!empty($questionDescription)) { echo Display::div($questionDescription, array('class' => 'question_description')); } } if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) { return ''; } echo '<div class="question_options row">'; // construction of the Answer object (also gets all answers details) $objAnswerTmp = new Answer($questionId); $nbrAnswers = $objAnswerTmp->selectNbrAnswers(); $quiz_question_options = Question::readQuestionOption($questionId, $course_id); // For "matching" type here, we need something a little bit special // because the match between the suggestions and the answers cannot be // done easily (suggestions and answers are in the same table), so we // have to go through answers first (elems with "correct" value to 0). $select_items = array(); //This will contain the number of answers on the left side. We call them // suggestions here, for the sake of comprehensions, while the ones // on the right side are called answers $num_suggestions = 0; if (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) { if ($answerType == DRAGGABLE) { $s .= '<div class="col-md-12 ui-widget ui-helper-clearfix"> <div class="clearfix"> <ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix">'; } else { $s .= <<<HTML <div id="drag{$questionId}_question" class="drag_question"> <table class="data_table"> HTML; } // Iterate through answers $x = 1; //mark letters for each answer $letter = 'A'; $answer_matching = array(); $cpt1 = array(); for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $answerCorrect = $objAnswerTmp->isCorrect($answerId); $numAnswer = $objAnswerTmp->selectAutoId($answerId); if ($answerCorrect == 0) { // options (A, B, C, ...) that will be put into the list-box // have the "correct" field set to 0 because they are answer $cpt1[$x] = $letter; $answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer); $x++; $letter++; } } $i = 1; $select_items[0]['id'] = 0; $select_items[0]['letter'] = '--'; $select_items[0]['answer'] = ''; foreach ($answer_matching as $id => $value) { $select_items[$i]['id'] = $value['id']; $select_items[$i]['letter'] = $cpt1[$id]; $select_items[$i]['answer'] = $value['answer']; $i++; } $user_choice_array_position = array(); if (!empty($user_choice)) { foreach ($user_choice as $item) { $user_choice_array_position[$item['position']] = $item['answer']; } } $num_suggestions = $nbrAnswers - $x + 1; } elseif ($answerType == FREE_ANSWER) { $fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer'] : null; $form = new FormValidator('free_choice_' . $questionId); $config = array('ToolbarSet' => 'TestFreeAnswer'); $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config); $form->setDefaults(array("choice[" . $questionId . "]" => $fck_content)); $s .= $form->returnForm(); } elseif ($answerType == ORAL_EXPRESSION) { // Add nanog if (api_get_setting('enable_nanogong') == 'true') { //@todo pass this as a parameter global $exercise_stat_info, $exerciseId, $exe_id; if (!empty($exercise_stat_info)) { $params = array('exercise_id' => $exercise_stat_info['exe_exo_id'], 'exe_id' => $exercise_stat_info['exe_id'], 'question_id' => $questionId); } else { $params = array('exercise_id' => $exerciseId, 'exe_id' => 'temp_exe', 'question_id' => $questionId); } $nano = new Nanogong($params); echo $nano->show_button(); } $form = new FormValidator('free_choice_' . $questionId); $config = array('ToolbarSet' => 'TestFreeAnswer'); $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config); //$form->setDefaults(array("choice[" . $questionId . "]" => $fck_content)); $s .= $form->return_form(); } // Now navigate through the possible answers, using the max number of // answers for the question as a limiter $lines_count = 1; // a counter for matching-type answers if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { $header = Display::tag('th', get_lang('Options')); foreach ($objQuestionTmp->options as $item) { if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) { if (in_array($item, $objQuestionTmp->options)) { $header .= Display::tag('th', get_lang($item)); } else { $header .= Display::tag('th', $item); } } else { $header .= Display::tag('th', $item); } } if ($show_comment) { $header .= Display::tag('th', get_lang('Feedback')); } $s .= '<table class="table table-hover table-striped">'; $s .= Display::tag('tr', $header, array('style' => 'text-align:left;')); } if ($show_comment) { if (in_array($answerType, array(MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, UNIQUE_ANSWER, UNIQUE_ANSWER_IMAGE, UNIQUE_ANSWER_NO_OPTION, GLOBAL_MULTIPLE_ANSWER))) { $header = Display::tag('th', get_lang('Options')); if ($exercise_feedback == EXERCISE_FEEDBACK_TYPE_END) { $header .= Display::tag('th', get_lang('Feedback')); } $s .= '<table class="table table-hover table-striped">'; $s .= Display::tag('tr', $header, array('style' => 'text-align:left;')); } } $matching_correct_answer = 0; $user_choice_array = array(); if (!empty($user_choice)) { foreach ($user_choice as $item) { $user_choice_array[] = $item['answer']; } } for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $answer = $objAnswerTmp->selectAnswer($answerId); $answerCorrect = $objAnswerTmp->isCorrect($answerId); $numAnswer = $objAnswerTmp->selectAutoId($answerId); $comment = $objAnswerTmp->selectComment($answerId); $attributes = array(); // Unique answer if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, UNIQUE_ANSWER_IMAGE])) { $input_id = 'choice-' . $questionId . '-' . $answerId; if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1); } else { $attributes = array('id' => $input_id); } if ($debug_mark_answer) { if ($answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } if ($show_comment) { $s .= '<tr><td>'; } if ($answerType == UNIQUE_ANSWER_IMAGE) { if ($show_comment) { if (empty($comment)) { $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image" style="text-align: center">'; } else { $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image col-xs-6 col-sm-12" style="text-align: center">'; } } else { $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image col-xs-6 col-md-3" style="text-align: center">'; } } $answer = Security::remove_XSS($answer, STUDENT); $s .= Display::input('hidden', 'choice2[' . $questionId . ']', '0'); $answer_input = null; if ($answerType == UNIQUE_ANSWER_IMAGE) { $attributes['style'] = 'display: none;'; $answer = '<div class="thumbnail">' . $answer . '</div>'; } $answer_input .= '<label class="radio">'; $answer_input .= Display::input('radio', 'choice[' . $questionId . ']', $numAnswer, $attributes); $answer_input .= $answer; $answer_input .= '</label>'; if ($answerType == UNIQUE_ANSWER_IMAGE) { $answer_input .= "</div>"; } if ($show_comment) { $s .= $answer_input; $s .= '</td>'; $s .= '<td>'; $s .= $comment; $s .= '</td>'; $s .= '</tr>'; } else { $s .= $answer_input; } } elseif ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == GLOBAL_MULTIPLE_ANSWER) { $input_id = 'choice-' . $questionId . '-' . $answerId; $answer = Security::remove_XSS($answer, STUDENT); if (in_array($numAnswer, $user_choice_array)) { $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1); } else { $attributes = array('id' => $input_id); } if ($debug_mark_answer) { if ($answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; $answer_input = '<label class="checkbox">'; $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', $numAnswer, $attributes); $answer_input .= $answer; $answer_input .= '</label>'; if ($show_comment) { $s .= '<tr><td>'; $s .= $answer_input; $s .= '</td>'; $s .= '<td>'; $s .= $comment; $s .= '</td>'; $s .= '</tr>'; } else { $s .= $answer_input; } } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) { $my_choice = array(); if (!empty($user_choice_array)) { foreach ($user_choice_array as $item) { $item = explode(':', $item); $my_choice[$item[0]] = $item[1]; } } $s .= '<tr>'; $s .= Display::tag('td', $answer); if (!empty($quiz_question_options)) { foreach ($quiz_question_options as $id => $item) { if (isset($my_choice[$numAnswer]) && $id == $my_choice[$numAnswer]) { $attributes = array('checked' => 1, 'selected' => 1); } else { $attributes = array(); } if ($debug_mark_answer) { if ($id == $answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $id, $attributes), array('style' => '')); } } if ($show_comment) { $s .= '<td>'; $s .= $comment; $s .= '</td>'; } $s .= '</tr>'; } } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { // multiple answers $input_id = 'choice-' . $questionId . '-' . $answerId; if (in_array($numAnswer, $user_choice_array)) { $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1); } else { $attributes = array('id' => $input_id); } if ($debug_mark_answer) { if ($answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } $answer = Security::remove_XSS($answer, STUDENT); $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; $answer_input .= '<label class="checkbox">'; $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', 1, $attributes); $answer_input .= $answer; $answer_input .= '</label>'; if ($show_comment) { $s .= '<tr>'; $s .= '<td>'; $s .= $answer_input; $s .= '</td>'; $s .= '<td>'; $s .= $comment; $s .= '</td>'; $s .= '</tr>'; } else { $s .= $answer_input; } } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; $my_choice = array(); if (!empty($user_choice_array)) { foreach ($user_choice_array as $item) { $item = explode(':', $item); if (isset($item[1]) && isset($item[0])) { $my_choice[$item[0]] = $item[1]; } } } $answer = Security::remove_XSS($answer, STUDENT); $s .= '<tr>'; $s .= Display::tag('td', $answer); foreach ($objQuestionTmp->options as $key => $item) { if (isset($my_choice[$numAnswer]) && $key == $my_choice[$numAnswer]) { $attributes = array('checked' => 1, 'selected' => 1); } else { $attributes = array(); } if ($debug_mark_answer) { if ($key == $answerCorrect) { $attributes['checked'] = 1; $attributes['selected'] = 1; } } $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $key, $attributes)); } if ($show_comment) { $s .= '<td>'; $s .= $comment; $s .= '</td>'; } $s .= '</tr>'; } elseif ($answerType == FILL_IN_BLANKS) { // display the question, with field empty, for student to fill it, // or filled to display the answer in the Question preview of the exercice/admin.php page $displayForStudent = true; $listAnswerInformations = FillBlanks::getAnswerInfo($answer); $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']); $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']); list($answer) = explode('::', $answer); //Correct answers $correctAnswerList = $listAnswerInformations['tabwords']; //Student's answer $studentAnswerList = array(); if (isset($user_choice[0]['answer'])) { $arrayStudentAnswer = FillBlanks::getAnswerInfo($user_choice[0]['answer'], true); $studentAnswerList = $arrayStudentAnswer['studentanswer']; } // If the question must be shown with the answer (in page exercice/admin.php) for teacher preview // set the student-answer to the correct answer if ($debug_mark_answer) { $studentAnswerList = $correctAnswerList; $displayForStudent = false; } if (!empty($correctAnswerList) && !empty($studentAnswerList)) { $answer = ""; for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) { // display the common word $answer .= $listAnswerInformations["commonwords"][$i]; // display the blank word $correctItem = $listAnswerInformations["tabwords"][$i]; $correctItemRegexp = $correctItem; // replace / with \/ to allow the preg_replace bellow and all the regexp char $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); if (isset($studentAnswerList[$i])) { // If student already started this test and answered this question, // fill the blank with his previous answers // may be "" if student viewed the question, but did not fill the blanks $correctItem = $studentAnswerList[$i]; } $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px"; $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, $correctItem, $attributes, $answer, $listAnswerInformations, $displayForStudent, $i); } // display the last common word $answer .= $listAnswerInformations["commonwords"][$i]; } else { // display empty [input] with the right width for student to fill it $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']); $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']); $answer = ""; for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) { // display the common words $answer .= $listAnswerInformations["commonwords"][$i]; // display the blank word $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px"; $correctItem = $listAnswerInformations["tabwords"][$i]; $correctItemRegexp = $correctItem; // replace / with \/ to allow the preg_replace bellow and all the regexp char $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, '', $attributes, $answer, $listAnswerInformations, $displayForStudent, $i); } // display the last common word $answer .= $listAnswerInformations["commonwords"][$i]; } $s .= $answer; } elseif ($answerType == CALCULATED_ANSWER) { /* * In the CALCULATED_ANSWER test * you mustn't have [ and ] in the textarea * you mustn't have @@ in the textarea * the text to find mustn't be empty or contains only spaces * the text to find mustn't contains HTML tags * the text to find mustn't contains char " */ if ($origin !== null) { global $exe_id; $trackAttempts = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $sqlTrackAttempt = 'SELECT answer FROM ' . $trackAttempts . ' WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId; $rsLastAttempt = Database::query($sqlTrackAttempt); $rowLastAttempt = Database::fetch_array($rsLastAttempt); $answer = $rowLastAttempt['answer']; if (empty($answer)) { $_SESSION['calculatedAnswerId'][$questionId] = mt_rand(1, $nbrAnswers); $answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]); } } list($answer) = explode('@@', $answer); // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]] api_preg_match_all('/\\[[^]]+\\]/', $answer, $correctAnswerList); // get student answer to display it if student go back to previous calculated answer question in a test if (isset($user_choice[0]['answer'])) { api_preg_match_all('/\\[[^]]+\\]/', $answer, $studentAnswerList); $studentAnswerListTobecleaned = $studentAnswerList[0]; $studentAnswerList = array(); for ($i = 0; $i < count($studentAnswerListTobecleaned); $i++) { $answerCorrected = $studentAnswerListTobecleaned[$i]; $answerCorrected = api_preg_replace('| / <font color="green"><b>.*$|', '', $answerCorrected); $answerCorrected = api_preg_replace('/^\\[/', '', $answerCorrected); $answerCorrected = api_preg_replace('|^<font color="red"><s>|', '', $answerCorrected); $answerCorrected = api_preg_replace('|</s></font>$|', '', $answerCorrected); $answerCorrected = '[' . $answerCorrected . ']'; $studentAnswerList[] = $answerCorrected; } } // If display preview of answer in test view for exemple, set the student answer to the correct answers if ($debug_mark_answer) { // contain the rights answers surronded with brackets $studentAnswerList = $correctAnswerList[0]; } /* Split the response by bracket tabComments is an array with text surrounding the text to find we add a space before and after the answerQuestion to be sure to have a block of text before and after [xxx] patterns so we have n text to find ([xxx]) and n+1 block of texts before, between and after the text to find */ $tabComments = api_preg_split('/\\[[^]]+\\]/', ' ' . $answer . ' '); if (!empty($correctAnswerList) && !empty($studentAnswerList)) { $answer = ""; $i = 0; foreach ($studentAnswerList as $studentItem) { // remove surronding brackets $studentResponse = api_substr($studentItem, 1, api_strlen($studentItem) - 2); $size = strlen($studentItem); $attributes['class'] = self::detectInputAppropriateClass($size); $answer .= $tabComments[$i] . Display::input('text', "choice[{$questionId}][]", $studentResponse, $attributes); $i++; } $answer .= $tabComments[$i]; } else { // display exercise with empty input fields // every [xxx] are replaced with an empty input field foreach ($correctAnswerList[0] as $item) { $size = strlen($item); $attributes['class'] = self::detectInputAppropriateClass($size); $answer = str_replace($item, Display::input('text', "choice[{$questionId}][]", '', $attributes), $answer); } } if ($origin !== null) { $s = $answer; break; } else { $s .= $answer; } } elseif ($answerType == MATCHING) { // matching type, showing suggestions and answers // TODO: replace $answerId by $numAnswer if ($answerCorrect != 0) { // only show elements to be answered (not the contents of // the select boxes, who are corrrect = 0) $s .= '<tr><td width="45%" valign="top">'; $parsed_answer = $answer; //left part questions $s .= '<p class="indent">' . $lines_count . '. ' . $parsed_answer . '</p></td>'; //middle part (matches selects) $s .= '<td width="10%" valign="top" align="center" > <div class="select-matching"> <select name="choice[' . $questionId . '][' . $numAnswer . ']">'; // fills the list-box foreach ($select_items as $key => $val) { // set $debug_mark_answer to true at function start to // show the correct answer with a suffix '-x' $selected = ''; if ($debug_mark_answer) { if ($val['id'] == $answerCorrect) { $selected = 'selected="selected"'; } } //$user_choice_array_position if (isset($user_choice_array_position[$numAnswer]) && $val['id'] == $user_choice_array_position[$numAnswer]) { $selected = 'selected="selected"'; } $s .= '<option value="' . $val['id'] . '" ' . $selected . '>' . $val['letter'] . '</option>'; } // end foreach() $s .= '</select></div></td><td width="5%" class="separate"> </td>'; $s .= '<td width="40%" valign="top" >'; if (isset($select_items[$lines_count])) { $s .= '<div class="text-right"><p class="indent">' . $select_items[$lines_count]['letter'] . '. ' . $select_items[$lines_count]['answer'] . '</p></div>'; } else { $s .= ' '; } $s .= '</td>'; $s .= '</tr>'; $lines_count++; //if the left side of the "matching" has been completely // shown but the right side still has values to show... if ($lines_count - 1 == $num_suggestions) { // if it remains answers to shown at the right side while (isset($select_items[$lines_count])) { $s .= '<tr> <td colspan="2"></td> <td valign="top">'; $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer']; $s .= "</td>\n </tr>"; $lines_count++; } // end while() } // end if() $matching_correct_answer++; } } elseif ($answerType == DRAGGABLE) { if ($answerCorrect != 0) { $parsed_answer = $answer; /*$lines_count = ''; $data = $objAnswerTmp->getAnswerByAutoId($numAnswer); $data = $objAnswerTmp->getAnswerByAutoId($data['correct']); $lines_count = $data['answer'];*/ $windowId = $questionId . '_' . $lines_count; $s .= '<li class="touch-items" id="' . $windowId . '">'; $s .= Display::div($parsed_answer, ['id' => "window_{$windowId}", 'class' => "window{$questionId}_question_draggable exercise-draggable-answer-option"]); $selectedValue = 0; $draggableSelectOptions = []; foreach ($select_items as $key => $val) { if ($debug_mark_answer) { if ($val['id'] == $answerCorrect) { $selectedValue = $val['id']; } } if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) { $selectedValue = $val['id']; } $draggableSelectOptions[$val['id']] = $val['letter']; } $s .= Display::select("choice[{$questionId}][{$numAnswer}]", $draggableSelectOptions, $selectedValue, ['id' => "window_{$windowId}_select", 'class' => 'select_option', 'style' => 'display: none;'], false); if (!empty($answerCorrect) && !empty($selectedValue)) { $s .= <<<JAVASCRIPT <script> \$(function() { DraggableAnswer.deleteItem( \$('#{$questionId}_{$selectedValue}'), \$('#drop_{$windowId}') ); }); </script> JAVASCRIPT; } if (isset($select_items[$lines_count])) { $s .= Display::div(Display::tag('b', $select_items[$lines_count]['letter']) . $select_items[$lines_count]['answer'], ['id' => "window_{$windowId}_answer", 'style' => 'display: none;']); } else { $s .= ' '; } $lines_count++; if ($lines_count - 1 == $num_suggestions) { while (isset($select_items[$lines_count])) { $s .= Display::tag('b', $select_items[$lines_count]['letter']); $s .= $select_items[$lines_count]['answer']; $lines_count++; } } $matching_correct_answer++; $s .= '</li>'; } } elseif ($answerType == MATCHING_DRAGGABLE) { if ($answerId == 1) { echo $objAnswerTmp->getJs(); } if ($answerCorrect != 0) { $parsed_answer = $answer; $windowId = "{$questionId}_{$lines_count}"; $s .= <<<HTML <tr> <td widht="45%"> <div id="window_{$windowId}" class="window window_left_question window{$questionId}_question"> <strong>{$lines_count}.</strong> {$parsed_answer} </div> </td> <td width="10%"> HTML; $selectedValue = 0; $questionOptions = []; foreach ($select_items as $key => $val) { if ($debug_mark_answer) { if ($val['id'] == $answerCorrect) { $selectedValue = $val['id']; } } if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) { $selectedValue = $val['id']; } $questionOptions[$val['id']] = $val['letter']; } $s .= Display::select("choice[{$questionId}][{$numAnswer}]", $questionOptions, $selectedValue, ['id' => "window_{$windowId}_select", 'class' => 'hidden'], false); if (!empty($answerCorrect) && !empty($selectedValue)) { // Show connect if is not freeze (question preview) if (!$freeze) { $s .= <<<JAVASCRIPT <script> jsPlumb.ready(function() { jsPlumb.connect({ source: 'window_{$windowId}', target: 'window_{$questionId}_{$selectedValue}_answer', endpoint: ['Blank', {radius: 15}], anchors: ['RightMiddle', 'LeftMiddle'], paintStyle: {strokeStyle: '#8A8888', lineWidth: 8}, connector: [ MatchingDraggable.connectorType, {curvines: MatchingDraggable.curviness} ] }); }); </script> JAVASCRIPT; } } $s .= <<<HTML </td> <td width="45%"> HTML; if (isset($select_items[$lines_count])) { $s .= <<<HTML <div id="window_{$windowId}_answer" class="window window_right_question"> <strong>{$select_items[$lines_count]['letter']}.</strong> {$select_items[$lines_count]['answer']} </div> HTML; } else { $s .= ' '; } $s .= '</td></tr>'; $lines_count++; if ($lines_count - 1 == $num_suggestions) { while (isset($select_items[$lines_count])) { $s .= <<<HTML <tr> <td colspan="2"></td> <td> <strong>{$select_items[$lines_count]['letter']}</strong> {$select_items[$lines_count]['answer']} </td> </tr> HTML; $lines_count++; } } $matching_correct_answer++; } } } // end for() if ($show_comment) { $s .= '</table>'; } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER_TRUE_FALSE, MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE])) { $s .= '</table>'; } if ($answerType == DRAGGABLE) { $s .= "</ul></div>"; $counterAnswer = 1; $s .= '<div class="col-md-12"><div class="row">'; for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $answerCorrect = $objAnswerTmp->isCorrect($answerId); $windowId = $questionId . '_' . $counterAnswer; if ($answerCorrect) { $s .= Display::div($counterAnswer, ['id' => "drop_{$windowId}", 'class' => 'droppable col-md-2']); $counterAnswer++; } } $s .= '</div></div>'; } if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { $s .= '</div>'; } $s .= '</div>'; // destruction of the Answer object unset($objAnswerTmp); // destruction of the Question object unset($objQuestionTmp); if ($origin != 'export') { echo $s; } else { return $s; } } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) { // Question is a HOT_SPOT //checking document/images visibility if (api_is_platform_admin() || api_is_course_admin()) { $course = api_get_course_info(); $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName); if (is_numeric($doc_id)) { $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id()); if (!$images_folder_visibility) { //This message is shown only to the course/platform admin if the image is set to visibility = false Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage')); } } } $questionName = $objQuestionTmp->selectTitle(); $questionDescription = $objQuestionTmp->selectDescription(); if ($freeze) { echo Display::img($objQuestionTmp->selectPicturePath()); return; } // Get the answers, make a list $objAnswerTmp = new Answer($questionId); $nbrAnswers = $objAnswerTmp->selectNbrAnswers(); // get answers of hotpost $answers_hotspot = array(); for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId)); $answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId); } // display answers of hotpost order by id $answer_list = '<div style="padding: 10px; margin-left: 0px; border: 1px solid #A4A4A4; height: 408px; width: 200px;"><b>' . get_lang('HotspotZones') . '</b><dl>'; if (!empty($answers_hotspot)) { ksort($answers_hotspot); foreach ($answers_hotspot as $key => $value) { $answer_list .= '<dt>' . $key . '.- ' . $value . '</dt><br />'; } } $answer_list .= '</dl></div>'; if ($answerType == HOT_SPOT_DELINEATION) { $answer_list = ''; $swf_file = 'hotspot_delineation_user'; $swf_height = 405; } else { $swf_file = 'hotspot_user'; $swf_height = 436; } if (!$only_questions) { if ($show_title) { TestCategory::displayCategoryAndTitle($objQuestionTmp->id); echo '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>'; } //@todo I need to the get the feedback type echo '<input type="hidden" name="hidden_hotspot_id" value="' . $questionId . '" />'; echo '<table class="exercise_questions" > <tr> <td valign="top" colspan="2">'; echo $questionDescription; echo '</td></tr>'; } $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); $s .= '<script type="text/javascript" src="../plugin/hotspot/JavaScriptFlashGateway.js"></script> <script src="../plugin/hotspot/hotspot.js" type="text/javascript" ></script> <script type="text/javascript"> <!-- // Globals // Major version of Flash required var requiredMajorVersion = 7; // Minor version of Flash required var requiredMinorVersion = 0; // Minor version of Flash required var requiredRevision = 0; // the version of javascript supported var jsVersion = 1.0; // --> </script> <script language="VBScript" type="text/vbscript"> <!-- // Visual basic helper required to detect Flash Player ActiveX control version information Function VBGetSwfVer(i) on error resume next Dim swControl, swVersion swVersion = 0 set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i)) if (IsObject(swControl)) then swVersion = swControl.GetVariable("$version") end if VBGetSwfVer = swVersion End Function // --> </script> <script language="JavaScript1.1" type="text/javascript"> <!-- // Detect Client Browser type var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; jsVersion = 1.1; // JavaScript helper required to detect Flash Player PlugIn version information function JSGetSwfVer(i) { // NS/Opera version >= 3 check for Flash plugin in plugin array if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; descArray = flashDescription.split(" "); tempArrayMajor = descArray[2].split("."); versionMajor = tempArrayMajor[0]; versionMinor = tempArrayMajor[1]; if ( descArray[3] != "" ) { tempArrayMinor = descArray[3].split("r"); } else { tempArrayMinor = descArray[4].split("r"); } versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } else { flashVer = -1; } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; // Can\'t detect in all other cases else { flashVer = -1; } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { reqVer = parseFloat(reqMajorVer + "." + reqRevision); // loop backwards through the versions until we find the newest version for (i=25;i>0;i--) { if (isIE && isWin && !isOpera) { versionStr = VBGetSwfVer(i); } else { versionStr = JSGetSwfVer(i); } if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { tempArray = versionStr.split(" "); tempString = tempArray[1]; versionArray = tempString .split(","); } else { versionArray = versionStr.split("."); } versionMajor = versionArray[0]; versionMinor = versionArray[1]; versionRevision = versionArray[2]; versionString = versionMajor + "." + versionRevision; // 7.0r24 == 7.24 versionNum = parseFloat(versionString); // is the major.revision >= requested major.revision AND the minor version >= requested minor if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) { return true; } else { return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false ); } } } } // --> </script>'; $s .= '<tr><td valign="top" colspan="2" width="520"><table><tr><td width="520"> <script> <!-- // Version check based upon the values entered above in "Globals" var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); // Check to see if the version meets the requirements for playback if (hasReqestedVersion) { // if we\'ve detected an acceptable version var oeTags = \'<object type="application/x-shockwave-flash" data="../plugin/hotspot/' . $swf_file . '.swf?modifyAnswers=' . $questionId . '&canClick:' . $canClick . '" width="600" height="' . $swf_height . '">\' + \'<param name="wmode" value="transparent">\' + \'<param name="movie" value="../plugin/hotspot/' . $swf_file . '.swf?modifyAnswers=' . $questionId . '&canClick:' . $canClick . '" />\' + \'<\\/object>\'; document.write(oeTags); // embed the Flash Content SWF when all tests are passed } else { // flash is too old or we can\'t detect the plugin var alternateContent = "Error<br \\/>" + "Hotspots requires Macromedia Flash 7.<br \\/>" + "<a href=\\"http://www.macromedia.com/go/getflash/\\">Get Flash<\\/a>"; document.write(alternateContent); // insert non-flash content } // --> </script> </td> <td valign="top" align="left">' . $answer_list . '</td></tr> </table> </td></tr>'; echo $s; echo '</table>'; } return $nbrAnswers; }
$_GET['category'] = 'Platform'; } $watermark_deleted = false; if (isset($_GET['delete_watermark'])) { $watermark_deleted = PDF::delete_watermark(); } if (isset($_GET['action']) && $_GET['action'] == 'delete_grading') { $id = intval($_GET['id']); api_delete_setting_option($id); } $form_search = new FormValidator('search_settings', 'get', api_get_self(), null, array('class' => 'well form-inline')); $form_search->addElement('text', 'search_field'); $form_search->addElement('hidden', 'category', 'search_setting'); $form_search->addElement('style_submit_button', 'submit_button', get_lang('Search'), 'value="submit_button", class="search"'); $form_search->setDefaults(array('search_field' => isset($_REQUEST['search_field']) ? $_REQUEST['search_field'] : null)); $form_search_html = $form_search->return_form(); $url_id = api_get_current_access_url_id(); $settings = null; function get_settings($category = null) { $url_id = api_get_current_access_url_id(); $settings_by_access_list = array(); if ($url_id == 1) { $settings = api_get_settings($category, 'group', $url_id); } else { $url_info = api_get_access_url($url_id); if ($url_info['active'] == 1) { // The default settings of Chamilo $settings = api_get_settings($category, 'group', 1, 0); // The settings that are changeable from a particular site. $settings_by_access = api_get_settings($category, 'group', $url_id, 1);
/** * Returns the form to update or create a document * @param string Action (add/edit) * @param integer ID of the lp_item (if already exists) * @param mixed Integer if document ID, string if info ('new') * @return string HTML form */ public function display_document_form($action = 'add', $id = 0, $extra_info = 'new') { $course_id = api_get_course_int_id(); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_doc = Database::get_course_table(TABLE_DOCUMENT); $no_display_edit_textarea = false; //If action==edit document //We don't display the document form if it's not an editable document (html or txt file) if ($action == "edit") { if (is_array($extra_info)) { $path_parts = pathinfo($extra_info['dir']); if ($path_parts['extension'] != "txt" && $path_parts['extension'] != "html") { $no_display_edit_textarea = true; } } } $no_display_add = false; // If action==add an existing document // We don't display the document form if it's not an editable document (html or txt file). if ($action == "add") { if (is_numeric($extra_info)) { $sql_doc = "SELECT path FROM " . $tbl_doc . " WHERE c_id = " . $course_id . " AND id = " . Database::escape_string($extra_info); $result = Database::query($sql_doc); $path_file = Database::result($result, 0, 0); $path_parts = pathinfo($path_file); if ($path_parts['extension'] != "txt" && $path_parts['extension'] != "html") { $no_display_add = true; } } } if ($id != 0 && is_array($extra_info)) { $item_title = stripslashes($extra_info['title']); $item_description = stripslashes($extra_info['description']); $item_terms = stripslashes($extra_info['terms']); if (empty($item_title)) { $path_parts = pathinfo($extra_info['path']); $item_title = stripslashes($path_parts['filename']); } } elseif (is_numeric($extra_info)) { $sql_doc = "SELECT path, title FROM " . $tbl_doc . "\n WHERE c_id = " . $course_id . " AND id = " . Database::escape_string($extra_info); $result = Database::query($sql_doc); $row = Database::fetch_array($result); $explode = explode('.', $row['title']); if (count($explode) > 1) { for ($i = 0; $i < count($explode) - 1; $i++) { $item_title .= $explode[$i]; } } else { $item_title = $row['title']; } $item_title = str_replace('_', ' ', $item_title); if (empty($item_title)) { $path_parts = pathinfo($row['path']); $item_title = stripslashes($path_parts['filename']); } } else { $item_title = ''; $item_description = ''; } $return = '<legend>'; 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 = null; if (isset($this->arrMenu)) { $arrLP = $this->arrMenu; unset($this->arrMenu); } if ($action == 'add') { $return .= get_lang('CreateTheDocument'); } elseif ($action == 'move') { $return .= get_lang('MoveTheCurrentDocument'); } else { $return .= get_lang('EditTheCurrentDocument'); } $return .= '</legend>'; if (isset($_GET['edit']) && $_GET['edit'] == 'true') { $return .= Display::return_warning_message('<strong>' . get_lang('Warning') . ' !</strong><br />' . get_lang('WarningEditingDocument'), false); } $form = new FormValidator('form', 'POST', api_get_self() . '?' . $_SERVER['QUERY_STRING'], '', array('enctype' => "multipart/form-data")); $defaults['title'] = Security::remove_XSS($item_title); if (empty($item_title)) { $defaults['title'] = Security::remove_XSS($item_title); } $defaults['description'] = $item_description; $form->addElement('html', $return); if ($action != 'move') { $form->addElement('text', 'title', get_lang('Title'), array('id' => 'idTitle', 'class' => 'span4')); $form->applyFilter('title', 'html_filter'); } //$arrHide = array($id); $arrHide[0]['value'] = $this->name; $arrHide[0]['padding'] = 3; 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)) { $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; $arrHide[$arrLP[$i]['id']]['padding'] = 3 + $arrLP[$i]['depth'] * 10; if ($parent == $arrLP[$i]['id']) { $s_selected_parent = $arrHide[$arrLP[$i]['id']]; } } } else { if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') { $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; $arrHide[$arrLP[$i]['id']]['padding'] = 3 + $arrLP[$i]['depth'] * 10; if ($parent == $arrLP[$i]['id']) { $s_selected_parent = $arrHide[$arrLP[$i]['id']]; } } } } $parent_select = $form->addElement('select', 'parent', get_lang('Parent'), '', 'class="learnpath_item_form" id="idParent" style="width:40%;" onchange="javascript: load_cbo(this.value);"'); $my_count = 0; foreach ($arrHide as $key => $value) { if ($my_count != 0) { // The LP name is also the first section and is not in the same charset like the other sections. $value['value'] = Security::remove_XSS($value['value']); $parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"'); } else { $value['value'] = Security::remove_XSS($value['value']); $parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"'); } $my_count++; } if (!empty($id)) { $parent_select->setSelected($parent); } else { $parent_item_id = Session::read('parent_item_id'); $parent_select->setSelected($parent_item_id); } if (is_array($arrLP)) { reset($arrLP); } $arrHide = array(); $s_selected_position = null; //POSITION for ($i = 0; $i < count($arrLP); $i++) { if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { $s_selected_position = $arrLP[$i]['id']; } elseif ($action == 'add') { $s_selected_position = $arrLP[$i]['id']; } $arrHide[$arrLP[$i]['id']]['value'] = get_lang('After') . ' "' . $arrLP[$i]['title'] . '"'; } } $position = $form->addElement('select', 'previous', get_lang('Position'), '', 'id="previous" class="learnpath_item_form" style="width:40%;"'); $position->addOption(get_lang('FirstPosition'), 0); foreach ($arrHide as $key => $value) { $padding = isset($value['padding']) ? $value['padding'] : 0; $position->addOption($value['value'], $key, 'style="padding-left:' . $padding . 'px;"'); } $position->setSelected($s_selected_position); if (is_array($arrLP)) { reset($arrLP); } 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 (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { $s_selected_position = $arrLP[$i]['id']; } elseif ($action == 'add') { $s_selected_position = $arrLP[$i]['id']; } $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; } } if (!$no_display_add) { if ($extra_info == 'new' || $extra_info['item_type'] == TOOL_DOCUMENT || $_GET['edit'] == 'true') { if (isset($_POST['content'])) { $content = stripslashes($_POST['content']); } elseif (is_array($extra_info)) { //If it's an html document or a text file if (!$no_display_edit_textarea) { $content = $this->display_document($extra_info['path'], false, false); } } elseif (is_numeric($extra_info)) { $content = $this->display_document($extra_info, false, false); } else { $content = ''; } if (!$no_display_edit_textarea) { // We need to calculate here some specific settings for the online editor. // The calculated settings work for documents in the Documents tool // (on the root or in subfolders). // For documents in native scorm packages it is unclear whether the // online editor should be activated or not. // A new document, it is in the root of the repository. $relative_path = ''; $relative_prefix = ''; if (is_array($extra_info) && $extra_info != 'new') { // The document already exists. Whe have to determine its relative path towards the repository root. $relative_path = explode('/', $extra_info['dir']); $cnt = count($relative_path) - 2; if ($cnt < 0) { $cnt = 0; } $relative_prefix = str_repeat('../', $cnt); $relative_path = array_slice($relative_path, 1, $cnt); $relative_path = implode('/', $relative_path); if (strlen($relative_path) > 0) { $relative_path = $relative_path . '/'; } } else { $_course = api_get_course_info(); $result = $this->generate_lp_folder($_course); $relative_path = api_substr($result['dir'], 1, strlen($result['dir'])); $relative_prefix = '../../'; } $editor_config = array('ToolbarSet' => 'LearningPathDocuments', 'Width' => '100%', 'Height' => '500', 'FullPage' => true, 'CreateDocumentDir' => $relative_prefix, 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/', 'BaseHref' => api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/' . $relative_path); if ($_GET['action'] == 'add_item') { $class = 'add'; $text = get_lang('LPCreateDocument'); } else { if ($_GET['action'] == 'edit_item') { $class = 'save'; $text = get_lang('SaveDocument'); } } $form->addElement('style_submit_button', 'submit_button', $text, 'class="' . $class . '"'); $renderer = $form->defaultRenderer(); $renderer->setElementTemplate('<br /> {label}<br />{element}', 'content_lp'); $form->addElement('html', '<div>'); $form->addElement('html_editor', 'content_lp', '', null, $editor_config); $form->addElement('html', '</div>'); $defaults['content_lp'] = $content; } } elseif (is_numeric($extra_info)) { $form->addElement('style_submit_button', 'submit_button', get_lang('SaveDocument'), 'class="save"'); $return = $this->display_document($extra_info, true, true, true); $form->addElement('html', $return); } } } if ($action == 'move') { $form->addElement('hidden', 'title', $item_title); $form->addElement('hidden', 'description', $item_description); } if (is_numeric($extra_info)) { $form->addElement('style_submit_button', 'submit_button', get_lang('SaveDocument'), 'value="submit_button", class="save"'); $form->addElement('hidden', 'path', $extra_info); } elseif (is_array($extra_info)) { $form->addElement('style_submit_button', 'submit_button', get_lang('SaveDocument'), 'class="save"'); $form->addElement('hidden', 'path', $extra_info['path']); } $form->addElement('hidden', 'type', TOOL_DOCUMENT); $form->addElement('hidden', 'post_time', time()); $form->setDefaults($defaults); return $form->return_form(); }
$tpl->assign('enable_nanogong', api_get_setting('enable_nanogong') == 'true' ? 1 : 0); $tpl->assign('enable_wami', api_get_setting('enable_wami_record') == 'true' ? 1 : 0); $tpl->assign('cur_dir_path', '/audio'); $tpl->assign('lp_item_id', $lp_item_id); $tpl->assign('lp_dir', api_remove_trailing_slash($lpPathInfo['dir'])); $recordVoiceForm .= $tpl->fetch('default/learnpath/record_voice.tpl'); $form->addElement('header', get_lang('Or')); $form->addElement('header', get_lang('AudioFile')); $form->addElement('html', sprintf(get_lang('AudioFileForItemX'), $lp_item->get_title())); if (!empty($file)) { $audioPlayer = '<div id="preview">' . Display::getMediaPlayer($file, array('url' => $urlFile)) . "</div>"; $form->addElement('label', get_lang('Listen'), $audioPlayer); $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?lp_id=' . $_SESSION['oLP']->get_id() . '&action=add_audio&id=' . $lp_item_id . '&delete_file=1&' . api_get_cidreq(); $form->addElement('label', null, Display::url(get_lang('RemoveAudio'), $url, array('class' => 'btn btn-danger'))); } else { $form->addElement('file', 'file'); $form->addElement('hidden', 'id', $lp_item_id); $form->addButtonSave(get_lang('Save')); } $form->addElement('header', get_lang('Or')); $courseInfo = api_get_course_info(); $documentTree = DocumentManager::get_document_preview($courseInfo, false, null, api_get_session_id(), false, '', urlencode('lp_controller.php?action=add_audio&lp_id=' . $_SESSION['oLP']->get_id() . '&id=' . $lp_item_id), false, true); $page .= $recordVoiceForm; $page .= $form->return_form(); $page .= '<legend>' . get_lang('SelectAnAudioFileFromDocuments') . '</legend>'; $page .= $documentTree; $page .= '</div>'; $page .= '</div>'; $tpl->assign('content', $page); $content = $tpl->fetch('default/learnpath/lp_upload_audio.tpl'); $tpl->display_one_col_template();
case 'delete_class': ClassManager::delete_class($_GET['class_id']); $message = Display::return_message(get_lang('ClassDeleted')); break; case 'show_message': $message = Display::return_message(Security::remove_XSS(stripslashes($_GET['message']))); break; } } // Create a search-box $form = new FormValidator('search_simple', 'get', '', '', null, false); $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<span>{element}</span> '); $form->addElement('text', 'keyword', get_lang('keyword')); $form->addElement('button', 'submit', get_lang('Search')); $content .= $form->return_form(); // Create the sortable table with class information $table = new SortableTable('classes', 'get_number_of_classes', 'get_class_data', 1); $table->set_additional_parameters(array('keyword' => $_GET['keyword'])); $table->set_header(0, '', false); $table->set_header(1, get_lang('ClassName')); $table->set_header(2, get_lang('NumberOfUsers')); $table->set_header(3, '', false); $table->set_column_filter(3, 'modify_filter'); $table->set_form_actions(array('delete_classes' => get_lang('DeleteSelectedClasses')), 'class'); $content .= $table->return_table(); $actions .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM), 'class_add.php'); $actions .= Display::url(Display::return_icon('import_csv.png', get_lang('AddUsersToAClass'), array(), ICON_SIZE_MEDIUM), 'class_user_import.php'); $actions .= Display::url(Display::return_icon('import_csv.png', get_lang('ImportClassListCSV'), array(), ICON_SIZE_MEDIUM), 'class_import.php'); $app['title'] = $tool_name; $tpl = $app['template'];
Security::clear_token(); } } // Create a search-box $form = new FormValidator('search_simple', 'get', '', '', array(), FormValidator::LAYOUT_INLINE); $form->addElement('text', 'keyword'); $form->addButtonSearch(get_lang('Search')); $form->addElement('static', 'search_advanced_link', null, '<a href="javascript://" class = "advanced_parameters" onclick="display_advanced_search_form();"> <span id="img_plus_and_minus"> ' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . ' ' . get_lang('AdvancedSearch') . ' </span> </a>'); $actions = ''; if (api_is_platform_admin()) { $actions .= '<span style="float:right;">' . '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/user_add.php">' . Display::return_icon('new_user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM) . '</a>' . '</span>'; } $actions .= $form->return_form(); if (isset($_GET['keyword'])) { $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); } elseif (isset($_GET['keyword_firstname'])) { $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']); $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']); $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); } // 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
Display::display_header($nameTools, "Doc"); // actions echo '<div class="actions">'; // link back to the documents overview if ($is_certificate_mode) { echo '<a href="document.php?certificate=true&id=' . $folder_id . '&selectcat=' . Security::remove_XSS($_GET['selectcat']) . '">' . Display::return_icon('back.png', get_lang('Back') . ' ' . get_lang('To') . ' ' . get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM) . '</a>'; } else { echo '<a href="document.php?curdirpath=' . Security::remove_XSS($dir) . '">' . Display::return_icon('back.png', get_lang('Back') . ' ' . get_lang('To') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>'; } echo '</div>'; if ($is_certificate_mode) { $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id()); $str_info = ''; foreach ($all_information_by_create_certificate[0] as $info_value) { $str_info .= $info_value . '<br/>'; } $create_certificate = get_lang('CreateCertificateWithTags'); Display::display_normal_message($create_certificate . ': <br /><br/>' . $str_info, false); } // HTML-editor echo '<div class="row-fluid" style="overflow:hidden"> <div id="template_col" class="span2" style="width:162px"> <div id="frmModel" style="overflow: visible;"></div> </div> <div id="hide_bar_template"></div> <div id="doc_form" class="span9"> ' . $form->return_form() . ' </div> </div>'; Display::display_footer(); }
if ($total_resource_weight != $total_weight) { Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight')); } } $filter = api_get_setting('certificate_filter_by_official_code'); $userList = array(); $filterForm = null; $certificate_list = array(); if ($filter === 'true') { echo '<br />'; $options = UserManager::getOfficialCodeGrouped(); $options = array_merge(array('all' => get_lang('All')), $options); $form = new FormValidator('official_code_filter', 'POST', api_get_self() . '?' . api_get_cidreq() . '&cat_id=' . $cat_id); $form->addElement('select', 'filter', get_lang('OfficialCode'), $options); $form->addButton('submit', get_lang('Submit')); $filterForm = '<br />' . $form->return_form(); if ($form->validate()) { $officialCode = $form->getSubmitValue('filter'); if ($officialCode == 'all') { $certificate_list = GradebookUtils::get_list_users_certificates($cat_id); } else { $userList = UserManager::getUsersByOfficialCode($officialCode); if (!empty($userList)) { $certificate_list = GradebookUtils::get_list_users_certificates($cat_id, $userList); } } } else { $certificate_list = GradebookUtils::get_list_users_certificates($cat_id); } } else { $certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
/** * Returns the form to update or create a document * * @param string Action (add/edit) * @param integer ID of the lp_item (if already exists) * @param mixed Integer if document ID, string if info ('new') * @return string HTML form */ function display_document_form($action = 'add', $id = 0, $extra_info = 'new') { global $charset, $_course; require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'document.lib.php'; $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_doc = Database::get_course_table(TABLE_DOCUMENT); $path_parts = pathinfo($extra_info['dir']); $no_display_edit_textarea = false; //If action==edit document //We don't display the document form if it's not an editable document (html or txt file) if ($action == "edit") { if (is_array($extra_info)) { if ($path_parts['extension'] != "txt" && $path_parts['extension'] != "html") { $no_display_edit_textarea = true; } } } $no_display_add = false; //If action==add an existing document //We don't display the document form if it's not an editable document (html or txt file) if ($action == "add") { if (is_numeric($extra_info)) { $sql_doc = "SELECT path FROM " . $tbl_doc . "WHERE id = " . Database::escape_string($extra_info); $result = Database::query($sql_doc, __FILE__, __LINE__); $path_file = Database::result($result, 0, 0); $path_parts = pathinfo($path_file); if ($path_parts['extension'] != "txt" && $path_parts['extension'] != "html") { $no_display_add = true; } } } // create css folder $css_name = api_get_setting('stylesheets'); $perm = api_get_setting('permissions_for_new_directories'); $perm = octdec(!empty($perm) ? $perm : '0770'); $css_folder = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/css'; if (!is_dir($css_folder)) { mkdir($css_folder); chmod($css_folder, $perm); $doc_id = add_document($_course, '/css', 'folder', 0, 'css'); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id']); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id']); } if (!file_exists($css_folder . '/templates.css')) { if (file_exists(api_get_path(SYS_PATH) . 'main/css/' . $css_name . '/templates.css')) { $template_content = str_replace('../../img/', api_get_path(REL_CODE_PATH) . 'img/', file_get_contents(api_get_path(SYS_PATH) . 'main/css/' . $css_name . '/templates.css')); $template_content = str_replace('images/', api_get_path(REL_CODE_PATH) . 'css/' . $css_name . '/images/', $template_content); file_put_contents($css_folder . '/templates.css', $template_content); } } if ($action == 'add' && (isset($_GET['tplid']) && $_GET['tplid'] >= 0)) { $table_sys_template = Database::get_main_table(TABLE_MAIN_SYSTEM_TEMPLATE); $user_id = api_get_user_id(); // Session used by the ajax request when we are using php 5.3 $_SESSION['dbName'] = $_course['dbName']; // setting some paths $img_dir = api_get_path(REL_CODE_PATH) . 'img/'; $default_course_dir = api_get_path(REL_CODE_PATH) . 'default_course_document/'; if (!isset($_GET['resource'])) { // Load a template into a document $query = 'SELECT content, title FROM ' . $table_sys_template . ' WHERE id=' . Database::escape_string(Security::remove_XSS($_GET['tplid'])); $result = Database::query($query, __FILE__, __LINE__); $obj = Database::fetch_object($result); $valcontent = $obj->content; $valtitle = $obj->title != '' ? get_lang($obj->title) : get_lang('Empty'); if (isset($_GET['tplid']) && $_GET['tplid'] == 0) { $valcontent = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body></body>'; } $template_css = ''; if (strpos($valcontent, '/css/templates.css') === false) { $template_css = '<link rel="stylesheet" href="' . api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/document/css/templates.css" type="text/css" />'; } $js = ''; if (strpos($valcontent, 'javascript/jquery.highlight.js') === false) { $js .= '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery-1.4.2.min.js" language="javascript"></script>'; $js .= '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'jwplayer/jwplayer.js" language="javascript"></script>' . PHP_EOL; if (api_get_setting('show_glossary_in_documents') != 'none') { $js .= '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery.highlight.js"></script>'; if (api_get_setting('show_glossary_in_documents') == 'ismanual') { $js .= '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'fckeditor/editor/plugins/glossary/fck_glossary_manual.js"></script>'; } else { $js .= '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'fckeditor/editor/plugins/glossary/fck_glossary_automatic.js"></script>'; } } } $valcontent = str_replace('{CSS}', $template_css . $js, $valcontent); if (strpos($valcontent, '/css/templates.css') === false) { $valcontent = str_replace('</head>', $template_css . '</head>', $valcontent); } if (strpos($valcontent, 'javascript/jquery.highlight.js') === false) { $valcontent = str_replace('</head>', $js . '</head>', $valcontent); } $valcontent = str_replace('{IMG_DIR}', $img_dir, $valcontent); $valcontent = str_replace('{REL_PATH}', api_get_path(REL_PATH), $valcontent); $valcontent = str_replace('{COURSE_DIR}', $default_course_dir, $valcontent); } elseif (isset($_GET['resource']) && $_GET['resource'] == 'mindmap' || $_GET['resource'] == 'video') { // Load a mindmap or video into a document $propTable = Database::get_course_table(TABLE_ITEM_PROPERTY); $curdirpath = '/mindmaps/'; if ($_GET['resource'] == 'video') { $curdirpath = '/video/'; $curdirpath_flv = '/video/flv/'; } $my_course = api_get_course_id(); $src_path = api_get_path(WEB_COURSE_PATH) . $my_course . '/document'; $sql = "SELECT path,title FROM {$tbl_doc} doc,{$propTable} prop WHERE doc.id = prop.ref AND prop.tool = '" . TOOL_DOCUMENT . "'\n AND doc.filetype = 'file' AND (doc.path LIKE '" . $curdirpath . "%' OR doc.path LIKE '" . $curdirpath_flv . "%') AND (doc.path NOT LIKE '" . $curdirpath . "%/%' OR doc.path NOT LIKE '" . $curdirpath_flv . "%/%')\n AND prop.visibility = 1 AND doc.id = '" . Database::escape_string(Security::remove_XSS($_GET['tplid'])) . "'"; $rs = Database::query($sql); $row = Database::fetch_array($rs); $resource = $src_path . $row['path']; $valtitle = $row['title']; if ($valtitle != '') { $search = array('.png', '.gif', '.jpg', '.mpg', '.flv', '.swf'); // Add other extensions $replace = array('', '', '', '', '', ''); $valtitle = str_replace($search, $replace, $valtitle); } if ($_GET['resource'] == 'mindmap') { $valcontent = '<table cellspacing="2" cellpadding="10" border="0" style="width: 95%; height: 500px;"> <tbody> <tr> <td valign="top"><img border="0" vspace="0" hspace="0" src="' . $resource . '" alt="' . $title . '" title="' . $title . '"/></td> </tr> </tbody> </table>'; } elseif ($_GET['resource'] == 'video') { $sys_resource = api_get_path(SYS_COURSE_PATH) . $my_course . '/document' . $row['path']; $resource_info = pathinfo($sys_resource); //$video_web_path = api_get_path(WEB_LIBRARY_PATH) . 'fckeditor/editor/plugins/flvPlayer/'; $valcontent = '<table cellspacing="2" cellpadding="10" border="0" style="width: 95%; height: 500px;"> <tbody> <tr> <td valign="top"> <!-- Video player plugin --> <div id="player986311-parent" align="left"> <div style="border-style: none; height: 240px; width: 375px; overflow: hidden; background-color: rgb(220, 220, 220);" id="test"> <div style="display: none; visibility: hidden; width: 0px; height: 0px; overflow: hidden;" id="player986311-config">url=' . $resource . ' width=375 height=240 loop=1 play=true downloadable=false fullscreen=true</div> <div class="thePlayer" id="player986311">'; if (in_array($resource_info['extension'], array('flv', 'mp4', 'mov'))) { /*if (!api_is_windows_os()) { $valcontent .= ' <script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/editor/plugins/videoPlayer/jwplayer.min.js" type="text/javascript"></script> <object id="player986311-parent2" name="player986311-parent2" width="375" height="240" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="movie" value="'.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/editor/plugins/videoPlayer/player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="seamlesstabbing" value="true" /> <param name="wmode" value="transparent" /> <param name="flashvars" value="id=player986311-parent2&autostart=true&repeat=false&file='.$resource.'&skin='.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/editor/plugins/videoPlayer/skins/facebook.zip&controlbar.position=over" /> </object> '; } else {*/ $valcontent .= ' <script src="' . api_get_path(WEB_CODE_PATH) . 'inc/lib/fckeditor/editor/plugins/videoPlayer/jwplayer.min.js" type="text/javascript"></script> <div id="player986311-parent2">Loading the player ...</div> <script type="text/javascript">jwplayer("player986311-parent2").setup({flashplayer: "' . api_get_path(WEB_CODE_PATH) . 'inc/lib/fckeditor/editor/plugins/videoPlayer/player.swf",autostart: "true",repeat: "always",file: "' . $resource . '",height: 240,width: 375,skin: "' . api_get_path(WEB_CODE_PATH) . 'inc/lib/fckeditor/editor/plugins/videoPlayer/skins/facebook.zip"});</script>'; //} } else { $sType = ''; if ($resource_info['extension'] == 'mpg' || $resource_info['extension'] == 'mpeg') { $sType = 'video/mpeg'; } else { if ($resource_info['extension'] == 'avi' || $resource_info['extension'] == 'wmv' || $resource_info['extension'] == 'asf') { $sType = 'video/x-msvideo'; } } $valcontent .= '<embed type="' . $sType . '" src="' . $resource . '" autosize = "false" autostart = "true" loop = "false" fullscreen = "true" showcontrols = "true" showpositioncontrols = "false" showtracker = "true" showaudiocontrols = "true" showgotobar = "true" showstatusbar = "true" pluginspace = "http://www.microsoft.com/Windows/MediaPlayer/" codebase = "http://www.microsoft.com/Windows/MediaPlayer/"'; $valcontent .= 'width="375px" height="240px"'; $valcontent .= '></embed>'; } $valcontent .= ' </div> </div> </div> </td> </tr> </tbody> </table>'; } } } if ($id != 0 && is_array($extra_info)) { $item_title = stripslashes($extra_info['title']); $item_description = stripslashes($extra_info['description']); $item_terms = stripslashes($extra_info['terms']); if (empty($item_title)) { $path_parts = pathinfo($extra_info['path']); $item_title = stripslashes($path_parts['filename']); } } elseif (is_numeric($extra_info)) { $sql_doc = "SELECT path, title\n\t\t\t\t\t\t\t\t\tFROM " . $tbl_doc . "\n\t\t\t\t\t\t\t\t\tWHERE id = " . Database::escape_string($extra_info); $result = Database::query($sql_doc, __FILE__, __LINE__); $row = Database::fetch_array($result); $explode = explode('.', $row['title']); if (count($explode) > 1) { for ($i = 0; $i < count($explode) - 1; $i++) { $item_title .= $explode[$i]; } } else { $item_title = $row['title']; } $item_title = str_replace('_', ' ', $item_title); if (empty($item_title)) { $path_parts = pathinfo($row['path']); $item_title = stripslashes($path_parts['filename']); } } else { $item_title = ''; $item_description = ''; } /* $return = ' <div class="row"> <div class="form_header">'; */ if ($id != 0 && is_array($extra_info)) { $parent = $extra_info['parent_item_id']; } else { $parent = 0; } $sql = "\n\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\tFROM " . $tbl_lp_item . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tlp_id = " . $this->lp_id; $result = Database::query($sql, __FILE__, __LINE__); $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 = $this->arrMenu; unset($this->arrMenu); if (isset($_GET['edit']) && $_GET['edit'] == 'true') { $return .= Display::return_warning_message('<strong>' . get_lang("Warning") . ' !</strong><br />' . get_lang("WarningEditingDocument"), false); } require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php'; $form = new FormValidator('form', 'POST', api_get_self() . "?" . $_SERVER["QUERY_STRING"], '', 'enctype="multipart/form-data"'); $defaults["title"] = Security::remove_XSS(api_convert_encoding($item_title, api_get_system_encoding(), $this->encoding)); if (empty($item_title)) { $defaults["title"] = Security::remove_XSS($item_title); } $defaults["description"] = api_convert_encoding($item_description, $charset, $this->encoding); $form->addElement('html', $return); if ($action != 'move') { $form->addElement('html', '<div style="float:left;padding-right:135px;">'); $form->addElement('text', 'title', get_lang('Title'), 'id="idTitle" class="learnpath_item_form" size=44%'); $form->applyFilter('title', 'html_filter'); $form->addElement('html', '</div>'); } //$arrHide = array($id); $arrHide[0]['value'] = $this->name; $arrHide[0]['padding'] = 3; 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)) { $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; $arrHide[$arrLP[$i]['id']]['padding'] = 3 + $arrLP[$i]['depth'] * 10; if ($parent == $arrLP[$i]['id']) { $s_selected_parent = $arrHide[$arrLP[$i]['id']]; } } } else { if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') { $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; $arrHide[$arrLP[$i]['id']]['padding'] = 3 + $arrLP[$i]['depth'] * 10; if ($parent == $arrLP[$i]['id']) { $s_selected_parent = $arrHide[$arrLP[$i]['id']]; } } } } //$parent_select = & $form->addElement('select', 'parent', get_lang('Parent'), '', 'class="learnpath_item_form" style="width:40%;" onchange="load_cbo(this.value);"'); $parent_select =& $form->addElement('select', 'parent', '', '', 'class="learnpath_item_form" style="width:40%;display:none;float:left" onchange="load_cbo(this.value);"'); $my_count = 0; foreach ($arrHide as $key => $value) { if ($my_count != 0) { // the LP name is also the first section and is not in the same charset like the other sections $value['value'] = Security::remove_XSS(api_convert_encoding($value['value'], api_get_system_encoding(), $this->encoding)); $parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"'); } else { $value['value'] = Security::remove_XSS($value['value']); $parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"'); } $my_count++; } if (!empty($id)) { $parent_select->setSelected($parent); } else { $parent_item_id = $_SESSION['parent_item_id']; $parent_select->setSelected($parent_item_id); } if (is_array($arrLP)) { reset($arrLP); } $arrHide = array(); //POSITION for ($i = 0; $i < count($arrLP); $i++) { if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { $s_selected_position = $arrLP[$i]['id']; } elseif ($action == 'add') { $s_selected_position = $arrLP[$i]['id']; } $arrHide[$arrLP[$i]['id']]['value'] = get_lang("After") . ' "' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding) . '"'; } } //$position = & $form->addElement('select', 'previous', get_lang('Position'), '', 'id="idPosition" class="learnpath_item_form" style="width:40%;"'); $position =& $form->addElement('select', 'previous', '', '', 'id="idPosition" class="learnpath_item_form" style="width:40%;float:left;display:none;"'); $position->addOption(get_lang("FirstPosition"), 0); foreach ($arrHide as $key => $value) { $position->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"'); } $position->setSelected($s_selected_position); if (is_array($arrLP)) { reset($arrLP); } if ($action != 'move') { $id_prerequisite = 0; if (is_array($arrLP)) { foreach ($arrLP as $key => $value) { if ($value['id'] == $id) { $id_prerequisite = $value['prerequisite']; break; } } } //comented the prerequisites, only visible in edit (new document) //$select_prerequisites=$form->addElement('select', 'prerequisites', get_lang('Prerequisites'),null,'id="prerequisites" class="learnpath_item_form" style="width:263px;"'); //$select_prerequisites->addOption(get_lang("NoPrerequisites"),0); // form element for uploading an mp3 file //$form->addElement('file','mp3',get_lang('UploadMp3audio'),'id="mp3" size="33"'); //$form->addRule('file', 'The extension of the Song file should be *.mp3', 'filename', '/^.*\.mp3$/'); /* Code deprecated - moved to lp level (not lp-item) if ( api_get_setting('search_enabled') === 'true' ) { //add terms field $terms = $form->addElement('text','terms', get_lang('SearchFeatureTerms').' :','id="idTerms" class="learnpath_item_form"'); $terms->setValue($item_terms); } */ $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 = $arrLP[$i]['id']; } $arrHide[$arrLP[$i]['id']]['value'] = api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding); } } /* foreach($arrHide as $key => $value){ $select_prerequisites->addOption($value['value'],$key,'style="padding-left:'.$value['padding'].'px;"'); if($key==$s_selected_position && $action == 'add'){ $select_prerequisites -> setSelected(0); } elseif($key==$id_prerequisite && $action == 'edit'){ $select_prerequisites -> setSelected($id_prerequisite); } } */ if (!$no_display_add) { if ($extra_info == 'new' || $extra_info['item_type'] == TOOL_DOCUMENT || $_GET['edit'] == 'true') { if (isset($_POST['content'])) { $content = stripslashes($_POST['content']); } elseif (is_array($extra_info)) { //If it's an html document or a text file if (!$no_display_edit_textarea) { $content = $this->display_document($extra_info['path'], false, false); } } elseif (is_numeric($extra_info)) { $content = $this->display_document($extra_info, false, false); } else { $content = ''; } if (!$no_display_edit_textarea) { // We need to claculate here some specific settings for the online editor. // The calculated settings work for documents in the Documents tool // (on the root or in subfolders). // For documents in native scorm packages it is unclear whether the // online editor should be activated or not. $relative_path = $extra_info['dir']; if ($relative_path == 'n/') { // A new document, it is in the root of the repository. $relative_path = ''; $relative_prefix = ''; } else { // The document already exists. Whe have to determine its relative path towards the repository root. $relative_path = explode('/', $relative_path); $cnt = count($relative_path) - 2; if ($cnt < 0) { $cnt = 0; } $relative_prefix = str_repeat('../', $cnt); $relative_path = array_slice($relative_path, 1, $cnt); $relative_path = implode('/', $relative_path); if (strlen($relative_path) > 0) { $relative_path = $relative_path . '/'; } } $editor_config = array('ToolbarSet' => api_is_allowed_to_edit() ? 'Documents' : 'DocumentsStudent', 'Width' => '100%', 'Height' => '700', 'FullPage' => true, 'CreateDocumentDir' => $relative_prefix, 'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH') . api_get_course_path() . '/document/', 'BaseHref' => api_get_path('WEB_COURSE_PATH') . api_get_course_path() . '/document/' . $relative_path); if ($_GET['action'] == 'add_item') { $class = 'save'; $text = get_lang('Validate'); } else { if ($_GET['action'] == 'edit_item') { $class = 'save'; $text = get_lang('SaveDocument'); } } $form->addElement('html', '<div style="float:right;margin-top:-55px">'); $form->addElement('style_submit_button', 'submit_button', $text, 'class="' . $class . '"'); $form->addElement('html', '</div>'); $renderer = $form->defaultRenderer(); $renderer->setElementTemplate('{label}{element}', 'content_lp'); //$form->addElement('html', '<div'); $form->addElement('html_editor', 'content_lp', '', null, $editor_config); //$form->addElement('html', '</div>'); $defaults["content_lp"] = $content; } } elseif (is_numeric($extra_info)) { $form->addElement('style_submit_button', 'submit_button', get_lang('SaveDocument'), 'class="save"'); $return = $this->display_document($extra_info, true, true, true); $form->addElement('html', $return); } } } // Add template to content if ($action == 'add' && (isset($_GET['tplid']) && $_GET['tplid'] >= 0)) { $defaults["content_lp"] = $valcontent; $defaults["title"] = $valtitle; } if ($action == 'move') { $form->addElement('hidden', 'title', $item_title); $form->addElement('hidden', 'description', $item_description); } if (is_numeric($extra_info)) { $form->addElement('style_submit_button', 'submit_button', get_lang('SaveDocument'), 'value="submit_button", class="save" style="float:right"'); $form->addElement('hidden', 'path', $extra_info); } elseif (is_array($extra_info)) { $form->addElement('html', '<div style="float:right;margin-top:-55px">'); $form->addElement('style_submit_button', 'submit_button', get_lang('SaveDocument'), 'class="save"'); $form->addElement('hidden', 'path', $extra_info['path']); $form->addElement('html', '</div>'); } $form->addElement('hidden', 'type', TOOL_DOCUMENT); $form->addElement('hidden', 'post_time', time()); $form->setDefaults($defaults); return $form->return_form(); }
/** * This function allows the platform admin to choose the default stylesheet * @author Patrick Cool <*****@*****.**>, Ghent University * @author Julio Montoya <*****@*****.**>, Chamilo */ function handle_stylesheets() { global $_configuration; // Current style. $currentstyle = api_get_setting('stylesheets'); $is_style_changeable = false; if ($_configuration['access_url'] != 1) { $style_info = api_get_settings('stylesheets', '', 1, 0); $url_info = api_get_access_url($_configuration['access_url']); if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) { $is_style_changeable = true; } } else { $is_style_changeable = true; } $form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=Stylesheets#tabs-2'); $form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); $form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet')); $allowed_file_types = array('css', 'zip', 'jpeg', 'jpg', 'png', 'gif', 'ico', 'psd'); $form->addRule('new_stylesheet', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types); $form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addButtonUpload(get_lang('Upload'), 'stylesheet_upload'); $show_upload_form = false; if (!is_writable(CSS_UPLOAD_PATH)) { Display::display_error_message(CSS_UPLOAD_PATH . get_lang('IsNotWritable')); } else { // Uploading a new stylesheet. if ($_configuration['access_url'] == 1) { $show_upload_form = true; } else { if ($is_style_changeable) { $show_upload_form = true; } } } // Stylesheet upload. if (isset($_POST['stylesheet_upload'])) { if ($form->validate()) { $values = $form->exportValues(); $picture_element = $form->getElement('new_stylesheet'); $picture = $picture_element->getValue(); $result = upload_stylesheet($values, $picture); // Add event to the system log. $user_id = api_get_user_id(); $category = $_GET['category']; Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id); if ($result) { Display::display_confirmation_message(get_lang('StylesheetAdded')); } } } $form_change = new FormValidator('stylesheet_upload', 'post', api_get_self() . '?category=Stylesheets', null, array('id' => 'stylesheets_id')); $list_of_names = array(); $selected = ''; $dirpath = ''; $safe_style_dir = ''; if ($handle = @opendir(CSS_UPLOAD_PATH)) { $counter = 1; while (false !== ($style_dir = readdir($handle))) { if (substr($style_dir, 0, 1) == '.') { // Skip directories starting with a '.' continue; } $dirpath = CSS_UPLOAD_PATH . $style_dir; if (is_dir($dirpath)) { if ($style_dir != '.' && $style_dir != '..') { if (isset($_POST['style']) && (isset($_POST['preview']) || isset($_POST['download'])) && $_POST['style'] == $style_dir) { $safe_style_dir = $style_dir; } else { if ($currentstyle == $style_dir || $style_dir == 'chamilo' && !$currentstyle) { if (isset($_POST['style'])) { $selected = Database::escape_string($_POST['style']); } else { $selected = $style_dir; } } } $show_name = ucwords(str_replace('_', ' ', $style_dir)); if ($is_style_changeable) { $list_of_names[$style_dir] = $show_name; } $counter++; } } } closedir($handle); } // Sort styles in alphabetical order. asort($list_of_names); $select_list = array(); foreach ($list_of_names as $style_dir => $item) { $select_list[$style_dir] = $item; } $styles =& $form_change->addElement('select', 'style', get_lang('NameStylesheet'), $select_list); $styles->setSelected($selected); if ($form_change->validate()) { // Submit stylesheets. if (isset($_POST['save'])) { store_stylesheets(); Display::display_normal_message(get_lang('Saved')); } if (isset($_POST['download'])) { $arch = api_get_path(SYS_ARCHIVE_PATH) . $safe_style_dir . '.zip'; $dir = api_get_path(SYS_CSS_PATH) . 'themes/' . $safe_style_dir; if (is_dir($dir)) { $zip = new PclZip($arch); // Remove path prefix except the style name and put file on disk $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir, 0, -strlen($safe_style_dir))); //@TODO: use more generic script to download. $str = '<a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '">' . get_lang('ClickHereToDownloadTheFile') . '</a>'; Display::display_normal_message($str, false); } else { Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning')); } } } if ($is_style_changeable) { $group = [$form_change->addButtonSave(get_lang('SaveSettings'), 'save', true), $form_change->addButtonPreview(get_lang('Preview'), 'preview', true), $form_change->addButtonDownload(get_lang('Download'), 'download', true)]; $form_change->addGroup($group); if ($show_upload_form) { echo '<script> $(function() { $( "#tabs" ).tabs(); }); </script>'; echo Display::tabs(array(get_lang('Update'), get_lang('UploadNewStylesheet')), array($form_change->return_form(), $form->return_form())); } else { $form_change->display(); } } else { $form_change->freeze(); } }
Display::display_header($nameTools, 'Doc'); Display::display_error_message(get_lang('Impossible')); Display::display_footer(); } } else { // Interbreadcrumb for the current directory root path // Copied from document.php $dir_array = explode('/', $dir); $array_len = count($dir_array); // Interbreadcrumb for the current directory root path if (empty($document_data['parents'])) { $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']); } else { foreach ($document_data['parents'] as $document_sub_data) { $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']); } } $interbreadcrumb[] = array('url' => '#', 'name' => $nameTools); Display::display_header($nameTools, "Doc"); if ($is_certificate_mode) { $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id()); $str_info = ''; foreach ($all_information_by_create_certificate[0] as $info_value) { $str_info .= $info_value . '<br/>'; } $create_certificate = get_lang('CreateCertificateWithTags'); Display::display_normal_message($create_certificate . ': <br /><br/>' . $str_info, false); } echo $form->return_form(); Display::display_footer(); }
/** * Adds a form to let users login * @return string An HTML string with the user login form * @assert () != '' * @version 1.1 */ public function displayLoginForm() { $form = new FormValidator('formLogin', 'POST', null, null, array('class' => 'form-vertical')); // 'placeholder'=>get_lang('UserName') //'autocomplete'=>"off", $form->addElement('text', 'login', get_lang('UserName'), array('class' => 'span2 autocapitalize_off', 'autofocus' => 'autofocus')); $form->addElement('password', 'password', get_lang('Pass'), array('class' => 'span2')); $form->addElement('style_submit_button', 'submitAuth', get_lang('LoginEnter'), array('class' => 'btn')); $html = $form->return_form(); if (api_get_setting('openid_authentication') == 'true') { include_once 'main/auth/openid/login.php'; $html .= '<div>' . openid_form() . '</div>'; } return $html; }