/** * Display table with tool/right of the profile */ public function displayProfileToolRightList() { $html = ''; $html_table_header_list = array(); $html_table_row_list = array(); foreach ($this->rightProfileToolRightList as $profile_id => $rightProfileToolRight) { $isLocked = $rightProfileToolRight->profile->isLocked(); $className = get_class($rightProfileToolRight); // use strtolower for PHP4 : get_class returns class name in lowercase $className = strtolower($className); $html_table_header_list[$profile_id] = claro_get_profile_name($profile_id); if ($isLocked && $className == strtolower('RightCourseProfileToolRight')) { $displayMode = claro_is_platform_admin() ? $this->displayMode : 'read'; $html_table_header_list[$profile_id] .= ' <img src="' . get_icon_url('locked') . '" alt="' . get_lang('Profile locked') . '" />'; } else { $displayMode = $this->displayMode; } foreach ($rightProfileToolRight->toolActionList as $tool_id => $action_list) { $action_right = $rightProfileToolRight->getToolRight($tool_id); $html_right = ''; if ($displayMode == 'edit') { $param_append = '?profile_id=' . urlencode($profile_id) . '&tool_id=' . urlencode($tool_id) . '&cmd=set_right'; foreach ($this->urlParamAppendList as $name => $value) { $param_append .= '&' . $name . '=' . $value; } } if (claro_get_profile_label($profile_id) != ANONYMOUS_PROFILE && claro_get_profile_label($profile_id) != GUEST_PROFILE) { if ($action_right == 'none') { $action_param_value = 'user'; $html_right = '<img src="' . get_icon_url('forbidden') . '" alt="' . get_lang('No access') . '" /> <span style="font-size: smaller;">' . get_lang('No access') . "</span>\n"; } elseif ($action_right == 'user') { $action_param_value = 'manager'; $html_right = '<img src="' . get_icon_url('user') . '" alt="' . get_lang('Access allowed') . '" /> <span style="font-size: smaller;">' . get_lang('Access allowed') . "</span>\n"; } else { $action_param_value = 'none'; $html_right = '<img src="' . get_icon_url('manager') . '" alt="' . get_lang('Edition allowed') . '" /> <span style="font-size: smaller;">' . get_lang('Edition allowed') . "</span>\n"; } } else { if ($action_right == 'none') { $action_param_value = 'user'; $html_right = '<img src="' . get_icon_url('forbidden') . '" alt="' . get_lang('No access') . '" /> <span style="font-size: smaller;">' . get_lang('No access') . "</span>\n"; } else { $action_param_value = 'none'; $html_right = '<img src="' . get_icon_url('user') . '" alt="' . get_lang('Access allowed') . '" /> <span style="font-size: smaller;">' . get_lang('Access allowed') . "</span>\n"; } } if ($displayMode == 'edit') { $html_right = '<a href="' . $_SERVER['PHP_SELF'] . $param_append . '&right_value=' . $action_param_value . '">' . $html_right . '</a>'; } $html_table_row_list[$tool_id][$profile_id] = $html_right; } } // build table $html .= '<table class="claroTable emphaseLine" >' . "\n" . '<thead>' . "\n" . '<tr class="headerX">' . "\n" . '<th>' . get_lang('Tools') . '</th>' . "\n"; // visibility column if ($this->isSetCourseToolInfo()) { $html .= '<th style="text-align:center; width:100px;" >' . get_lang('Visibility') . '</th>' . "\n"; } foreach ($html_table_header_list as $html_table_header) { $html .= '<th style="text-align:center; width:100px;" >' . $html_table_header . '</th>' . "\n"; } $html .= '</tr>' . "\n" . '</thead>' . "\n" . '<tbody>'; foreach ($html_table_row_list as $tool_id => $html_table_row) { if (claro_is_in_a_course() && (!$this->isSetCourseToolInfo() || !isset($this->courseToolInfo[$tool_id]))) { // Not activated in course ! continue; } $html .= '<tr>' . "\n"; if ($this->isSetCourseToolInfo()) { // Add visibility and icon from courseToolInfo $html .= '<td ' . ($this->courseToolInfo[$tool_id]['visibility'] == true ? '' : 'class="invisible"') . '>' . '<img src="' . $this->courseToolInfo[$tool_id]['icon'] . '" alt="" />' . get_lang(claro_get_tool_name($tool_id)) . '</td>'; } else { $html .= '<td>' . get_lang(claro_get_tool_name($tool_id)) . '</td>' . "\n"; } // visibility column if ($this->isSetCourseToolInfo()) { if ($this->courseToolInfo[$tool_id]['visibility'] == true) { $html .= '<td align="center">' . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exInvisible&tool_id=' . $this->courseToolInfo[$tool_id]['tid'] . '" >' . '<img src="' . get_icon_url('visible') . '" alt="' . get_lang('Visible') . '" />' . '</a>' . '</td>' . "\n"; } else { $html .= '<td align="center">' . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exVisible&tool_id=' . $this->courseToolInfo[$tool_id]['tid'] . '" >' . '<img src="' . get_icon_url('invisible') . '" alt="' . get_lang('Invisible') . '" />' . '</a></td>' . "\n"; } } // profile colums foreach ($html_table_row as $html_table_row_cell) { $html .= '<td align="center">' . $html_table_row_cell . '</td>'; } $html .= '</tr>' . "\n"; } $html .= '</tbody></table>'; return $html; }
/** * @param int $gid * @param string $courseId * @param boolean $active if set to true, only actvated tool will be considered for display */ function get_group_tool_menu($gid = null, $courseId = null, $active = true) { $toolList = array(); if (is_null($gid)) { $gid = claro_get_current_group_id(); } if (is_null($courseId)) { $courseId = claro_get_current_course_id(); } require_once dirname(__FILE__) . '/../group.lib.inc.php'; $groupToolList = get_group_tool_list($courseId, $active); // group space links /* $toolList[] = claro_html_cmd_link( claro_htmlspecialchars(Url::Contextualize( get_module_url('CLGRP').'/group_space.php' )) , '<img src="' . get_icon_url('group') . '" alt="" /> ' . get_lang('Group area') ); */ $courseGroupData = claro_get_main_group_properties($courseId); foreach ($groupToolList as $groupTool) { if (is_tool_activated_in_groups($courseId, $groupTool['label']) && (isset($courseGroupData['tools'][$groupTool['label']]) && $courseGroupData['tools'][$groupTool['label']])) { $toolList[] = claro_html_cmd_link(claro_htmlspecialchars(Url::Contextualize(get_module_url($groupTool['label']) . '/' . $groupTool['url'])), '<img src="' . get_module_url($groupTool['label']) . '/' . $groupTool['icon'] . '" alt="" />' . ' ' . claro_get_tool_name($groupTool['label']), array('class' => $groupTool['visibility'] ? 'visible' : 'invisible')); } } if (count($toolList)) { return claro_html_menu_horizontal($toolList); } else { return ''; } }
protected function renderHeader() { return claro_get_tool_name('CLFRM'); }
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; }
*/ 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;
$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();
$action_link = '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exRmTool&toolLabel=' . claro_htmlspecialchars($activeTool['label']) . '&section=' . claro_htmlspecialchars($currentSection))) . '" ' . 'title="' . get_lang('Remove') . '">' . '<img src="' . get_icon_url('delete') . '" border="0" alt="' . get_lang('Remove') . '"/>' . '</a>'; } else { $action_link = '-'; } $out .= '<tr>' . '<td><img src="' . get_module_url($activeTool['label']) . '/' . $activeTool['icon'] . '" alt="" /> ' . get_lang(claro_get_tool_name($activeTool['tool_id'])) . '</td>' . '<td>' . $action_link . '</td>' . '</tr>' . "\n"; } } else { $out .= '<tr><td colspan="2">' . get_lang('Empty') . '</td></tr>' . "\n"; } $out .= '</tbody>' . "\n" . '</table>' . "\n\n" . '</blockquote>' . "\n"; $out .= '<h3>' . get_lang('Available tools to add to your course') . '</h3>' . "\n"; $out .= '<blockquote>' . "\n" . '<table class="claroTable emphaseLine" style="width: 100%" >' . "\n\n" . '<thead>' . "\n" . '<tr>' . "\n" . '<th>' . get_lang('Tool') . '</th>' . "\n" . '<th>' . get_lang('Add to course') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n\n" . '<tbody>' . "\n"; if (!empty($completeInactiveToolList)) { foreach ($completeInactiveToolList as $inactiveTool) { if ($inactiveTool['access_manager'] == 'COURSE_ADMIN' || claro_is_platform_admin()) { $action_link = '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exAddTool&toolLabel=' . claro_htmlspecialchars($inactiveTool['label']) . '&section=' . claro_htmlspecialchars($currentSection))) . '" ' . 'title="' . get_lang('Add') . '">' . '<img src="' . get_icon_url('select') . '" alt="' . get_lang('Add') . '"/>' . '</a>'; } else { $action_link = '<em>' . get_lang('Activable only by the platform administrator !') . '</em>'; } $out .= '<tr>' . '<td><img src="' . $inactiveTool['icon'] . '" alt="" /> ' . get_lang(claro_get_tool_name($inactiveTool['tool_id'])) . '</td>' . '<td>' . $action_link . '</td>' . '</tr>' . "\n"; } } else { $out .= '<tr><td colspan="2">' . get_lang('Empty') . '</td></tr>' . "\n"; } $out .= '</tbody>' . "\n" . '</table>' . "\n\n" . '</blockquote>' . "\n"; } else { // should never happen $out .= get_lang('Invalid section'); } $claroline->display->body->appendContent($out); echo $claroline->display->render();
* */ 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;