Minor - format code, add int casting, fix phpdocs

pull/2874/head
Julio Montoya 7 years ago
parent f4ded69c9d
commit 0ee66bd213
  1. 39
      main/inc/lib/tracking.lib.php
  2. 22
      main/mySpace/index.php

@ -2636,7 +2636,7 @@ class Tracking
return false; return false;
} }
$sessionId = intval($sessionId); $sessionId = (int) $sessionId;
$courseInfo = api_get_course_info($courseCode); $courseInfo = api_get_course_info($courseCode);
if (empty($courseInfo)) { if (empty($courseInfo)) {
@ -2679,7 +2679,7 @@ class Tracking
$conditions = [ $conditions = [
" c_id = {$courseInfo['real_id']} ", " c_id = {$courseInfo['real_id']} ",
" lp_view.lp_id IN(".implode(', ', $filteredLP).") ", " lp_view.lp_id IN (".implode(', ', $filteredLP).") ",
]; ];
$groupBy = 'GROUP BY lp_id'; $groupBy = 'GROUP BY lp_id';
@ -2688,7 +2688,7 @@ class Tracking
$studentId = array_map('intval', $studentId); $studentId = array_map('intval', $studentId);
$conditions[] = " lp_view.user_id IN (".implode(',', $studentId).") "; $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).") ";
} else { } else {
$studentId = intval($studentId); $studentId = (int) $studentId;
$conditions[] = " lp_view.user_id = '$studentId' "; $conditions[] = " lp_view.user_id = '$studentId' ";
if (empty($lpIdList)) { if (empty($lpIdList)) {
@ -2714,7 +2714,7 @@ class Tracking
if (!empty($sessionId)) { if (!empty($sessionId)) {
$conditions[] = " session_id = $sessionId "; $conditions[] = " session_id = $sessionId ";
} else { } else {
$conditions[] = " (session_id = 0 OR session_id IS NULL) "; $conditions[] = ' (session_id = 0 OR session_id IS NULL) ';
} }
$conditionToString = implode('AND', $conditions); $conditionToString = implode('AND', $conditions);
@ -3185,13 +3185,11 @@ class Tracking
* 3. And finally it will return the average between 1. and 2. * 3. And finally it will return the average between 1. and 2.
* This function does not take the results of a Test out of a LP. * This function does not take the results of a Test out of a LP.
* *
* @param int|array Array of user ids or an user id * @param int|array $student_id Array of user ids or an user id
* @param string $course_code Course code * @param string $course_code Course code
* @param array $lp_ids List of LP ids * @param array $lp_ids List of LP ids
* @param int $session_id Session id (optional), if param $session_id is 0(default) * @param int $session_id Session id (optional), if param $session_id is 0(default)
* it'll return results including sessions, 0 = session is not filtered * it'll return results including sessions, 0 = session is not filtered
* @param bool Returns an array of the type [sum_score, num_score] if set to true
* @param bool get only the latest attempts or ALL attempts
* *
* @return string value (number %) Which represents a round integer explain in got in 3 * @return string value (number %) Which represents a round integer explain in got in 3
*/ */
@ -3220,11 +3218,11 @@ class Tracking
// Compose a filter based on optional learning paths list given // Compose a filter based on optional learning paths list given
if (!empty($lp_ids) && count($lp_ids) > 0) { if (!empty($lp_ids) && count($lp_ids) > 0) {
$conditions[] = " id IN(".implode(',', $lp_ids).") "; $conditions[] = ' id IN ('.implode(',', $lp_ids).') ';
} }
// Compose a filter based on optional session id // Compose a filter based on optional session id
$session_id = intval($session_id); $session_id = (int) $session_id;
if (!empty($session_id)) { if (!empty($session_id)) {
$conditions[] = " session_id = $session_id "; $conditions[] = " session_id = $session_id ";
} }
@ -3233,6 +3231,7 @@ class Tracking
array_walk($student_id, 'intval'); array_walk($student_id, 'intval');
$conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") "; $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
} else { } else {
$student_id = (int) $student_id;
$conditions[] = " lp_view.user_id = $student_id "; $conditions[] = " lp_view.user_id = $student_id ";
} }
@ -3994,17 +3993,13 @@ class Tracking
/** /**
* Count assignments per student. * Count assignments per student.
* *
* @param $student_id * @param array|int $student_id
* @param null $course_code * @param string $course_code
* @param null $session_id * @param int $session_id if param is null(default) return count of assignments including sessions,
* 0 = session is not filtered
* *
* @return int Count of assignments * @return int Count of assignments
* *
* @internal param array|int $Student id(s)
* @internal param Course $string code
* @internal param Session $int id (optional),
* if param $session_id is null(default) return count of assignments
* including sessions, 0 = session is not filtered
*/ */
public static function count_student_assignments( public static function count_student_assignments(
$student_id, $student_id,
@ -4032,7 +4027,7 @@ class Tracking
$studentList = array_map('intval', $student_id); $studentList = array_map('intval', $student_id);
$conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') "; $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
} else { } else {
$student_id = intval($student_id); $student_id = (int) $student_id;
$conditions[] = " ip.insert_user_id = '$student_id' "; $conditions[] = " ip.insert_user_id = '$student_id' ";
} }

@ -12,17 +12,17 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
// Access control
api_block_anonymous_users();
$htmlHeadXtra[] = api_get_jqgrid_js(); $htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = '<script type="text/javascript" src="' $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>';
.api_get_path(WEB_PUBLIC_PATH).'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>';
// the section (for the tabs)
$this_section = SECTION_TRACKING; $this_section = SECTION_TRACKING;
//for HTML editor repository
//Session::erase('this_section');
ob_start(); ob_start();
$nameTools = get_lang('MySpace'); $nameTools = get_lang('MySpace');
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false; $export_csv = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false;
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null; $display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;
$csv_content = []; $csv_content = [];
$user_id = api_get_user_id(); $user_id = api_get_user_id();
@ -31,18 +31,12 @@ $is_coach = api_is_coach($session_id);
$is_platform_admin = api_is_platform_admin(); $is_platform_admin = api_is_platform_admin();
$is_drh = api_is_drh(); $is_drh = api_is_drh();
$is_session_admin = api_is_session_admin(); $is_session_admin = api_is_session_admin();
$title = '';
$skipData = api_get_configuration_value('tracking_skip_generic_data'); $skipData = api_get_configuration_value('tracking_skip_generic_data');
// Access control
api_block_anonymous_users();
$logInfo = [ $logInfo = [
'tool' => SECTION_TRACKING, 'tool' => SECTION_TRACKING,
'tool_id' => 0, 'tool_id' => 0,
'tool_id_detail' => 0, 'tool_id_detail' => 0,
'action' => '',
'action_details' => '',
]; ];
Event::registerLog($logInfo); Event::registerLog($logInfo);
@ -70,7 +64,6 @@ $calendarMenuAdded = false;
if ($is_platform_admin) { if ($is_platform_admin) {
if ($view == 'admin') { if ($view == 'admin') {
$title = get_lang('CoachList');
$menu_items[] = Display::url( $menu_items[] = Display::url(
Display::return_icon('teacher.png', get_lang('TeacherInterface'), [], ICON_SIZE_MEDIUM), Display::return_icon('teacher.png', get_lang('TeacherInterface'), [], ICON_SIZE_MEDIUM),
api_get_self().'?view=teacher' api_get_self().'?view=teacher'
@ -312,13 +305,12 @@ $form = new FormValidator(
api_get_path(WEB_CODE_PATH).'mySpace/student.php' api_get_path(WEB_CODE_PATH).'mySpace/student.php'
); );
$form = Tracking::setUserSearchForm($form); $form = Tracking::setUserSearchForm($form);
$skipData = api_get_configuration_value('tracking_skip_generic_data');
$totalTimeSpent = null; $totalTimeSpent = null;
$averageScore = null; $averageScore = null;
$posts = null; $posts = null;
if ($skipData == false) { if ($skipData === false) {
if (!empty($students)) { if (!empty($students)) {
// Students // Students
$studentIds = array_values($students); $studentIds = array_values($students);

Loading…
Cancel
Save