Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent 76501eb534
commit 145eca9797
  1. 4
      main/admin/teacher_time_report.php
  2. 36
      main/inc/lib/course.lib.php
  3. 1
      main/inc/lib/sessionmanager.lib.php
  4. 2
      main/inc/lib/usermanager.lib.php
  5. 8
      main/inc/lib/userportal.lib.php

@ -119,7 +119,7 @@ if (!empty($selectedCourse)) {
foreach ($sessionsByCourse as $session) { foreach ($sessionsByCourse as $session) {
$coaches = CourseManager::get_coachs_from_course($session['id'], $course['real_id']); $coaches = CourseManager::get_coachs_from_course($session['id'], $course['real_id']);
if ($coaches) { if (!empty($coaches)) {
foreach ($coaches as $coach) { foreach ($coaches as $coach) {
$totalTime = UserManager::getTimeSpentInCourses( $totalTime = UserManager::getTimeSpentInCourses(
$coach['user_id'], $coach['user_id'],
@ -173,7 +173,7 @@ if (!empty($selectedSession)) {
$coaches = CourseManager::get_coachs_from_course($selectedSession, $course['id']); $coaches = CourseManager::get_coachs_from_course($selectedSession, $course['id']);
if ($coaches) { if (!empty($coaches)) {
foreach ($coaches as $coach) { foreach ($coaches as $coach) {
$totalTime = UserManager::getTimeSpentInCourses( $totalTime = UserManager::getTimeSpentInCourses(
$coach['user_id'], $coach['user_id'],

@ -1911,6 +1911,7 @@ class CourseManager
$rs = Database::query($sql); $rs = Database::query($sql);
$listTeachers = array(); $listTeachers = array();
$teachers = array(); $teachers = array();
$url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup';
while ($teacher = Database::fetch_array($rs)) { while ($teacher = Database::fetch_array($rs)) {
$userPicture = UserManager::getUserPicture($teacher['user_id'], USER_IMAGE_SIZE_SMALL); $userPicture = UserManager::getUserPicture($teacher['user_id'], USER_IMAGE_SIZE_SMALL);
$teachers['id'] = $teacher['user_id']; $teachers['id'] = $teacher['user_id'];
@ -1920,7 +1921,7 @@ class CourseManager
$teachers['username'] = $teacher['username']; $teachers['username'] = $teacher['username'];
$teachers['status'] = $teacher['status']; $teachers['status'] = $teacher['status'];
$teachers['avatar'] = $userPicture; $teachers['avatar'] = $userPicture;
$teachers['url'] = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup&user_id=' . $teacher['user_id']; $teachers['url'] = $url.'&user_id='. $teacher['user_id'];
$listTeachers[]=$teachers; $listTeachers[]=$teachers;
} }
return $listTeachers; return $listTeachers;
@ -2001,7 +2002,6 @@ class CourseManager
$tbl_user = Database:: get_main_table(TABLE_MAIN_USER); $tbl_user = Database:: get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coaches = array();
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
u.user_id, u.user_id,
@ -2017,15 +2017,15 @@ class CourseManager
scu.status = 2"; scu.status = 2";
$rs = Database::query($sql); $rs = Database::query($sql);
$coaches = array();
if (Database::num_rows($rs) > 0) { if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) { while ($row = Database::fetch_array($rs)) {
$completeName = api_get_person_name($row['firstname'], $row['lastname']); $completeName = api_get_person_name($row['firstname'], $row['lastname']);
$coaches[] = $row + ['full_name' => $completeName]; $coaches[] = $row + ['full_name' => $completeName];
} }
return $coaches;
} else {
return false;
} }
return $coaches;
} }
/** /**
@ -2037,17 +2037,16 @@ class CourseManager
*/ */
public static function get_coachs_from_course_to_string( public static function get_coachs_from_course_to_string(
$session_id = 0, $session_id = 0,
$courseId = null, $courseId = 0,
$separator = self::USER_SEPARATOR, $separator = self::USER_SEPARATOR,
$add_link_to_profile = false, $add_link_to_profile = false,
$orderList = false $orderList = false
) { ) {
$coachs_course = self::get_coachs_from_course($session_id, $courseId); $coachList = self::get_coachs_from_course($session_id, $courseId);
$course_coachs = array(); $course_coachs = array();
$html = ''; if (!empty($coachList)) {
if (is_array($coachs_course)) { foreach ($coachList as $coach_course) {
foreach ($coachs_course as $coach_course) { $coach_name = $coach_course['full_name'];
$coach_name = api_get_person_name($coach_course['firstname'], $coach_course['lastname']);
if ($add_link_to_profile) { if ($add_link_to_profile) {
$url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup&user_id=' . $coach_course['user_id']; $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup&user_id=' . $coach_course['user_id'];
$coach_name = Display::url( $coach_name = Display::url(
@ -2063,7 +2062,7 @@ class CourseManager
} }
} }
$coaches_to_string = ''; $html = '';
if (!empty($course_coachs)) { if (!empty($course_coachs)) {
if ($orderList === true) { if ($orderList === true) {
$html .= '<ul class="user-coachs">'; $html .= '<ul class="user-coachs">';
@ -2072,9 +2071,8 @@ class CourseManager
} }
$html .= '</ul>'; $html .= '</ul>';
} else { } else {
$coaches_to_string = array_to_string($course_coachs, $separator); $html = array_to_string($course_coachs, $separator);
} }
} }
return $html; return $html;
@ -3447,7 +3445,7 @@ class CourseManager
$special_course_list = self::get_special_course_list(); $special_course_list = self::get_special_course_list();
$with_special_courses = ''; $with_special_courses = '';
if (!empty($special_course_list)) { if (!empty($special_course_list)) {
$with_special_courses = ' course.code IN ("' . implode('","', $special_course_list) . '")'; $with_special_courses = ' AND course.code IN ("' . implode('","', $special_course_list) . '")';
} }
$courseList = []; $courseList = [];
@ -3530,9 +3528,7 @@ class CourseManager
} }
$params['is_special_course'] = true; $params['is_special_course'] = true;
$courseList[] = $params; $courseList[] = $params;
} }
} }
} }
@ -3965,7 +3961,6 @@ class CourseManager
$session_accessible = true, $session_accessible = true,
$load_dirs = false $load_dirs = false
) { ) {
$entityManager = Database::getManager();
$now = date('Y-m-d h:i:s'); $now = date('Y-m-d h:i:s');
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$course_info = api_get_course_info_by_id($course['real_id']); $course_info = api_get_course_info_by_id($course['real_id']);
@ -3983,7 +3978,7 @@ class CourseManager
$course_info['status'] = empty($session_id) ? $userInCourseStatus : STUDENT; $course_info['status'] = empty($session_id) ? $userInCourseStatus : STUDENT;
$course_info['id_session'] = $session_id; $course_info['id_session'] = $session_id;
$is_coach = api_is_coach($course_info['id_session'], $course_info['real_id']); $is_coach = api_is_coach($session_id, $course_info['real_id']);
// Display course entry. // Display course entry.
// Show a hyperlink to the course, unless the course is closed and user is not course admin. // Show a hyperlink to the course, unless the course is closed and user is not course admin.
@ -4003,7 +3998,7 @@ class CourseManager
if ($course_visibility != COURSE_VISIBILITY_CLOSED && if ($course_visibility != COURSE_VISIBILITY_CLOSED &&
$course_visibility != COURSE_VISIBILITY_HIDDEN $course_visibility != COURSE_VISIBILITY_HIDDEN
) { ) {
$notifications .= Display:: show_notification($course_info); $notifications .= Display::show_notification($course_info);
} }
if ($session_accessible) { if ($session_accessible) {
@ -4148,6 +4143,7 @@ class CourseManager
); );
if (api_get_setting('allow_skills_tool') === 'true') { if (api_get_setting('allow_skills_tool') === 'true') {
$entityManager = Database::getManager();
$objUser = $entityManager->find('ChamiloUserBundle:User', $user_id); $objUser = $entityManager->find('ChamiloUserBundle:User', $user_id);
$objCourse = $entityManager->find('ChamiloCoreBundle:Course', $course['real_id']); $objCourse = $entityManager->find('ChamiloCoreBundle:Course', $course['real_id']);
$objSession = $entityManager->find('ChamiloCoreBundle:Session', $session_id); $objSession = $entityManager->find('ChamiloCoreBundle:Session', $session_id);

@ -3268,7 +3268,6 @@ class SessionManager
} }
$whereConditions .= $keywordCondition; $whereConditions .= $keywordCondition;
$subQuery = $sessionQuery.$courseSessionQuery; $subQuery = $sessionQuery.$courseSessionQuery;
$sql = " $select FROM $tbl_session s $sql = " $select FROM $tbl_session s

@ -3038,7 +3038,7 @@ class UserManager
WHERE WHERE
s.id = $session_id AND s.id = $session_id AND
( (
(scu.user_id = $user_id AND scu.status=2) OR (scu.user_id = $user_id AND scu.status = 2) OR
s.id_coach = $user_id s.id_coach = $user_id
) )
$where_access_url $where_access_url

@ -1105,7 +1105,7 @@ class IndexManager
*/ */
public function returnCoursesAndSessions($user_id) public function returnCoursesAndSessions($user_id)
{ {
$gamificationModeIsActive = api_get_setting('gamification_mode'); $gameModeIsActive = api_get_setting('gamification_mode');
$listCourse = ''; $listCourse = '';
$specialCourseList = ''; $specialCourseList = '';
$load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false; $load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false;
@ -1126,8 +1126,6 @@ class IndexManager
$sessionCount = 0; $sessionCount = 0;
$courseCount = 0; $courseCount = 0;
//$template = new Template(null, false, false, false, false, false, false);
// If we're not in the history view... // If we're not in the history view...
if (!isset($_GET['history'])) { if (!isset($_GET['history'])) {
// Display special courses. // Display special courses.
@ -1296,7 +1294,7 @@ class IndexManager
$params['show_simple_session_info'] = true; $params['show_simple_session_info'] = true;
} }
if ($gamificationModeIsActive) { if ($gameModeIsActive) {
$params['stars'] = GamificationUtils::getSessionStars($params['id'], $this->user_id); $params['stars'] = GamificationUtils::getSessionStars($params['id'], $this->user_id);
$params['progress'] = GamificationUtils::getSessionProgress($params['id'], $this->user_id); $params['progress'] = GamificationUtils::getSessionProgress($params['id'], $this->user_id);
$params['points'] = GamificationUtils::getSessionPoints($params['id'], $this->user_id); $params['points'] = GamificationUtils::getSessionPoints($params['id'], $this->user_id);
@ -1459,7 +1457,7 @@ class IndexManager
$this->tpl->assign('all_courses', $allCoursesInSessions); $this->tpl->assign('all_courses', $allCoursesInSessions);
$this->tpl->assign('session', $listSession); $this->tpl->assign('session', $listSession);
$this->tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false)); $this->tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
$this->tpl->assign('gamification_mode', $gamificationModeIsActive); $this->tpl->assign('gamification_mode', $gameModeIsActive);
if (api_get_configuration_value('view_grid_courses')) { if (api_get_configuration_value('view_grid_courses')) {
$sessions_with_no_category = $this->tpl->fetch( $sessions_with_no_category = $this->tpl->fetch(

Loading…
Cancel
Save