} else { $csv_headers[] = get_lang('LastName', ''); $csv_headers[] = get_lang('FirstName', ''); } $csv_headers[] = get_lang('Login', ''); // $csv_headers[] = get_lang('TrainingTime', ''); $csv_headers[] = get_lang('CourseProgress', ''); $csv_headers[] = get_lang('ExerciseProgress', ''); $csv_headers[] = get_lang('ExerciseAverage', ''); $csv_headers[] = get_lang('Score', ''); $csv_headers[] = get_lang('Student_publication', ''); $csv_headers[] = get_lang('Messages', ''); if (empty($session_id)) { $csv_headers[] = get_lang('Survey'); } $csv_headers[] = get_lang('FirstLogin', ''); $csv_headers[] = get_lang('LatestLogin', ''); if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) { $csv_headers[] = $extra_info['field_display_text']; } ob_end_clean(); array_unshift($csv_content, $csv_headers); // Adding headers before the content. Export::export_table_csv($csv_content, 'reporting_student_list'); exit; } Display::display_footer();
$data['username'] = $userinfo['username']; //$result->get_user_id(); $data['official_code'] = $userinfo['official_code']; $data['lastname'] = $userinfo['lastname']; $data['firstname'] = $userinfo['firstname']; $data['score'] = $result->get_score(); $data['date'] = api_format_date($result->get_date(), "%d/%m/%Y %R"); $alldata[] = $data; } switch ($file_type) { case 'xml': Export::export_table_xml($alldata, $filename, 'Result', 'XMLResults'); exit; break; case 'csv': Export::export_table_csv($alldata, $filename); exit; break; } } } if (isset($_GET['resultdelete'])) { $result = Result::load($_GET['resultdelete']); $result[0]->delete(); header('Location: gradebook_view_result.php?deleteresult=&selecteval=' . Security::remove_XSS($_GET['selecteval'])); exit; } if (isset($_POST['action'])) { $number_of_selected_items = count($_POST['id']); if ($number_of_selected_items == '0') { Display::display_warning_message(get_lang('NoItemsSelected'), false);
exit; break; case 'export_pdf': $content = GroupManager::getOverview($courseId, $keyword); $pdf = new PDF(); $extra = '<div style="text-align:center"><h2>' . get_lang('GroupList') . '</h2></div>'; $extra .= '<strong>' . get_lang('Course') . ': </strong>' . $courseInfo['title'] . ' (' . $courseInfo['code'] . ')'; $content = $extra . $content; $pdf->content_to_pdf($content, null, null, api_get_course_id()); break; case 'export': $groupId = isset($_GET['id']) ? intval($_GET['id']) : null; $data = GroupManager::exportCategoriesAndGroupsToArray($groupId, true); switch ($_GET['type']) { case 'csv': Export::export_table_csv($data); exit; break; case 'xls': if (!empty($data)) { Export::export_table_xls($data); exit; } break; } break; } } /* Header */ $interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups')); if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') {
/** * @param int $user_id * @param array $courseInfo * @param int $session_id * @param string $origin * @param bool $export_csv * @param int $lp_id * @param int $lp_item_id * @param int $extendId * @param int $extendAttemptId * @param string $extendedAttempt * @param string $extendedAll * @param string $type classic or simple * @return null|string */ public static function getLpStats( $user_id, $courseInfo, $session_id, $origin, $export_csv, $lp_id, $lp_item_id = null, $extendId = null, $extendAttemptId = null, $extendedAttempt = null, $extendedAll = null, $type = 'classic' ) { if (empty($courseInfo) || empty($lp_id)) { return null; } $lp_id = intval($lp_id); $lp_item_id = intval($lp_item_id); $user_id = intval($user_id); $session_id = intval($session_id); $origin = Security::remove_XSS($origin); $list = learnpath :: get_flat_ordered_items_list($lp_id, 0, $courseInfo['real_id']); $is_allowed_to_edit = api_is_allowed_to_edit(null, true); $course_id = $courseInfo['real_id']; $courseCode = $courseInfo['code']; $session_condition = api_get_session_condition($session_id); // Extend all button $output = null; $extend_all = 0; if ($origin == 'tracking') { $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin; } else { $url_suffix = '&lp_id=' . $lp_id; } if (!empty($extendedAll)) { $extend_all_link = Display::url( Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')), api_get_self() . '?action=stats' . $url_suffix ); $extend_all = 1; } else { $extend_all_link = Display::url( Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')), api_get_self() . '?action=stats&extend_all=1' . $url_suffix ); } if ($origin != 'tracking') { $output .= Display::page_header(get_lang('ScormMystatus')); } $actionColumn = null; if ($type == 'classic') { $actionColumn = ' <th>' . get_lang('Actions') . '</th>'; } $output .= '<table class="data_table"> <tr> <th width="16">' . $extend_all_link . '</th> <th colspan="4"> ' . get_lang('ScormLessonTitle') .' </th> <th colspan="2"> ' . get_lang('ScormStatus') . ' </th> <th colspan="2"> ' . get_lang('ScormScore') . ' </th> <th colspan="2"> ' . get_lang('ScormTime') . ' </th> '.$actionColumn.' </tr>'; // Going through the items using the $items[] array instead of the database order ensures // we get them in the same order as in the imsmanifest file, which is rather random when using // the database table. $TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM); $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW); $TBL_LP_VIEW = Database :: get_course_table(TABLE_LP_VIEW); $tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION); $TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST); $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $sql = "SELECT max(view_count) FROM $TBL_LP_VIEW WHERE c_id = $course_id AND lp_id = $lp_id AND user_id = $user_id $session_condition"; $res = Database::query($sql); $view = ''; if (Database :: num_rows($res) > 0) { $myrow = Database :: fetch_array($res); $view = $myrow[0]; } $counter = 0; $total_time = 0; $h = get_lang('h'); if (!empty($export_csv)) { $csv_content[] = array( get_lang('ScormLessonTitle'), get_lang('ScormStatus'), get_lang('ScormScore'), get_lang('ScormTime') ); } $result_disabled_ext_all = true; $chapterTypes = learnpath::getChapterTypes(); // Show lp items if (is_array($list) && count($list) > 0) { foreach ($list as $my_item_id) { $extend_this = 0; $order = 'DESC'; if ((!empty($extendId) && $extendId == $my_item_id) || $extend_all) { $extend_this = 1; $order = 'ASC'; } // Prepare statement to go through each attempt. $viewCondition = null; if (!empty($view)) { $viewCondition = " AND v.view_count = $view "; } $sql = "SELECT iv.status as mystatus, v.view_count as mycount, iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, i.title as mytitle, i.max_score as mymaxscore, iv.max_score as myviewmaxscore, i.item_type as item_type, iv.view_count as iv_view_count, iv.id as iv_id, path FROM $TBL_LP_ITEM as i INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id) INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id) WHERE i.id = $my_item_id AND i.lp_id = $lp_id AND v.user_id = $user_id AND v.session_id = $session_id $viewCondition ORDER BY iv.view_count $order "; $result = Database::query($sql); $num = Database :: num_rows($result); $time_for_total = 'NaN'; // Extend all if (($extend_this || $extend_all) && $num > 0) { $row = Database :: fetch_array($result); $result_disabled_ext_all = false; if ($row['item_type'] == 'quiz') { // Check results_disabled in quiz table. $my_path = Database::escape_string($row['path']); $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='" . $my_path . "'"; $res_result_disabled = Database::query($sql); $row_result_disabled = Database::fetch_row($res_result_disabled); if (Database::num_rows($res_result_disabled) > 0 && (int) $row_result_disabled[0] === 1 ) { $result_disabled_ext_all = true; } } // If there are several attempts, and the link to extend has been clicked, show each attempt... if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $extend_link = ''; if (!empty($inter_num)) { $extend_link = Display::url( Display::return_icon('visible.gif', get_lang('HideAttemptView')), api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix ); } $title = $row['mytitle']; if (empty($title)) { $title = rl_get_resource_name($courseInfo['code'], $lp_id, $row['myid']); } if (in_array($row['item_type'], $chapterTypes)) { $title = "<h4> $title </h4>"; } $lesson_status = $row['mystatus']; $title = Security::remove_XSS($title); $counter++; $action = null; if ($type == 'classic') { $action = '<td></td>'; } if (in_array($row['item_type'], $chapterTypes)) { $output .= '<tr class="'.$oddclass.'"> <td>'.$extend_link.'</td> <td colspan="4"> '.$title.' </td> <td colspan="2">'.learnpathItem::humanize_status($lesson_status, true, $type).'</td> <td colspan="2"></td> <td colspan="2"></td> '.$action.' </tr>'; continue; } else { $output .= '<tr class="'.$oddclass.'"> <td>'.$extend_link.'</td> <td colspan="4"> '.$title.' </td> <td colspan="2"></td> <td colspan="2"></td> <td colspan="2"></td> '.$action.' </tr>'; } $attemptCount = 1; do { // Check if there are interactions below. $extend_attempt_link = ''; $extend_this_attempt = 0; if ((learnpath::get_interactions_count_from_db($row['iv_id'], $course_id) > 0 || learnpath::get_objectives_count_from_db($row['iv_id'], $course_id) > 0) && !$extend_all ) { if ($extendAttemptId == $row['iv_id']) { // The extend button for this attempt has been clicked. $extend_this_attempt = 1; $extend_attempt_link = Display::url( Display::return_icon('visible.gif', get_lang('HideAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix ); } else { // Same case if fold_attempt_id is set, so not implemented explicitly. // The extend button for this attempt has not been clicked. $extend_attempt_link = Display::url( Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix ); } } if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $lesson_status = $row['mystatus']; $score = $row['myscore']; $time_for_total = $row['mytime']; $time = learnpathItem :: getScormTimeFromParameter('js', $row['mytime']); if ($score == 0) { $maxscore = $row['mymaxscore']; } else { if ($row['item_type'] == 'sco') { if (!empty($row['myviewmaxscore']) && $row['myviewmaxscore'] > 0) { $maxscore = $row['myviewmaxscore']; } elseif ($row['myviewmaxscore'] === '') { $maxscore = 0; } else { $maxscore = $row['mymaxscore']; } } else { $maxscore = $row['mymaxscore']; } } // Remove "NaN" if any (@todo: locate the source of these NaN) $time = str_replace('NaN', '00' . $h . '00\'00"', $time); if ($row['item_type'] != 'dokeos_chapter') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { switch ($row['item_type']) { case 'sco': if ($maxscore == 0) { $view_score = $score; } else { $view_score = show_score($score, $maxscore, false); } break; case 'document': $view_score = ($score == 0 ? '/' : show_score($score, $maxscore, false)); break; default: $view_score = show_score($score, $maxscore, false); break; } } $action = null; if ($type == 'classic') { $action = '<td></td>'; } $output .= '<tr class="' . $oddclass . '"> <td></td> <td>' . $extend_attempt_link . '</td> <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td> <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td> <td colspan="2">' . $view_score . '</td> <td colspan="2">' . $time . '</td> '.$action.' </tr>'; $attemptCount++; if (!empty($export_csv)) { $temp = array(); $temp[] = $title = Security::remove_XSS($title); $temp[] = Security::remove_XSS(learnpathItem::humanize_status($lesson_status, false, $type)); if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $temp[] = '/'; } else { $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); } } else { $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); } $temp[] = $time; $csv_content[] = $temp; } } $counter++; $action = null; if ($type == 'classic') { $action = '<td></td>'; } if ($extend_this_attempt OR $extend_all) { $list1 = learnpath :: get_iv_interactions_array($row['iv_id']); foreach ($list1 as $id => $interaction) { if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $student_response = urldecode($interaction['student_response']); $content_student_response = explode('__|', $student_response); if (count($content_student_response) > 0) { if (count($content_student_response) >= 3) { // Pop the element off the end of array. array_pop($content_student_response); } $student_response = implode(',', $content_student_response); } $output .= '<tr class="'.$oddclass.'"> <td></td> <td></td> <td></td> <td>'.$interaction['order_id'] . '</td> <td>'.$interaction['id'] . '</td> <td colspan="2">' . $interaction['type'].'</td> <td>'.$student_response . '</td> <td>'.$interaction['result'] . '</td> <td>'.$interaction['latency'] . '</td> <td>'.$interaction['time'] . '</td> '.$action.' </tr>'; $counter++; } $list2 = learnpath :: get_iv_objectives_array($row['iv_id']); foreach ($list2 as $id => $interaction) { if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $output .= '<tr class="'.$oddclass.'"> <td></td> <td></td> <td></td> <td>' . $interaction['order_id'] . '</td> <td colspan="2">' . $interaction['objective_id'] . '</td> <td colspan="2">' . $interaction['status'] .'</td> <td>' . $interaction['score_raw'] . '</td> <td>' . $interaction['score_max'] . '</td> <td>' . $interaction['score_min'] . '</td> '.$action.' </tr>'; $counter++; } } } while ($row = Database :: fetch_array($result)); } elseif ($num > 0) { // Not extended. $row = Database :: fetch_array($result, 'ASSOC'); $my_id = $row['myid']; $my_lp_id = $row['mylpid']; $my_lp_view_id = $row['mylpviewid']; $my_path = $row['path']; $result_disabled_ext_all = false; if ($row['item_type'] == 'quiz') { // Check results_disabled in quiz table. $my_path = Database::escape_string($my_path); $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='" . $my_path . "'"; $res_result_disabled = Database::query($sql); $row_result_disabled = Database::fetch_row($res_result_disabled); if (Database::num_rows($res_result_disabled) > 0 && (int) $row_result_disabled[0] === 1 ) { $result_disabled_ext_all = true; } } // Check if there are interactions below $extend_this_attempt = 0; $inter_num = learnpath::get_interactions_count_from_db($row['iv_id'], $course_id); $objec_num = learnpath::get_objectives_count_from_db($row['iv_id'], $course_id); $extend_attempt_link = ''; if ($inter_num > 0 || $objec_num > 0) { if (!empty($extendAttemptId) && $extendAttemptId == $row['iv_id']) { // The extend button for this attempt has been clicked. $extend_this_attempt = 1; $extend_attempt_link = Display::url( Display::return_icon('visible.gif', get_lang('HideAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix ); } else { // Same case if fold_attempt_id is set, so not implemented explicitly. // The extend button for this attempt has not been clicked. $extend_attempt_link = Display::url( Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix ); } } if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $extend_link = ''; if ($inter_num > 1) { $extend_link = Display::url( Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix ); } $lesson_status = $row['mystatus']; $score = $row['myscore']; $subtotal_time = $row['mytime']; while ($tmp_row = Database :: fetch_array($result)) { $subtotal_time += $tmp_row['mytime']; } $title = $row['mytitle']; // Selecting the exe_id from stats attempts tables in order to look the max score value. $sql = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $user_id . '" AND orig_lp_id = "' . $lp_id . '" AND orig_lp_item_id = "' . $row['myid'] . '" AND exe_cours_id="' . $courseCode . '" AND status <> "incomplete" AND session_id = ' . $session_id . ' ORDER BY exe_date DESC LIMIT 1'; $resultLastAttempt = Database::query($sql); $num = Database :: num_rows($resultLastAttempt); $id_last_attempt = null; if ($num > 0) { while ($rowLA = Database :: fetch_array($resultLastAttempt)) { $id_last_attempt = $rowLA['exe_id']; } } if ($score == 0) { $maxscore = $row['mymaxscore']; } else { if ($row['item_type'] == 'sco') { if (!empty($row['myviewmaxscore']) and $row['myviewmaxscore'] > 0) { $maxscore = $row['myviewmaxscore']; } elseif ($row['myviewmaxscore'] === '') { $maxscore = 0; } else { $maxscore = $row['mymaxscore']; } } else { if ($row['item_type'] == 'quiz') { // Get score and total time from last attempt of a exercise en lp. $sql = "SELECT score FROM $TBL_LP_ITEM_VIEW WHERE c_id = $course_id AND lp_item_id = '" . (int) $my_id . "' AND lp_view_id = '" . (int) $my_lp_view_id . "' ORDER BY view_count DESC limit 1"; $res_score = Database::query($sql); $row_score = Database::fetch_array($res_score); $sql = "SELECT SUM(total_time) as total_time FROM $TBL_LP_ITEM_VIEW WHERE c_id = $course_id AND lp_item_id = '" . (int) $my_id . "' AND lp_view_id = '" . (int) $my_lp_view_id . "'"; $res_time = Database::query($sql); $row_time = Database::fetch_array($res_time); if (Database::num_rows($res_score) > 0 && Database::num_rows($res_time) > 0 ) { $score = (float) $row_score['score']; $subtotal_time = (int) $row_time['total_time']; } else { $score = 0; $subtotal_time = 0; } // Selecting the max score from an attempt. $sql = "SELECT SUM(t.ponderation) as maxscore FROM ( SELECT DISTINCT question_id, marks, ponderation FROM $tbl_stats_attempts as at INNER JOIN $tbl_quiz_questions as q ON (q.id = at.question_id AND q.c_id = $course_id) WHERE exe_id ='$id_last_attempt' ) as t"; $result = Database::query($sql); $row_max_score = Database :: fetch_array($result); $maxscore = $row_max_score['maxscore']; } else { $maxscore = $row['mymaxscore']; } } } $time_for_total = $subtotal_time; $time = learnpathItem::getScormTimeFromParameter('js', $subtotal_time); if (empty($title)) { $title = rl_get_resource_name($courseInfo['code'], $lp_id, $row['myid']); } $action = null; if ($type == 'classic') { $action = '<td></td>'; } if (in_array($row['item_type'], $chapterTypes)) { $title = Security::remove_XSS($title); $output .= '<tr class="'.$oddclass.'"> <td>'.$extend_link.'</td> <td colspan="4"> <h4>'.$title.'</h4> </td> <td colspan="2">'.learnpathitem::humanize_status($lesson_status).'</td> <td colspan="2"></td> <td colspan="2"></td> '.$action.' </tr>'; } else { $correct_test_link = '-'; if ($row['item_type'] == 'quiz') { $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin; $sql = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $user_id . '" AND orig_lp_id = "' . $lp_id . '" AND orig_lp_item_id = "' . $row['myid'] . '" AND exe_cours_id="' . $courseCode. '" AND status <> "incomplete" AND session_id = ' . $session_id . ' ORDER BY exe_date DESC '; $resultLastAttempt = Database::query($sql); $num = Database :: num_rows($resultLastAttempt); if ($num > 0) { if ($extendedAttempt == 1 && $lp_id == $my_lp_id && $lp_item_id == $my_id ) { $correct_test_link = Display::url( Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')), api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id ); } else { $correct_test_link = Display::url( Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')), api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id ); } } } $title = Security::remove_XSS($title); $action = null; if ($type == 'classic') { $action = '<td>' . $correct_test_link . '</td>'; } if ($lp_id == $my_lp_id && false) { $output .= '<tr class =' . $oddclass . '> <td>' . $extend_link . '</td> <td colspan="4">' . $title . '</td> <td colspan="2"> </td> <td colspan="2"> </td> <td colspan="2"> </td> '.$action.' </tr>'; $output .= '</tr>'; } else { if ($lp_id == $my_lp_id && $lp_item_id == $my_id) { $output .= "<tr class='$oddclass'>"; } else { $output .= "<tr class='$oddclass'>"; } /*if (($is_allowed_to_edit || api_is_drh()) && isset($_GET['lp_id']) && isset($course_code)) { $lp = new learnpath($course_code, $_GET['lp_id'], api_get_user_id()); $lp->set_course_int_id($course_id); $item_path_url = $lp->get_link('http', $my_id, false); $item_path_url .= "&width=600"; $title = Display::url($title, $item_path_url, array('class' => 'ajax')); }*/ $scoreItem = null; if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $scoreItem .= Display::return_icon( 'invisible.gif', get_lang('ResultsHiddenByExerciseSetting') ); } else { $scoreItem .= show_score($score, $maxscore, false); } } else { $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore); } $output .= ' <td>'.$extend_link.'</td> <td colspan="4">' . $title . '</td> <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td> <td colspan="2">'.$scoreItem.'</td> <td colspan="2">'.$time.'</td> '.$action.' '; $output .= '</tr>'; } if (!empty($export_csv)) { $temp = array(); $temp[] = api_html_entity_decode($title, ENT_QUOTES); $temp[] = api_html_entity_decode($lesson_status, ENT_QUOTES); if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $temp[] = '/'; } else { $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); } } else { $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); } $temp[] = $time; $csv_content[] = $temp; } } $counter++; $action = null; if ($type == 'classic') { $action = '<td></td>'; } if ($extend_this_attempt OR $extend_all) { $list1 = learnpath :: get_iv_interactions_array($row['iv_id']); foreach ($list1 as $id => $interaction) { if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $output .= '<tr class="'.$oddclass.'"> <td></td> <td></td> <td></td> <td>'.$interaction['order_id'].'</td> <td>'.$interaction['id'].'</td> <td colspan="2">' . $interaction['type'].'</td> <td>'.urldecode($interaction['student_response']).'</td> <td>'.$interaction['result'].'</td> <td>'.$interaction['latency'].'</td> <td>'.$interaction['time'].'</td> '.$action.' </tr>'; $counter++; } $list2 = learnpath :: get_iv_objectives_array($row['iv_id']); foreach ($list2 as $id => $interaction) { if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $output .= '<tr class="'.$oddclass.'"> <td></td> <td></td> <td></td> <td>' . $interaction['order_id'] . '</td> <td colspan="2">'.$interaction['objective_id'] . '</td> <td colspan="2">' . $interaction['status'] . '</td> <td>' . $interaction['score_raw'].'</td> <td>' . $interaction['score_max'] .'</td> <td>' . $interaction['score_min'].'</td> '.$action.' </tr>'; $counter++; } } // Attempts listing by exercise. if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) { // Get attempts of a exercise. if (!empty($lp_id) && !empty($lp_item_id) && $row['item_type'] === 'quiz' ) { $sql = "SELECT path FROM $TBL_LP_ITEM WHERE c_id = $course_id AND id = '$lp_item_id' AND lp_id = '$lp_id'"; $res_path = Database::query($sql); $row_path = Database::fetch_array($res_path); if (Database::num_rows($res_path) > 0) { $sql = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND status <> "incomplete" AND exe_user_id="' . $user_id . '" AND orig_lp_id = "' . (int) $lp_id . '" AND orig_lp_item_id = "' . (int) $lp_item_id . '" AND exe_cours_id="' . $courseCode . '" AND session_id = ' . $session_id . ' ORDER BY exe_date'; $res_attempts = Database::query($sql); $num_attempts = Database::num_rows($res_attempts); if ($num_attempts > 0) { $n = 1; while ($row_attempts = Database :: fetch_array($res_attempts)) { $my_score = $row_attempts['exe_result']; $my_maxscore = $row_attempts['exe_weighting']; $my_exe_id = $row_attempts['exe_id']; $my_orig_lp = $row_attempts['orig_lp_id']; $my_orig_lp_item = $row_attempts['orig_lp_item_id']; $my_exo_exe_id = $row_attempts['exe_exo_id']; $mktime_start_date = api_strtotime($row_attempts['start_date'], 'UTC'); $mktime_exe_date = api_strtotime($row_attempts['exe_date'], 'UTC'); if ($mktime_start_date && $mktime_exe_date) { $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date); $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime); $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp); } else { $time_attemp = ' - '; } if (!$is_allowed_to_edit && $result_disabled_ext_all) { $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { // Show only float when need it if ($my_score == 0) { $view_score = show_score(0, $my_maxscore, false); } else { if ($my_maxscore == 0) { $view_score = $my_score; } else { $view_score = show_score($my_score, $my_maxscore, false); } } } $my_lesson_status = $row_attempts['status']; if ($my_lesson_status == '') { $my_lesson_status = learnpathitem::humanize_status('completed'); } elseif ($my_lesson_status == 'incomplete') { $my_lesson_status = learnpathitem::humanize_status('incomplete'); } $output .= '<tr class="' . $oddclass . '" > <td></td> <td>' . $extend_attempt_link . '</td> <td colspan="3">' . get_lang('Attempt').' '. $n.'</td> <td colspan="2">' . $my_lesson_status . '</td> <td colspan="2">'.$view_score . '</td> <td colspan="2">'.$time_attemp . '</td>'; if ($action == 'classic') { if ($origin != 'tracking') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $output .= '<td> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '"> </td>'; } else { $output .= '<td> <a href="../exercice/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '"> </a></td>'; } } else { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $output .= '<td> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>'; } else { $output .= '<td> <a href="../exercice/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>'; } } } $output .= '</tr>'; $n++; } } $output .= '<tr><td colspan="12"> </td></tr>'; } } } } $total_time += $time_for_total; // QUIZZ IN LP $a_my_id = array(); if (!empty($my_lp_id)) { $a_my_id[] = $my_lp_id; } } } // NOT Extend all "left green cross" if (!empty($a_my_id)) { if ($extendedAttempt) { // "Right green cross" extended $total_score = self::get_avg_student_score( $user_id, $course_id, $a_my_id, $session_id, false, false ); } else { // "Left green cross" extended $total_score = self::get_avg_student_score( $user_id, $course_id, $a_my_id, $session_id, false, true ); } } else { // Extend all "left green cross" $total_score = self::get_avg_student_score( $user_id, $course_id, array($lp_id), $session_id, false, false ); } $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time); $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time); if (!$is_allowed_to_edit && $result_disabled_ext_all) { $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { if (is_numeric($total_score)) { $final_score = $total_score . '%'; } else { $final_score = $total_score; } } $progress = learnpath::getProgress($lp_id, $user_id, $course_id, $session_id); if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $action = null; if ($type == 'classic') { $action = '<td></td>'; } $output .= '<tr class="'.$oddclass.'"> <td></td> <td colspan="4"> <i>' . get_lang('AccomplishedStepsTotal') .'</i> </td> <td colspan="2">'.$progress.'%</td> <td colspan="2"> ' . $final_score.' </td> <td colspan="2">' . $total_time . '</div> '.$action.' </tr>'; $output .= "</table>"; if (!empty($export_csv)) { $temp = array( '', '', '', '' ); $csv_content[] = $temp; $temp = array( get_lang('AccomplishedStepsTotal'), '', $final_score, $total_time ); $csv_content[] = $temp; ob_end_clean(); Export :: export_table_csv($csv_content, 'reporting_learning_path_details'); exit; } return $output; }
} if ($export_csv) { $csv_content = array_merge($csv_header, $csv_content); } foreach ($all_datas as $row) { $table->addRow($row, 'align="right"'); } $table->display(); } } } } // send the csv file if asked if ($export_csv) { ob_end_clean(); Export::export_table_csv($csv_content, 'reporting_index'); exit; } //footer if (!$export_csv) { Display::display_footer(); } /** * Get number of courses for sortable with pagination * @return int */ function get_number_of_courses() { global $courses; return count($courses); }
foreach ($column_names as $col) { $array[0][] = $col; } foreach ($result as $row) { foreach ($columns as $col) { $array[$j][] = strip_tags($row[$col]); } $j++; } switch ($export_format) { case 'xls': Export::export_table_xls($array, 'company_report'); break; case 'csv': default: Export::export_table_csv($array, 'company_report'); break; } exit; } $i = 0; if (!empty($result)) { foreach ($result as $row) { //print_r($row); // if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235 if (!isset($row['id']) || isset($row['id']) && $row['id'] == "") { $response->rows[$i]['id'] = $i; } else { $response->rows[$i]['id'] = $row['id']; } $array = array();
/** * This method is used for thematic control (update, insert or listing) * @param string Action * render to thematic.php */ public function thematic($action) { $courseInfo = api_get_course_info(); $thematic = new Thematic($courseInfo); $data = array(); $error = false; $check = Security::check_token('request'); $thematic_id = isset($_REQUEST['thematic_id']) ? intval($_REQUEST['thematic_id']) : null; if ($check) { switch ($action) { case 'thematic_add': case 'thematic_edit': // insert or update a thematic if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { if (trim($_POST['title']) !== '') { if (api_is_allowed_to_edit(null, true)) { $id = $_POST['thematic_id']; $title = $_POST['title']; $content = $_POST['content']; $session_id = api_get_session_id(); $thematic->set_thematic_attributes($id, $title, $content, $session_id); $last_id = $thematic->thematic_save(); if ($_POST['action'] == 'thematic_add') { $action = 'thematic_details'; $thematic_id = null; if ($last_id) { $data['last_id'] = $last_id; } } else { $action = 'thematic_details'; $thematic_id = null; } } } else { $error = true; $data['error'] = $error; $data['action'] = $_POST['action']; $data['thematic_id'] = $_POST['thematic_id']; // render to the view $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('thematic'); $this->view->render(); } } break; case 'thematic_copy': //Copy a thematic to a session $thematic->copy($thematic_id); $thematic_id = null; $action = 'thematic_details'; break; case 'thematic_delete_select': //Delete many thematics if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { if (api_is_allowed_to_edit(null, true)) { $thematic_ids = $_POST['id']; $affected_rows = $thematic->thematic_destroy($thematic_ids); } $action = 'thematic_details'; } break; case 'thematic_delete': // Delete a thematic if (isset($thematic_id)) { if (api_is_allowed_to_edit(null, true)) { $affected_rows = $thematic->thematic_destroy($thematic_id); } $thematic_id = null; $action = 'thematic_details'; } break; case 'thematic_import_select': break; case 'thematic_import': $csv_import_array = Import::csv_to_array($_FILES['file']['tmp_name'], 'horizontal'); if (isset($_POST['replace']) && $_POST['replace']) { // Remove current thematic. $list = $thematic->get_thematic_list(); foreach ($list as $i) { $thematic->thematic_destroy($i); } } // Import the progress. $current_thematic = null; foreach ($csv_import_array as $data) { foreach ($data as $key => $item) { if ($key == 'title') { $thematic->set_thematic_attributes(null, $item[0], $item[1], api_get_session_id()); $current_thematic = $thematic->thematic_save(); $description_type = 0; } if ($key == 'plan') { $thematic->set_thematic_plan_attributes($current_thematic, $item[0], $item[1], $description_type); $thematic->thematic_plan_save(); $description_type++; } if ($key == 'progress') { $thematic->set_thematic_advance_attributes(null, $current_thematic, 0, $item[2], $item[0], $item[1]); $thematic->thematic_advance_save(); } } } $action = 'thematic_details'; break; case 'thematic_export': $list = $thematic->get_thematic_list(); $csv = array(); foreach ($list as $theme) { $csv[] = array('title', $theme['title'], $theme['content']); $data = $thematic->get_thematic_plan_data($theme['id']); if (!empty($data)) { foreach ($data as $plan) { $csv[] = array('plan', $plan['title'], $plan['description']); } } $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']); if (!empty($data)) { foreach ($data as $advance) { $csv[] = array('progress', $advance['start_date'], $advance['duration'], $advance['content']); } } } Export::export_table_csv($csv); exit; // Don't continue building a normal page. return; case 'thematic_export_pdf': $list = $thematic->get_thematic_list(); $table = array(); $table[] = array(get_lang('Thematic'), get_lang('ThematicPlan'), get_lang('ThematicAdvance')); foreach ($list as $theme) { $data = $thematic->get_thematic_plan_data($theme['id']); $plan_html = null; if (!empty($data)) { foreach ($data as $plan) { $plan_html .= '<strong>' . $plan['title'] . '</strong><br /> ' . $plan['description'] . '<br />'; } } $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']); $advance_html = null; if (!empty($data)) { foreach ($data as $advance) { $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_LONG) . ' (' . $advance['duration'] . ' ' . get_lang('HourShort') . ')<br />' . $advance['content'] . '<br />'; } } $table[] = array($theme['title'], $plan_html, $advance_html); } $params = array('filename' => get_lang('Thematic') . '-' . api_get_local_time(), 'pdf_title' => get_lang('Thematic'), 'add_signatures' => true, 'format' => 'A4-L', 'orientation' => 'L'); Export::export_table_pdf($table, $params); break; case 'moveup': $thematic->move_thematic('up', $thematic_id); $action = 'thematic_details'; $thematic_id = null; break; case 'movedown': $thematic->move_thematic('down', $thematic_id); $action = 'thematic_details'; $thematic_id = null; break; } Security::clear_token(); } else { $action = 'thematic_details'; $thematic_id = null; } if (isset($thematic_id)) { $data['thematic_data'] = $thematic->get_thematic_list($thematic_id); $data['thematic_id'] = $thematic_id; } if ($action == 'thematic_details') { if (isset($thematic_id)) { $thematic_data_result = $thematic->get_thematic_list($thematic_id); if (!empty($thematic_data_result)) { $thematic_data[$thematic_id] = $thematic_data_result; } $data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id); } else { $thematic_data = $thematic->get_thematic_list(null, null, api_get_session_id()); $data['max_thematic_item'] = $thematic->get_max_thematic_item(); $data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance(); $data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances(); } //Second column $thematic_plan_data = $thematic->get_thematic_plan_data(); //Third column $thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true); $data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data); $data['thematic_advance_div'] = $thematic->get_thematic_advance_div($thematic_advance_data); $data['thematic_plan_data'] = $thematic_plan_data; $data['thematic_advance_data'] = $thematic_advance_data; $data['thematic_data'] = $thematic_data; } $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); $data['action'] = $action; // render to the view $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('thematic'); $this->view->render(); }
case 'xls': //TODO add date if exists $file_name = !empty($action) ? $action : 'company_report'; require_once api_get_path(LIBRARY_PATH) . 'browser/Browser.php'; $browser = new Browser(); if ($browser->getPlatform() == Browser::PLATFORM_WINDOWS) { Export::export_table_xls_html($array, $file_name, 'ISO-8859-15'); } else { Export::export_table_xls_html($array, $file_name); } break; case 'csv': default: //TODO add date if exists $file_name = !empty($action) ? $action : 'company_report'; Export::export_table_csv($array, $file_name); break; } exit; } $i = 0; if (!empty($result)) { foreach ($result as $row) { // if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235 if (!isset($row['id']) || isset($row['id']) && $row['id'] == '') { $response->rows[$i]['id'] = $i; } else { $response->rows[$i]['id'] = $row['id']; } $array = array(); foreach ($columns as $col) {
function export_complete_report_csv($filename, $array) { $header[] = array(get_lang('Course'), get_lang('LearningPath'), get_lang('Exercise'), get_lang('User'), get_lang('Attempt'), get_lang('Date'), get_lang('Results')); if (!empty($array)) { $array = array_merge($header, $array); Export::export_table_csv($array, $filename); } exit; /* * Too much encoding problems while exporting to XLS, keep it simple * * global $global, $filter_score; $workbook = new Spreadsheet_Excel_Writer(); $workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH)); $workbook->send($filename); $workbook->setVersion(8); // BIFF8 $worksheet =& $workbook->addWorksheet('Report'); $worksheet->setInputEncoding(api_get_system_encoding()); $line = 0; $column = 0; //skip the first column (row titles) $worksheet->write($line,$column,get_lang('Course')); $column++; $worksheet->write($line,$column,get_lang('LearningPath')); $column++; $worksheet->write($line,$column,get_lang('Exercise')); $column++; $worksheet->write($line,$column,get_lang('User')); $column++; $worksheet->write($line,$column,get_lang('Attempt')); $column++; $worksheet->write($line,$column,get_lang('Date')); $column++; $worksheet->write($line,$column,get_lang('Results')); $column++; $line++; foreach ($array as $row) { $column = 0; foreach ($row as $item) { $worksheet->write($line,$column,html_entity_decode(strip_tags($item))); $column++; } $line++; } $line++; $workbook->close(); exit;*/ }
/** * @param Application $app * @return string */ public function indexAction(Application $app) { $request = $app['request']; $language_file = array('admin', 'exercice', 'gradebook', 'tracking'); // 1. Setting variables needed by jqgrid $action = $request->get('a'); $page = $request->get('page'); //page $limit = $request->get('rows'); //quantity of rows $sidx = $request->get('sidx'); //index (field) to filter $sord = $request->get('sord'); //asc or desc if (strpos(strtolower($sidx), 'asc') !== false) { $sidx = str_replace(array('asc', ','), '', $sidx); $sord = 'asc'; } if (strpos(strtolower($sidx), 'desc') !== false) { $sidx = str_replace(array('desc', ','), '', $sidx); $sord = 'desc'; } if (!in_array($sord, array('asc', 'desc'))) { $sord = 'desc'; } if (!in_array($action, array('get_exercise_results', 'get_hotpotatoes_exercise_results', 'get_work_user_list', 'get_timelines', 'get_user_skill_ranking', 'get_usergroups_teacher', 'get_question_list', 'get_user_list_plugin_widescale'))) { api_protect_admin_script(true); } if ($action == 'get_user_list_plugin_widescale') { $allowed = api_is_drh() || api_is_platform_admin(); if (!$allowed) { api_not_allowed(); } } // Search features. // If there is no search request sent by jqgrid, $where should be empty. $where_condition = ""; $operation = $request->get('oper'); $export_format = $request->get('export_format'); $search_field = $request->get('searchField'); $search_oper = $request->get('searchOper'); $search_string = $request->get('searchString'); $isSearch = $request->get('_search'); $filters = $request->get('filters'); $type = $request->get('type'); $extra_fields = array(); $questionFields = array(); if ($isSearch == 'true') { $where_condition = ' 1 = 1 '; $where_condition_in_form = $this->getWhereClause($search_field, $search_oper, $search_string); if (!empty($where_condition_in_form)) { $where_condition .= ' AND ' . $where_condition_in_form; } $filters = isset($filters) ? json_decode($filters) : false; // for now if (!empty($filters)) { switch ($action) { case 'get_questions': $extraFieldtype = 'question'; break; case 'get_sessions': $extraFieldtype = 'session'; break; } // Extra field. $extraField = new \ExtraField($extraFieldtype); $result = $extraField->getExtraFieldRules($filters, 'extra_'); $extra_fields = $result['extra_fields']; $condition_array = $result['condition_array']; if (!empty($condition_array)) { $where_condition .= ' AND ( '; $where_condition .= implode($filters->groupOp, $condition_array); $where_condition .= ' ) '; } // Question field. $resultQuestion = $extraField->getExtraFieldRules($filters, 'question_'); $questionFields = $resultQuestion['extra_fields']; $condition_array = $resultQuestion['condition_array']; if (!empty($condition_array)) { $where_condition .= ' AND ( '; $where_condition .= implode($filters->groupOp, $condition_array); $where_condition .= ' ) '; } } } // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if (!$sidx) { $sidx = 1; } //2. Selecting the count FIRST //@todo rework this switch ($action) { case 'get_questions': $categoryId = $request->get('categoryId'); $exerciseId = $request->get('exerciseId'); //$courseId = null; //$request->get('courseId'); $courseId = $request->get('courseId'); // Question manager can view all questions if (api_is_question_manager()) { $courseId = null; } $count = \Question::getQuestions($app, $categoryId, $exerciseId, $courseId, array('where' => $where_condition, 'extra' => $extra_fields, 'question' => $questionFields), true); break; case 'get_user_list_plugin_widescale': $count = \UserManager::get_user_data(null, null, null, null, true); break; case 'get_question_list': require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php'; $exerciseId = $request->get('exerciseId'); $exercise = new \Exercise(api_get_course_int_id()); $exercise->read($exerciseId); $count = $exercise->selectNbrQuestions(); break; case 'get_group_reporting': $course_id = $request->get('course_id'); $group_id = $request->get('gidReq'); $count = \Tracking::get_group_reporting($course_id, $group_id, 'count'); break; case 'get_user_course_report_resumed': $count = \CourseManager::get_count_user_list_from_course_code(true, 'ruc'); break; case 'get_user_course_report': $count = \CourseManager::get_count_user_list_from_course_code(false); break; case 'get_course_exercise_medias': $course_id = api_get_course_int_id(); $count = \Question::get_count_course_medias($course_id); break; case 'get_user_skill_ranking': $skill = new \Skill(); $count = $skill->get_user_list_skill_ranking_count(); break; case 'get_work_user_list': require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; $work_id = $request->get('work_id'); //$_REQUEST['work_id']; $count = get_count_work($work_id); break; case 'get_exercise_results': $exercise_id = $request->get('exerciseId'); //$_REQUEST['exerciseId']; $filter_by_user = $request->get('filter_by_user'); if (isset($filter_by_user) && !empty($filter_by_user)) { $filter_user = intval($filter_by_user); if ($where_condition == "") { $where_condition .= " te.exe_user_id = '{$filter_user}'"; } else { $where_condition .= " AND te.exe_user_id = '{$filter_user}'"; } } $count = \ExerciseLib::get_count_exam_results($exercise_id, $where_condition); break; case 'get_hotpotatoes_exercise_results': $hotpot_path = $request->get('path'); //$_REQUEST['path']; $count = \ExerciseLib::get_count_exam_hotpotatoes_results($hotpot_path); break; case 'get_sessions': $list_type = $request->get('list_type'); if ($list_type == 'simple' || empty($list_type)) { $count = \SessionManager::get_sessions_admin(array('where' => $where_condition, 'extra' => $extra_fields), true); } else { $count = \SessionManager::get_count_admin_complete(array('where' => $where_condition, 'extra' => $extra_fields)); } break; case 'get_extra_fields': $obj = new \ExtraField($type); $count = $obj->get_count(); break; case 'get_extra_field_options': $field_id = $request->get('field_id'); $obj = new \ExtraFieldOption($type); $count = $obj->get_count_by_field_id($field_id); break; case 'get_timelines': $obj = new \Timeline(); $count = $obj->get_count(); break; case 'get_gradebooks': $obj = new \Gradebook(); $count = $obj->get_count(); break; case 'get_event_email_template': $obj = new \EventEmailTemplate(); $count = $obj->get_count(); break; case 'get_careers': $obj = new \Career(); $count = $obj->get_count(); break; case 'get_promotions': $obj = new \Promotion(); $count = $obj->get_count(); break; case 'get_grade_models': $obj = new \GradeModel(); $count = $obj->get_count(); break; case 'get_usergroups': $obj = new \UserGroup(); $count = $obj->get_count(); break; case 'get_usergroups_teacher': $obj = new \UserGroup(); $course_id = api_get_course_int_id(); if ($type == 'registered') { $count = $obj->get_usergroup_by_course_with_data_count($course_id); } else { $count = $obj->get_count(); } break; default: exit; } //3. Calculating first, end, etc $total_pages = 0; if ((int) $count > 0) { if (!empty($limit)) { $total_pages = ceil($count / $limit); } } if ($page > $total_pages) { $page = $total_pages; } $start = $limit * $page - $limit; if ($start < 0) { $start = 0; } //4. Deleting an element if the user wants to if ($operation == 'del') { $obj->delete($request->get('id')); } $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh(); //5. Querying the DB for the elements $columns = array(); switch ($action) { case 'get_questions': $columns = \Question::getQuestionColumns(api_get_course_id(), $extra_fields, $questionFields, true); $columns = $columns['simple_column_name']; $result = \Question::getQuestions($app, $categoryId, $exerciseId, $courseId, array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'question' => $questionFields, 'limit' => "{$start} , {$limit}")); //var_dump($result); break; case 'get_user_list_plugin_widescale': $columns = array('username', 'firstname', 'lastname', 'exam_password'); $column_names = array(get_lang('Username'), get_lang('Firstname'), get_lang('Lastname'), get_lang('Password')); $result = \UserManager::get_user_data($start, $limit, $sidx, $sord); break; case 'get_question_list': if (isset($exercise) && !empty($exercise)) { $columns = array('question', 'type', 'category', 'level', 'score', 'actions'); $result = $exercise->getQuestionListPagination($start, $limit, $sidx, $sord, $where_condition); } break; case 'get_group_reporting': $columns = array('name', 'time', 'progress', 'score', 'works', 'messages', 'actions'); $result = \Tracking::get_group_reporting($course_id, $group_id, 'all', $start, $limit, $sidx, $sord, $where_condition); break; case 'get_course_exercise_medias': $columns = array('question'); $result = \Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $where_condition); if (!empty($result)) { foreach ($result as &$media) { $media['id'] = $media['iid']; } } break; case 'get_user_course_report_resumed': $columns = array('extra_ruc', 'training_hours', 'count_users', 'count_users_registered', 'average_hours_per_user', 'count_certificates'); $column_names = array(get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscriptions'), get_lang('CountOfUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates')); $result = \CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", " {$sidx} {$sord}", null, null, true, true, 'ruc'); $new_result = array(); if (!empty($result)) { foreach ($result as $row) { $row['training_hours'] = api_time_to_hms($row['training_hours']); $row['average_hours_per_user'] = api_time_to_hms($row['average_hours_per_user']); $new_result[] = $row; } $result = $new_result; } break; case 'get_user_course_report': $columns = array('course', 'user', 'time', 'certificate', 'progress_100', 'progress'); $column_names = array(get_lang('Course'), get_lang('User'), get_lang('ManHours'), get_lang('CertificateGenerated'), get_lang('Approved'), get_lang('CourseAdvance')); $extra_fields = \UserManager::get_extra_fields(0, 100, null, null, true, true); if (!empty($extra_fields)) { foreach ($extra_fields as $extra) { $columns[] = $extra['1']; $column_names[] = $extra['3']; } } $result = \CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", " {$sidx} {$sord}", null, null, true); break; case 'get_user_skill_ranking': $columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank'); $result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $where_condition); $result = \ArrayClass::msort($result, 'skills_acquired', 'asc'); $skills_in_course = array(); if (!empty($result)) { //$counter = 1; foreach ($result as &$item) { $user_info = api_get_user_info($item['user_id']); $personal_course_list = \UserManager::get_personal_session_course_list($item['user_id']); $count_skill_by_course = array(); foreach ($personal_course_list as $course_item) { if (!isset($skills_in_course[$course_item['code']])) { $count_skill_by_course[$course_item['code']] = $skill->get_count_skills_by_course($course_item['code']); $skills_in_course[$course_item['code']] = $count_skill_by_course[$course_item['code']]; } else { $count_skill_by_course[$course_item['code']] = $skills_in_course[$course_item['code']]; } } $item['photo'] = \Display::img($user_info['avatar_small']); $item['currently_learning'] = !empty($count_skill_by_course) ? array_sum($count_skill_by_course) : 0; } } break; case 'get_work_user_list': if (isset($type) && $type == 'simple') { $columns = array('type', 'firstname', 'lastname', 'username', 'title', 'qualification', 'sent_date', 'qualificator_id', 'actions'); } else { $columns = array('type', 'firstname', 'lastname', 'username', 'title', 'sent_date', 'actions'); } $result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition); break; case 'get_exercise_results': $course = api_get_course_info(); //used inside get_exam_results_data() $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; if ($is_allowedToEdit) { $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions'); } else { //$columns = array('exe_duration', 'start_date', 'exe_date', 'score', 'status', 'actions'); } $result = \ExerciseLib::get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition); break; case 'get_hotpotatoes_exercise_results': $course = api_get_course_info(); //used inside get_exam_results_data() $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date', 'score', 'actions'); $result = ExerciseLib::get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $where_condition); //get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition); break; case 'get_sessions': $session_columns = \SessionManager::get_session_columns($list_type); $columns = $session_columns['simple_column_name']; if ($list_type == 'simple') { $result = SessionManager::get_sessions_admin(array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'limit' => "{$start} , {$limit}"), false); } else { $result = SessionManager::get_sessions_admin_complete(array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'limit' => "{$start} , {$limit}")); } break; case 'get_timelines': $columns = array('headline', 'actions'); //$columns = array('headline', 'type', 'start_date', 'end_date', 'text', 'media', 'media_credit', 'media_caption', 'title_slide', 'parent_id'); if (!in_array($sidx, $columns)) { $sidx = 'headline'; } $course_id = api_get_course_int_id(); $result = Database::select('*', $obj->table, array('where' => array('parent_id = ? AND c_id = ?' => array('0', $course_id)), 'order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if (!$item['status']) { $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>'; } $item['headline'] = Display::url($item['headline'], api_get_path(WEB_CODE_PATH) . 'timeline/view.php?id=' . $item['id']); $item['actions'] = Display::url(Display::return_icon('add.png', get_lang('AddItems')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=add_item&parent_id=' . $item['id']); $item['actions'] .= Display::url(Display::return_icon('edit.png', get_lang('Edit')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=edit&id=' . $item['id']); $item['actions'] .= Display::url(Display::return_icon('delete.png', get_lang('Delete')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=delete&id=' . $item['id']); $new_result[] = $item; } $result = $new_result; break; case 'get_gradebooks': $columns = array('name', 'certificates', 'skills', 'actions', 'has_certificates'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if ($item['parent_id'] != 0) { continue; } $skills = $obj->get_skills_by_gradebook($item['id']); //Fixes bug when gradebook doesn't have names if (empty($item['name'])) { $item['name'] = $item['course_code']; } else { //$item['name'] = $item['name'].' ['.$item['course_code'].']'; } $item['name'] = Display::url($item['name'], api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?id_session=0&cidReq=' . $item['course_code']); if (!empty($item['certif_min_score']) && !empty($item['document_id'])) { $item['certificates'] = Display::return_icon('accept.png', get_lang('WithCertificate'), array(), ICON_SIZE_SMALL); $item['has_certificates'] = '1'; } else { $item['certificates'] = Display::return_icon('warning.png', get_lang('NoCertificate'), array(), ICON_SIZE_SMALL); $item['has_certificates'] = '0'; } if (!empty($skills)) { foreach ($skills as $skill) { $item['skills'] .= Display::span($skill['name'], array('class' => 'label_tag skill')); } } $new_result[] = $item; } $result = $new_result; break; case 'get_event_email_template': $columns = array('subject', 'event_type_name', 'language_id', 'activated', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'subject'; } $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { $language_info = api_get_language_info($item['language_id']); $item['language_id'] = $language_info['english_name']; $item['actions'] = Display::url(Display::return_icon('edit.png', get_lang('Edit')), api_get_path(WEB_CODE_PATH) . 'admin/event_type.php?action=edit&event_type_name=' . $item['event_type_name']); $item['actions'] .= Display::url(Display::return_icon('delete.png', get_lang('Delete')), api_get_path(WEB_CODE_PATH) . 'admin/event_controller.php?action=delete&id=' . $item['id']); /*if (!$item['status']) { $item['name'] = '<font style="color:#AAA">'.$item['subject'].'</font>'; }*/ $new_result[] = $item; } $result = $new_result; break; case 'get_careers': $columns = array('name', 'description', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if (!$item['status']) { $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>'; } $new_result[] = $item; } $result = $new_result; break; case 'get_promotions': $columns = array('name', 'career', 'description', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('p.id,p.name, p.description, c.name as career, p.status', "{$obj->table} p LEFT JOIN " . Database::get_main_table(TABLE_CAREER) . " c ON c.id = p.career_id ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if (!$item['status']) { $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>'; } $new_result[] = $item; } $result = $new_result; break; case 'get_grade_models': $columns = array('name', 'description', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('*', "{$obj->table} ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { $new_result[] = $item; } $result = $new_result; break; case 'get_usergroups': $columns = array('name', 'users', 'courses', 'sessions', 'group_type', 'actions'); $result = Database::select('*', $obj->table, array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); if (!empty($result)) { foreach ($result as $group) { $group['sessions'] = count($obj->get_sessions_by_usergroup($group['id'])); $group['courses'] = count($obj->get_courses_by_usergroup($group['id'])); $group['users'] = count($obj->get_users_by_usergroup($group['id'])); switch ($group['group_type']) { case '0': $group['group_type'] = Display::label(get_lang('Class'), 'info'); break; case '1': $group['group_type'] = Display::label(get_lang('Social'), 'success'); break; } $new_result[] = $group; } $result = $new_result; } $columns = array('name', 'users', 'courses', 'sessions', 'group_type'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } //Multidimensional sort ArrayClass::msort($result, $sidx); break; case 'get_extra_fields': $obj = new \ExtraField($type); $columns = array('field_display_text', 'field_variable', 'field_type', 'field_changeable', 'field_visible', 'field_filter', 'field_order'); $result = \Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); if (!empty($result)) { foreach ($result as $item) { $item['field_type'] = $obj->get_field_type_by_id($item['field_type']); $item['field_changeable'] = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_visible'] = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_filter'] = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $new_result[] = $item; } $result = $new_result; } break; case 'get_extra_field_options': $obj = new \ExtraFieldOption($type); $columns = array('option_display_text', 'option_value', 'option_order'); $result = \Database::select('*', $obj->table, array('where' => array("field_id = ? " => $field_id), 'order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); /*$new_result = array(); if (!empty($result)) { foreach ($result as $item) { $item['field_type'] = $obj->get_field_type_by_id($item['field_type']); $item['field_changeable'] = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_visible'] = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_filter'] = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $new_result[] = $item; } $result = $new_result; }*/ break; case 'get_usergroups_teacher': $columns = array('name', 'users', 'actions'); $options = array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}"); $options['course_id'] = $course_id; switch ($type) { case 'not_registered': $options['where'] = array(" (course_id IS NULL OR course_id != ?) " => $course_id); $result = $obj->get_usergroup_not_in_course($options); break; case 'registered': $options['where'] = array(" usergroup.course_id = ? " => $course_id); $result = $obj->get_usergroup_in_course($options); break; } $new_result = array(); if (!empty($result)) { foreach ($result as $group) { $group['users'] = count($obj->get_users_by_usergroup($group['id'])); if ($obj->usergroup_was_added_in_course($group['id'], $course_id)) { $url = 'class.php?action=remove_class_from_course&id=' . $group['id']; $icon = Display::return_icon('delete.png', get_lang('Remove')); } else { $url = 'class.php?action=add_class_to_course&id=' . $group['id']; $icon = Display::return_icon('add.png', get_lang('Add')); } $group['actions'] = Display::url($icon, $url); $new_result[] = $group; } $result = $new_result; } if (!in_array($sidx, $columns)) { $sidx = 'name'; } //Multidimensional sort \ArrayClass::msort($result, $sidx); break; default: exit; } $allowed_actions = array('get_careers', 'get_promotions', 'get_usergroups', 'get_usergroups_teacher', 'get_gradebooks', 'get_sessions', 'get_exercise_results', 'get_hotpotatoes_exercise_results', 'get_work_user_list', 'get_timelines', 'get_grade_models', 'get_event_email_template', 'get_user_skill_ranking', 'get_extra_fields', 'get_extra_field_options', 'get_course_exercise_medias', 'get_user_course_report', 'get_user_course_report_resumed', 'get_group_reporting', 'get_question_list', 'get_user_list_plugin_widescale', 'get_questions'); //5. Creating an obj to return a json if (in_array($action, $allowed_actions)) { $response = new \stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $count; if ($operation && $operation == 'excel') { $j = 1; $array = array(); if (empty($column_names)) { $column_names = $columns; } //Headers foreach ($column_names as $col) { $array[0][] = $col; } foreach ($result as $row) { foreach ($columns as $col) { $array[$j][] = strip_tags($row[$col]); } $j++; } switch ($export_format) { case 'xls': Export::export_table_xls($array, 'company_report'); break; case 'csv': default: Export::export_table_csv($array, 'company_report'); break; } exit; } $i = 0; if (!empty($result)) { foreach ($result as $row) { //print_r($row); // if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235 if (!isset($row['id']) || isset($row['id']) && $row['id'] == "") { $response->rows[$i]['id'] = $i; } else { $response->rows[$i]['id'] = $row['id']; } $array = array(); foreach ($columns as $col) { $array[] = isset($row[$col]) ? $row[$col] : null; } $response->rows[$i]['cell'] = $array; $i++; } } return json_encode($response); } }
$user['phone'] ); } $a_users[] = $user_pdf; } else { $a_users[] = $user; } $data[] = $user; $counter++; } } switch ($_GET['type']) { case 'csv' : Export::export_table_csv($a_users); exit; case 'xls' : Export::export_table_xls($a_users); exit; case 'pdf' : $header_attributes = array( array('style' => 'width:10px'), array('style' => 'width:30px'), array('style' => 'width:50px'), array('style' => 'width:500px'), ); $params = array( 'add_signatures' => false, 'filename' => get_lang('UserList'),
/** * This function exports the table that we see in display_tracking_user_overview() * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version Dokeos 1.8.6 * @since October 2008 */ public static function export_tracking_user_overview() { // database table definitions $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT); $sort_by_first_name = api_sort_by_first_name(); // the values of the sortable table if ($_GET['tracking_user_overview_page_nr']) { $from = $_GET['tracking_user_overview_page_nr']; } else { $from = 0; } if ($_GET['tracking_user_overview_column']) { $orderby = $_GET['tracking_user_overview_column']; } else { $orderby = 0; } if ($is_western_name_order != api_is_western_name_order() && ($orderby == 1 || $orderby == 2)) { // Swapping the sorting column if name order for export is different than the common name order. $orderby = 3 - $orderby; } if ($_GET['tracking_user_overview_direction']) { $direction = $_GET['tracking_user_overview_direction']; } else { $direction = 'ASC'; } $user_data = MySpace::get_user_data_tracking_overview($from, 1000, $orderby, $direction); // the first line of the csv file with the column headers $csv_row = array(); $csv_row[] = get_lang('OfficialCode'); if ($is_western_name_order) { $csv_row[] = get_lang('FirstName', ''); $csv_row[] = get_lang('LastName', ''); } else { $csv_row[] = get_lang('LastName', ''); $csv_row[] = get_lang('FirstName', ''); } $csv_row[] = get_lang('LoginName'); $csv_row[] = get_lang('CourseCode'); // the additional user defined fields (only those that were selected to be exported) $fields = UserManager::get_extra_fields(0, 50, 5, 'ASC'); if (is_array($_SESSION['additional_export_fields'])) { foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) { $csv_row[] = $fields[$extra_field_export][3]; $field_names_to_be_exported[] = 'extra_'.$fields[$extra_field_export][1]; } } $csv_row[] = get_lang('AvgTimeSpentInTheCourse', ''); $csv_row[] = get_lang('AvgStudentsProgress', ''); $csv_row[] = get_lang('AvgCourseScore', ''); $csv_row[] = get_lang('AvgExercisesScore', ''); $csv_row[] = get_lang('AvgMessages', ''); $csv_row[] = get_lang('AvgAssignments', ''); $csv_row[] = get_lang('TotalExercisesScoreObtained', ''); $csv_row[] = get_lang('TotalExercisesScorePossible', ''); $csv_row[] = get_lang('TotalExercisesAnswered', ''); $csv_row[] = get_lang('TotalExercisesScorePercentage', ''); $csv_row[] = get_lang('FirstLogin', ''); $csv_row[] = get_lang('LatestLogin', ''); $csv_content[] = $csv_row; // the other lines (the data) foreach ($user_data as $key => $user) { // getting all the courses of the user $sql = "SELECT * FROM $tbl_course_user WHERE user_id = '".intval($user[4])."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." "; $result = Database::query($sql); while ($row = Database::fetch_row($result)) { $csv_row = array(); // user official code $csv_row[] = $user[0]; // user first|last name $csv_row[] = $user[1]; // user last|first name $csv_row[] = $user[2]; // user login name $csv_row[] = $user[3]; // course code $csv_row[] = $row[0]; // the additional defined user fields $extra_fields = MySpace::get_user_overview_export_extra_fields($user[4]); if (is_array($field_names_to_be_exported)) { foreach ($field_names_to_be_exported as $key => $extra_field_export) { $csv_row[] = $extra_fields[$extra_field_export]; } } // time spent in the course $csv_row[] = api_time_to_hms(Tracking :: get_time_spent_on_the_course ($user[4], $row[0])); // student progress in course $csv_row[] = round(Tracking :: get_avg_student_progress ($user[4], $row[0]), 2); // student score $csv_row[] = round(Tracking :: get_avg_student_score ($user[4], $row[0]), 2); // student tes score $csv_row[] = round(Tracking :: get_avg_student_exercise_score ($user[4], $row[0]), 2); // student messages $csv_row[] = Tracking :: count_student_messages ($user[4], $row[0]); // student assignments $csv_row[] = Tracking :: count_student_assignments ($user[4], $row[0]); // student exercises results $exercises_results = MySpace::exercises_results($user[4], $row[0]); $csv_row[] = $exercises_results['score_obtained']; $csv_row[] = $exercises_results['score_possible']; $csv_row[] = $exercises_results['questions_answered']; $csv_row[] = $exercises_results['percentage']; // first connection $csv_row[] = Tracking :: get_first_connection_date_on_the_course ($user[4], $row[0]); // last connection $csv_row[] = strip_tags(Tracking :: get_last_connection_date_on_the_course ($user[4], $row[0])); $csv_content[] = $csv_row; } } Export :: export_table_csv($csv_content, 'reporting_user_overview'); exit; }
$temp = array(get_lang('LinksMostClicked'), ''); $csv_content[] = array('', ''); $csv_content[] = $temp; } if (!empty($links_most_visited)) { foreach ($links_most_visited as $row) { echo ' <tr> <td>' . Display::url($row['title'] . ' (' . $row['url'] . ')', $row['url']) . '</td> <td align="right">' . $row['count_visits'] . ' ' . get_lang('Clicks') . '</td> </tr>'; if ($export_csv) { $temp = array($row['title'], $row['count_visits'] . ' ' . get_lang('Clicks', '')); $csv_content[] = $temp; } } } else { echo '<tr><td>' . get_lang('NoLinkVisited') . '</td></tr>'; if ($export_csv) { $temp = array(get_lang('NoLinkVisited'), ''); $csv_content[] = $temp; } } echo '</table></div>'; echo '<div class="clear"></div>'; // send the csv file if asked if ($export_csv) { ob_end_clean(); Export::export_table_csv($csv_content, 'reporting_course_tools'); exit; } Display::display_footer();
} //if (empty($extend_all)) { $output .= '<tr class="' . $oddclass . '"> <td></td> <td colspan="4"> <i>' . get_lang('AccomplishedStepsTotal') . '</i> </td> <td colspan="2"></td> <td colspan="2"> ' . $final_score . ' </td> <td colspan="2">' . $total_time . '</div><td></td> </tr>'; //} $output .= "</table>"; if (!empty($export_csv)) { $temp = array('', '', '', ''); $csv_content[] = $temp; $temp = array(get_lang('AccomplishedStepsTotal'), '', $final_score, $total_time); $csv_content[] = $temp; ob_end_clean(); Export::export_table_csv($csv_content, 'reporting_learning_path_details'); exit; } if ($origin != 'tracking') { $output .= "</body></html>"; } if (empty($export_csv)) { echo $output; } Display::display_footer();
} } $form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH).'mySpace/teachers.php'); $form = Tracking::setUserSearchForm($form); $form->setDefaults($params); if ($export_csv) { // send the csv file if asked $content = $table->return_table(); foreach ($content as &$row) { unset($row[4]); } $csv_content = array_merge($csv_header, $content); ob_end_clean(); Export :: export_table_csv($csv_content, 'reporting_teacher_list'); exit; } else { Display::display_header($nameTools); echo $actions; $page_title = get_lang('Teachers'); echo Display::page_subheader($page_title); if (isset($active)) { if ($active) { $activeLabel = get_lang('ActiveUsers'); } else { $activeLabel = get_lang('InactiveUsers'); } echo Display::page_subheader2($activeLabel); } $form->display();
/** * This function exports the table that we see in display_tracking_user_overview() * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version Dokeos 1.8.6 * @since October 2008 */ function export_tracking_user_overview() { // database table definitions $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); // the values of the sortable table if ($_GET['tracking_user_overview_page_nr']) { $from = $_GET['tracking_user_overview_page_nr']; } else { $from = 0; } if ($_GET['tracking_user_overview_column']) { $orderby = $_GET['tracking_user_overview_column']; } else { $orderby = 0; } if ($_GET['tracking_user_overview_direction']) { $direction = $_GET['tracking_user_overview_direction']; } else { $direction = 'ASC'; } $user_data = get_user_data_tracking_overview($from, 1000, $orderby, $direction); // the first line of the csv file with the column headers $csv_row = array(); $csv_row[] = get_lang('OfficialCode'); $csv_row[] = get_lang('LastName'); $csv_row[] = get_lang('FirstName'); $csv_row[] = get_lang('LoginName'); $csv_row[] = get_lang('CourseCode'); // the additional user defined fields (only those that were selected to be exported) require_once api_get_path(LIBRARY_PATH) . 'usermanager.lib.php'; $fields = UserManager::get_extra_fields(0, 50, 5, 'ASC'); foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) { $csv_row[] = $fields[$extra_field_export][3]; $field_names_to_be_exported[] = 'extra_' . $fields[$extra_field_export][1]; } $csv_row[] = get_lang('AvgTimeSpentInTheCourse'); $csv_row[] = get_lang('AvgStudentsProgress'); $csv_row[] = get_lang('AvgCourseScore'); $csv_row[] = get_lang('AvgExercisesScore'); $csv_row[] = get_lang('AvgMessages'); $csv_row[] = get_lang('AvgAssignments'); $csv_row[] = get_lang('TotalExercisesScoreObtained'); $csv_row[] = get_lang('TotalExercisesScorePossible'); $csv_row[] = get_lang('TotalExercisesAnswered'); $csv_row[] = get_lang('TotalExercisesScorePercentage'); $csv_row[] = get_lang('FirstLogin'); $csv_row[] = get_lang('LatestLogin'); $csv_content[] = $csv_row; // the other lines (the data) foreach ($user_data as $key => $user) { // getting all the courses of the user $sql = "SELECT * FROM {$tbl_course_user} WHERE user_id = '" . Database::escape_string($user[4]) . "'"; $result = api_sql_query($sql, __FILE__, __LINE__); while ($row = Database::fetch_row($result)) { $csv_row = array(); // user official code $csv_row[] = $user[0]; // user last name $csv_row[] = $user[1]; // user first name $csv_row[] = $user[2]; // user login name $csv_row[] = $user[3]; // course code $csv_row[] = $row[0]; // the additional defined user fields $extra_fields = get_user_overview_export_extra_fields($user[4]); foreach ($field_names_to_be_exported as $key => $extra_field_export) { $csv_row[] = $extra_fields[$extra_field_export]; } // time spent in the course $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user[4], $row[0])); // student progress in course $csv_row[] = round(Tracking::get_avg_student_progress($user[4], $row[0]), 2); // student score $csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2); // student tes score $csv_row[] = round(Tracking::get_avg_student_exercise_score($user[4], $row[0]), 2); // student messages $csv_row[] = Tracking::count_student_messages($user[4], $row[0]); // student assignments $csv_row[] = Tracking::count_student_assignments($user[4], $row[0]); // student exercises results $exercises_results = exercises_results($user[4], $row[0]); $csv_row[] = $exercises_results['score_obtained']; $csv_row[] = $exercises_results['score_possible']; $csv_row[] = $exercises_results['questions_answered']; $csv_row[] = $exercises_results['percentage']; // first connection $csv_row[] = Tracking::get_first_connection_date_on_the_course($user[4], $row[0]); // last connection $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $row[0])); $csv_content[] = $csv_row; } } Export::export_table_csv($csv_content, 'reporting_user_overview'); }