|
|
|
@ -1177,7 +1177,7 @@ class IndexManager |
|
|
|
|
* @param int $user_id |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public function returnCoursesAndSessions($user_id) |
|
|
|
|
public function returnCoursesAndSessions($user_id, $showSessions = true, $categoryCodeFilter = '') |
|
|
|
|
{ |
|
|
|
|
$gameModeIsActive = api_get_setting('gamification_mode'); |
|
|
|
|
$listCourse = ''; |
|
|
|
@ -1387,6 +1387,10 @@ class IndexManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($specialCourses) { |
|
|
|
|
if ($categoryCodeFilter) { |
|
|
|
|
$specialCourses = self::filterByCategory($specialCourses, $categoryCodeFilter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->tpl->assign('courses', $specialCourses); |
|
|
|
|
|
|
|
|
|
$specialCourseList = $this->tpl->fetch( |
|
|
|
@ -1395,6 +1399,11 @@ class IndexManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($courses['in_category'] || $courses['not_category']) { |
|
|
|
|
if ($categoryCodeFilter) { |
|
|
|
|
$courses['in_category'] = self::filterByCategory($courses['in_category'], $categoryCodeFilter); |
|
|
|
|
$courses['not_category'] = self::filterByCategory($courses['not_category'], $categoryCodeFilter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->tpl->assign('courses', $courses['not_category']); |
|
|
|
|
$this->tpl->assign('categories', $courses['in_category']); |
|
|
|
|
|
|
|
|
@ -1410,6 +1419,9 @@ class IndexManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sessions_with_category = ''; |
|
|
|
|
$sessions_with_no_category = ''; |
|
|
|
|
|
|
|
|
|
if ($showSessions) { |
|
|
|
|
$coursesListSessionStyle = api_get_configuration_value('courses_list_session_title_link'); |
|
|
|
|
$coursesListSessionStyle = $coursesListSessionStyle === false ? 1 : $coursesListSessionStyle; |
|
|
|
|
if (api_is_drh()) { |
|
|
|
@ -1426,8 +1438,8 @@ class IndexManager |
|
|
|
|
$session_category_id = $session_category['session_category']['id']; |
|
|
|
|
// Sessions and courses that are not in a session category |
|
|
|
|
if ( |
|
|
|
|
empty($session_category_id) && |
|
|
|
|
isset($session_category['sessions']) |
|
|
|
|
empty($session_category_id) |
|
|
|
|
&& isset($session_category['sessions']) |
|
|
|
|
) { |
|
|
|
|
// Independent sessions |
|
|
|
|
foreach ($session_category['sessions'] as $session) { |
|
|
|
@ -1500,7 +1512,8 @@ class IndexManager |
|
|
|
|
); |
|
|
|
|
if (isset($courseUserHtml[1])) { |
|
|
|
|
$course_session = $courseUserHtml[1]; |
|
|
|
|
$course_session['skill'] = isset($courseUserHtml['skill']) ? $courseUserHtml['skill'] : ''; |
|
|
|
|
$course_session['skill'] = |
|
|
|
|
isset($courseUserHtml['skill']) ? $courseUserHtml['skill'] : ''; |
|
|
|
|
|
|
|
|
|
//Course option (show student progress) |
|
|
|
|
//This code will add new variables (Progress, Score, Certificate) |
|
|
|
@ -1512,7 +1525,8 @@ class IndexManager |
|
|
|
|
array(), |
|
|
|
|
$session_id |
|
|
|
|
); |
|
|
|
|
$course_session['student_info']['progress'] = ($progress === false) ? null : $progress; |
|
|
|
|
$course_session['student_info']['progress'] = |
|
|
|
|
($progress === false) ? null : $progress; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($studentInfoScore) { |
|
|
|
@ -1537,9 +1551,11 @@ class IndexManager |
|
|
|
|
$course_session['student_info']['certificate'] = null; |
|
|
|
|
if (isset($category[0])) { |
|
|
|
|
if ($category[0]->is_certificate_available($user_id)) { |
|
|
|
|
$course_session['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success'); |
|
|
|
|
$course_session['student_info']['certificate'] = |
|
|
|
|
Display::label(get_lang('Yes'), 'success'); |
|
|
|
|
} else { |
|
|
|
|
$course_session['student_info']['certificate'] = Display::label(get_lang('No')); |
|
|
|
|
$course_session['student_info']['certificate'] = |
|
|
|
|
Display::label(get_lang('No')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1563,7 +1579,8 @@ class IndexManager |
|
|
|
|
'id' => $session_id |
|
|
|
|
); |
|
|
|
|
$session_box = Display::get_session_title_box($session_id); |
|
|
|
|
$actions = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session_id; |
|
|
|
|
$actions = |
|
|
|
|
api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session_id; |
|
|
|
|
$coachId = $session_box['id_coach']; |
|
|
|
|
$extraFieldValue = new ExtraFieldValue('session'); |
|
|
|
|
$imageField = $extraFieldValue->get_values_by_handler_and_field_variable( |
|
|
|
@ -1574,7 +1591,9 @@ class IndexManager |
|
|
|
|
$params['category_id'] = $session_box['category_id']; |
|
|
|
|
$params['title'] = $session_box['title']; |
|
|
|
|
$params['id_coach'] = $coachId; |
|
|
|
|
$params['coach_url'] = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coachId; |
|
|
|
|
$params['coach_url'] = |
|
|
|
|
api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id=' |
|
|
|
|
.$coachId; |
|
|
|
|
$params['coach_name'] = !empty($session_box['coach']) ? $session_box['coach'] : null; |
|
|
|
|
$params['coach_avatar'] = UserManager::getUserPicture( |
|
|
|
|
$coachId, |
|
|
|
@ -1582,9 +1601,11 @@ class IndexManager |
|
|
|
|
); |
|
|
|
|
$params['date'] = $session_box['dates']; |
|
|
|
|
$params['image'] = isset($imageField['value']) ? $imageField['value'] : null; |
|
|
|
|
$params['duration'] = isset($session_box['duration']) ? ' '.$session_box['duration'] : null; |
|
|
|
|
$params['duration'] = |
|
|
|
|
isset($session_box['duration']) ? ' '.$session_box['duration'] : null; |
|
|
|
|
$params['edit_actions'] = $actions; |
|
|
|
|
$params['show_description'] = $session_box['show_description'] == 1 && $portalShowDescription; |
|
|
|
|
$params['show_description'] = |
|
|
|
|
$session_box['show_description'] == 1 && $portalShowDescription; |
|
|
|
|
$params['description'] = $session_box['description']; |
|
|
|
|
$params['visibility'] = $session_box['visibility']; |
|
|
|
|
$params['show_simple_session_info'] = $showSimpleSessionInfo; |
|
|
|
@ -1605,10 +1626,12 @@ class IndexManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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['points'] = GamificationUtils::getSessionPoints($params['id'], $this->user_id); |
|
|
|
|
$params['points'] = |
|
|
|
|
GamificationUtils::getSessionPoints($params['id'], $this->user_id); |
|
|
|
|
} |
|
|
|
|
$listSession[] = $params; |
|
|
|
|
$sessionCount++; |
|
|
|
@ -1692,14 +1715,18 @@ class IndexManager |
|
|
|
|
$session_box = Display::get_session_title_box($session_id); |
|
|
|
|
$sessionParams[0]['id'] = $session_id; |
|
|
|
|
$sessionParams[0]['date'] = $session_box['dates']; |
|
|
|
|
$sessionParams[0]['duration'] = isset($session_box['duration']) ? ' '.$session_box['duration'] : null; |
|
|
|
|
$sessionParams[0]['duration'] = |
|
|
|
|
isset($session_box['duration']) ? ' '.$session_box['duration'] : null; |
|
|
|
|
$sessionParams[0]['course_list_session_style'] = $coursesListSessionStyle; |
|
|
|
|
$sessionParams[0]['title'] = $session_box['title']; |
|
|
|
|
$sessionParams[0]['subtitle'] = (!empty($session_box['coach']) ? $session_box['coach'].' | ' : '').$session_box['dates']; |
|
|
|
|
$sessionParams[0]['subtitle'] = |
|
|
|
|
(!empty($session_box['coach']) ? $session_box['coach'].' | ' : '') |
|
|
|
|
.$session_box['dates']; |
|
|
|
|
$sessionParams[0]['show_actions'] = api_is_platform_admin(); |
|
|
|
|
$sessionParams[0]['courses'] = $html_courses_session; |
|
|
|
|
$sessionParams[0]['show_simple_session_info'] = $showSimpleSessionInfo; |
|
|
|
|
$sessionParams[0]['coach_name'] = !empty($session_box['coach']) ? $session_box['coach'] : null; |
|
|
|
|
$sessionParams[0]['coach_name'] = |
|
|
|
|
!empty($session_box['coach']) ? $session_box['coach'] : null; |
|
|
|
|
|
|
|
|
|
if ($showSimpleSessionInfo) { |
|
|
|
|
$sessionParams[0]['subtitle'] = self::getSimpleSessionDetails( |
|
|
|
@ -1739,8 +1766,8 @@ class IndexManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
!empty($session_category_start_date) && |
|
|
|
|
!empty($session_category_end_date) |
|
|
|
|
!empty($session_category_start_date) |
|
|
|
|
&& !empty($session_category_end_date) |
|
|
|
|
) { |
|
|
|
|
$categoryParams['subtitle'] = sprintf( |
|
|
|
|
get_lang('FromDateXToDateY'), |
|
|
|
@ -1791,6 +1818,7 @@ class IndexManager |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
'html' => trim($specialCourseList.$sessions_with_category.$sessions_with_no_category.$listCourse), |
|
|
|
@ -2242,4 +2270,48 @@ class IndexManager |
|
|
|
|
|
|
|
|
|
return implode(' | ', $strDetails); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $userId |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public static function returnCourseCategoryListFromUser($userId) |
|
|
|
|
{ |
|
|
|
|
$sessionCount = 0; |
|
|
|
|
|
|
|
|
|
$courseList = CourseManager::get_courses_list_by_user_id($userId); |
|
|
|
|
$categoryCodes = CourseManager::getCourseCategoriesFromCourseList($courseList); |
|
|
|
|
$categories = []; |
|
|
|
|
|
|
|
|
|
foreach ($categoryCodes as $categoryCode) { |
|
|
|
|
$categories[] = CourseCategory::getCategory($categoryCode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$template = new Template('', false, false, false, true, false, false); |
|
|
|
|
$layout = $template->get_template('user_portal/course_categories.tpl'); |
|
|
|
|
$template->assign('course_categories', $categories); |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
'html' => $template->fetch($layout), |
|
|
|
|
'course_count' => count($courseList), |
|
|
|
|
'session_count' => $sessionCount |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Filter the course list by category code |
|
|
|
|
* @param array $courseList course list |
|
|
|
|
* @param string $categoryCode |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
private static function filterByCategory($courseList, $categoryCode) |
|
|
|
|
{ |
|
|
|
|
return array_filter($courseList, function ($courseInfo) use ($categoryCode) { |
|
|
|
|
if ($courseInfo['category_code'] === $categoryCode) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|