Exemplo n.º 1
0
     switch ($exportFormat) {
         case 'xls':
             //TODO add date if exists
             $file_name = !empty($action) ? $action : 'company_report';
             $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::arrayToCsv($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) {
Exemplo n.º 2
0
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'unsubscribe':
            if (CourseManager::get_user_in_course_status($_GET['user_id'], $_GET['course_code']) == STUDENT) {
                CourseManager::unsubscribe_user($_GET['user_id'], $_GET['course_code'], $_GET['id_session']);
                $message = Display::return_message(get_lang('UserUnsubscribed'));
            } else {
                $message = Display::return_message(get_lang('CannotUnsubscribeUserFromCourse'), 'error');
            }
            break;
        case 'unsubscribeSessionCourse':
            SessionManager::removeUsersFromCourseSession(array($_GET['user_id']), $_GET['id_session'], api_get_course_info($_GET['course_code']));
            $message = Display::return_message(get_lang('UserUnsubscribed'));
            break;
        case 'export':
            Export::arrayToCsv($csvContent, 'user_information_' . $user);
            exit;
            break;
    }
}
Display::display_header($tool_name);
echo '<div class="actions">
        <a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . intval($_GET['user_id']) . '" title="' . get_lang('Reporting') . '">' . Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM) . '
        </a>
        ' . $login_as_icon . '
        ' . $editUser . '
        ' . $exportLink . '
    </div>';
echo Display::page_header($tool_name);
$fullUrlBig = Usermanager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_BIG);
$fullUrl = Usermanager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_ORIGINAL);
Exemplo n.º 3
0
            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::arrayToCsv($data);
                    exit;
                    break;
                case 'xls':
                    if (!empty($data)) {
                        Export::arrayToXls($data);
                        exit;
                    }
                    break;
            }
            break;
    }
}
/*	Header */
$interbreadcrumb[] = array('url' => 'group.php?' . api_get_cidReq(), 'name' => get_lang('Groups'));
if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') {
Exemplo n.º 4
0
    } else {
        $csv_header[] = array(get_lang('LastName'), get_lang('FirstName'), get_lang('FirstLogin'), get_lang('LastConnexion'));
    }
}
$form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH) . 'mySpace/student.php');
$form = Tracking::setUserSearchForm($form);
$form->setDefaults($params);
if ($export_csv) {
    // send the csv file if asked
    $content = $table->get_table_data();
    foreach ($content as &$row) {
        unset($row[4]);
    }
    $csv_content = array_merge($csv_header, $content);
    ob_end_clean();
    Export::arrayToCsv($csv_content, 'reporting_student_list');
    exit;
} else {
    Display::display_header($nameTools);
    echo $actions;
    $page_title = get_lang('Students');
    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();
Exemplo n.º 5
0
 /**
  * @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
  * @param boolean $allowExtend Optional. Allow or not extend te results
  * @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', $allowExtend = true)
 {
     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 .= '<div class="section-status">';
         $output .= Display::page_header(get_lang('ScormMystatus'));
         $output .= '</div>';
     }
     $actionColumn = null;
     if ($type == 'classic') {
         $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
     }
     $output .= '<div class="table-responsive">';
     $output .= '<table class="table tracking">
         <thead>
         <tr class="table-header">
             <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</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>
         </thead>
         <tbody>
     ';
     // 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_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     $tbl_stats_attempts = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
     $sql = "SELECT max(view_count)\n                FROM {$TBL_LP_VIEW}\n                WHERE\n                    c_id = {$course_id} AND\n                    lp_id = {$lp_id} AND\n                    user_id = {$user_id}\n                    {$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\n                    iv.status as mystatus,\n                    v.view_count as mycount,\n                    iv.score as myscore,\n                    iv.total_time as mytime,\n                    i.id as myid,\n                    i.lp_id as mylpid,\n                    iv.lp_view_id as mylpviewid,\n                    i.title as mytitle,\n                    i.max_score as mymaxscore,\n                    iv.max_score as myviewmaxscore,\n                    i.item_type as item_type,\n                    iv.view_count as iv_view_count,\n                    iv.id as iv_id,\n                    path\n                FROM {$TBL_LP_ITEM} as i\n                INNER JOIN {$TBL_LP_ITEM_VIEW} as iv\n                ON (i.id = iv.lp_item_id AND i.c_id = iv.c_id)\n                INNER JOIN {$TBL_LP_VIEW} as v\n                ON (iv.lp_view_id = v.id AND v.c_id = iv.c_id)\n                WHERE\n                    v.c_id = {$course_id} AND\n                    i.id = {$my_item_id} AND\n                    i.lp_id = {$lp_id}  AND\n                    v.user_id = {$user_id} AND\n                    v.session_id = {$session_id}\n                    {$viewCondition}\n                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\n                                FROM {$TBL_QUIZ}\n                                WHERE\n                                    c_id = {$course_id} AND\n                                    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 = ExerciseLib::show_score($score, $maxscore, false);
                                     }
                                     break;
                                 case 'document':
                                     $view_score = $score == 0 ? '/' : ExerciseLib::show_score($score, $maxscore, false);
                                     break;
                                 default:
                                     $view_score = ExerciseLib::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 || $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\n                                FROM {$TBL_QUIZ}\n                                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
                             c_id = ' . $course_id . ' 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\n                                        FROM {$TBL_LP_ITEM_VIEW}\n                                        WHERE\n                                            c_id = {$course_id} AND\n                                            lp_item_id = '" . (int) $my_id . "' AND\n                                            lp_view_id = '" . (int) $my_lp_view_id . "'\n                                        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\n                                        FROM {$TBL_LP_ITEM_VIEW}\n                                        WHERE\n                                            c_id = {$course_id} AND\n                                            lp_item_id = '" . (int) $my_id . "' AND\n                                            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 = (double) $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\n                                        FROM (\n                                            SELECT DISTINCT\n                                                question_id, marks, ponderation\n                                            FROM {$tbl_stats_attempts} as at\n                                            INNER JOIN  {$tbl_quiz_questions} as q\n                                            ON (q.id = at.question_id AND q.c_id = {$course_id})\n                                            WHERE exe_id ='{$id_last_attempt}'\n                                        ) 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
                                     c_id = ' . $course_id . ' 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">&nbsp;</td>
                                 <td colspan="2">&nbsp;</td>
                                 <td colspan="2">&nbsp;</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}'>";
                         }
                         $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 .= ExerciseLib::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 || $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}\n                                    WHERE\n                                        c_id = {$course_id} AND\n                                        id = '{$lp_item_id}' AND\n                                        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
                                         c_id = ' . $course_id . '  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 = ExerciseLib::show_score(0, $my_maxscore, false);
                                         } else {
                                             if ($my_maxscore == 0) {
                                                 $view_score = $my_score;
                                             } else {
                                                 $view_score = ExerciseLib::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">&nbsp;</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 .= '
                 </tbody>
             </table>
         </div>
     ';
     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::arrayToCsv($csv_content, 'reporting_learning_path_details');
         exit;
     }
     return $output;
 }
Exemplo n.º 6
0
        $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::arrayToCsv($csv_content, 'reporting_course_tools');
    exit;
}
Display::display_footer();
Exemplo n.º 7
0
            $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::arrayToXml($alldata, $filename, 'Result', 'XMLResults');
                exit;
                break;
            case 'csv':
                Export::arrayToCsv($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);
Exemplo n.º 8
0
 /**
  * This method is used for thematic control (update, insert or listing)
  * @param 	string	Action
  * render to thematic.php
  */
 public function thematic($action)
 {
     $thematic = new Thematic();
     $data = array();
     $error = false;
     $msg_add = false;
     $check = Security::check_token('request');
     $thematic_id = isset($_REQUEST['thematic_id']) ? intval($_REQUEST['thematic_id']) : null;
     $displayHeader = !empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header' ? false : true;
     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 = isset($_POST['thematic_id']) ? $_POST['thematic_id'] : null;
                             $title = trim($_POST['title']);
                             $content = trim($_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)) {
                         $thematic->thematic_destroy($thematic_id);
                     }
                     $thematic_id = null;
                     $action = 'thematic_details';
                 }
                 break;
             case 'thematic_import_select':
                 break;
             case 'thematic_import':
                 $csv_import_array = Import::csvToArray($_FILES['file']['tmp_name']);
                 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 $item) {
                     $key = $item['type'];
                     switch ($key) {
                         case 'title':
                             $thematic->set_thematic_attributes(null, $item['data1'], $item['data2'], api_get_session_id());
                             $current_thematic = $thematic->thematic_save();
                             $description_type = 0;
                             break;
                         case 'plan':
                             $thematic->set_thematic_plan_attributes($current_thematic, $item['data1'], $item['data2'], $description_type);
                             $thematic->thematic_plan_save();
                             $description_type++;
                             break;
                         case 'progress':
                             $thematic->set_thematic_advance_attributes(null, $current_thematic, 0, $item['data3'], $item['data1'], $item['data2']);
                             $thematic->thematic_advance_save();
                             break;
                     }
                 }
                 $action = 'thematic_details';
                 break;
             case 'thematic_export':
                 $list = $thematic->get_thematic_list();
                 $csv = array();
                 $csv[] = array('type', 'data1', 'data2', 'data3');
                 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::arrayToCsv($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, api_get_course_id(), 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;
     $layoutName = $displayHeader ? 'layout' : 'layout_no_header';
     // render to the view
     $this->view->set_data($data);
     $this->view->set_layout($layoutName);
     $this->view->set_template('thematic');
     $this->view->render();
 }
Exemplo n.º 9
0
 /**
  * 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}\n                    WHERE user_id = '" . intval($user[4]) . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " ";
         $result = Database::query($sql);
         while ($row = Database::fetch_row($result)) {
             $courseInfo = api_get_course_info($row['course_code']);
             $courseId = $courseInfo['real_id'];
             $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], $courseId));
             // 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], $courseId);
             // last connection
             $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo));
             $csv_content[] = $csv_row;
         }
     }
     Export::arrayToCsv($csv_content, 'reporting_user_overview');
     exit;
 }
Exemplo n.º 10
0
    } else {
        $csv_header[] = array(get_lang('LastName'), get_lang('FirstName'), get_lang('FirstLogin'), get_lang('LastConnexion'));
    }
}
$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::arrayToCsv($csv_content, 'reporting_teacher_list');
    exit;
} else {
    Display::display_header($nameTools);
    echo $toolbar;
    $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();
Exemplo n.º 11
0
                        } else {
                            $a_users[] = $user;
                        }
                        $data[] = $user;
                        $counter++;
                    }
                }
                $fileName = get_lang('StudentList');
                $pdfTitle = get_lang('StudentList');
                if ($type == COURSEMANAGER) {
                    $fileName = get_lang('Teachers');
                    $pdfTitle = get_lang('Teachers');
                }
                switch ($_GET['format']) {
                    case 'csv':
                        Export::arrayToCsv($a_users, $fileName);
                        exit;
                    case 'xls':
                        Export::arrayToXls($a_users, $fileName);
                        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' => $fileName, 'pdf_title' => $pdfTitle, 'header_attributes' => $header_attributes);
                        Export::export_table_pdf($a_users, $params);
                        exit;
                }
        }
    }
}
// end if allowed to edit
if (api_is_allowed_to_edit(null, true)) {
Exemplo n.º 12
0
        break;
    case 'changeview':
    default:
        $tool_name = get_lang('List');
        break;
}
if (isset($_GET['action']) && $_GET['action'] == 'export') {
    $data = GlossaryManager::get_glossary_data(0, GlossaryManager::get_number_glossary_terms(api_get_session_id()), 0, 'ASC');
    usort($data, "sorter");
    $list = array();
    $list[] = array('term', 'definition');
    foreach ($data as $line) {
        $list[] = array($line[0], $line[1]);
    }
    $filename = 'glossary_course_' . api_get_course_id();
    Export::arrayToCsv($list, $filename);
}
if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') {
    GlossaryManager::export_to_pdf();
}
Display::display_header($tool_name);
// Tool introduction
Display::display_introduction_section(TOOL_GLOSSARY);
if (isset($_GET['action']) && $_GET['action'] == 'changeview' && in_array($_GET['view'], array('list', 'table'))) {
    Session::write('glossary_view', $_GET['view']);
} else {
    $viewFromSession = Session::read('glossary_view');
    if (!isset($viewFromSession)) {
        // Default option
        Session::write('glossary_view', 'table');
    }
Exemplo n.º 13
0
                    <td>' . get_lang('AverageTimeSpentOnThePlatform') . '</td>
                    <td align="right">' . (is_null($avg_time_spent) ? '' : api_time_to_hms($avg_time_spent)) . '</td>
                </tr>
                <tr>
                    <td>' . get_lang('AverageProgressInLearnpath') . '</td>
                    <td align="right">' . (is_null($avg_total_progress) ? '' : round($avg_total_progress, 2) . '%') . '</td>
                </tr>
                <tr>
                    <td>' . get_lang('AvgCourseScore') . '</td>
                    <td align="right">' . (is_null($avg_results_to_exercises) ? '' : round($avg_results_to_exercises, 2) . '%') . '</td>
                </tr>
                <tr>
                    <td>' . get_lang('AveragePostsInForum') . '</td>
                    <td align="right">' . (is_null($nb_posts) ? '' : round($nb_posts, 2)) . '</td>
                </tr>
                <tr>
                    <td>' . get_lang('AverageAssignments') . '</td>
                    <td align="right">' . (is_null($nb_assignments) ? '' : round($nb_assignments, 2)) . '</td>
                </tr>
            </table>
         </div>';
}
// Send the csv file if asked
if ($export_csv) {
    ob_end_clean();
    Export::arrayToCsv($csv_content, 'reporting_index');
    exit;
}
if (!$export_csv) {
    Display::display_footer();
}
Exemplo n.º 14
0
                } else {
                    $dataToExport['students'] .= $user['username'] . '|';
                }
            }
            $dataToExport['students'] = substr($dataToExport['students'], 0, -1);
            $dataToExport['teachers'] = substr($dataToExport['teachers'], 0, -1);
            $listToExport[] = $dataToExport;
        }
        switch ($file_type) {
            case 'xml':
                // Remove header
                unset($listToExport[0]);
                Export::arrayToXml($listToExport, $archiveFile);
                break;
            case 'csv':
                Export::arrayToCsv($listToExport, $archiveFile);
            case 'xls':
                Export::arrayToXls($listToExport, $archiveFile);
                break;
        }
    } else {
        Display::addFlash(Display::return_message(get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty')));
    }
}
Display::display_header($tool_name);
$form = new FormValidator('export', 'post', api_get_self());
$form->addHeader($tool_name);
$form->addHidden('formSent', 1);
$form->addElement('radio', 'select_type', get_lang('Option'), get_lang('ExportAllCoursesList'), '1', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='none';}"]);
$form->addElement('radio', 'select_type', '', get_lang('ExportSelectedCoursesFromCoursesList'), '2', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='block';}"]);
if (!empty($course_list)) {
Exemplo n.º 15
0
                            if ($is_western_name_order) {
                                $user_pdf = array($counter, $user_image, $user['official_code'], $user['firstname'] . ', ' . $user['lastname'], $user['email'], $user['phone']);
                            } else {
                                $user_pdf = array($counter, $user_image, $user['official_code'], $user['lastname'] . ', ' . $user['firstname'], $user['email'], $user['phone']);
                            }
                            $a_users[] = $user_pdf;
                        } else {
                            $a_users[] = $user;
                        }
                        $data[] = $user;
                        $counter++;
                    }
                }
                switch ($_GET['type']) {
                    case 'csv':
                        Export::arrayToCsv($a_users);
                        exit;
                    case 'xls':
                        Export::arrayToXls($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'), 'pdf_title' => get_lang('StudentList'), 'header_attributes' => $header_attributes);
                        Export::export_table_pdf($a_users, $params);
                        exit;
                }
        }
    }
}
// end if allowed to edit
if (api_is_allowed_to_edit(null, true)) {
Exemplo n.º 16
0
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::arrayToCsv($array, $filename);
    }
    exit;
}
Exemplo n.º 17
0
                $add = "\t<Session>\n" . "\t\t<SessionName>{$row['name']}</SessionName>\n" . "\t\t<Coach>{$row['username']}</Coach>\n" . "\t\t<DateStart>{$row['access_start_date']}</DateStart>\n" . "\t\t<DateEnd>{$row['access_end_date']}</DateEnd>\n" . "\t\t<Visibility>{$row['visibility']}</Visibility>\n" . "\t\t<SessionCategory>{$row['session_category']}</SessionCategory>\n";
            }
            if (!$cvs) {
                $add .= "\t</Session>\n";
                fputs($fp, $add);
            }
        }
        switch ($file_type) {
            case 'xml':
                fputs($fp, "</Sessions>\n");
                fclose($fp);
                $errorMsg = get_lang('UserListHasBeenExported') . '<br/>
				<a class="btn btn-default" href="' . $archiveURL . $archiveFile . '">' . get_lang('ClickHereToDownloadTheFile') . '</a>';
                break;
            case 'csv':
                Export::arrayToCsv($sessionListToExport, $archiveFile);
                exit;
            case 'xls':
                Export::arrayToXls($sessionListToExport, $archiveFile);
                exit;
                break;
        }
    }
}
// display the header
Display::display_header($tool_name);
//select of sessions
$sql = "SELECT id, name FROM {$tbl_session} ORDER BY name";
if (api_is_multiple_url_enabled()) {
    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
    $access_url_id = api_get_current_access_url_id();
Exemplo n.º 18
0
     $content = edit_category_form('editcategory');
     break;
 case 'deletecategory':
     delete_category_form('deletecategory');
     break;
 case 'export_category':
     $archiveFile = 'export_exercise_categoroes_' . api_get_course_id() . '_' . api_get_local_time();
     $categories = $category->getCategories($courseId, $sessionId);
     $export = [];
     $export[] = ['title', 'description'];
     if (!empty($categories)) {
         foreach ($categories as $category) {
             $export[] = [$category['title'], $category['description']];
         }
     }
     Export::arrayToCsv($export, $archiveFile);
     exit;
     break;
 case 'import_category':
     $form = importCategoryForm();
     if ($form->validate()) {
         $categories = Import::csv_reader($_FILES['file']['tmp_name']);
         if (!empty($categories)) {
             foreach ($categories as $item) {
                 $cat = new TestCategory(0, $item['title'], $item['description']);
                 $cat->addCategoryInBDD();
             }
             Display::addFlash(Display::return_message(get_lang('Imported')));
         }
     }
     $content = $form->returnForm();