/**
  * Get activities data to display
  */
 static function get_activities_data($from, $number_of_items, $column, $direction)
 {
     global $dateTimeFormatLong;
     $track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $current_url_id = api_get_current_access_url_id();
     $column = intval($column);
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'DESC';
     }
     if (api_is_multiple_url_enabled()) {
         $sql = "SELECT " . "default_event_type  as col0, " . "default_value_type    as col1, " . "default_value        as col2, " . "user.username         as col3, " . "user.user_id         as col4, " . "default_date         as col5 " . "FROM {$track_e_default} as track_default, {$table_user} as user, {$access_url_rel_user_table} as url " . "WHERE track_default.default_user_id = user.user_id AND url.user_id=user.user_id AND access_url_id='" . $current_url_id . "'";
     } else {
         $sql = "SELECT " . "default_event_type  as col0, " . "default_value_type    as col1, " . "default_value        as col2, " . "user.username         as col3, " . "user.user_id         as col4, " . "default_date         as col5 " . "FROM {$track_e_default} track_default, {$table_user} user " . "WHERE track_default.default_user_id = user.user_id ";
     }
     if (isset($_GET['keyword'])) {
         $keyword = Database::escape_string(trim($_GET['keyword']));
         $sql .= " AND (user.username LIKE '%" . $keyword . "%' OR default_event_type LIKE '%" . $keyword . "%' OR default_value_type LIKE '%" . $keyword . "%' OR default_value LIKE '%" . $keyword . "%') ";
     }
     if (!empty($column) && !empty($direction)) {
         $sql .= " ORDER BY col{$column} {$direction}";
     } else {
         $sql .= " ORDER BY col5 DESC ";
     }
     $sql .= " LIMIT {$from}, {$number_of_items} ";
     $res = Database::query($sql);
     $activities = array();
     while ($row = Database::fetch_row($res)) {
         if (strpos($row[1], '_object') === false) {
             $row[2] = $row[2];
         } else {
             if (!empty($row[2])) {
                 $row[2] = unserialize($row[2]);
                 if (is_array($row[2]) && !empty($row[2])) {
                     $row[2] = Text::implode_with_key(', ', $row[2]);
                 }
             }
         }
         if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') {
             $row['default_date'] = api_get_local_time($row['default_date']);
         } else {
             $row['default_date'] = '-';
         }
         if (!empty($row[4])) {
             //user ID
             $row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH) . 'admin/user_information?user_id=' . $row[5], array('title' => get_lang('UserInfo')));
             $row[4] = TrackingUserLog::get_ip_from_user_event($row[4], $row[5], true);
             if (empty($row[4])) {
                 $row[4] = get_lang('Unknown');
             }
         }
         $activities[] = $row;
     }
     return $activities;
 }
 /**
  * Get activities data to display
  * @param int $from
  * @param int $numberOfItems
  * @param int $column
  * @param string $direction
  * @return array
  */
 public static function getActivitiesData($from, $numberOfItems, $column, $direction)
 {
     $track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $current_url_id = api_get_current_access_url_id();
     $column = intval($column);
     $from = intval($from);
     $numberOfItems = intval($numberOfItems);
     if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'DESC';
     }
     if (api_is_multiple_url_enabled()) {
         $sql = "SELECT\n                    default_event_type  as col0,\n                    default_value_type    as col1,\n                    default_value        as col2,\n                    c_id         as col3,\n                    session_id as col4,\n                    user.username         as col5,\n                    user.user_id         as col6,\n                    default_date         as col7\n                    FROM {$track_e_default} as track_default, {$table_user} as user, {$access_url_rel_user_table} as url\n                    WHERE\n                        track_default.default_user_id = user.user_id AND\n                        url.user_id = user.user_id AND\n                        access_url_id='" . $current_url_id . "'";
     } else {
         $sql = "SELECT\n                   default_event_type  as col0,\n                   default_value_type    as col1,\n                   default_value        as col2,\n                   c_id         as col3,\n                   session_id as col4,\n                   user.username         as col5,\n                   user.user_id         as col6,\n                   default_date         as col7\n                   FROM {$track_e_default} track_default, {$table_user} user\n                   WHERE track_default.default_user_id = user.user_id ";
     }
     if (isset($_GET['keyword'])) {
         $keyword = Database::escape_string(trim($_GET['keyword']));
         $sql .= " AND (user.username LIKE '%" . $keyword . "%' OR\n                        default_event_type LIKE '%" . $keyword . "%' OR\n                        default_value_type LIKE '%" . $keyword . "%' OR\n                        default_value LIKE '%" . $keyword . "%') ";
     }
     if (!empty($column) && !empty($direction)) {
         $sql .= " ORDER BY col{$column} {$direction}";
     } else {
         $sql .= " ORDER BY col5 DESC ";
     }
     $sql .= " LIMIT {$from},{$numberOfItems} ";
     $res = Database::query($sql);
     $activities = array();
     while ($row = Database::fetch_row($res)) {
         if (strpos($row[1], '_object') === false && strpos($row[1], '_array') === false) {
             $row[2] = $row[2];
         } else {
             if (!empty($row[2])) {
                 $originalData = str_replace('\\', '', $row[2]);
                 $row[2] = unserialize($originalData);
                 if (is_array($row[2]) && !empty($row[2])) {
                     $row[2] = implode_with_key(', ', $row[2]);
                 } else {
                     $row[2] = $originalData;
                 }
             }
         }
         if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') {
             $row['default_date'] = api_get_local_time($row['default_date']);
         } else {
             $row['default_date'] = '-';
         }
         if (!empty($row[5])) {
             //course
             if (!empty($row[3])) {
                 $row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH) . 'admin/course_edit.php?id=' . $row[3]);
             } else {
                 $row[3] = '-';
             }
             // session
             if (!empty($row[4])) {
                 $row[4] = Display::url($row[4], api_get_path(WEB_CODE_PATH) . 'session/resume_session.php?id_session=' . $row[4]);
             } else {
                 $row[4] = '-';
             }
             // User id.
             $row[5] = Display::url($row[5], api_get_path(WEB_CODE_PATH) . 'admin/user_information.php?user_id=' . $row[6], array('title' => get_lang('UserInfo')));
             $row[6] = TrackingUserLog::get_ip_from_user_event($row[6], $row[7], true);
             if (empty($row[6])) {
                 $row[6] = get_lang('Unknown');
             }
         }
         $activities[] = $row;
     }
     return $activities;
 }
示例#3
0
 /**
  * @param $from
  * @param $number_of_items
  * @param $column
  * @param $direction
  * @return array
  */
 public static function get_item_resources_data($from, $number_of_items, $column, $direction)
 {
     $session_id = api_get_session_id();
     $course_id = api_get_course_int_id();
     $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     $table_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $session_id = intval($session_id);
     $sql = "SELECT\n                    tool as col0,\n                    lastedit_type as col1,\n                    ref as ref,\n                    user.username as col3,\n                    insert_date as col5,\n                    visibility as col6,\n                    user.user_id as user_id\n                FROM {$table_item_property} track_resource, {$table_user} user\n                WHERE\n                  track_resource.c_id = {$course_id} AND\n                  track_resource.insert_user_id = user.user_id AND\n                  session_id = {$session_id} ";
     if (isset($_GET['keyword'])) {
         $keyword = Database::escape_string(trim($_GET['keyword']));
         $sql .= " AND (\n    \t\t            user.username LIKE '%" . $keyword . "%' OR\n    \t\t            lastedit_type LIKE '%" . $keyword . "%' OR\n    \t\t            tool LIKE '%" . $keyword . "%'\n                     ) ";
     }
     $sql .= " AND tool IN (\n    \t            'document',\n    \t            'learnpath',\n    \t            'quiz',\n    \t            'glossary',\n    \t            'link',\n    \t            'course_description',\n    \t            'announcement',\n    \t            'thematic',\n    \t            'thematic_advance',\n    \t            'thematic_plan'\n                )";
     if ($column == 0) {
         $column = '0';
     }
     if ($column != '' && $direction != '') {
         if ($column != 2 && $column != 4) {
             $sql .= " ORDER BY col{$column} {$direction}";
         }
     } else {
         $sql .= " ORDER BY col5 DESC ";
     }
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $sql .= " LIMIT {$from}, {$number_of_items} ";
     $res = Database::query($sql);
     $resources = array();
     $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
     while ($row = Database::fetch_array($res)) {
         $ref = $row['ref'];
         $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
         $table_tool = Database::get_course_table($table_name['table_name']);
         $id = $table_name['id_tool'];
         $recorset = false;
         if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
             $tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
             $sql = "SELECT thematic_id FROM {$table_tool}\n    \t\t\t        WHERE c_id = {$course_id} AND id = {$ref}";
             $rs_thematic = Database::query($sql);
             if (Database::num_rows($rs_thematic)) {
                 $row_thematic = Database::fetch_array($rs_thematic);
                 $thematic_id = $row_thematic['thematic_id'];
                 $sql = "SELECT session.id, session.name, user.username\n                            FROM {$tbl_thematic} t, {$table_session} session, {$table_user} user\n                            WHERE\n                              t.c_id = {$course_id} AND\n                              t.session_id = session.id AND\n                              session.id_coach = user.user_id AND\n                              t.id = {$thematic_id}";
                 $recorset = Database::query($sql);
             }
         } else {
             $sql = "SELECT session.id, session.name, user.username\n                          FROM {$table_tool} tool, {$table_session} session, {$table_user} user\n    \t\t\t          WHERE\n    \t\t\t              tool.c_id = {$course_id} AND\n    \t\t\t              tool.session_id = session.id AND\n    \t\t\t              session.id_coach = user.user_id AND\n    \t\t\t              tool.{$id} = {$ref}";
             $recorset = Database::query($sql);
         }
         if (!empty($recorset)) {
             $obj = Database::fetch_object($recorset);
             $name_session = '';
             $coach_name = '';
             if (!empty($obj)) {
                 $name_session = $obj->name;
                 $coach_name = $obj->username;
             }
             $url_tool = api_get_path(WEB_CODE_PATH) . $table_name['link_tool'];
             $row[0] = '';
             if ($row['col6'] != 2) {
                 if (in_array($row['col0'], $thematic_tools)) {
                     $exp_thematic_tool = explode('_', $row['col0']);
                     $thematic_tool_title = '';
                     if (is_array($exp_thematic_tool)) {
                         foreach ($exp_thematic_tool as $exp) {
                             $thematic_tool_title .= api_ucfirst($exp);
                         }
                     } else {
                         $thematic_tool_title = api_ucfirst($row['col0']);
                     }
                     $row[0] = '<a href="' . $url_tool . '?' . api_get_cidreq() . '&action=thematic_details">' . get_lang($thematic_tool_title) . '</a>';
                 } else {
                     $row[0] = '<a href="' . $url_tool . '?' . api_get_cidreq() . '">' . get_lang('Tool' . api_ucfirst($row['col0'])) . '</a>';
                 }
             } else {
                 $row[0] = api_ucfirst($row['col0']);
             }
             $row[1] = get_lang($row[1]);
             $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
             $row[5] = '';
             //@todo Improve this code please
             switch ($table_name['table_name']) {
                 case 'document':
                     $sql = "SELECT tool.title as title FROM {$table_tool} tool\n                                WHERE c_id = {$course_id} AND id = {$ref}";
                     $rs_document = Database::query($sql);
                     $obj_document = Database::fetch_object($rs_document);
                     $row[5] = $obj_document->title;
                     break;
                 case 'announcement':
                     $sql = "SELECT title FROM {$table_tool}\n                                WHERE c_id = {$course_id} AND id = {$ref}";
                     $rs_document = Database::query($sql);
                     $obj_document = Database::fetch_object($rs_document);
                     if ($obj_document) {
                         $row[5] = $obj_document->title;
                     }
                     break;
                 case 'glossary':
                     $sql = "SELECT name FROM {$table_tool}\n    \t\t\t\t\t        WHERE c_id = {$course_id} AND glossary_id = {$ref}";
                     $rs_document = Database::query($sql);
                     $obj_document = Database::fetch_object($rs_document);
                     if ($obj_document) {
                         $row[5] = $obj_document->name;
                     }
                     break;
                 case 'lp':
                     $sql = "SELECT name\n                                FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}";
                     $rs_document = Database::query($sql);
                     $obj_document = Database::fetch_object($rs_document);
                     $row[5] = $obj_document->name;
                     break;
                 case 'quiz':
                     $sql = "SELECT title FROM {$table_tool}\n                                WHERE c_id = {$course_id} AND id = {$ref}";
                     $rs_document = Database::query($sql);
                     $obj_document = Database::fetch_object($rs_document);
                     if ($obj_document) {
                         $row[5] = $obj_document->title;
                     }
                     break;
                 case 'course_description':
                     $sql = "SELECT title FROM {$table_tool}\n                                WHERE c_id = {$course_id} AND id = {$ref}";
                     $rs_document = Database::query($sql);
                     $obj_document = Database::fetch_object($rs_document);
                     if ($obj_document) {
                         $row[5] = $obj_document->title;
                     }
                     break;
                 case 'thematic':
                     $rs = Database::query("SELECT title FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}");
                     if (Database::num_rows($rs) > 0) {
                         $obj = Database::fetch_object($rs);
                         $row[5] = $obj->title;
                     }
                     break;
                 case 'thematic_advance':
                     $rs = Database::query("SELECT content FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}");
                     if (Database::num_rows($rs) > 0) {
                         $obj = Database::fetch_object($rs);
                         $row[5] = $obj->content;
                     }
                     break;
                 case 'thematic_plan':
                     $rs = Database::query("SELECT title FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}");
                     if (Database::num_rows($rs) > 0) {
                         $obj = Database::fetch_object($rs);
                         $row[5] = $obj->title;
                     }
                     break;
                 default:
                     break;
             }
             $row2 = $name_session;
             if (!empty($coach_name)) {
                 $row2 .= '<br />' . get_lang('Coach') . ': ' . $coach_name;
             }
             $row[2] = $row2;
             if (!empty($row['col3'])) {
                 $userInfo = api_get_user_info($row['user_id']);
                 $row['col3'] = Display::url($row['col3'], $userInfo['profile_url']);
                 $row[3] = $row['col3'];
                 $ip = TrackingUserLog::get_ip_from_user_event($row['user_id'], $row['col5'], true);
                 if (empty($ip)) {
                     $ip = get_lang('Unknown');
                 }
                 $row[4] = $ip;
             }
             $resources[] = $row;
         }
     }
     return $resources;
 }
示例#4
0
 /**
  * Gets the exam'data results
  * @todo this function should be moved in a library  + no global calls
  * @param int $from
  * @param int $number_of_items
  * @param int $column
  * @param string $direction
  * @param int $exercise_id
  * @param null $extra_where_conditions
  * @param bool $get_count
  * @return array
  */
 public static function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false)
 {
     //@todo replace all this globals
     global $documentPath, $filter;
     $course_id = api_get_course_int_id();
     $sessionId = api_get_session_id();
     $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss();
     $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
     $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
     $TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER);
     $TBL_GROUP = Database::get_course_table(TABLE_GROUP);
     $TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
     $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
     $session_id_and = ' AND te.session_id = ' . $sessionId . ' ';
     $exercise_id = intval($exercise_id);
     $exercise_where = '';
     if (!empty($exercise_id)) {
         $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . '  ';
     }
     $hotpotatoe_where = '';
     if (!empty($_GET['path'])) {
         $hotpotatoe_path = Database::escape_string($_GET['path']);
         $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '"  ';
     }
     // sql for chamilo-type tests for teacher / tutor view
     $sql_inner_join_tbl_track_exercices = "\n        (\n            SELECT DISTINCT ttte.*, if(tr.exe_id,1, 0) as revised\n            FROM {$TBL_TRACK_EXERCICES} ttte LEFT JOIN {$TBL_TRACK_ATTEMPT_RECORDING} tr\n            ON (ttte.exe_id = tr.exe_id)\n            WHERE\n                c_id = {$course_id} AND\n                exe_exo_id = {$exercise_id} AND\n                ttte.session_id = " . $sessionId . "\n        )";
     if ($is_allowedToEdit) {
         //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries
         // Hack in order to filter groups
         $sql_inner_join_tbl_user = '';
         if (strpos($extra_where_conditions, 'group_id')) {
             $sql_inner_join_tbl_user = "******" . $course_id . ")\n                    INNER JOIN {$TBL_GROUP} g\n                    ON (gru.group_id = g.id AND g.c_id=" . $course_id . ")\n                )";
         }
         if (strpos($extra_where_conditions, 'group_all')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_all'  )", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_all'", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("group_id = 'group_all' AND", '', $extra_where_conditions);
             $sql_inner_join_tbl_user = "******";
             $sql_inner_join_tbl_user = null;
         }
         if (strpos($extra_where_conditions, 'group_none')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_none'  )", "AND (  group_id is null  )", $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_none'", "AND (  group_id is null  )", $extra_where_conditions);
             $sql_inner_join_tbl_user = "******" . $course_id . " )\n                LEFT OUTER JOIN {$TBL_GROUP} g\n                ON (gru.group_id = g.id AND g.c_id = " . $course_id . ")\n            )";
         }
         // All
         $is_empty_sql_inner_join_tbl_user = false;
         if (empty($sql_inner_join_tbl_user)) {
             $is_empty_sql_inner_join_tbl_user = true;
             $sql_inner_join_tbl_user = "******" . api_get_users_status_ignored_in_reports('string') . ")\n            )";
         }
         $sqlFromOption = " , {$TBL_GROUP_REL_USER} AS gru ";
         $sqlWhereOption = "  AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id ";
         $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname";
         if ($get_count) {
             $sql_select = "SELECT count(te.exe_id) ";
         } else {
             $sql_select = "SELECT DISTINCT\n                    user_id,\n                    {$first_and_last_name},\n                    official_code,\n                    ce.title,\n                    username,\n                    te.exe_result,\n                    te.exe_weighting,\n                    te.exe_date,\n                    te.exe_id,\n                    email as exemail,\n                    te.start_date,\n                    steps_counter,\n                    exe_user_id,\n                    te.exe_duration,\n                    propagate_neg,\n                    revised,\n                    group_name,\n                    group_id,\n                    orig_lp_id,\n                    te.user_ip";
         }
         $sql = " {$sql_select}\n                FROM {$TBL_EXERCICES} AS ce\n                INNER JOIN {$sql_inner_join_tbl_track_exercices} AS te\n                ON (te.exe_exo_id = ce.id)\n                INNER JOIN {$sql_inner_join_tbl_user} AS user\n                ON (user.user_id = exe_user_id)\n                WHERE\n                    te.status != 'incomplete' AND\n                    te.c_id = " . $course_id . " {$session_id_and} AND\n                    ce.active <>-1 AND ce.c_id = " . $course_id . "\n                    {$exercise_where}\n                    {$extra_where_conditions}\n                ";
         // sql for hotpotatoes tests for teacher / tutor view
         if ($get_count) {
             $hpsql_select = "SELECT count(username)";
         } else {
             $hpsql_select = "SELECT\n                    {$first_and_last_name} ,\n                    username,\n                    official_code,\n                    tth.exe_name,\n                    tth.exe_result ,\n                    tth.exe_weighting,\n                    tth.exe_date";
         }
         $hpsql = " {$hpsql_select}\n                FROM\n                    {$TBL_TRACK_HOTPOTATOES} tth,\n                    {$TBL_USER} user\n                    {$sqlFromOption}\n                WHERE\n                    user.user_id=tth.exe_user_id\n                    AND tth.c_id = " . $course_id . "\n                    {$hotpotatoe_where}\n                    {$sqlWhereOption}\n                    AND user.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n                ORDER BY\n                    tth.c_id ASC,\n                    tth.exe_date DESC";
     }
     if ($get_count) {
         $resx = Database::query($sql);
         $rowx = Database::fetch_row($resx, 'ASSOC');
         return $rowx[0];
     }
     $teacher_list = CourseManager::getTeacherListFromCourse(api_get_course_int_id());
     $teacher_id_list = array();
     if (!empty($teacher_list)) {
         foreach ($teacher_list as $teacher) {
             $teacher_id_list[] = $teacher['user_id'];
         }
     }
     $list_info = array();
     // Simple exercises
     if (empty($hotpotatoe_where)) {
         $column = !empty($column) ? Database::escape_string($column) : null;
         $from = intval($from);
         $number_of_items = intval($number_of_items);
         if (!empty($column)) {
             $sql .= " ORDER BY {$column} {$direction} ";
         }
         $sql .= " LIMIT {$from}, {$number_of_items}";
         $results = array();
         $resx = Database::query($sql);
         while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
             $results[] = $rowx;
         }
         $group_list = GroupManager::get_group_list();
         $clean_group_list = array();
         if (!empty($group_list)) {
             foreach ($group_list as $group) {
                 $clean_group_list[$group['id']] = $group['name'];
             }
         }
         $lp_list_obj = new LearnpathList(api_get_user_id());
         $lp_list = $lp_list_obj->get_flat_list();
         if (is_array($results)) {
             $users_array_id = array();
             $from_gradebook = false;
             if (isset($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
                 $from_gradebook = true;
             }
             $sizeof = count($results);
             $user_list_id = array();
             $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
             // Looping results
             for ($i = 0; $i < $sizeof; $i++) {
                 $revised = $results[$i]['revised'];
                 if ($from_gradebook && $is_allowedToEdit) {
                     if (in_array($results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], $users_array_id)) {
                         continue;
                     }
                     $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'];
                 }
                 $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null;
                 $lp_name = null;
                 if ($lp_obj) {
                     $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id'];
                     $lp_name = Display::url($lp_obj['lp_name'], $url, array('target' => '_blank'));
                 }
                 //Add all groups by user
                 $group_name_list = null;
                 if ($is_empty_sql_inner_join_tbl_user) {
                     $group_list = GroupManager::get_group_ids(api_get_course_int_id(), $results[$i]['user_id']);
                     foreach ($group_list as $id) {
                         $group_name_list .= $clean_group_list[$id] . '<br/>';
                     }
                     $results[$i]['group_name'] = $group_name_list;
                 }
                 $results[$i]['exe_duration'] = !empty($results[$i]['exe_duration']) ? round($results[$i]['exe_duration'] / 60) : 0;
                 $user_list_id[] = $results[$i]['exe_user_id'];
                 $id = $results[$i]['exe_id'];
                 $dt = api_convert_and_format_date($results[$i]['exe_weighting']);
                 // we filter the results if we have the permission to
                 if (isset($results[$i]['results_disabled'])) {
                     $result_disabled = intval($results[$i]['results_disabled']);
                 } else {
                     $result_disabled = 0;
                 }
                 if ($result_disabled == 0) {
                     $my_res = $results[$i]['exe_result'];
                     $my_total = $results[$i]['exe_weighting'];
                     $results[$i]['start_date'] = api_get_local_time($results[$i]['start_date']);
                     $results[$i]['exe_date'] = api_get_local_time($results[$i]['exe_date']);
                     if (!$results[$i]['propagate_neg'] && $my_res < 0) {
                         $my_res = 0;
                     }
                     $score = self::show_score($my_res, $my_total);
                     $actions = '';
                     if ($is_allowedToEdit) {
                         if (isset($teacher_id_list)) {
                             if (in_array($results[$i]['exe_user_id'], $teacher_id_list)) {
                                 $actions .= Display::return_icon('teachers.gif', get_lang('Teacher'));
                             }
                         }
                         if ($revised) {
                             $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id={$id}'>" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL);
                             $actions .= '&nbsp;';
                         } else {
                             $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id={$id}'>" . Display::return_icon('quiz.gif', get_lang('Qualify'));
                             $actions .= '&nbsp;';
                         }
                         $actions .= "</a>";
                         if ($filter == 2) {
                             $actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' . Display::return_icon('history.gif', get_lang('ViewHistoryChange')) . '</a>';
                         }
                         //Admin can always delete the attempt
                         if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) {
                             $ip = TrackingUserLog::get_ip_from_user_event($results[$i]['exe_user_id'], date('Y-m-d h:i:s'), false);
                             $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank">';
                             $actions .= Display::return_icon('info.png', $ip, ['title' => $ip]);
                             $actions .= '</a>';
                             $delete_link = '<a href="exercise_report.php?' . api_get_cidreq() . '&filter_by_user='******'filter_by_user']) . '&filter=' . $filter . '&exerciseId=' . $exercise_id . '&delete=delete&did=' . $id . '"
                             onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $results[$i]['username'], $dt) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>';
                             $delete_link = utf8_encode($delete_link);
                             if (api_is_drh() && !api_is_platform_admin()) {
                                 $delete_link = null;
                             }
                             $actions .= $delete_link . '&nbsp;';
                         }
                     } else {
                         $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
                         $attempt_link = Display::url(get_lang('Show'), $attempt_url, ['class' => 'ajax btn btn-default', 'data-title' => get_lang('Show')]);
                         $actions .= $attempt_link;
                     }
                     if ($revised) {
                         $revised = Display::label(get_lang('Validated'), 'success');
                     } else {
                         $revised = Display::label(get_lang('NotValidated'), 'info');
                     }
                     if ($is_allowedToEdit) {
                         $results[$i]['status'] = $revised;
                         $results[$i]['score'] = $score;
                         $results[$i]['lp'] = $lp_name;
                         $results[$i]['actions'] = $actions;
                         $list_info[] = $results[$i];
                     } else {
                         $results[$i]['status'] = $revised;
                         $results[$i]['score'] = $score;
                         $results[$i]['actions'] = $actions;
                         $list_info[] = $results[$i];
                     }
                 }
             }
         }
     } else {
         $hpresults = StatsUtils::getManyResultsXCol($hpsql, 6);
         // Print HotPotatoes test results.
         if (is_array($hpresults)) {
             for ($i = 0; $i < sizeof($hpresults); $i++) {
                 $hp_title = GetQuizName($hpresults[$i][3], $documentPath);
                 if ($hp_title == '') {
                     $hp_title = basename($hpresults[$i][3]);
                 }
                 $hp_date = api_get_local_time($hpresults[$i][6], null, date_default_timezone_get());
                 $hp_result = round($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1) * 100, 2) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')';
                 if ($is_allowedToEdit) {
                     $list_info[] = array($hpresults[$i][0], $hpresults[$i][1], $hpresults[$i][2], '', $hp_title, '-', $hp_date, $hp_result, '-');
                 } else {
                     $list_info[] = array($hp_title, '-', $hp_date, $hp_result, '-');
                 }
             }
         }
     }
     return $list_info;
 }
示例#5
0
     // show all : number of 1 is equal to or bigger than number of categories
     // show none : number of 0 is equal to or bigger than number of categories
     echo "<tr>\n                    <td>\n                    [<a href='" . api_get_self() . "?uInfo=" . Security::remove_XSS($uInfo) . "&view=1111111'>" . get_lang('ShowAll') . "</a>]\n                    [<a href='" . api_get_self() . "?uInfo=" . Security::remove_XSS($uInfo) . "&view=0000000'>" . get_lang('ShowNone') . "</a>]" . "</td>\n                </tr>\n            ";
     if (!isset($view)) {
         $view = '0000000';
     }
     //Logins
     TrackingUserLog::display_login_tracking_info($view, $uInfo, $courseId);
     //Exercise results
     TrackingUserLog::display_exercise_tracking_info($view, $uInfo, $courseId);
     //Student publications uploaded
     TrackingUserLog::display_student_publications_tracking_info($view, $uInfo, $courseId);
     //Links usage
     TrackingUserLog::display_links_tracking_info($view, $uInfo, $courseId);
     //Documents downloaded
     TrackingUserLog::display_document_tracking_info($view, $uInfo, $courseId);
 } else {
     echo get_lang('ErrorUserNotInGroup');
 }
 /*
  *		Scorm contents and Learning Path
  */
 if (substr($view, 5, 1) == '1') {
     $new_view = substr_replace($view, '0', 5, 1);
     echo "<tr>\n                        <td valign='top'>\n                        <font     color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>" . get_lang('ScormAccess') . "</b>&nbsp;&nbsp;&nbsp;[<a href='" . api_get_self() . "?view=" . Security::remove_XSS($new_view) . "&uInfo=" . Security::remove_XSS($uInfo) . "'>" . get_lang('Close') . "</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?" . api_get_cidreq() . "&uInfo=" . Security::remove_XSS($_GET['uInfo']) . "&view=000001'>" . get_lang('ExportAsCSV') . "</a>]\n                        </td>\n                </tr>";
     $sql = "SELECT id, name FROM {$tbl_learnpath_main}";
     $result = Database::query($sql);
     $ar = Database::fetch_array($result);
     echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
     echo "<table cellpadding='2' cellspacing='1' border='0' align='center'><tr>\n                                    <td class='secLine'>\n                                    &nbsp;" . get_lang('ScormContentColumn') . "&nbsp;\n                                    </td>\n            </tr>";
     if (is_array($ar)) {
示例#6
0
     // show all : number of 1 is equal to or bigger than number of categories
     // show none : number of 0 is equal to or bigger than number of categories
     echo "<tr>\n                    <td>\n                    [<a href='" . api_get_self() . "?uInfo=" . Security::remove_XSS($uInfo) . "&view=1111111'>" . get_lang('ShowAll') . "</a>]\n                    [<a href='" . api_get_self() . "?uInfo=" . Security::remove_XSS($uInfo) . "&view=0000000'>" . get_lang('ShowNone') . "</a>]" . "</td>\n                </tr>\n            ";
     if (!isset($view)) {
         $view = '0000000';
     }
     //Logins
     TrackingUserLog::display_login_tracking_info($view, $uInfo, $courseId);
     //Exercise results
     TrackingUserLog::display_exercise_tracking_info($view, $uInfo, $_cid);
     //Student publications uploaded
     TrackingUserLog::display_student_publications_tracking_info($view, $uInfo, $courseId);
     //Links usage
     TrackingUserLog::display_links_tracking_info($view, $uInfo, $_cid);
     //Documents downloaded
     TrackingUserLog::display_document_tracking_info($view, $uInfo, $_cid);
 } else {
     echo get_lang('ErrorUserNotInGroup');
 }
 /*
  *		Scorm contents and Learning Path
  */
 if (substr($view, 5, 1) == '1') {
     $new_view = substr_replace($view, '0', 5, 1);
     echo "<tr>\n                        <td valign='top'>\n                        <font     color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>" . get_lang('ScormAccess') . "</b>&nbsp;&nbsp;&nbsp;[<a href='" . api_get_self() . "?view=" . Security::remove_XSS($new_view) . "&uInfo=" . Security::remove_XSS($uInfo) . "'>" . get_lang('Close') . "</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?" . api_get_cidreq() . "&uInfo=" . Security::remove_XSS($_GET['uInfo']) . "&view=000001'>" . get_lang('ExportAsCSV') . "</a>]\n                        </td>\n                </tr>";
     $sql = "SELECT id, name FROM {$tbl_learnpath_main}";
     $result = Database::query($sql);
     $ar = Database::fetch_array($result);
     echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
     echo "<table cellpadding='2' cellspacing='1' border='0' align='center'><tr>\n                                    <td class='secLine'>\n                                    &nbsp;" . get_lang('ScormContentColumn') . "&nbsp;\n                                    </td>\n            </tr>";
     if (is_array($ar)) {