parent
							
								
									b86351c8a4
								
							
						
					
					
						commit
						ec916c4533
					
				@ -0,0 +1,107 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
/** | 
				
			||||
 * See the progress for a user when the gamification mode is active | 
				
			||||
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> | 
				
			||||
 * @package chamilo.gamification | 
				
			||||
 */ | 
				
			||||
$cidReset = true; | 
				
			||||
require_once '../inc/global.inc.php'; | 
				
			||||
 | 
				
			||||
$this_section = SECTION_TRACKING; | 
				
			||||
$nameTools = get_lang('MyProgress'); | 
				
			||||
 | 
				
			||||
api_block_anonymous_users(); | 
				
			||||
 | 
				
			||||
if (api_get_setting('gamification_mode') == '0') { | 
				
			||||
    api_not_allowed(true); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$userId = api_get_user_id(); | 
				
			||||
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0; | 
				
			||||
$allowAccess = false; | 
				
			||||
 | 
				
			||||
$userManager = UserManager::getManager(); | 
				
			||||
$entityManager = Database::getManager(); | 
				
			||||
 | 
				
			||||
$user = $userManager->findUserBy(['id' => $userId]); | 
				
			||||
$sessionCourseSubscriptions = $user->getSessionCourseSubscriptions(); | 
				
			||||
$currentSession = $entityManager->find('ChamiloCoreBundle:Session', $sessionId); | 
				
			||||
 | 
				
			||||
$sessionList = []; | 
				
			||||
 | 
				
			||||
foreach ($sessionCourseSubscriptions as $subscription) { | 
				
			||||
    $session = $subscription->getSession(); | 
				
			||||
 | 
				
			||||
    if ($currentSession && $currentSession->getId() === $session->getId()) { | 
				
			||||
        $allowAccess = true; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    $sessionList[] = $session; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
if ($currentSession && !$allowAccess) { | 
				
			||||
    api_not_allowed(true); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$template = new Template($nameTools); | 
				
			||||
$template->assign('user', $user); | 
				
			||||
$template->assign( | 
				
			||||
    'user_avatar', | 
				
			||||
    SocialManager::show_social_avatar_block('home', 0, $user->getId()) | 
				
			||||
); | 
				
			||||
$template->assign( | 
				
			||||
    'gamification_stars', | 
				
			||||
     GamificationUtils::getTotalUserStars($user->getId(), $user->getStatus()) | 
				
			||||
); | 
				
			||||
$template->assign( | 
				
			||||
    'gamification_points', | 
				
			||||
     GamificationUtils::getTotalUserPoints($user->getId(), $user->getStatus()) | 
				
			||||
); | 
				
			||||
$template->assign( | 
				
			||||
    'gamification_progress', | 
				
			||||
     GamificationUtils::getSessionProgress($user->getId(), $user->getStatus()) | 
				
			||||
); | 
				
			||||
$template->assign('sessions', $sessionList); | 
				
			||||
$template->assign('current_session', $currentSession); | 
				
			||||
 | 
				
			||||
if ($currentSession) { | 
				
			||||
    $sessionData = []; | 
				
			||||
 | 
				
			||||
    $sessionCourses = $currentSession->getCourses(); | 
				
			||||
 | 
				
			||||
    foreach ($sessionCourses as $sessionCourse) { | 
				
			||||
        $course = $sessionCourse->getCourse(); | 
				
			||||
 | 
				
			||||
        $courseData = [ | 
				
			||||
            'title' => $course->getTitle(), | 
				
			||||
            'stats' => [] | 
				
			||||
        ]; | 
				
			||||
 | 
				
			||||
        $learningPathList = new LearnpathList($user->getId(), $course->getCode(), $currentSession->getId()); | 
				
			||||
 | 
				
			||||
        foreach ($learningPathList->list as $learningPathId => $learningPath) { | 
				
			||||
            $courseData['stats'][] = [ | 
				
			||||
                $learningPath['lp_name'], | 
				
			||||
                'newscorm/lp_controller.php?' . http_build_query([ | 
				
			||||
                    'action' => 'stats', | 
				
			||||
                    'cidReq' => $course->getCode(), | 
				
			||||
                    'id_session' => $currentSession->getId(), | 
				
			||||
                    'gidReq' => 0, | 
				
			||||
                    'lp_id' => $learningPathId | 
				
			||||
                ]) . api_get_cidreq() | 
				
			||||
            ]; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        $sessionData[$course->getId()] = $courseData; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    $template->assign('session_data', $sessionData); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$layout = $template->get_template('gamification/my_progress.tpl'); | 
				
			||||
 | 
				
			||||
$template->assign('header', $nameTools); | 
				
			||||
$template->assign('content', $template->fetch($layout)); | 
				
			||||
$template->display_one_col_template(); | 
				
			||||
@ -0,0 +1,50 @@ | 
				
			||||
<div class="row"> | 
				
			||||
    <div class="col-md-3"> | 
				
			||||
        <div class="well"> | 
				
			||||
            {{ user_avatar }} | 
				
			||||
            <p>{{ user.getCompleteName() }}</p> | 
				
			||||
            <p>{{ 'Stars'|get_lang ~ ' ' ~ gamification_stars }}</p> | 
				
			||||
            <p>{{ 'XPoints'|get_lang|format(gamification_points) }}</p> | 
				
			||||
            <p>{{ 'GamificationProgress'|get_lang ~ ' ' ~ gamification_progress }}</p> | 
				
			||||
        </div> | 
				
			||||
 | 
				
			||||
        <h4>{{ 'ShowProgress'|get_lang }}</h4> | 
				
			||||
        <div class="list-group"> | 
				
			||||
            {% for session in sessions %} | 
				
			||||
                <a href="{{ _p.self ~ '?' ~ {"session_id": session.getId}|url_encode() }}" class="list-group-item {{ current_session and session.getId == current_session.getId ? 'active' }}">{{ session.getName }}</a> | 
				
			||||
            {% endfor %} | 
				
			||||
        </div> | 
				
			||||
    </div> | 
				
			||||
 | 
				
			||||
    <div class="col-md-9"> | 
				
			||||
        {% if current_session %} | 
				
			||||
            <h2 class="page-header">{{ current_session.getName() }}</h2> | 
				
			||||
 | 
				
			||||
            {% for course_id, course in session_data %} | 
				
			||||
                <h3>{{ course.title }}</h3> | 
				
			||||
 | 
				
			||||
                <div class="panel-group" id="course-accordion" role="tablist" aria-multiselectable="true"> | 
				
			||||
                    {% for stats_url in course.stats %} | 
				
			||||
                        {% set panel_id = course_id ~ '-' ~ loop.index %} | 
				
			||||
                        <div class="panel panel-default"> | 
				
			||||
                            <div class="panel-heading" role="tab" id="heading-{{ panel_id }}"> | 
				
			||||
                                <h4 class="panel-title"> | 
				
			||||
                                    <a role="button" data-toggle="collapse" data-parent="#course-accordion" href="#collapse-{{ panel_id }}" aria-expanded="true" aria-controls="collapse-{{ panel_id }}"> | 
				
			||||
                                        {{ stats_url.0 }} | 
				
			||||
                                    </a> | 
				
			||||
                                </h4> | 
				
			||||
                            </div> | 
				
			||||
                            <div id="collapse-{{ panel_id }}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading-{{ panel_id }}"> | 
				
			||||
                                <div class="panel-body"> | 
				
			||||
                                    <div class="embed-responsive embed-responsive-4by3"> | 
				
			||||
                                        <iframe src="{{ _p.web_main ~ stats_url.1 }}"></iframe> | 
				
			||||
                                    </div> | 
				
			||||
                                </div> | 
				
			||||
                            </div> | 
				
			||||
                        </div> | 
				
			||||
                    {% endfor %} | 
				
			||||
                </div> | 
				
			||||
            {% endfor %} | 
				
			||||
        {% endif %} | 
				
			||||
    </div> | 
				
			||||
</div> | 
				
			||||
					Loading…
					
					
				
		Reference in new issue