/** * Creates the mPDF object * @param string $pageFormat format A4 A4-L see http://mpdf1.com/manual/index.php?tid=184&searchstring=format * @param string $orientation orientation "P" = Portrait "L" = Landscape * @param array $params * @param Template $template */ public function __construct($pageFormat = 'A4', $orientation = 'P', $params = array(), $template = null) { $this->template = $template; /* More info @ http://mpdf1.com/manual/index.php?tid=184&searchstring=mPDF * mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]]) */ if (!in_array($orientation, array('P', 'L'))) { $orientation = 'P'; } //$this->pdf = $pdf = new mPDF('UTF-8', $pageFormat, '', '', 30, 20, 27, 25, 16, 13, $orientation); //left, right, top, bottom, margin_header, margin footer $params['left'] = isset($params['left']) ? $params['left'] : 15; $params['right'] = isset($params['right']) ? $params['right'] : 15; $params['top'] = isset($params['top']) ? $params['top'] : 20; $params['bottom'] = isset($params['bottom']) ? $params['bottom'] : 15; $this->params['filename'] = isset($params['filename']) ? $params['filename'] : api_get_local_time(); $this->params['pdf_title'] = isset($params['pdf_title']) ? $params['pdf_title'] : get_lang('Untitled'); $this->params['course_info'] = isset($params['course_info']) ? $params['course_info'] : api_get_course_info(); $this->params['session_info'] = isset($params['session_info']) ? $params['session_info'] : api_get_session_info(api_get_session_id()); $this->params['course_code'] = isset($params['course_code']) ? $params['course_code'] : api_get_course_id(); $this->params['add_signatures'] = isset($params['add_signatures']) ? $params['add_signatures'] : false; $this->params['show_real_course_teachers'] = isset($params['show_real_course_teachers']) ? $params['show_real_course_teachers'] : false; $this->params['student_info'] = isset($params['student_info']) ? $params['student_info'] : false; $this->params['show_grade_generated_date'] = isset($params['show_grade_generated_date']) ? $params['show_grade_generated_date'] : false; $this->params['show_teacher_as_myself'] = isset($params['show_teacher_as_myself']) ? $params['show_teacher_as_myself'] : true; $this->params['pdf_date'] = isset($params['pdf_date']) ? $params['pdf_date'] : api_format_date(api_get_local_time(), DATE_TIME_FORMAT_LONG); $this->pdf = new mPDF('UTF-8', $pageFormat, '', '', $params['left'], $params['right'], $params['top'], $params['bottom'], 8, 8, $orientation); }
/** * Get course data to display */ function get_request_data($from, $number_of_items, $column, $direction) { global $keyword; $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST); $sql = "SELECT id AS col0,\n code AS col1,\n title AS col2,\n category_code AS col3,\n tutor_name AS col4,\n request_date AS col5,\n id AS col6\n FROM {$course_request_table}\n WHERE status = " . COURSE_REQUEST_ACCEPTED; if ($keyword != '') { $sql .= " AND (title LIKE '%" . $keyword . "%' OR code LIKE '%" . $keyword . "%' OR visual_code LIKE '%" . $keyword . "%')"; } $sql .= " ORDER BY col{$column} {$direction} "; $sql .= " LIMIT {$from},{$number_of_items}"; $res = Database::query($sql); $course_requests = array(); while ($course_request = Database::fetch_row($res)) { $course_request[5] = api_get_local_time($course_request[5]); $course_requests[] = $course_request; } return $course_requests; }
/** * Creates the mPDF object * @param string format A4 A4-L see http://mpdf1.com/manual/index.php?tid=184&searchstring=format * @param string orientation "P" = Portrait "L" = Landscape */ public function __construct($page_format = 'A4', $orientation = 'P', $params = array()) { /* More info @ http://mpdf1.com/manual/index.php?tid=184&searchstring=mPDF * mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]]) */ if (!in_array($orientation, array('P', 'L'))) { $orientation = 'P'; } //$this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 30, 20, 27, 25, 16, 13, $orientation); //left, right, top, bottom, margin_header, margin footer $params['left'] = isset($params['left']) ? $params['left'] : 15; $params['right'] = isset($params['right']) ? $params['right'] : 15; $params['top'] = isset($params['top']) ? $params['top'] : 20; $params['bottom'] = isset($params['bottom']) ? $params['bottom'] : 15; $this->params['filename'] = isset($params['filename']) ? $params['filename'] : api_get_local_time(); $this->params['pdf_title'] = isset($params['pdf_title']) ? $params['pdf_title'] : get_lang('Untitled'); $this->params['course_code'] = isset($params['course_code']) ? $params['course_code'] : api_get_course_id(); $this->params['add_signatures'] = isset($params['add_signatures']) ? $params['add_signatures'] : false; $this->pdf = new mPDF('UTF-8', $page_format, '', '', $params['left'], $params['right'], $params['top'], $params['bottom'], 8, 8, $orientation); }
/** * Get course data to display */ function get_request_data($from, $number_of_items, $column, $direction) { $keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : null; $course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST); $from = intval($from); $number_of_items = intval($number_of_items); $column = intval($column); $direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction; $sql = "SELECT\n id AS col0,\n code AS col1,\n title AS col2,\n category_code AS col3,\n tutor_name AS col4,\n request_date AS col5,\n id AS col6\n FROM {$course_request_table}\n WHERE status = " . COURSE_REQUEST_ACCEPTED; if ($keyword != '') { $sql .= " AND (\n title LIKE '%" . $keyword . "%' OR\n code LIKE '%" . $keyword . "%' OR\n visual_code LIKE '%" . $keyword . "%'\n )"; } $sql .= " ORDER BY col{$column} {$direction} "; $sql .= " LIMIT {$from},{$number_of_items}"; $res = Database::query($sql); $course_requests = array(); while ($course_request = Database::fetch_row($res)) { $course_request[5] = api_get_local_time($course_request[5]); $course_requests[] = $course_request; } return $course_requests; }
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300')); $element = $form->addElement('text', 'insert_date', get_lang('CreationDate'), array('size' => '100')); $element->freeze(); $element = $form->addElement('text', 'update_date', get_lang('UpdateDate'), array('size' => '100')); $element->freeze(); $form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"'); // setting the defaults $glossary_data = GlossaryManager::get_glossary_information($_GET['glossary_id']); // Date treatment for timezones if (!empty($glossary_data['insert_date']) && $glossary_data['insert_date'] != '0000-00-00 00:00:00:') { $glossary_data['insert_date'] = api_get_local_time($glossary_data['insert_date']); } else { $glossary_data['insert_date'] = ''; } if (!empty($glossary_data['update_date']) && $glossary_data['update_date'] != '0000-00-00 00:00:00:') { $glossary_data['update_date'] = api_get_local_time($glossary_data['update_date']); } else { $glossary_data['update_date'] = ''; } $form->setDefaults($glossary_data); // setting the rules $form->addRule('glossary_title', get_lang('ThisFieldIsRequired'), 'required'); // The validation or display if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $values = $form->exportValues(); GlossaryManager::update_glossary($values); } Security::clear_token(); GlossaryManager::display_glossary();
/** * Returns a human readable string * @params array An array with all the session dates * @return string */ static function parse_session_dates($session_info) { //This will clean the variables if 0000-00-00 00:00:00 the variable will be empty $start_date = null; $end_date = null; if (isset($session_info['display_start_date'])) { $start_date = api_get_local_time($session_info['display_start_date'], null, null, true); } if (isset($session_info['display_end_date'])) { $end_date = api_get_local_time($session_info['display_end_date'], null, null, true); } $msg_date = null; if (!empty($start_date) && !empty($end_date)) { //$msg_date = get_lang('From').' '.$start_date.' '.get_lang('To').' '.$end_date; $msg_date = sprintf(get_lang('FromDateXToDateY'), $start_date, $end_date); } else { if (!empty($start_date)) { $msg_date = get_lang('From') . ' ' . $start_date; } if (!empty($end_date)) { $msg_date = get_lang('Until') . ' ' . $end_date; } } return $msg_date; }
/** * * @param int student id * @param int years * @param bool show warning_message * @param bool return_timestamp */ public static function delete_inactive_student($student_id, $years = 2, $warning_message = false, $return_timestamp = false) { $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $sql = 'SELECT login_date FROM ' . $tbl_track_login . ' WHERE login_user_id = ' . intval($student_id) . ' ORDER BY login_date DESC LIMIT 0,1'; if (empty($years)) { $years = 1; } $inactive_time = $years * 31536000; //1 year $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { if ($last_login_date = Database::result($rs, 0, 0)) { $last_login_date = api_get_local_time($last_login_date, null, date_default_timezone_get()); if ($return_timestamp) { return api_strtotime($last_login_date); } else { if (!$warning_message) { return api_format_date($last_login_date, DATE_FORMAT_SHORT); } else { $timestamp = api_strtotime($last_login_date); $currentTimestamp = time(); //If the last connection is > than 7 days, the text is red //345600 = 7 days in seconds 63072000= 2 ans // if ($currentTimestamp - $timestamp > 184590 ) if ($currentTimestamp - $timestamp > $inactive_time && UserManager::delete_user($student_id)) { Display::display_normal_message(get_lang('UserDeleted')); echo '<p>', 'id', $student_id, ':', $last_login_date, '</p>'; } } } } } return false; }
/** * display message box in the inbox * @param int the message id * @param string inbox or outbox strings are available * @todo replace numbers with letters in the $row array pff... * @return string html with the message content */ public static function show_message_box($message_id, $source = 'inbox') { $table_message = Database::get_main_table(TABLE_MESSAGE); $message_id = intval($message_id); if ($source == 'outbox') { if (isset($message_id) && is_numeric($message_id)) { $query = "SELECT * FROM {$table_message}\n WHERE\n user_sender_id = " . api_get_user_id() . " AND\n id = " . $message_id . " AND\n msg_status = 4;"; $result = Database::query($query); } } else { if (is_numeric($message_id) && !empty($message_id)) { $query = "UPDATE {$table_message} SET\n msg_status = '" . MESSAGE_STATUS_NEW . "'\n WHERE\n user_receiver_id=" . api_get_user_id() . " AND\n id='" . $message_id . "'"; Database::query($query); $query = "SELECT * FROM {$table_message}\n WHERE\n msg_status<>4 AND\n user_receiver_id=" . api_get_user_id() . " AND\n id='" . $message_id . "'"; $result = Database::query($query); } } $row = Database::fetch_array($result, 'ASSOC'); $user_sender_id = $row['user_sender_id']; // get file attachments by message id $files_attachments = self::get_links_message_attachment_files($message_id, $source); $user_con = self::users_connected_by_id(); $band = 0; for ($i = 0; $i < count($user_con); $i++) { if ($user_sender_id == $user_con[$i]) { $band = 1; } } $title = Security::remove_XSS($row['title'], STUDENT, true); $content = Security::remove_XSS($row['content'], STUDENT, true); $from_user = api_get_user_info($user_sender_id); $name = $from_user['complete_name']; $user_image = Display::img($from_user['avatar'], $name, array('title' => $name)); $message_content = Display::page_subheader(str_replace("\\", "", $title)); if (api_get_setting('social.allow_social_tool') == 'true') { $message_content .= $user_image . ' '; } $receiverUserInfo = api_get_user_info($row['user_receiver_id']); $message_content .= '<tr>'; if (api_get_setting('social.allow_social_tool') == 'true') { if ($source == 'outbox') { $message_content .= get_lang('From') . ': <a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $user_sender_id . '">' . $name . '</a> ' . api_strtolower(get_lang('To')) . ' <b>' . $receiverUserInfo['complete_name'] . '</b>'; } else { $message_content .= get_lang('From') . ' <a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $user_sender_id . '">' . $name . '</a> ' . api_strtolower(get_lang('To')) . ' <b>' . get_lang('Me') . '</b>'; } } else { if ($source == 'outbox') { $message_content .= get_lang('From') . ': ' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . $receiverUserInfo['complete_name'] . '</b>'; } else { $message_content .= get_lang('From') . ': ' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . get_lang('Me') . '</b>'; } } $message_content .= ' ' . get_lang('Date') . ': ' . api_get_local_time($row['send_date']) . ' <br /> <hr style="color:#ddd" /> <table height="209px" width="100%"> <tr> <td valign=top class="view-message-content">' . str_replace("\\", "", $content) . '</td> </tr> </table> <div id="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div> <div style="padding: 15px 0px 5px 0px">'; $social_link = ''; if (isset($_GET['f']) && $_GET['f'] == 'social') { $social_link = 'f=social'; } if ($source == 'outbox') { $message_content .= '<a href="outbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToOutbox')) . '</a>  '; } else { $message_content .= '<a href="inbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToInbox')) . '</a>  '; $message_content .= '<a href="new_message.php?re_id=' . $message_id . '&' . $social_link . '">' . Display::return_icon('message_reply.png', get_lang('ReplyToMessage')) . '</a>  '; } $message_content .= '<a href="inbox.php?action=deleteone&id=' . $message_id . '&' . $social_link . '" >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a> '; $message_content .= '</div></td> <td width=10></td> </tr> </table>'; return $message_content; }
/** * Creates the form to create / edit an exercise * @param FormValidator $form */ public function createForm($form, $type = 'full') { if (empty($type)) { $type = 'full'; } // form title if (!empty($_GET['exerciseId'])) { $form_title = get_lang('ModifyExercise'); } else { $form_title = get_lang('NewEx'); } $form->addElement('header', $form_title); // Title. $form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), array('id' => 'exercise_title')); $form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters')); $form->addElement('html', '<div id="advanced_params_options" style="display:none">'); $editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150'); if (is_array($type)) { $editor_config = array_merge($editor_config, $type); } $form->addHtmlEditor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config); if ($type == 'full') { //Can't modify a DirectFeedback question if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) { // feedback type $radios_feedback = array(); $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()')); if (api_get_setting('exercise.enable_quiz_scenario') == 'true') { //Can't convert a question from one feedback to another if there is more than 1 question already added if ($this->selectNbrQuestions() == 0) { $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()')); } } $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2')); $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), ''); // Type of results display on the final page $radios_results_disabled = array(); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0')); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()')); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2')); //$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'), '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()')); $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); // Type of questions disposition on page $radios = array(); $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all')); $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one')); $form->addGroup($radios, null, get_lang('QuestionsPerPage'), ''); } else { // if is Directfeedback but has not questions we can allow to modify the question type if ($this->selectNbrQuestions() == 0) { // feedback type $radios_feedback = array(); $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()')); if (api_get_setting('exercise.enable_quiz_scenario') == 'true') { $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()')); } $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2')); $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions'))); //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"'); $radios_results_disabled = array(); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0')); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()')); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()')); $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); // Type of questions disposition on page $radios = array(); $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2'); $form->addGroup($radios, null, get_lang('ExerciseType')); } else { //Show options freeze $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0')); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()')); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()')); $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); $result_disable_group->freeze(); //we force the options to the DirectFeedback exercisetype $form->addElement('hidden', 'exerciseFeedbackType', EXERCISE_FEEDBACK_TYPE_DIRECT); $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE); // Type of questions disposition on page $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all')); $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one')); $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), ''); $type_group->freeze(); } } // number of random question $max = $this->id > 0 ? $this->selectNbrQuestions() : 10; $option = range(0, $max); $option[0] = get_lang('No'); $option[-1] = get_lang('AllQuestionsShort'); $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id' => 'randomQuestions')); // Random answers $radios_random_answers = array(); $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1'); $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0'); $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), ''); // Random by category $form->addElement('html', '<div class="clear"> </div>'); $radiocat = array(); $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1'); $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2'); $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0'); $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), ''); $form->addElement('html', '<div class="clear"> </div>'); // add the radio display the category name for student $radio_display_cat_name = array(); $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('Yes'), '1'); $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('No'), '0'); $form->addGroup($radio_display_cat_name, null, get_lang('QuestionDisplayCategoryName'), ''); // Attempts $attempt_option = range(0, 10); $attempt_option[0] = get_lang('Infinite'); $form->addElement('select', 'exerciseAttempts', get_lang('ExerciseAttempts'), $attempt_option, ['id' => 'exerciseAttempts']); // Exercise time limit $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); $var = Exercise::selectTimeLimit(); if ($this->start_time != '0000-00-00 00:00:00') { $form->addElement('html', '<div id="start_date_div" style="display:block;">'); } else { $form->addElement('html', '<div id="start_date_div" style="display:none;">'); } $form->addElement('date_time_picker', 'start_time'); $form->addElement('html', '</div>'); $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); if ($this->end_time != '0000-00-00 00:00:00') { $form->addElement('html', '<div id="end_date_div" style="display:block;">'); } else { $form->addElement('html', '<div id="end_date_div" style="display:none;">'); } $form->addElement('date_time_picker', 'end_time'); $form->addElement('html', '</div>'); //$check_option=$this->selectType(); $diplay = 'block'; $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults')); $form->addElement('html', '<div class="clear"> </div>'); $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); $form->addElement('html', '<div id="divtimecontrol" style="display:' . $diplay . ';">'); //Timer control //$time_hours_option = range(0,12); //$time_minutes_option = range(0,59); $form->addElement('checkbox', 'enabletimercontrol', null, get_lang('EnableTimerControl'), array('onclick' => 'option_time_expired()', 'id' => 'enabletimercontrol', 'onload' => 'check_load_time()')); $expired_date = (int) $this->selectExpiredTime(); if ($expired_date != '0') { $form->addElement('html', '<div id="timercontrol" style="display:block;">'); } else { $form->addElement('html', '<div id="timercontrol" style="display:none;">'); } $form->addText('enabletimercontroltotalminutes', get_lang('ExerciseTotalDurationInMinutes'), false, ['id' => 'enabletimercontroltotalminutes', 'cols-size' => [2, 2, 8]]); $form->addElement('html', '</div>'); $form->addElement('text', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), array('id' => 'pass_percentage')); $form->addRule('pass_percentage', get_lang('Numeric'), 'numeric'); // add the text_when_finished textbox $form->addHtmlEditor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config); $defaults = array(); if (api_get_setting('search.search_enabled') === 'true') { require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument')); $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); $specific_fields = get_specific_field_list(); foreach ($specific_fields as $specific_field) { $form->addElement('text', $specific_field['code'], $specific_field['name']); $filter = array('c_id' => "'" . api_get_course_int_id() . "'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\'' . TOOL_QUIZ . '\''); $values = get_specific_field_values_list($filter, array('value')); if (!empty($values)) { $arr_str_values = array(); foreach ($values as $value) { $arr_str_values[] = $value['value']; } $defaults[$specific_field['code']] = implode(', ', $arr_str_values); } } //$form->addElement ('html','</div>'); } $form->addElement('html', '</div>'); //End advanced setting $form->addElement('html', '</div>'); } // submit if (isset($_GET['exerciseId'])) { $form->addButtonSave(get_lang('ModifyExercise'), 'submitExercise'); } else { $form->addButtonUpdate(get_lang('ProcedToQuestions'), 'submitExercise'); } $form->addRule('exerciseTitle', get_lang('GiveExerciseName'), 'required'); if ($type == 'full') { // rules $form->addRule('exerciseAttempts', get_lang('Numeric'), 'numeric'); $form->addRule('start_time', get_lang('InvalidDate'), 'datetime'); $form->addRule('end_time', get_lang('InvalidDate'), 'datetime'); } // defaults if ($type == 'full') { if ($this->id > 0) { if ($this->random > $this->selectNbrQuestions()) { $defaults['randomQuestions'] = $this->selectNbrQuestions(); } else { $defaults['randomQuestions'] = $this->random; } $defaults['randomAnswers'] = $this->selectRandomAnswers(); $defaults['exerciseType'] = $this->selectType(); $defaults['exerciseTitle'] = $this->get_formated_title(); $defaults['exerciseDescription'] = $this->selectDescription(); $defaults['exerciseAttempts'] = $this->selectAttempts(); $defaults['exerciseFeedbackType'] = $this->selectFeedbackType(); $defaults['results_disabled'] = $this->selectResultsDisabled(); $defaults['propagate_neg'] = $this->selectPropagateNeg(); $defaults['review_answers'] = $this->review_answers; $defaults['randomByCat'] = $this->selectRandomByCat(); $defaults['text_when_finished'] = $this->selectTextWhenFinished(); $defaults['display_category_name'] = $this->selectDisplayCategoryName(); $defaults['pass_percentage'] = $this->selectPassPercentage(); if ($this->start_time != '0000-00-00 00:00:00') { $defaults['activate_start_date_check'] = 1; } if ($this->end_time != '0000-00-00 00:00:00') { $defaults['activate_end_date_check'] = 1; } $defaults['start_time'] = $this->start_time != '0000-00-00 00:00:00' ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); $defaults['end_time'] = $this->end_time != '0000-00-00 00:00:00' ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600); // Get expired time if ($this->expired_time != '0') { $defaults['enabletimercontrol'] = 1; $defaults['enabletimercontroltotalminutes'] = $this->expired_time; } else { $defaults['enabletimercontroltotalminutes'] = 0; } } else { $defaults['exerciseType'] = 2; $defaults['exerciseAttempts'] = 0; $defaults['randomQuestions'] = 0; $defaults['randomAnswers'] = 0; $defaults['exerciseDescription'] = ''; $defaults['exerciseFeedbackType'] = 0; $defaults['results_disabled'] = 0; $defaults['randomByCat'] = 0; $defaults['text_when_finished'] = ""; $defaults['start_time'] = date('Y-m-d 12:00:00'); $defaults['display_category_name'] = 1; $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600); $defaults['pass_percentage'] = ''; } } else { $defaults['exerciseTitle'] = $this->selectTitle(); $defaults['exerciseDescription'] = $this->selectDescription(); } if (api_get_setting('search.search_enabled') === 'true') { $defaults['index_document'] = 'checked="checked"'; } $form->setDefaults($defaults); // Freeze some elements. if ($this->id != 0 && $this->edit_exercise_in_lp == false) { $elementsToFreeze = array('randomQuestions', 'exerciseAttempts', 'propagate_neg', 'enabletimercontrol', 'review_answers'); foreach ($elementsToFreeze as $elementName) { /** @var HTML_QuickForm_element $element */ $element = $form->getElement($elementName); $element->freeze(); } $radioCatGroup->freeze(); } }
switch ($_GET['class']) { case 'public': $vevent->setClass('PUBLIC'); break; case 'private': $vevent->setClass('PRIVATE'); break; case 'confidential': $vevent->setClass('CONFIDENTIAL'); break; default: $vevent->setClass('PRIVATE'); break; } $event['start_date'] = api_get_local_time($event['start_date']); $event['end_date'] = api_get_local_time($event['end_date']); switch ($type) { case 'personal': case 'platform': $vevent->setProperty('summary', api_convert_encoding($event['title'], 'UTF-8', $charset)); if (empty($event['start_date'])) { header('location:' . Security::remove_XSS($_SERVER['HTTP_REFERER'])); } list($y, $m, $d, $h, $M, $s) = preg_split('/[\\s:-]/', $event['start_date']); $vevent->setProperty('dtstart', array('year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s)); if (empty($event['end_date'])) { $y2 = $y; $m2 = $m; $d2 = $d; $h2 = $h; $M2 = $M + 15;
$row++; $column = 0; $url = api_get_path(WEB_CODE_PATH) . 'work/'; foreach ($workPerUser as $work) { $work = $work['work']; $scoreWeight = intval($work->qualification) == 0 ? null : $work->qualification; $workId = $work->id; $workExtraData = get_work_assignment_by_id($workId); foreach ($work->user_results as $userResult) { $itemId = $userResult['id']; $table->setCellContents($row, $column, $work->title . ' [' . trim(strip_tags($userResult['title'])) . ']'); $table->setCellAttributes($row, $column, array('width' => '300px')); $column++; $table->setCellContents($row, $column, $userResult['sent_date']); $column++; $dateQualification = !empty($workExtraData['expires_on']) ? api_get_local_time($workExtraData['expires_on']) : '-'; $table->setCellContents($row, $column, $dateQualification); $column++; $score = null; $score = $userResult['qualification']; $table->setCellContents($row, $column, $score); $column++; // Actions $links = null; // is a text $url = api_get_path(WEB_CODE_PATH) . 'work/view.php?' . api_get_cidreq() . '&id=' . $itemId; $links .= Display::url(Display::return_icon('default.png', get_lang('View')), $url); if (!empty($userResult['url'])) { $url = api_get_path(WEB_CODE_PATH) . 'work/download.php?' . api_get_cidreq() . '&id=' . $itemId; $links .= Display::url(Display::return_icon('save.png', get_lang('Download')), $url); }
/** * This function retrieves all the personal agenda items and add them to the agenda items found by the other functions. */ public static function get_personal_agenda_items($user_id, $agendaitems, $day = "", $month = "", $year = "", $week = "", $type) { $tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA); $user_id = intval($user_id); // 1. creating the SQL statement for getting the personal agenda items in MONTH view if ($type == "month_view" or $type == "") { // we are in month view $sql = "SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' and MONTH(date)='" . $month . "' AND YEAR(date) = '" . $year . "' ORDER BY date ASC"; } // 2. creating the SQL statement for getting the personal agenda items in WEEK view // we are in week view if ($type == "week_view") { $start_end_day_of_week = self::calculate_start_end_of_week($week, $year); $start_day = $start_end_day_of_week['start']['day']; $start_month = $start_end_day_of_week['start']['month']; $start_year = $start_end_day_of_week['start']['year']; $end_day = $start_end_day_of_week['end']['day']; $end_month = $start_end_day_of_week['end']['month']; $end_year = $start_end_day_of_week['end']['year']; // in sql statements you have to use year-month-day for date calculations $start_filter = $start_year . "-" . $start_month . "-" . $start_day . " 00:00:00"; $start_filter = api_get_utc_datetime($start_filter); $end_filter = $end_year . "-" . $end_month . "-" . $end_day . " 23:59:59"; $end_filter = api_get_utc_datetime($end_filter); $sql = " SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' AND date>='" . $start_filter . "' AND date<='" . $end_filter . "'"; } // 3. creating the SQL statement for getting the personal agenda items in DAY view if ($type == "day_view") { // we are in day view // we could use mysql date() function but this is only available from 4.1 and higher $start_filter = $year . "-" . $month . "-" . $day . " 00:00:00"; $start_filter = api_get_utc_datetime($start_filter); $end_filter = $year . "-" . $month . "-" . $day . " 23:59:59"; $end_filter = api_get_utc_datetime($end_filter); $sql = " SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' AND date>='" . $start_filter . "' AND date<='" . $end_filter . "'"; } $result = Database::query($sql); while ($item = Database::fetch_array($result, 'ASSOC')) { $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT); $item['date'] = api_get_local_time($item['date']); $item['start_date_tms'] = api_strtotime($item['date']); $item['content'] = $item['text']; // we break the date field in the database into a date and a time part $agenda_db_date = explode(" ", $item['date']); $date = $agenda_db_date[0]; $time = $agenda_db_date[1]; // we divide the date part into a day, a month and a year $agendadate = explode("-", $item['date']); $year = intval($agendadate[0]); $month = intval($agendadate[1]); $day = intval($agendadate[2]); // we divide the time part into hour, minutes, seconds $agendatime = explode(":", $time); $hour = $agendatime[0]; $minute = $agendatime[1]; $second = $agendatime[2]; if ($type == 'month_view') { $item['calendar_type'] = 'personal'; $item['start_date'] = $item['date']; $agendaitems[$day][] = $item; continue; } // if the student has specified a course we a add a link to that course if ($item['course'] != "") { $url = api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?cidReq=" . urlencode($item['course']) . "&day={$day}&month={$month}&year={$year}#{$day}"; // RH //Patrick Cool: to highlight the relevant agenda item $course_link = "<a href=\"{$url}\" title=\"" . $item['course'] . "\">" . $item['course'] . "</a>"; } else { $course_link = ""; } // Creating the array that will be returned. If we have week or month view we have an array with the date as the key // if we have a day_view we use a half hour as index => key 33 = 16h30 if ($type !== "day_view") { // This is the array construction for the WEEK or MONTH view //Display events in agenda $agendaitems[$day] .= "<div><i>{$time_minute}</i> {$course_link} <a href=\"myagenda.php?action=view&view=personal&day={$day}&month={$month}&year={$year}&id=" . $item['id'] . "#" . $item['id'] . "\" class=\"personal_agenda\">" . $item['title'] . "</a></div><br />"; } else { // this is the array construction for the DAY view $halfhour = 2 * $agendatime['0']; if ($agendatime['1'] >= '30') { $halfhour = $halfhour + 1; } //Display events by list $agendaitems[$halfhour] .= "<div><i>{$time_minute}</i> {$course_link} <a href=\"myagenda.php?action=view&view=personal&day={$day}&month={$month}&year={$year}&id=" . $item['id'] . "#" . $item['id'] . "\" class=\"personal_agenda\">" . $item['title'] . "</a></div>"; } } return $agendaitems; }
/** * @param FormValidator $form * @param array $extraData * @param string $form_name * @param bool $admin_permissions * @param int $user_id * @param array $extra * @param int $itemId * * @return array */ public function set_extra_fields_in_form($form, $extraData, $form_name, $admin_permissions = false, $user_id = null, $extra = array(), $itemId = null) { $user_id = intval($user_id); $type = $this->type; // User extra fields if ($type == 'user') { $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC', true, null, true); } $jquery_ready_content = null; if (!empty($extra)) { foreach ($extra as $field_details) { // Getting default value id if is set $defaultValueId = null; if (isset($field_details['options']) && !empty($field_details['options'])) { $valueToFind = null; if (isset($field_details['field_default_value'])) { $valueToFind = $field_details['field_default_value']; } // If a value is found we override the default value if (isset($extraData['extra_' . $field_details['field_variable']])) { $valueToFind = $extraData['extra_' . $field_details['field_variable']]; } foreach ($field_details['options'] as $option) { if ($option['option_value'] == $valueToFind) { $defaultValueId = $option['id']; } } } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { continue; } } switch ($field_details['field_type']) { case ExtraField::FIELD_TYPE_TEXT: $form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('class' => 'span4')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_TEXTAREA: $form->add_html_editor('extra_' . $field_details['field_variable'], $field_details['field_display_text'], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_RADIO: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; $group[] = $form->createElement('radio', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']); } } $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ''); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_CHECKBOX: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']); } } else { // We assume that is a switch on/off with 1 and 0 as values $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], null, 'Yes <br />', null); } $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ''); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_SELECT: $get_lang_variables = false; if (in_array($field_details['field_variable'], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) { $get_lang_variables = true; } // Get extra field workflow $userInfo = api_get_user_info(); $addOptions = array(); $optionsExists = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_details['id'])); if ($optionsExists) { if (isset($userInfo['status']) && !empty($userInfo['status'])) { $fieldWorkFlow = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption')->findBy(array('fieldId' => $field_details['id'], 'relatedFieldOptionId' => $defaultValueId, 'roleId' => $userInfo['status'])); foreach ($fieldWorkFlow as $item) { $addOptions[] = $item->getFieldOptionId(); } } } $options = array(); if (empty($defaultValueId)) { $options[''] = get_lang('SelectAnOption'); } $optionList = array(); if (!empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $optionList[$option_details['id']] = $option_details; if ($get_lang_variables) { $options[$option_details['option_value']] = get_lang($option_details['option_display_text']); } else { if ($optionsExists) { // Adding always the default value if ($option_details['id'] == $defaultValueId) { $options[$option_details['option_value']] = $option_details['option_display_text']; } else { if (isset($addOptions) && !empty($addOptions)) { // Parsing filters if (in_array($option_details['id'], $addOptions)) { $options[$option_details['option_value']] = $option_details['option_display_text']; } } } } else { // Normal behaviour $options[$option_details['option_value']] = $option_details['option_display_text']; } } } if (isset($optionList[$defaultValueId])) { if (isset($optionList[$defaultValueId]['option_value']) && $optionList[$defaultValueId]['option_value'] == 'aprobada') { if (api_is_question_manager() == false) { $form->freeze(); } } } // Setting priority message if (isset($optionList[$defaultValueId]) && isset($optionList[$defaultValueId]['priority'])) { if (!empty($optionList[$defaultValueId]['priority'])) { $priorityId = $optionList[$defaultValueId]['priority']; $option = new ExtraFieldOption($this->type); $messageType = $option->getPriorityMessageType($priorityId); $form->addElement('label', null, Display::return_message($optionList[$defaultValueId]['priority_message'], $messageType)); } } } if ($get_lang_variables) { $field_details['field_display_text'] = get_lang($field_details['field_display_text']); } // chzn-select doesn't work for sessions?? $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('id' => 'extra_' . $field_details['field_variable'])); if ($optionsExists && $field_details['field_loggeable'] && !empty($defaultValueId)) { $form->addElement('textarea', 'extra_' . $field_details['field_variable'] . '_comment', $field_details['field_display_text'] . ' ' . get_lang('Comment')); $em = Database::getManager(); $extraFieldValue = new ExtraFieldValue($this->type); $repo = $em->getRepository($extraFieldValue->entityName); $repoLog = $em->getRepository('Gedmo\\Loggable\\Entity\\LogEntry'); $newEntity = $repo->findOneBy(array($this->handlerEntityId => $itemId, 'fieldId' => $field_details['id'])); // @todo move this in a function inside the class if ($newEntity) { $logs = $repoLog->getLogEntries($newEntity); if (!empty($logs)) { $html = '<b>' . get_lang('LatestChanges') . '</b><br /><br />'; $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Value')); $table->setHeaderContents(0, 1, get_lang('Comment')); $table->setHeaderContents(0, 2, get_lang('ModifyDate')); $table->setHeaderContents(0, 3, get_lang('Username')); $row = 1; foreach ($logs as $log) { $column = 0; $data = $log->getData(); $fieldValue = isset($data['fieldValue']) ? $data['fieldValue'] : null; $comment = isset($data['comment']) ? $data['comment'] : null; $table->setCellContents($row, $column, $fieldValue); $column++; $table->setCellContents($row, $column, $comment); $column++; $table->setCellContents($row, $column, api_get_local_time($log->getLoggedAt()->format('Y-m-d H:i:s'))); $column++; $table->setCellContents($row, $column, $log->getUsername()); $row++; } $form->addElement('label', null, $html . $table->toHtml()); } } } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: $options = array(); foreach ($field_details['options'] as $option_id => $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; } $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('multiple' => 'multiple')); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('form_name' => $form_name)); $form->_elements[$form->_elementIndex['extra_' . $field_details['field_variable']]]->setLocalOption('minYear', 1900); $defaults['extra_' . $field_details['field_variable']] = date('Y-m-d 12:00:00'); if (!isset($form->_defaultValues['extra_' . $field_details['field_variable']])) { $form->setDefaults($defaults); } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('form_name' => $form_name)); $form->_elements[$form->_elementIndex['extra_' . $field_details['field_variable']]]->setLocalOption('minYear', 1900); $defaults['extra_' . $field_details['field_variable']] = date('Y-m-d 12:00:00'); if (!isset($form->_defaultValues['extra_' . $field_details['field_variable']])) { $form->setDefaults($defaults); } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DOUBLE_SELECT: $first_select_id = 'first_extra_' . $field_details['field_variable']; $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php?1=1'; $jquery_ready_content .= ' $("#' . $first_select_id . '").on("change", function() { var id = $(this).val(); if (id) { $.ajax({ url: "' . $url . '&a=get_second_select_options", dataType: "json", data: "type=' . $type . '&field_id=' . $field_details['id'] . '&option_value_id="+id, success: function(data) { $("#second_extra_' . $field_details['field_variable'] . '").empty(); $.each(data, function(index, value) { $("#second_extra_' . $field_details['field_variable'] . '").append($("<option/>", { value: index, text: value })); }); }, }); } else { $("#second_extra_' . $field_details['field_variable'] . '").empty(); } });'; $first_id = null; $second_id = null; if (!empty($extraData)) { $first_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable']]; $second_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable'] . '_second']; } $options = ExtraField::extra_field_double_select_convert_array_to_ordered_array($field_details['options']); $values = array('' => get_lang('Select')); $second_values = array(); if (!empty($options)) { foreach ($options as $option) { foreach ($option as $sub_option) { if ($sub_option['option_value'] == '0') { $values[$sub_option['id']] = $sub_option['option_display_text']; } else { if ($first_id === $sub_option['option_value']) { $second_values[$sub_option['id']] = $sub_option['option_display_text']; } } } } } $group = array(); $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'], null, $values, array('id' => $first_select_id)); $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['field_variable'])); $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ' '); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_DIVIDER: $form->addElement('static', $field_details['field_variable'], '<br /><strong>' . $field_details['field_display_text'] . '</strong>'); break; case ExtraField::FIELD_TYPE_TAG: $field_variable = $field_details['field_variable']; $field_id = $field_details['id']; if ($this->type == 'user') { // The magic should be here $user_tags = UserManager::get_user_tags($user_id, $field_details['id']); $tag_list = ''; if (is_array($user_tags) && count($user_tags) > 0) { foreach ($user_tags as $tag) { $tag_list .= '<option value="' . $tag['tag'] . '" class="selected">' . $tag['tag'] . '</option>'; } } $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?'; } else { $extraFieldValue = new ExtraFieldValue($this->type); $tags = array(); if (!empty($itemId)) { $tags = $extraFieldValue->getAllValuesByItemAndField($itemId, $field_id); } $tag_list = ''; if (is_array($tags) && count($tags) > 0) { $extraFieldOption = new ExtraFieldOption($this->type); foreach ($tags as $tag) { $option = $extraFieldOption->get($tag['field_value']); $tag_list .= '<option value="' . $option['id'] . '" class="selected">' . $option['option_display_text'] . '</option>'; } } $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php'; } $form->addElement('hidden', 'extra_' . $field_details['field_variable'] . '__persist__', 1); $multiSelect = '<select id="extra_' . $field_details['field_variable'] . '" name="extra_' . $field_details['field_variable'] . '"> ' . $tag_list . ' </select>'; $form->addElement('label', $field_details['field_display_text'], $multiSelect); $complete_text = get_lang('StartToType'); //if cache is set to true the jquery will be called 1 time $jquery_ready_content .= <<<EOF \$("#extra_{$field_variable}").fcbkcomplete({ json_url: "{$url}?a=search_tags&field_id={$field_id}&type={$this->type}", cache: false, filter_case: true, filter_hide: true, complete_text:"{$complete_text}", firstselected: false, filter_selected: true, newel: true }); EOF; $jquery_ready_content = null; break; case ExtraField::FIELD_TYPE_TIMEZONE: $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], api_get_timezones(), ''); if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } break; case ExtraField::FIELD_TYPE_SOCIAL_PROFILE: // get the social network's favicon $icon_path = UserManager::get_favicon_from_url($extraData['extra_' . $field_details['field_variable']], $field_details['field_default_value']); // special hack for hi5 $leftpad = '1.7'; $top = '0.4'; $domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $leftpad = '3'; $top = '0'; } // print the input field $form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('size' => 60, 'style' => 'background-image: url(\'' . $icon_path . '\'); background-repeat: no-repeat; background-position: 0.4em ' . $top . 'em; padding-left: ' . $leftpad . 'em; ')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } break; } } } $return = array(); $return['jquery_ready_content'] = $jquery_ready_content; return $return; }
/** * Get las connection date for a student * @param int $student_id * @param bool $warning_message Show a warning message (optional) * @param bool $return_timestamp True for returning results in timestamp (optional) * @return string|int|bool Date format long without day, false if there are no connections or * timestamp if parameter $return_timestamp is true */ public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false) { $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $sql = 'SELECT login_date FROM ' . $table . ' WHERE login_user_id = ' . intval($student_id) . ' ORDER BY login_date DESC LIMIT 0,1'; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { if ($last_login_date = Database::result($rs, 0, 0)) { $last_login_date = api_get_local_time($last_login_date); if ($return_timestamp) { return api_strtotime($last_login_date, 'UTC'); } else { if (!$warning_message) { return api_format_date($last_login_date, DATE_FORMAT_SHORT); } else { $timestamp = api_strtotime($last_login_date, 'UTC'); $currentTimestamp = time(); //If the last connection is > than 7 days, the text is red //345600 = 7 days in seconds if ($currentTimestamp - $timestamp > 604800) { return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>'; } else { return api_format_date($last_login_date, DATE_FORMAT_SHORT); } } } } } return false; }
/** * Get activities data to display */ static function get_activities_data($from, $number_of_items, $column, $direction) { global $dateTimeFormatLong; $track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); $table_user = Database::get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $current_url_id = api_get_current_access_url_id(); $column = intval($column); $from = intval($from); $number_of_items = intval($number_of_items); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'DESC'; } if (api_is_multiple_url_enabled()) { $sql = "SELECT " . "default_event_type as col0, " . "default_value_type as col1, " . "default_value as col2, " . "user.username as col3, " . "user.user_id as col4, " . "default_date as col5 " . "FROM {$track_e_default} as track_default, {$table_user} as user, {$access_url_rel_user_table} as url " . "WHERE track_default.default_user_id = user.user_id AND url.user_id=user.user_id AND access_url_id='" . $current_url_id . "'"; } else { $sql = "SELECT " . "default_event_type as col0, " . "default_value_type as col1, " . "default_value as col2, " . "user.username as col3, " . "user.user_id as col4, " . "default_date as col5 " . "FROM {$track_e_default} track_default, {$table_user} user " . "WHERE track_default.default_user_id = user.user_id "; } if (isset($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " AND (user.username LIKE '%" . $keyword . "%' OR default_event_type LIKE '%" . $keyword . "%' OR default_value_type LIKE '%" . $keyword . "%' OR default_value LIKE '%" . $keyword . "%') "; } if (!empty($column) && !empty($direction)) { $sql .= " ORDER BY col{$column} {$direction}"; } else { $sql .= " ORDER BY col5 DESC "; } $sql .= " LIMIT {$from}, {$number_of_items} "; $res = Database::query($sql); $activities = array(); while ($row = Database::fetch_row($res)) { if (strpos($row[1], '_object') === false) { $row[2] = $row[2]; } else { if (!empty($row[2])) { $row[2] = unserialize($row[2]); if (is_array($row[2]) && !empty($row[2])) { $row[2] = Text::implode_with_key(', ', $row[2]); } } } if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') { $row['default_date'] = api_get_local_time($row['default_date']); } else { $row['default_date'] = '-'; } if (!empty($row[4])) { //user ID $row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH) . 'admin/user_information?user_id=' . $row[5], array('title' => get_lang('UserInfo'))); $row[4] = TrackingUserLog::get_ip_from_user_event($row[4], $row[5], true); if (empty($row[4])) { $row[4] = get_lang('Unknown'); } } $activities[] = $row; } return $activities; }
$userCondition = null; // All users if ($courseInfo['show_score'] == 0) { // Do another filter } else { // Only teachers $userCondition = " AND props.insert_user_id = " . api_get_user_id(); } //for other users, we need to create a zipfile with only visible files and folders $sql = "SELECT DISTINCT url, title, description, insert_user_id, insert_date, contains_file\n FROM {$tbl_student_publication} AS work INNER JOIN {$prop_table} AS props\n ON (props.c_id = {$course_id} AND\n work.c_id = {$course_id} AND\n work.id = props.ref)\n WHERE\n props.tool='work' AND\n work.accepted = 1 AND\n work.active = 1 AND\n work.parent_id = {$work_id} AND\n work.filetype = 'file' AND\n props.visibility = '1' AND\n work.post_group_id = {$groupId}\n {$userCondition}\n "; } $query = Database::query($sql); //add tem to the zip file while ($not_deleted_file = Database::fetch_assoc($query)) { $user_info = api_get_user_info($not_deleted_file['insert_user_id']); $insert_date = api_get_local_time($not_deleted_file['insert_date']); $insert_date = str_replace(array(':', '-', ' '), '_', $insert_date); $filename = $insert_date . '_' . $user_info['username'] . '_' . basename($not_deleted_file['title']); if (file_exists($sys_course_path . $_course['path'] . '/' . $not_deleted_file['url']) && !empty($not_deleted_file['url'])) { $files[basename($not_deleted_file['url'])] = $filename; $zip_folder->add($sys_course_path . $_course['path'] . '/' . $not_deleted_file['url'], PCLZIP_OPT_REMOVE_PATH, $sys_course_path . $_course['path'] . '/work', PCLZIP_CB_PRE_ADD, 'my_pre_add_callback'); } //Convert texts in html files if ($not_deleted_file['contains_file'] == 0) { $filename = trim($filename) . ".html"; $work_temp = api_get_path(SYS_ARCHIVE_PATH) . api_get_unique_id() . '_' . $filename; file_put_contents($work_temp, $not_deleted_file['description']); $files[basename($work_temp)] = $filename; $zip_folder->add($work_temp, PCLZIP_OPT_REMOVE_PATH, api_get_path(SYS_ARCHIVE_PATH), PCLZIP_CB_PRE_ADD, 'my_pre_add_callback'); @unlink($work_temp); }
/** * Gets all the course meetings saved in the plugin_openmeetings table * @return array Array of current open meeting rooms */ public function getCourseMeetings() { $newMeetingsList = array(); $item = array(); $meetingsList = \Database::select('*', $this->table, array('where' => array('c_id = ? ' => api_get_course_int_id(), ' AND session_id = ? ' => api_get_session_id(), ' AND status <> ? ' => 2))); /*$urlWsdl = $this->url."/services/RoomService?wsdl"; $omServices = new \SoapClient($urlWsdl);*/ $room = new Room(); /* try { $rooms = $this->gateway->getRoomsWithCurrentUsersByType(); //$rooms = $omServices->getRoomsPublic(array( //'SID' => $this->sessionId, //'start' => 0, //'max' => 10, //'orderby' => 'name', //'asc' => 'true', //'externalRoomType' => 'chamilo', //'roomtypes_id' => 'chamilo', //) //); } catch (SoapFault $e) { error_log(__FILE__.'+'.__LINE__.' '.$e->faultstring); //error_log($rooms->getDebug()); return false; } */ $room->SID = $this->sessionId; //error_log(__FILE__.'+'.__LINE__.' Meetings found: '.print_r($room->SID,1)); if (!empty($meetingsList)) { foreach ($meetingsList as $meetingDb) { //$room->rooms_id = $meetingDb['room_id']; error_log(__FILE__ . '+' . __LINE__ . ' Meetings found: ' . print_r($meetingDb, 1)); $remoteMeeting = array(); $meetingDb['created_at'] = api_get_local_time($meetingDb['created_at']); $meetingDb['closed_at'] = !empty($meetingDb['closed_at']) ? api_get_local_time($meetingDb['closed_at']) : ''; // Fixed value for now $meetingDb['participantCount'] = 40; $rec = $this->gateway->getFlvRecordingByRoomId($meetingDb['room_id']); $links = array(); // Links to videos look like these: // http://video2.openmeetings.com:5080/openmeetings/DownloadHandler?fileName=flvRecording_4.avi&moduleName=lzRecorderApp&parentPath=&room_id=&sid=dfc0cac396d384f59242aa66e5a9bbdd $link = $this->url . '/DownloadHandler?fileName=%s&moduleName=lzRecorderApp&parentPath=&room_id=%s&sid=%s'; if (!empty($rec)) { $link1 = sprintf($link, $rec['fileHash'], $meetingDb['room_id'], $this->sessionId); $link2 = sprintf($link, $rec['alternateDownload'], $meetingDb['room_id'], $this->sessionId); $links[] = $rec['fileName'] . ' ' . \Display::url('[.flv]', $link1, array('target' => '_blank')) . ' ' . \Display::url('[.avi]', $link2, array('target' => '_blank')); } $item['show_links'] = implode('<br />', $links); // The following code is currently commented because the web service // says this is not allowed by the SOAP user. /* try { // Get the conference room object from OpenMeetings server - requires SID and rooms_id to be defined $objRoomId = $this->gateway->getRoomById($meetingDb['room_id']); if (empty($objRoomId->return)) { error_log(__FILE__.'+'.__LINE__.' Emptyyyyy '); //\Database::delete($this->table, "id = {$meetingDb['id']}"); // Don't delete expired rooms, just mark as closed \Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $meetingDb['id'])); continue; } //$objCurUs = $omServices->getRoomWithCurrentUsersById($objCurrentUsers); } catch (SoapFault $e) { error_log(__FILE__.'+'.__LINE__.' '.$e->faultstring); exit; } //if( empty($objCurUs->returnMeetingID) ) continue; $current_room = array( 'roomtype' => $objRoomId->return->roomtype->roomtypes_id, 'meetingName' => $objRoomId->return->name, 'meetingId' => $objRoomId->return->meetingID, 'createTime' => $objRoomId->return->rooms_id, 'showMicrophoneStatus' => $objRoomId->return->showMicrophoneStatus, 'attendeePw' => $objRoomId->return->attendeePW, 'moderatorPw' => $objRoomId->return->moderators, 'isClosed' => $objRoomId->return->isClosed, 'allowRecording' => $objRoomId->return->allowRecording, 'startTime' => $objRoomId->return->startTime, 'endTime' => $objRoomId->return->updatetime, 'participantCount' => count($objRoomId->return->currentusers), 'maxUsers' => $objRoomId->return->numberOfPartizipants, 'moderatorCount' => count($objRoomId->return->moderators) ); // Then interate through attendee results and return them as part of the array: if (!empty($objRoomId->return->currentusers)) { foreach ($objRoomId->return->currentusers as $a) $current_room[] = array( 'userId' => $a->username, 'fullName' => $a->firstname . " " . $a->lastname, 'isMod' => $a->isMod ); } $remoteMeeting = $current_room; */ if (empty($remoteMeeting)) { /* error_log(__FILE__.'+'.__LINE__.' Empty remote Meeting for now'); if ($meetingDb['status'] == 1 && $this->isTeacher()) { $this->endMeeting($meetingDb['id']); } */ } else { $remoteMeeting['add_to_calendar_url'] = api_get_self() . '?action=add_to_calendar&id=' . $meetingDb['id'] . '&start=' . api_strtotime($meetingDb['startTime']); } $remoteMeeting['end_url'] = api_get_self() . '?action=end&id=' . $meetingDb['id']; $remoteMeeting['delete_url'] = api_get_self() . '?action=delete&id=' . $meetingDb['id']; //$record_array = array(); // if ($meetingDb['record'] == 1) { // $recordingParams = array( // 'meetingId' => $meetingDb['id'], //-- OPTIONAL - comma separate if multiple ids // ); // // $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams); // if (!empty($records)) { // $count = 1; // if (isset($records['message']) && !empty($records['message'])) { // if ($records['messageKey'] == 'noRecordings') { // $record_array[] = get_lang('NoRecording'); // } else { // //$record_array[] = $records['message']; // } // } else { // foreach ($records as $record) { // if (is_array($record) && isset($record['recordId'])) { // $url = Display::url(get_lang('ViewRecord'), $record['playbackFormatUrl'], array('target' => '_blank')); // if ($this->is_teacher()) { // $url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meetingDb['id'].'&record_id='.$record['recordId']); // $url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meetingDb['id'].'&start='.api_strtotime($meetingDb['created_at']).'&url='.$record['playbackFormatUrl']); // $url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordId']); // } // //$url .= api_get_self().'?action=publish&id='.$record['recordID']; // $count++; // $record_array[] = $url; // } else { // // } // } // } // } // //var_dump($record_array); // $item['show_links'] = implode('<br />', $record_array); // // } // //$item['created_at'] = api_convert_and_format_date($meetingDb['created_at']); // //created_at // // $item['publish_url'] = api_get_self().'?action=publish&id='.$meetingDb['id']; // $item['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meetingDb['id']; // //if ($meetingDb['status'] == 1) { // $joinParams = array( // 'meetingId' => $meetingDb['id'], //-- REQUIRED - A unique id for the meeting // 'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting // 'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here // 'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly. // 'userID' => '', // -- OPTIONAL - string // 'webVoiceConf' => '' // -- OPTIONAL - string // ); // $returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag( array('room_id' => $meetingDb['id']) ); // $joinUrl = CONFIG_OPENMEETINGS_SERVER_URL . "?" . // "secureHash=" . $returnVal; // // $item['go_url'] = $joinUrl; //} $item = array_merge($item, $meetingDb, $remoteMeeting); //error_log(__FILE__.'+'.__LINE__.' Item: '.print_r($item,1)); $newMeetingsList[] = $item; } //end foreach $meetingsList } return $newMeetingsList; }
/** * This function retrieves all the personal agenda items of the user and shows * these items in one list (ordered by date and grouped by month (the month_bar) */ function show_personal_agenda() { global $MonthsLong, $charset; $tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA); // The SQL statement that retrieves all the personal agenda items of this user $sql = "SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' ORDER BY date DESC"; $result = Database::query($sql); // variable initialisation $month_bar = ""; // setting the default day, month and year if (!isset($_GET['day']) and !isset($_GET['month']) and !isset($_GET['year'])) { $today = getdate(); $year = $today['year']; $month = $today['mon']; $day = $today['mday']; } $export_icon = 'export.png'; $export_icon_low = 'export_low_fade.png'; $export_icon_high = 'export_high_fade.png'; // starting the table output echo '<table class="data_table">'; $th = Display::tag('th', get_lang('Title')); $th .= Display::tag('th', get_lang('Content')); $th .= Display::tag('th', get_lang('StartTimeWindow')); $th .= Display::tag('th', get_lang('Modify')); echo Display::tag('tr', $th); if (Database::num_rows($result) > 0) { $counter = 0; while ($myrow = Database::fetch_array($result)) { /* display: the month bar */ if ($month_bar != date("m", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"]))) { $month_bar = date("m", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"])); //echo "<tr><th class=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."</th></tr>"; } // highlight: if a date in the small calendar is clicked we highlight the relevant items $db_date = (int) date("d", strtotime($myrow["date"])) . date("n", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"])); /* if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date) { $style = "data"; $text_style = "text"; } else { $style = "datanow"; $text_style = "text"; }*/ $class = 'row_even'; if ($counter % 2) { $class = 'row_odd'; } echo '<tr class="' . $class . '">'; echo '<td>'; /* display: the title */ echo $myrow['title']; echo "</td>"; // display: the content $content = $myrow['text']; echo "<td>"; echo $content; echo "</td>"; //display: date and time echo '<td>'; // adding an internal anchor /*echo "<a name=\"".$myrow["id"]."\"></a>"; echo date("d", strtotime($myrow["date"]))." ".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))." ";*/ $myrow["date"] = api_get_local_time($myrow["date"]); echo api_format_date($myrow["date"], DATE_TIME_FORMAT_LONG); echo "</td>"; //echo '<td></td>'; //remove when enabling ical //echo '<td class="'.$style.'">'; //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a>'; //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a>'; //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a>'; //echo "</td>"; //echo "</tr>"; /* display: the edit / delete icons */ echo "<td>"; echo "<a href=\"myagenda.php?action=edit_personal_agenda_item&id=" . $myrow['id'] . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a> "; echo "<a href=\"" . api_get_self() . "?action=delete&id=" . $myrow['id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; echo "</td></tr>"; $counter++; } } else { echo '<tr><td colspan="2">' . get_lang('NoAgendaItems') . '</td></tr>'; } echo "</table>"; }
$extraField = new ExtraField('lp'); $extra = $extraField->addElements($form, $_SESSION['oLP']->get_id()); $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>'; $htmlHeadXtra[] = '<link href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css" rel="stylesheet" type="text/css" />'; $htmlHeadXtra[] = '<script> $(function() { ' . $extra['jquery_ready_content'] . ' }); </script>'; //Submit button $form->addElement('style_submit_button', 'Submit', get_lang('SaveLPSettings'), 'class="save"'); // Hidden fields $form->addElement('hidden', 'action', 'update_lp'); $form->addElement('hidden', 'lp_id', $_SESSION['oLP']->get_id()); $defaults['publicated_on'] = $publicated_on != '0000-00-00 00:00:00' && !empty($publicated_on) ? api_get_local_time($publicated_on) : date('Y-m-d 12:00:00'); $defaults['expired_on'] = $expired_on != '0000-00-00 00:00:00' && !empty($expired_on) ? api_get_local_time($expired_on) : date('Y-m-d 12:00:00', time() + 84600); $defaults['max_attempts'] = $_SESSION['oLP']->get_max_attempts(); $defaults['subscribe_users'] = $_SESSION['oLP']->get_subscribe_users(); $form->setDefaults($defaults); Display::display_header(get_lang('CourseSettings'), 'Path'); echo $_SESSION['oLP']->build_action_menu(); echo '<div class="row">'; if ($_SESSION['oLP']->get_hide_toc_frame() == 1) { echo '<div class="span12">'; $form->display(); echo '</div>'; } else { echo '<div class="span6">'; $form->display(); echo '</div>'; echo '<div class="span6" align="center">';
static function display_notes() { global $_user; if (!$_GET['direction']) { $sort_direction = 'ASC'; $link_sort_direction = 'DESC'; } elseif ($_GET['direction'] == 'ASC') { $sort_direction = 'ASC'; $link_sort_direction = 'DESC'; } else { $sort_direction = 'DESC'; $link_sort_direction = 'ASC'; } // action links echo '<div class="actions">'; if (!api_is_anonymous()) { if (api_get_session_id() == 0) echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>'; elseif (api_is_allowed_to_session_edit(false, true)) { echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>'; } } else { echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>'; } echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>'; echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=update_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>'; echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=title&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>'; echo '</div>'; if (!in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))) { $_SESSION['notebook_view'] = 'creation_date'; } // Database table definition $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); $order_by = ""; if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') { $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction "; } else { $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction "; } //condition for the session $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $cond_extra = ($_SESSION['notebook_view'] == 'update_date') ? " AND update_date <> '0000-00-00 00:00:00'" : " "; $course_id = api_get_course_int_id(); $sql = "SELECT * FROM $t_notebook WHERE c_id = $course_id AND user_id = '" . api_get_user_id() . "' $condition_session $cond_extra $order_by"; $result = Database::query($sql); while ($row = Database::fetch_array($result)) { //validacion when belongs to a session $session_img = api_get_session_image($row['session_id'], $_user['status']); $creation_date = api_get_local_time($row['creation_date'], null, date_default_timezone_get()); $update_date = api_get_local_time($row['update_date'], null, date_default_timezone_get()); echo '<div class="sectiontitle">'; echo '<span style="float: right;"> (' . get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . ' <span class="dropbox_date">' . $creation_date . '</span>'; if ($row['update_date'] <> $row['creation_date']) { echo ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . ' <span class="dropbox_date">' . $update_date . '</span>'; } echo ')</span>'; echo $row['title'] . $session_img; echo '</div>'; echo '<div class="sectioncomment">' . $row['description'] . '</div>'; echo '<div>'; echo '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>'; echo '<a href="' . api_get_self() . '?action=deletenote&notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>'; echo '</div>'; } }
$column++; } $row++; $column = 0; foreach ($workPerUser as $work) { $work = $work['work']; $scoreWeight = intval($work->qualification) == 0 ? null : $work->qualification; $workId = $work->id; $workExtraData = get_work_assignment_by_id($workId); foreach ($work->user_results as $userResult) { $table->setCellContents($row, $column, $work->title . ' [' . strip_tags($userResult['title']) . ']'); $table->setCellAttributes($row, $column, array('width' => '300px')); $column++; $table->setCellContents($row, $column, $userResult['sent_date']); $column++; $dateQualification = !empty($workExtraData['expires_on']) && $workExtraData['expires_on'] != '0000-00-00 00:00:00' ? api_get_local_time($workExtraData['expires_on']) : '-'; $table->setCellContents($row, $column, $dateQualification); $column++; $score = '-'; if (!empty($scoreWeight)) { $score = strip_tags($userResult['qualification']) . "/" . $scoreWeight; } $table->setCellContents($row, $column, $score); $column++; // Actions $links = null; // is a text $url = api_get_path(WEB_CODE_PATH) . 'work/view.php?' . api_get_cidreq() . '&id=' . $userResult['id']; $links .= Display::url(Display::return_icon('default.png'), $url); if (!empty($userResult['url'])) { $url = api_get_path(WEB_CODE_PATH) . 'work/download.php?' . api_get_cidreq() . '&id=' . $userResult['id'];
if (in_array($file_type, ['csv', 'xls'])) { $archiveFile = 'export_sessions_' . $session_id . '_' . api_get_local_time(); $cvs = true; $sessionListToExport[] = ['SessionName', 'Coach', 'DateStart', 'DateEnd', 'Visibility', 'SessionCategory', 'Users', 'Courses']; } else { if (!file_exists($archivePath)) { mkdir($archivePath, api_get_permissions_for_new_directories(), true); } if (!file_exists($archivePath . 'index.html')) { $fp = fopen($archivePath . 'index.html', 'w'); fputs($fp, '<html><head></head><body></body></html>'); fclose($fp); } $archiveFile = 'export_sessions_' . $session_id . '_' . api_get_local_time() . '.' . $file_type; while (file_exists($archivePath . $archiveFile)) { $archiveFile = 'export_users_' . $session_id . '_' . api_get_local_time() . '_' . uniqid('') . '.' . $file_type; } $cvs = false; $fp = fopen($archivePath . $archiveFile, 'w'); fputs($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Sessions>\n"); } while ($row = Database::fetch_array($result)) { $row['name'] = str_replace(';', ',', $row['name']); $row['username'] = str_replace(';', ',', $row['username']); $row['access_start_date'] = str_replace(';', ',', $row['access_start_date']); $row['access_end_date'] = str_replace(';', ',', $row['access_end_date']); $row['visibility'] = str_replace(';', ',', $row['visibility']); $row['session_category'] = str_replace(';', ',', $row['session_category_id']); // users $sql = "SELECT DISTINCT {$tbl_user}.username\n\t\t\t\t\tFROM {$tbl_user}\n\t\t\t\t\tINNER JOIN {$tbl_session_user}\n\t\t\t\t\tON\n\t\t\t\t\t\t{$tbl_user}.user_id = {$tbl_session_user}.user_id AND\n\t\t\t\t\t\t{$tbl_session_user}.relation_type<>" . SESSION_RELATION_TYPE_RRHH . " AND\n\t\t\t\t\t\t{$tbl_session_user}.session_id = '" . $row['id'] . "'"; $rsUsers = Database::query($sql);
echo Display::div('', array('id' => "thematic_plan_" . $thematic['id'])); } else { echo $thematic_plan_div[$thematic['id']]; } echo '</td>'; // Display 3rd column - thematic advance data echo '<td style="vertical-align:top">'; //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) { if (api_is_allowed_to_edit(null, true)) { echo '<div style="text-align:right"><a href="index.php?' . api_get_cidreq() . '&action=thematic_advance_add&thematic_id=' . $thematic['id'] . '">' . Display::return_icon('add.png', get_lang('NewThematicAdvance'), '', ICON_SIZE_MEDIUM) . '</a></div>'; } //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) { if (!empty($thematic_advance_data[$thematic['id']])) { echo '<table width="100%">'; foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) { $thematic_advance['start_date'] = api_get_local_time($thematic_advance['start_date']); $thematic_advance['start_date'] = api_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG); echo '<tr>'; echo '<td width="90%" class="thematic_advance_content" id="thematic_advance_content_id_' . $thematic_advance['id'] . '">'; $edit_link = ''; if (api_is_allowed_to_edit(null, true)) { $edit_link = Display::url(Display::return_icon('edit.png', get_lang('EditThematicAdvance'), [], ICON_SIZE_SMALL), 'index.php?' . api_get_cidreq() . '&' . http_build_query(['action' => 'thematic_advance_edit', 'thematic_id' => $thematic['id'], 'thematic_advance_id' => $thematic_advance['id'], 'display' => 'no_header']), ['class' => 'ajax', 'data-title' => get_lang('EditThematicAdvance')]); $edit_link .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToDelete') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=thematic_advance_delete&thematic_id=' . $thematic['id'] . '&thematic_advance_id=' . $thematic_advance['id'] . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a></center>'; //Links $edit_link = Display::div(Display::div($edit_link, array('id' => 'thematic_advance_tools_' . $thematic_advance['id'], 'class' => 'thematic_advance_actions')), array('style' => 'height:20px;')); } $thematic_advance_item = isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null; echo Display::div($thematic_advance_item, array('id' => 'thematic_advance_' . $thematic_advance['id'])); echo $edit_link; echo '</td>'; //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
$values['action'] = 'add'; // Set default time window: NOW -> NEXT WEEK $values['start'] = date('Y-m-d H:i:s', api_strtotime(api_get_local_time())); $values['end'] = date('Y-m-d H:i:s', api_strtotime(api_get_local_time()) + 7 * 24 * 60 * 60); $values['range'] = substr(api_get_local_time(time()), 0, 16) . ' / ' . substr(api_get_local_time(time() + 7 * 24 * 60 * 60), 0, 16); $action_todo = true; break; case 'edit': // Edit an announcement. $announcement = SystemAnnouncementManager::get_announcement($_GET['id']); $values['id'] = $announcement->id; $values['title'] = $announcement->title; $values['content'] = $announcement->content; $values['start'] = api_get_local_time($announcement->date_start); $values['end'] = api_get_local_time($announcement->date_end); $values['range'] = substr(api_get_local_time($announcement->date_start), 0, 16) . ' / ' . substr(api_get_local_time($announcement->date_end), 0, 16); $values['visible_teacher'] = $announcement->visible_teacher; $values['visible_student'] = $announcement->visible_student; $values['visible_guest'] = $announcement->visible_guest; $values['lang'] = $announcement->lang; $values['action'] = 'edit'; $groups = SystemAnnouncementManager::get_announcement_groups($announcement->id); $values['group'] = isset($groups['group_id']) ? $groups['group_id'] : 0; $action_todo = true; break; } if ($action_todo) { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { $form_title = get_lang('AddNews'); $url = api_get_self(); } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
/** * Get activities data to display * @param int $from * @param int $numberOfItems * @param int $column * @param string $direction * @return array */ public static function getActivitiesData($from, $numberOfItems, $column, $direction) { $track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); $table_user = Database::get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $current_url_id = api_get_current_access_url_id(); $column = intval($column); $from = intval($from); $numberOfItems = intval($numberOfItems); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'DESC'; } if (api_is_multiple_url_enabled()) { $sql = "SELECT\n default_event_type as col0,\n default_value_type as col1,\n default_value as col2,\n c_id as col3,\n session_id as col4,\n user.username as col5,\n user.user_id as col6,\n default_date as col7\n FROM {$track_e_default} as track_default, {$table_user} as user, {$access_url_rel_user_table} as url\n WHERE\n track_default.default_user_id = user.user_id AND\n url.user_id = user.user_id AND\n access_url_id='" . $current_url_id . "'"; } else { $sql = "SELECT\n default_event_type as col0,\n default_value_type as col1,\n default_value as col2,\n c_id as col3,\n session_id as col4,\n user.username as col5,\n user.user_id as col6,\n default_date as col7\n FROM {$track_e_default} track_default, {$table_user} user\n WHERE track_default.default_user_id = user.user_id "; } if (isset($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " AND (user.username LIKE '%" . $keyword . "%' OR\n default_event_type LIKE '%" . $keyword . "%' OR\n default_value_type LIKE '%" . $keyword . "%' OR\n default_value LIKE '%" . $keyword . "%') "; } if (!empty($column) && !empty($direction)) { $sql .= " ORDER BY col{$column} {$direction}"; } else { $sql .= " ORDER BY col5 DESC "; } $sql .= " LIMIT {$from},{$numberOfItems} "; $res = Database::query($sql); $activities = array(); while ($row = Database::fetch_row($res)) { if (strpos($row[1], '_object') === false && strpos($row[1], '_array') === false) { $row[2] = $row[2]; } else { if (!empty($row[2])) { $originalData = str_replace('\\', '', $row[2]); $row[2] = unserialize($originalData); if (is_array($row[2]) && !empty($row[2])) { $row[2] = implode_with_key(', ', $row[2]); } else { $row[2] = $originalData; } } } if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') { $row['default_date'] = api_get_local_time($row['default_date']); } else { $row['default_date'] = '-'; } if (!empty($row[5])) { //course if (!empty($row[3])) { $row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH) . 'admin/course_edit.php?id=' . $row[3]); } else { $row[3] = '-'; } // session if (!empty($row[4])) { $row[4] = Display::url($row[4], api_get_path(WEB_CODE_PATH) . 'session/resume_session.php?id_session=' . $row[4]); } else { $row[4] = '-'; } // User id. $row[5] = Display::url($row[5], api_get_path(WEB_CODE_PATH) . 'admin/user_information.php?user_id=' . $row[6], array('title' => get_lang('UserInfo'))); $row[6] = TrackingUserLog::get_ip_from_user_event($row[6], $row[7], true); if (empty($row[6])) { $row[6] = get_lang('Unknown'); } } $activities[] = $row; } return $activities; }
/** * @param array $result * @return array */ private static function create_evaluation_objects_from_sql_result($result) { $alleval = array(); if (Database::num_rows($result)) { while ($data = Database::fetch_array($result)) { $eval = new Evaluation(); $eval->set_id($data['id']); $eval->set_name($data['name']); $eval->set_description($data['description']); $eval->set_user_id($data['user_id']); $eval->set_course_code($data['course_code']); $eval->set_category_id($data['category_id']); $eval->set_date(api_get_local_time($data['created_at'])); $eval->set_weight($data['weight']); $eval->set_max($data['max']); $eval->set_visible($data['visible']); $eval->set_type($data['type']); $eval->set_locked($data['locked']); $eval->setSessionId(api_get_session_id()); $alleval[] = $eval; } } return $alleval; }
/** * Retrieve results and return them as an array of Result objects * @param $id result id * @param $user_id user id (student) * @param $evaluation_id evaluation where this is a result for */ public static function load($id = null, $user_id = null, $evaluation_id = null) { $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); $tbl_course_rel_course = Database::get_main_table(TABLE_MAIN_COURSE_USER); $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); if (is_null($id) && is_null($user_id) && !is_null($evaluation_id)) { $sql_verified_if_exist_evaluation = 'SELECT COUNT(*) AS count FROM ' . $tbl_grade_results . ' WHERE evaluation_id="' . Database::escape_string($evaluation_id) . '";'; $res_verified_if_exist_evaluation = Database::query($sql_verified_if_exist_evaluation); $info_verified_if_exist_evaluation = Database::result($res_verified_if_exist_evaluation, 0, 0); if ($info_verified_if_exist_evaluation != 0) { $sql_course_rel_user = ''; if (api_get_session_id()) { $sql_course_rel_user = '******' . $tbl_session_rel_course_user . ' WHERE status=0 AND c_id="' . api_get_course_int_id() . '" AND id_session=' . api_get_session_id(); } else { $sql_course_rel_user = '******' . $tbl_course_rel_course . ' WHERE status ="' . STUDENT . '" AND c_id ="' . api_get_course_int_id() . '" '; } $res_course_rel_user = Database::query($sql_course_rel_user); $list_user_course_list = array(); while ($row_course_rel_user = Database::fetch_array($res_course_rel_user, 'ASSOC')) { $list_user_course_list[] = $row_course_rel_user; } $current_date = api_get_utc_datetime(); for ($i = 0; $i < count($list_user_course_list); $i++) { $sql_verified = 'SELECT COUNT(*) AS count FROM ' . $tbl_grade_results . ' WHERE user_id="' . intval($list_user_course_list[$i]['user_id']) . '" AND evaluation_id="' . intval($evaluation_id) . '";'; $res_verified = Database::query($sql_verified); $info_verified = Database::result($res_verified, 0, 0); if ($info_verified == 0) { $sql_insert = 'INSERT INTO ' . $tbl_grade_results . '(user_id,evaluation_id,created_at,score) VALUES ("' . intval($list_user_course_list[$i]['user_id']) . '","' . intval($evaluation_id) . '","' . $current_date . '",0);'; $res_insert = Database::query($sql_insert); } } $list_user_course_list = array(); } } $sql = "SELECT gr.id, gr.user_id, gr.evaluation_id, gr.created_at, gr.score \n FROM {$tbl_grade_results} gr\n LEFT JOIN {$tbl_user} u ON gr.user_id = u.user_id "; $paramcount = 0; if (!empty($id)) { $sql .= ' WHERE gr.id = ' . Database::escape_string($id); $paramcount++; } if (!empty($user_id)) { if ($paramcount != 0) { $sql .= ' AND'; } else { $sql .= ' WHERE'; } $sql .= ' user_id = ' . Database::escape_string($user_id); $paramcount++; } if (!empty($evaluation_id)) { if ($paramcount != 0) { $sql .= ' AND'; } else { $sql .= ' WHERE'; } $sql .= ' evaluation_id = ' . Database::escape_string($evaluation_id); $paramcount++; } $result = Database::query($sql); $allres = array(); while ($data = Database::fetch_array($result)) { $res = new Result(); $res->set_id($data['id']); $res->set_user_id($data['user_id']); $res->set_evaluation_id($data['evaluation_id']); $res->set_date(api_get_local_time($data['created_at'])); $res->set_score($data['score']); $allres[] = $res; } return $allres; }
/** * It's used to print attendance sheet * @param string action * @param int attendance id */ public function attendance_sheet_export_to_pdf($action, $attendance_id, $student_id = 0, $course_id = '') { $attendance = new Attendance(); $courseInfo = CourseManager::get_course_information($course_id); $attendance->set_course_id($courseInfo['code']); $data_array = array(); $data_array['attendance_id'] = $attendance_id; $data_array['users_in_course'] = $attendance->get_users_rel_course($attendance_id); $filter_type = 'today'; if (!empty($_REQUEST['filter'])) { $filter_type = $_REQUEST['filter']; } $my_calendar_id = null; if (is_numeric($filter_type)) { $my_calendar_id = $filter_type; $filter_type = 'calendar_id'; } $data_array['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type, $my_calendar_id); if (api_is_allowed_to_edit(null, true) || api_is_drh()) { $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id); } else { if (!empty($student_id)) { $user_id = intval($student_id); } else { $user_id = api_get_user_id(); } $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, $user_id); $data_array['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id); $data_array['user_id'] = $user_id; } $data_array['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id); //Set headers pdf $courseCategory = CourseManager::get_course_category($courseInfo['category_code']); $teacherInfo = CourseManager::get_teacher_list_from_course_code($courseInfo['real_id']); $teacherName = null; foreach ($teacherInfo as $dados) { if ($teacherName != null) { $teacherName = $teacherName . " / "; } $teacherName .= $dados['firstname'] . " " . $dados['lastname']; } // Get data table - Marco - ordenacao fixa - just fullname $data_table = array(); $head_table = array('#', get_lang('Name')); foreach ($data_array['attendant_calendar'] as $class_day) { //$head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_SHORT).' <br />'.api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT); $head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_NUMBER_NO_YEAR); } $data_table[] = $head_table; $dataClass = array(); $max_dates_per_page = 10; $data_attendant_calendar = $data_array['attendant_calendar']; $data_users_presence = $data_array['users_presence']; $count = 1; if (!empty($data_array['users_in_course'])) { foreach ($data_array['users_in_course'] as $user) { $cols = 1; $result = array(); $result['count'] = $count; $result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']); foreach ($data_array['attendant_calendar'] as $class_day) { if ($class_day['done_attendance'] == 1) { if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1) { $result[$class_day['id']] = get_lang('UserAttendedSymbol'); } else { $result[$class_day['id']] = get_lang('UserNotAttendedSymbol'); } } else { $result[$class_day['id']] = " "; } $cols++; } $count++; $data_table[] = $result; } } $max_cols_per_page = 12; //10 dates + 2 name and number $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2; //10 $rows = count($data_table); if ($cols > $max_cols_per_page) { $number_tables = round(($cols - 2) / $max_dates_per_page); $headers = $data_table[0]; $all = array(); $tables = array(); $changed = 1; for ($i = 0; $i <= $rows; $i++) { $row = $data_table[$i]; $key = 1; $max_dates_per_page = 10; $item = $data_table[$i]; $count_j = 0; if (!empty($item)) { foreach ($item as $value) { if ($count_j >= $max_dates_per_page) { $key++; $max_dates_per_page = $max_dates_per_page_original * $key; //magic hack $tables[$key][$i][] = $tables[1][$i][0]; $tables[$key][$i][] = $tables[1][$i][1]; } $tables[$key][$i][] = $value; $count_j++; } } } $content = null; if (!empty($tables)) { foreach ($tables as $sub_table) { $content .= Export::convert_array_to_html($sub_table) . '<br /><br />'; } } } else { $content .= Export::convert_array_to_html($data_table, array('header_attributes' => array('align' => 'center'))); } $params = array('filename' => get_lang('Attendance') . '-' . api_get_local_time(), 'pdf_title' => $courseInfo['title'], 'course_code' => $courseInfo['code'], 'add_signatures' => true, 'orientation' => 'landscape', 'pdf_teachers' => $teacherName, 'pdf_course_category' => $courseCategory['name'], 'format' => 'A4-L', 'orientation' => 'L'); Export::export_html_to_pdf($content, $params); exit; }
/** * Get all attendance calendar data inside current attendance * @param int $attendance_id * @param string $type * @param int $calendar_id * @param int $groupId * @param bool $showAll = false show group calendar items or not * * @return array attendance calendar data */ public function get_attendance_calendar($attendance_id, $type = 'all', $calendar_id = null, $groupId = null, $showAll = false) { $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); $tbl_acrg = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); $attendance_id = intval($attendance_id); $course_id = api_get_course_int_id(); $groupCondition = null; if ($showAll) { $sql = "SELECT * FROM {$tbl_attendance_calendar}\n\t\t\t\t\tWHERE c_id = {$course_id} AND attendance_id = '{$attendance_id}'"; } else { $sql = "SELECT * FROM {$tbl_attendance_calendar}\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tc_id = {$course_id} AND\n\t\t\t\t\t\tattendance_id = '{$attendance_id}' AND\n\t\t\t\t\t\tid NOT IN (\n\t\t\t\t\t\t\tSELECT calendar_id FROM {$tbl_acrg}\n\t\t\t\t\t\t\tWHERE c_id = {$course_id} AND group_id != 0 AND group_id IS NOT NULL\n\t\t\t\t\t\t)\n\t\t\t\t\t"; } if (!empty($groupId)) { $groupId = intval($groupId); $sql = "SELECT c.* FROM {$tbl_attendance_calendar} c\n\t\t\t\t\tINNER JOIN {$tbl_acrg} g\n\t\t\t\t\tON c.c_id = g.c_id AND c.id = g.calendar_id\n\t\t\t\t\tWHERE\n\t\t\t\t\t c.c_id = {$course_id} AND\n\t\t\t\t\t g.group_id = '{$groupId}' AND\n\t\t\t\t\t c.attendance_id = '{$attendance_id}'\n "; } if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done', 'calendar_id'))) { $type = 'all'; } switch ($type) { case 'calendar_id': $calendar_id = intval($calendar_id); if (!empty($calendar_id)) { $sql .= " AND id = {$calendar_id}"; } break; case 'today': //$sql .= ' AND DATE_FORMAT(date_time,"%d-%m-%Y") = DATE_FORMAT("'.api_get_utc_datetime().'", "%d-%m-%Y" )'; break; case 'all_done': $sql .= " AND done_attendance = 1 "; break; case 'all_not_done': $sql .= " AND done_attendance = 0 "; break; case 'all': default: break; } $sql .= " ORDER BY date_time "; $rs = Database::query($sql); $data = array(); if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs, 'ASSOC')) { $row['db_date_time'] = $row['date_time']; $row['date_time'] = api_get_local_time($row['date_time']); $row['date'] = api_format_date($row['date_time'], DATE_FORMAT_SHORT); $row['time'] = api_format_date($row['date_time'], TIME_NO_SEC_FORMAT); $row['groups'] = $this->getGroupListByAttendanceCalendar($row['id'], $course_id); if ($type == 'today') { if (date('d-m-Y', api_strtotime($row['date_time'], 'UTC')) == date('d-m-Y', time())) { $data[] = $row; } } else { $data[] = $row; } } } return $data; }
/** * Exports the complete report as an XLS file * @return boolean False on error */ public function exportCompleteReportXLS($data) { $filename = 'gradebook-results-' . api_get_local_time() . '.xls'; $spreadsheet = new PHPExcel(); $spreadsheet->setActiveSheetIndex(0); $worksheet = $spreadsheet->getActiveSheet(); $line = 0; $column = 0; //skip the first column (row titles) //headers foreach ($data[0] as $header_col) { $worksheet->SetCellValueByColumnAndRow($line, $column, $header_col); $column++; } $line++; $cant_students = count($data[1]); for ($i = 0; $i < $cant_students; $i++) { $column = 0; foreach ($data[1][$i] as $col_name) { $worksheet->SetCellValueByColumnAndRow($line, $column, html_entity_decode(strip_tags($col_name))); $column++; } $line++; } $file = api_get_path(SYS_ARCHIVE_PATH) . api_replace_dangerous_char($filename); $writer = new PHPExcel_Writer_Excel2007($spreadsheet); $writer->save($file); DocumentManager::file_send_for_download($file, true, $filename); exit; }