Пример #1
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;
 }
Пример #2
0
 function get_html_toc()
 {
     //	$charset = api_get_setting('platform_charset');
     global $charset;
     $display_action_links_with_icons = false;
     if ($this->debug > 0) {
         error_log('New LP - In learnpath::get_html_toc()', 0);
     }
     $list = $this->get_toc();
     //	$html = '<div class="actions" style="height:680px;overflow:auto;"><div class="scorm_title"><div class="scorm_title_text">' . Security::remove_XSS(api_convert_encoding($this->get_name(), $this->encoding, $charset)) . '</div></div>';
     $html = '<div class="actions" style="height:680px;overflow:auto;"><div class="scorm_title"><div class="scorm_title_text">' . $this->get_name() . '</div></div>';
     // build, display
     $html .= '<div id="inner_lp_toc" class="inner_lp_toc">' . "\n";
     //require_once ('resourcelinker.inc.php');
     //temp variables
     $mycurrentitemid = $this->get_current_item_id();
     $color_counter = 0;
     $i = 0;
     foreach ($list as $item) {
         if ($this->debug > 2) {
             error_log('New LP - learnpath::get_html_toc(): using item ' . $item['id'], 0);
         }
         //TODO complete this
         $icon_name = array('not attempted' => '../img/notattempted.gif', 'incomplete' => '../img/incomplete.gif', 'failed' => '../img/failed.gif', 'completed' => '../img/completed.gif', 'passed' => '../img/passed.gif', 'succeeded' => '../img/succeeded.gif', 'browsed' => '../img/completed.gif');
         $style = 'scorm_item';
         $scorm_color_background = 'scorm_item';
         $style_item = 'scorm_item';
         $current = false;
         if ($item['id'] == $this->current) {
             $style = 'scorm_item_highlight';
             $scorm_color_background = 'scorm_item_highlight';
         } else {
             if ($color_counter % 2 == 0) {
                 $scorm_color_background = 'scorm_item_1';
             } else {
                 $scorm_color_background = 'scorm_item_2';
             }
         }
         if ($scorm_color_background != '') {
             $html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . '">';
         }
         //the anchor will let us center the TOC on the currently viewed item &^D
         if ($item['type'] != 'dokeos_module' and $item['type'] != 'dokeos_chapter') {
             $html .= '<a name="atoc_' . $item['id'] . '"> </a>';
             $html .= '<div class="' . $style_item . '" style="padding-left: ' . $item['level'] * 1.5 . 'em; padding-right:' . $item['level'] / 2 . 'em"             title="' . $item['description'] . '" >';
         } else {
             $html .= '<div class="' . $style_item . '" style="padding-left: ' . $item['level'] * 2 . 'em; padding-right:' . $item['level'] * 1.5 . 'em"             title="' . $item['description'] . '" >';
         }
         $title = $item['title'];
         if (empty($title)) {
             $title = rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
         }
         //$title = api_htmlentities($title, ENT_QUOTES, $this->encoding);
         //$title = Security::remove_XSS($title);
         if ($item['type'] != 'dokeos_chapter' and $item['type'] != 'dir' and $item['type'] != 'dokeos_module') {
             //$html .= "<a href='lp_controller.php?".api_get_cidreq()."&action=content&lp_id=".$this->get_id()."&item_id=".$item['id']."' target='lp_content_frame_name'>".$title."</a>" ;
             $url = $this->get_link('http', $item['id']);
             //$html .= '<a href="'.$url.'" target="content_name" onclick="top.load_item('.$item['id'].',\''.$url.'\');">'.$title.'</a>' ;
             //$html .= '<a href="" onclick="top.load_item('.$item['id'].',\''.$url.'\');return false;">'.$title.'</a>' ;
             //<img align="absbottom" width="13" height="13" src="../img/lp_document.png">&nbsp;background:#aaa;
             $html .= '<a href="" onclick="switch_item(' . $mycurrentitemid . ',' . $item['id'] . ');' . 'setTimeout(\'window.location.reload()\', 50);' . 'return false;" >' . stripslashes($title) . '</a>';
         } elseif ($item['type'] == 'dokeos_module' || $item['type'] == 'dokeos_chapter') {
             $html .= "<img align='absbottom' width='13' height='13' src='../img/lp_dokeos_module.png'>&nbsp;" . stripslashes($title);
         } elseif ($item['type'] == 'dir') {
             $html .= stripslashes($title);
         }
         /*$tbl_track_e_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
               $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
               $user_id = api_get_user_id();
               $course_id = api_get_course_id();
               $sql = "SELECT path  FROM $tbl_track_e_exercises, $tbl_lp_item
         		WHERE path =   '" . $item['path'] . "' AND exe_user_id =  '$user_id' AND exe_cours_id = '$course_id' AND path = exe_exo_id AND status <> 'incomplete'";
               $result = Database::query($sql, __FILE__, __LINE__);
               $count = Database :: num_rows($result);*/
         if ($item['type'] == 'quiz') {
             if ($item['status'] == 'completed') {
                 $html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name[$item['status']] . "' alt='" . substr($item['status'], 0, 1) . "' width='12' height='12' />";
             }
         } else {
             if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dokeos_module' && $item['type'] != 'dir') {
                 $html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name[$item['status']] . "' alt='" . substr($item['status'], 0, 1) . "' width='12' height='12' />";
             }
         }
         $html .= "</div>";
         if ($scorm_color_background != '') {
             $html .= '</div>';
         }
         $color_counter++;
     }
     $html .= "</div>\n</div>";
     return $html;
 }
Пример #3
0
 /**
  * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
  * @param array
  * @return  string HTML TOC ready to display
  */
 public function get_html_toc($toc_list = null)
 {
     global $_configuration;
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
     if ($this->debug > 0) {
         error_log('In learnpath::get_html_toc()', 0);
     }
     if (empty($toc_list)) {
         $toc_list = $this->get_toc();
     }
     $html = '';
     $hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true;
     if ($is_allowed_to_edit && $hide_teacher_icons_lp == false) {
         $gradebook = Security::remove_XSS($_GET['gradebook']);
         if ($this->get_lp_session_id() == api_get_session_id()) {
             $html .= '<div id="actions_lp" class="actions_lp">';
             $html .= '<div class="btn-group">';
             $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq() . "&amp;gradebook={$gradebook}&amp;action=build&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Overview') . "</a>";
             $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq() . "&amp;action=add_item&amp;type=step&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Edit') . "</a>";
             $html .= '<a class="btn" href="lp_controller.php?' . api_get_cidreq() . "&amp;gradebook={$gradebook}&amp;action=edit&amp;lp_id=" . $this->lp_id . '">' . get_lang('Settings') . '</a>';
             $html .= '</div>';
             $html .= '</div>';
         }
     }
     require_once 'resourcelinker.inc.php';
     // Temporary variables.
     $mycurrentitemid = $this->get_current_item_id();
     $color_counter = 0;
     $i = 0;
     foreach ($toc_list as $item) {
         // TODO: Complete this
         $icon_name = array('not attempted' => 'notattempted.gif', 'incomplete' => 'incomplete.png', 'failed' => 'delete.png', 'completed' => 'completed.png', 'passed' => 'passed.png', 'succeeded' => 'succeeded.png', 'browsed' => 'completed.png');
         $style_item = 'scorm_item';
         $active = null;
         if ($item['id'] == $this->current) {
             $scorm_color_background = 'scorm_item_highlight';
             $active = ' active';
         } else {
             if ($color_counter % 2 == 0) {
                 $scorm_color_background = 'scorm_item_1';
             } else {
                 $scorm_color_background = 'scorm_item_2';
             }
             if ($item['type'] == 'dokeos_module' || $item['type'] == 'dokeos_chapter') {
                 $scorm_color_background = ' scorm_item_section ';
             }
         }
         $onClick = null;
         if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dir' && $item['type'] != 'dokeos_module') {
             $onClick = 'onclick="switch_item(' . $mycurrentitemid . ',' . $item['id'] . ');' . 'return false;"';
         }
         $html .= '<a href="" ' . $onClick . ' class="list-group-item">';
         $imageStatus = null;
         if ($item['type'] == 'quiz') {
             if ($item['status'] == 'completed') {
                 $imageStatus = "&nbsp;" . Display::return_icon($icon_name[$item['status']], substr($item['status'], 0, 1), array('id' => "toc_img_" . $item['id'], 'width' => '14'));
             } else {
                 $imageStatus = "&nbsp;" . Display::return_icon($icon_name['not attempted'], substr('not attempted', 0, 1), array('id' => "toc_img_" . $item['id'], 'width' => '14'));
             }
         } else {
             if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dokeos_module' && $item['type'] != 'dir') {
                 $imageStatus = "&nbsp;" . Display::return_icon($icon_name[$item['status']], substr($item['status'], 0, 1), array('id' => "toc_img_" . $item['id'], 'width' => '14'));
             }
         }
         $html .= '<span class="badge_lp">' . $imageStatus . "</span>";
         if ($scorm_color_background != '') {
             $html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . '">';
         }
         // The anchor will let us center the TOC on the currently viewed item &^D
         if ($item['type'] != 'dokeos_module' && $item['type'] != 'dokeos_chapter') {
             $html .= '<div class="' . $style_item . '" style="padding-left: ' . $item['level'] * 1.5 . 'em; padding-right:' . $item['level'] / 2 . 'em"  title="' . $item['description'] . '" >';
             //$html .= '<a name="atoc_'.$item['id'].'"></a>';
         } else {
             $html .= '<div class="' . $style_item . '" style="padding-left: ' . $item['level'] * 2 . 'em; padding-right:' . $item['level'] * 1.5 . 'em"  title="' . $item['description'] . '" >';
         }
         $title = $item['title'];
         if (empty($title)) {
             $title = rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
         }
         $title = Security::remove_XSS($title);
         if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dir' && $item['type'] != 'dokeos_module') {
             //$html .= '<a href=""  >'.stripslashes($title).'</a>';
             $html .= $title;
         } elseif ($item['type'] == 'dokeos_module' || $item['type'] == 'dokeos_chapter') {
             $html .= Display::return_icon('lp_dokeos_module.png', $title) . '&nbsp;' . $title;
         } elseif ($item['type'] == 'dir') {
             $html .= $title;
         }
         $html .= "</div>";
         if ($scorm_color_background != '') {
             $html .= '</div>';
         }
         $html .= '</a>';
         $color_counter++;
     }
     return $html;
 }
Пример #4
0
 /**
  * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
  * @return	string	HTML TOC ready to display
  */
 public function get_html_toc($toc_list = null)
 {
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
     if ($this->debug > 0) {
         error_log('In learnpath::get_html_toc()', 0);
     }
     if (empty($toc_list)) {
         $toc_list = $this->get_toc();
     }
     //$html = '<div id="scorm_title" class="scorm-heading">'.Security::remove_XSS($this->get_name()) . '</div>';
     $html = '<div class="scorm-body">';
     $html .= '<div id="inner_lp_toc" class="inner_lp_toc scrollbar-light">';
     require_once 'resourcelinker.inc.php';
     // Temporary variables.
     $mycurrentitemid = $this->get_current_item_id();
     $color_counter = 0;
     $i = 0;
     foreach ($toc_list as $item) {
         // TODO: Complete this
         $icon_name = array('not attempted' => '../img/notattempted.gif', 'incomplete' => '../img/incomplete.png', 'failed' => '../img/delete.png', 'completed' => '../img/completed.png', 'passed' => '../img/passed.png', 'succeeded' => '../img/succeeded.png', 'browsed' => '../img/completed.png');
         // Style Status
         $class_name = array('not attempted' => 'scorm_not_attempted', 'incomplete' => 'scorm_not_attempted', 'failed' => 'scorm_failed', 'completed' => 'scorm_completed', 'passed' => 'scorm_completed', 'succeeded' => 'scorm_completed', 'browsed' => 'scorm_completed');
         $scorm_color_background = 'row_odd';
         $style_item = '';
         if ($color_counter % 2 == 0) {
             $scorm_color_background = 'row_even';
         }
         $dirTypes = self::getChapterTypes();
         if (in_array($item['type'], $dirTypes)) {
             $scorm_color_background = 'scorm_item_section ';
             $style_item = '';
         }
         if ($item['id'] == $this->current) {
             $scorm_color_background = 'scorm_item_normal ' . $scorm_color_background . ' scorm_highlight';
         } elseif (!in_array($item['type'], $dirTypes)) {
             $scorm_color_background = 'scorm_item_normal ' . $scorm_color_background . ' ';
         }
         $html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . ' ' . $class_name[$item['status']] . ' ">';
         // Learning path title
         $title = $item['title'];
         if (empty($title)) {
             $title = rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
         }
         $title = Security::remove_XSS($title);
         // Learning path personalization
         // build the LP tree
         // The anchor atoc_ will let us center the TOC on the currently viewed item &^D
         $description = $item['description'];
         if (empty($description)) {
             $description = $title;
         }
         if (in_array($item['type'], $dirTypes)) {
             // Chapters
             $html .= '<div class="' . $style_item . ' scorm_section_level_' . $item['level'] . '" title="' . $description . '" >';
         } else {
             $html .= '<div class="' . $style_item . ' scorm_item_level_' . $item['level'] . ' scorm_type_' . learnpath::format_scorm_type_item($item['type']) . '" title="' . $description . '" >';
             $html .= '<a name="atoc_' . $item['id'] . '" />';
         }
         if (in_array($item['type'], $dirTypes)) {
             // Chapter
             // if you want to put an image before, you should use css
             $html .= stripslashes($title);
         } else {
             $this->get_link('http', $item['id'], $toc_list);
             $html .= '<a class="items-list" href="" onClick="switch_item(' . $mycurrentitemid . ',' . $item['id'] . ');' . 'return false;" >' . stripslashes($title) . '</a>';
         }
         $html .= "</div>";
         if ($scorm_color_background != '') {
             $html .= '</div>';
         }
         $color_counter++;
     }
     $html .= "</div>";
     $html .= "</div>";
     return $html;
 }
Пример #5
0
 /**
  * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
  * @return	string	HTML TOC ready to display
  */
 public function get_html_toc($toc_list = null)
 {
     global $_configuration;
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
     if ($this->debug > 0) {
         error_log('In learnpath::get_html_toc()', 0);
     }
     if (empty($toc_list)) {
         $toc_list = $this->get_toc();
     }
     $html = '<div id="scorm_title" class="scorm_title">' . Security::remove_XSS($this->get_name()) . '</div>';
     $hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true;
     if ($is_allowed_to_edit && $hide_teacher_icons_lp == false) {
         $gradebook = Security::remove_XSS($_GET['gradebook']);
         if ($this->get_lp_session_id() == api_get_session_id()) {
             $html .= '<div id="actions_lp" class="actions_lp">';
             $html .= '<div class="btn-group">';
             $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq() . "&amp;gradebook={$gradebook}&amp;action=build&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Overview') . "</a>";
             $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq() . "&amp;action=add_item&amp;type=step&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Edit') . "</a>";
             $html .= '<a class="btn" href="lp_controller.php?' . api_get_cidreq() . "&amp;gradebook={$gradebook}&amp;action=edit&amp;lp_id=" . $this->lp_id . '">' . get_lang('Settings') . '</a>';
             $html .= '</div>';
             $html .= '</div>';
         }
     }
     $html .= '<div id="inner_lp_toc" class="inner_lp_toc">';
     require_once 'resourcelinker.inc.php';
     // Temporary variables.
     $mycurrentitemid = $this->get_current_item_id();
     $color_counter = 0;
     $i = 0;
     foreach ($toc_list as $item) {
         // TODO: Complete this
         $icon_name = array('not attempted' => '../img/notattempted.gif', 'incomplete' => '../img/incomplete.png', 'failed' => '../img/delete.png', 'completed' => '../img/completed.png', 'passed' => '../img/passed.png', 'succeeded' => '../img/succeeded.png', 'browsed' => '../img/completed.png');
         $style = 'scorm_item';
         $scorm_color_background = 'scorm_item';
         $style_item = 'scorm_item';
         $current = false;
         if ($item['id'] == $this->current) {
             $style = 'scorm_item_highlight';
             $scorm_color_background = 'scorm_item_highlight';
         } else {
             if ($color_counter % 2 == 0) {
                 $scorm_color_background = 'scorm_item_1';
             } else {
                 $scorm_color_background = 'scorm_item_2';
             }
             if ($item['type'] == 'dokeos_module' || $item['type'] == 'dokeos_chapter') {
                 $scorm_color_background = ' scorm_item_section ';
             }
         }
         if ($scorm_color_background != '') {
             $html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . '">';
         }
         // The anchor will let us center the TOC on the currently viewed item &^D
         if ($item['type'] != 'dokeos_module' && $item['type'] != 'dokeos_chapter') {
             $html .= '<div class="' . $style_item . '" style="padding-left: ' . $item['level'] * 1.5 . 'em; padding-right:' . $item['level'] / 2 . 'em"             title="' . $item['description'] . '" >';
             $html .= '<a name="atoc_' . $item['id'] . '" />';
         } else {
             $html .= '<div class="' . $style_item . '" style="padding-left: ' . $item['level'] * 2 . 'em; padding-right:' . $item['level'] * 1.5 . 'em"             title="' . $item['description'] . '" >';
         }
         $title = $item['title'];
         if (empty($title)) {
             $title = rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
         }
         $title = Security::remove_XSS($title);
         if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dir' && $item['type'] != 'dokeos_module') {
             //$html .= "<a href='lp_controller.php?".api_get_cidreq()."&action=content&lp_id=".$this->get_id()."&item_id=".$item['id']."' target='lp_content_frame_name'>".$title."</a>" ;
             $url = $this->get_link('http', $item['id'], $toc_list);
             //$html .= '<a href="'.$url.'" target="content_name" onClick="top.load_item('.$item['id'].',\''.$url.'\');">'.$title.'</a>' ;
             //$html .= '<a href="" onClick="top.load_item('.$item['id'].',\''.$url.'\');return false;">'.$title.'</a>' ;
             //<img align="absbottom" width="13" height="13" src="../img/lp_document.png">&nbsp;background:#aaa;
             $html .= '<a href="" onClick="switch_item(' . $mycurrentitemid . ',' . $item['id'] . ');' . 'return false;" >' . stripslashes($title) . '</a>';
         } elseif ($item['type'] == 'dokeos_module' || $item['type'] == 'dokeos_chapter') {
             $html .= "<img align='absbottom' width='13' height='13' src='../img/lp_dokeos_module.png'>&nbsp;" . stripslashes($title);
         } elseif ($item['type'] == 'dir') {
             $html .= stripslashes($title);
         }
         ///axo//////////////////////////// 130713
         $user_id = api_get_user_id();
         //echo "==== " . $item['description'];
         $grade = Student_Exercise_Progress($item['description'], $user_id);
         if ($grade == 100) {
             $image = '<img src="../img/star.png" border="0" align="absmiddle" >';
         } elseif ($grade > 0) {
             $image = '<img src="../img/star_half.png" border="0" align="absmiddle" >';
         } else {
             $image = "";
         }
         //////////////////////////////////////
         /*$tbl_track_e_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
                     $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
                     $user_id = api_get_user_id();
         
                     $sql = "SELECT path  FROM $tbl_track_e_exercises, $tbl_lp_item
                             WHERE   c_id = $course_id AND
                                     path =   '" . $item['path'] . "' AND
                                     exe_user_id =  '$user_id' AND
                                     exe_cours_id = '$course_code' AND
                                     path = exe_exo_id AND
                                     status <> 'incomplete'";
                     $result = Database::query($sql);
                     $count = Database :: num_rows($result);*/
         if ($item['type'] == 'quiz') {
             if ($item['status'] == 'completed') {
                 $html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name[$item['status']] . "' alt='" . substr($item['status'], 0, 1) . "' width='14' />";
             } else {
                 $html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name['not attempted'] . "' alt='" . substr('not attempted', 0, 1) . "' width='14' />";
             }
         } else {
             if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dokeos_module' && $item['type'] != 'dir') {
                 $html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name[$item['status']] . "' alt='" . substr($item['status'], 0, 1) . "' width='14' />" . str_repeat('&nbsp;', 3) . $image . " " . $grade;
                 ///axo/////////
                 /// Aquí arriba va la imagen de progreso
             }
         }
         $html .= "</div>";
         if ($scorm_color_background != '') {
             $html .= '</div>';
         }
         $color_counter++;
     }
     $html .= "</div>";
     return $html;
 }
Пример #6
0
             //echo $subtotal_time ;
             //$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
             // Selecting the max score from an attempt.
             $sql = "SELECT SUM(t.ponderation) as maxscore\n                                FROM (\n                        \t\t\tSELECT distinct question_id, marks, ponderation\n                                    FROM {$tbl_stats_attempts} as at INNER JOIN  {$tbl_quiz_questions} as q\n                        \t\t\tON (q.id = at.question_id AND q.c_id = {$course_id}\n                                    )\n                                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::get_scorm_time('js', $subtotal_time);
 if (empty($title)) {
     $title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
 }
 // 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 ($row['item_type'] == 'quiz') {
         $correct_test_link = '';
         $my_url_suffix = '';
         if ($origin != 'tracking' && $origin != 'tracking_course') {
             $my_url_suffix = '&course=' . api_get_course_id() . '&student_id=' . api_get_user_id() . '&lp_id=' . Security::remove_XSS($row['mylpid']);
             $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
                                  WHERE  exe_exo_id="' . $row['path'] . '" AND
                                         exe_user_id="' . api_get_user_id() . '" AND
                                         orig_lp_id = "' . $lp_id . '" AND
                                         orig_lp_item_id = "' . $row['myid'] . '" AND
                                         c_id = "' . $course_id . '" AND
Пример #7
0
    /**
     * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
     * @return	string	HTML TOC ready to display
     */
    public function get_html_toc($toc_list = null)
    {
        global $_configuration;
        $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);

        if ($this->debug > 0) {
            error_log('In learnpath::get_html_toc()', 0);
        }
        if (empty($toc_list)) {
            $toc_list = $this->get_toc();
        }
        $html = '<div id="scorm_title" class="scorm_title">'.Security::remove_XSS($this->get_name()) . '</div>';

        $hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true;

        if ($is_allowed_to_edit && $hide_teacher_icons_lp == false) {
            $gradebook = Security :: remove_XSS($_GET['gradebook']);
            if ($this->get_lp_session_id() == api_get_session_id()) {
                $html .= '<div id="actions_lp" class="actions_lp">';
                $html .= '<div class="btn-group">';
                $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=build&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Overview') . "</a>";
                $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;action=add_item&amp;type=step&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Edit') . "</a>";
                $html .= '<a class="btn" href="lp_controller.php?'.api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=edit&amp;lp_id=" . $this->lp_id.'">'.get_lang('Settings').'</a>';
                $html .= '</div>';
                $html .= '</div>';
            }
        }
        $html .= '<div id="inner_lp_toc" class="inner_lp_toc">';
        require_once 'resourcelinker.inc.php';

        // Temporary variables.
        $mycurrentitemid = $this->get_current_item_id();
        $color_counter = 0;
        $i = 0;

        foreach ($toc_list as $item) {
            // TODO: Complete this
            $icon_name = array (
                'not attempted' => '../img/notattempted.gif',
                'incomplete'    => '../img/incomplete.png',
                'failed'        => '../img/delete.png',
                'completed'     => '../img/completed.png',
                'passed'        => '../img/passed.png',
                'succeeded'     => '../img/succeeded.png',
                'browsed'       => '../img/completed.png',
            );

            // Style Status

            $class_name = array (
                'not attempted' => 'scorm_not_attempted',
                'incomplete'    => 'scorm_not_attempted',
                'failed'        => 'scorm_failed',
                'completed'     => 'scorm_completed',
                'passed'        => 'scorm_completed',
                'succeeded'     => 'scorm_completed',
                'browsed'       => 'scorm_completed',
            );

            $scorm_color_background = 'scorm_item_2';
            $style_item = '';

            if ($color_counter % 2 == 0) {
                $scorm_color_background = 'scorm_item_1';
            }

            $dirTypes = self::getChapterTypes();

            if (in_array($item['type'], $dirTypes)) {
                $scorm_color_background =' scorm_item_section ';
                $style_item = '';
            }
            if ($item['id'] == $this->current) {
                $scorm_color_background = 'scorm_item_normal scorm_highlight '.$scorm_color_background.' ';
            } elseif (!in_array($item['type'], $dirTypes)) {
                $scorm_color_background = 'scorm_item_normal '.$scorm_color_background.' ';
            }

            $html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . ' '.$class_name[$item['status']].' ">';

            // Learning path title
            $title = $item['title'];
            if (empty ($title)) {
                $title = rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
            }
            $title = Security::remove_XSS($title);

            // Learning path personalization
            // build the LP tree
            // The anchor atoc_ will let us center the TOC on the currently viewed item &^D
            $description = $item['description'];
            if (empty($description)) {
                $description = $title;
            }
            if (in_array($item['type'], $dirTypes)) {
                // Chapters
                $html .= '<div class="'.$style_item.' scorm_section_level_'.$item['level'].'" title="'.$description.'" >';
            } else {
                $html .= '<div class="'.$style_item.' scorm_item_level_'.$item['level'].' scorm_type_'.learnpath::format_scorm_type_item($item['type']).'" title="'.$description.'" >';
                $html .= '<a name="atoc_'.$item['id'].'" />';
            }

            if (in_array($item['type'], $dirTypes)) {
                // Chapter
                // if you want to put an image before, you should use css
                $html .= stripslashes($title);
            } else {
                $this->get_link('http', $item['id'], $toc_list);
                $html .= '<a href="" onClick="switch_item(' .$mycurrentitemid . ',' .$item['id'] . ');' .'return false;" >' . stripslashes($title) . '</a>';
            }
            $html .= "</div>";

            if ($scorm_color_background != '') {
                $html .= '</div>';
            }

            $color_counter++;
        }
        $html .= "</div>";
        return $html;
    }