protected function renderContent() { $html = ''; $sql = "SELECT `tool_id`,\n COUNT(DISTINCT `user_id`) AS `nbr_distinct_users_access`,\n COUNT( `tool_id` ) AS `nbr_access`\n FROM `" . $this->tbl_course_tracking_event . "`\n WHERE `type` = 'tool_access'\n AND `tool_id` IS NOT NULL\n AND `tool_id` <> ''\n GROUP BY `tool_id`"; $results = claro_sql_query_fetch_all($sql); $html .= '<table class="claroTable" cellpadding="2" cellspacing="1" border="0" align="center" style="width: 99%;">' . "\n" . '<thead><tr class="headerX">' . "\n" . '<th> ' . get_lang('Name of the tool') . ' </th>' . "\n" . '<th> ' . get_lang('Users\' Clicks') . ' </th>' . "\n" . '<th> ' . get_lang('Total Clicks') . ' </th>' . "\n" . '</tr></thead>' . "\n" . '<tbody>' . "\n"; if (!empty($results) && is_array($results)) { foreach ($results as $result) { $thisTid = (int) $result['tool_id']; // FIXME check that claro_get_tool_name returns a toolname... check that tool exists $thisToolName = claro_get_tool_name(claro_get_tool_id_from_course_tid($thisTid)); $html .= '<tr>' . "\n" . '<td>' . '<a href="tool_access_details.php?toolId=' . $thisTid . '">' . $thisToolName . '</a></td>' . "\n" . '<td align="right"><a href="user_access_details.php?cmd=tool&id=' . $thisTid . '">' . (int) $result['nbr_distinct_users_access'] . '</a></td>' . "\n" . '<td align="right">' . (int) $result['nbr_access'] . '</td>' . "\n" . '</tr>' . "\n\n"; } } else { $html .= '<tr>' . "\n" . '<td colspan="3"><div align="center">' . get_lang('No result') . '</div></td>' . "\n" . '</tr>' . "\n"; } $html .= '</tbody>' . '</table>' . "\n"; return $html; }
$i = 0; while ($i < sizeof($accessList)) { $output .= '<tr>' . "\n" . '<td><small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), strtotime($accessList[$i]['date'])) . '</small></td>' . "\n" . '</tr>' . "\n"; // $limit is used to select only results between current login and next one if ($i == sizeof($accessList) - 1 || !isset($accessList[$i + 1]['date'])) { $limit = date("Y-m-d H:i:s", $nextReqDate); } else { $limit = $accessList[$i + 1]['date']; } // select all access in the displayed date range $sql = "SELECT `tool_id`, count(`id`) AS `nbr_access`\n FROM `" . $tbl_course_tracking_event . "`\n WHERE `user_id` = '" . (int) $userId . "'\n AND `type` = 'tool_access'\n AND `date` >= '" . $accessList[$i]['date'] . "'\n AND `date` < '" . $limit . "'\n GROUP BY `tool_id`\n ORDER BY `tool_id` ASC"; $toolAccess = claro_sql_query_fetch_all($sql); if (!empty($toolAccess) && is_array($toolAccess)) { $output .= '<tr>' . "\n" . '<td colspan="2">' . "\n" . '<table width="100%" cellpadding="0" cellspacing="0" border="0">' . "\n"; foreach ($toolAccess as $aToolAccess) { $output .= '<tr>' . "\n" . '<td width="70%"><small>' . claro_get_tool_name(claro_get_tool_id_from_course_tid($aToolAccess['tool_id'])) . '</small></td>' . "\n" . '<td width="30%" align="right"><small>' . $aToolAccess['nbr_access'] . ' ' . get_lang('Visits') . '</small></td>' . "\n" . '</tr>' . "\n"; } $output .= '</table>' . "\n" . '</td></tr>' . "\n\n"; } $i++; } } else { $output .= '<tr>' . "\n" . '<td colspan="2">' . '<div align="center">' . get_lang('No result') . '</div>' . '</td>' . "\n" . '</tr>' . "\n"; } $output .= '</tbody></table>' . "\n"; $output .= "\n" . '</div>' . "\n"; /* * Output rendering */ $claroline->display->body->setContent($output); echo $claroline->display->render();
*/ ClaroBreadCrumbs::getInstance()->prepend(get_lang('Statistics'), 'courseReport.php'); $nameTools = get_lang('Statistics'); $html = ''; $langMonthNames = get_locale('langMonthNames'); if (claro_is_in_a_course()) { // to see stats of one course user must be courseAdmin of this course $is_allowedToTrack = claro_is_course_manager(); } else { // cid has to be set here else it probably means that the user has directly access this page by url $is_allowedToTrack = false; } if ($is_allowedToTrack) { // Title parts $titleParts['mainTitle'] = $nameTools; $titleParts['subTitle'] = get_lang('Details for the tool') . ': ' . claro_get_tool_name(claro_get_tool_id_from_course_tid($toolId)); // Command list $cmdList = array(); $cmdList[] = array('name' => get_lang('View list of all tools'), 'url' => './courseReport.php'); $html .= claro_html_tool_title($titleParts, null, $cmdList); $langDay_of_weekNames = get_locale('langDay_of_weekNames'); switch ($period) { case "month": $html .= $langMonthNames['long'][date("n", $reqdate) - 1] . date(" Y", $reqdate); break; case "week": $weeklowreqdate = $reqdate - 86400 * date("w", $reqdate); $weekhighreqdate = $reqdate + 86400 * (6 - date("w", $reqdate)); $html .= '<b>' . get_lang('From') . '</b> ' . date('d ', $weeklowreqdate) . $langMonthNames['long'][date('n', $weeklowreqdate) - 1] . date(' Y', $weeklowreqdate) . "\n"; $html .= ' <b>' . get_lang('to') . '</b> ' . date('d ', $weekhighreqdate) . $langMonthNames['long'][date('n', $weekhighreqdate) - 1] . date(' Y', $weekhighreqdate) . "\n"; break;
* */ require '../inc/claro_init_global.inc.php'; $nameTools = get_lang('User access details'); $interbredcrump[] = array("url" => "courseReport.php", "name" => get_lang('Statistics')); $tbl_mdb_names = claro_sql_get_main_tbl(); $tbl_user = $tbl_mdb_names['user']; $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued(claro_get_current_course_id())); $tbl_course_tracking_event = $tbl_cdb_names['tracking_event']; require_once get_path('incRepositorySys') . '/lib/statsUtils.lib.inc.php'; $toolTitle['mainTitle'] = $nameTools; $is_allowedToTrack = claro_is_course_manager(); $out = ''; if ($is_allowedToTrack && get_conf('is_trackingEnabled')) { if (isset($_REQUEST['cmd']) && ($_REQUEST['cmd'] == 'tool' && !empty($_REQUEST['id']))) { $toolTitle['subTitle'] = claro_get_tool_name(claro_get_tool_id_from_course_tid((int) $_REQUEST['id'])); // prepare SQL query $sql = "SELECT `U`.`nom` AS `lastName`,\n `U`.`prenom` AS `firstName`,\n MAX(UNIX_TIMESTAMP(`TE`.`date`)) AS `data`,\n COUNT(`TE`.`date`) AS `nbr`\n FROM `" . $tbl_course_tracking_event . "` AS `TE`\n LEFT JOIN `" . $tbl_user . "` AS `U`\n ON `TE`.`user_id` = `U`.`user_id`\n WHERE `TE`.`tool_id` = '" . (int) $_REQUEST['id'] . "'\n GROUP BY `U`.`nom`, `U`.`prenom`\n ORDER BY `U`.`nom`, `U`.`prenom`"; } elseif (isset($_REQUEST['cmd']) && ($_REQUEST['cmd'] == 'doc' && !empty($_REQUEST['path']))) { // FIXME : fix query, probably not a good idea to use like to find a match inside serialized data // set the subtitle for the echo claro_html_tool_title function $toolTitle['subTitle'] = get_lang('Documents and Links') . " : " . claro_htmlspecialchars($_REQUEST['path']); // prepare SQL query $sql = "SELECT `U`.`nom` as `lastName`,\n `U`.`prenom` as `firstName`,\n MAX(UNIX_TIMESTAMP(`TE`.`date`)) AS `data`,\n COUNT(`TE`.`date`) AS `nbr`\n FROM `" . $tbl_course_tracking_event . "` AS `TE`\n LEFT JOIN `" . $tbl_user . "` AS `U`\n ON `U`.`user_id` = `TE`.`user_id`\n WHERE `TE`.`data` LIKE '%" . claro_sql_escape($_REQUEST['path']) . "%'\n GROUP BY `U`.`nom`, `U`.`prenom`\n ORDER BY `U`.`nom`, `U`.`prenom`"; } else { claro_die(get_lang('Wrong operation')); } $out .= claro_html_tool_title($toolTitle); // TODO use datagrid $out .= '<br />' . "\n\n" . '<table class="claroTable" border="0" cellpadding="5" cellspacing="1">' . "\n" . '<tr class="headerX">' . "\n" . '<th>' . get_lang('Username') . '</th>' . "\n" . '<th>' . get_lang('Last access') . '</th>' . "\n" . '<th>' . get_lang('Access count') . '</th>' . "\n" . '</tr>' . "\n" . '<tbody>' . "\n\n"; $i = 0;