Session: Restore resume session page for user

pull/3995/head
Angel Fernando Quiroz Campos 3 years ago
parent e1a6b7424b
commit c4bf060135
  1. 193
      public/main/user/resume_session.php

@ -6,7 +6,10 @@
* @author Bart Mollet, Julio Montoya lot of fixes * @author Bart Mollet, Julio Montoya lot of fixes
*/ */
use Chamilo\CoreBundle\Component\Utils\NameConvention;
use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\CoreBundle\Framework\Container;
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
@ -31,41 +34,9 @@ if ('true' === $allowTutors) {
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = 'SELECT $nameConvention = Container::$container->get(NameConvention::class);
name,
nbr_courses,
nbr_users,
nbr_classes,
DATE_FORMAT(access_start_date,"%d-%m-%Y") as access_start_date,
DATE_FORMAT(access_end_date,"%d-%m-%Y") as access_end_date,
lastname,
firstname,
username,
session_admin_id,
coach_access_start_date,
coach_access_end_date,
session_category_id,
visibility
FROM '.$tbl_session.'
LEFT JOIN '.$tbl_user.'
ON id_coach = user_id
WHERE '.$tbl_session.'.id='.$id_session;
$rs = Database::query($sql); $session = api_get_session_entity($id_session);
$session = Database::store_result($rs);
$session = $session[0];
$sql = 'SELECT name
FROM '.$tbl_session_category.'
WHERE id = '.intval($session['session_category_id']);
$rs = Database::query($sql);
$session_category = '';
if (Database::num_rows($rs) > 0) {
$rows_session_category = Database::store_result($rs);
$rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name'];
}
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
@ -130,74 +101,50 @@ if ('true' === $allowTutors) {
Display::return_icon( Display::return_icon(
'session.png', 'session.png',
get_lang('Session') get_lang('Session')
).' '.$session['name'] ).' '.$session->getName()
); );
echo Display::page_subheader(get_lang('General properties').$url); ?> echo Display::page_subheader(get_lang('General properties').$url); ?>
<!-- General properties --> <!-- General properties -->
<table class="table table-hover table-striped data_table"> <table class="table table-hover table-striped data_table">
<tr> <tr>
<td><?php echo get_lang('General coach'); ?> :</td> <td><?php echo get_lang('General coaches'); ?> :</td>
<td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')'; ?></td>
</tr>
<?php if (!empty($session_category)) {
?>
<tr>
<td><?php echo get_lang('Sessions categories'); ?></td>
<td><?php echo $session_category; ?></td>
</tr>
<?php
} ?>
<tr>
<td><?php echo get_lang('Date'); ?> :</td>
<td> <td>
<?php <?php
if ('00-00-0000' == $session['access_start_date'] && '00-00-0000' == $session['access_end_date']) { foreach ($session->getGeneralCoaches() as $generalCoach) {
echo get_lang('No time limits'); echo $nameConvention->getPersonName($generalCoach).'<br>';
} else {
if ('00-00-0000' != $session['access_start_date']) {
//$session['date_start'] = Display::tag('i', get_lang('No time limits'));
$session['access_start_date'] = get_lang('From').' '.$session['access_start_date'];
} else {
$session['access_start_date'] = '';
}
if ('00-00-0000' == $session['access_end_date']) {
$session['access_end_date'] = '';
} else {
$session['access_end_date'] = get_lang('Until').' '.$session['access_end_date'];
} }
echo $session['access_start_date'].' '.$session['access_end_date']; ?>
} ?>
</td>
</tr>
<!-- show nb_days_before and nb_days_after only if they are different from 0 -->
<tr>
<td>
<?php echo api_ucfirst(get_lang('Access start date for coaches')); ?> :
</td>
<td>
<?php echo intval($session['coach_access_start_date']); ?>
</td> </td>
</tr> </tr>
<?php if ($session->getCategory()) { ?>
<tr> <tr>
<td> <td><?php echo get_lang('Sessions categories'); ?></td>
<?php echo api_ucfirst(get_lang('Access end date for coaches')); ?> : <td><?php echo $session->getCategory()->getName(); ?></td>
</td>
<td>
<?php echo intval($session['coach_session_access_end_date']); ?>
</td>
</tr> </tr>
<?php } ?>
<?php if ($session->getDuration()) { ?>
<tr>
<td><?php echo get_lang('Duration'); ?></td>
<td><?php echo $session->getDuration().' '.get_lang('Days'); ?></td>
</tr>
<?php } else { ?>
<?php $sessionDates = SessionManager::parseSessionDates($session, true); ?>
<tr>
<td><?php echo get_lang('Access dates for students'); ?></td>
<td><?php echo $sessionDates['access'] ?></td>
</tr>
<tr>
<td><?php echo get_lang('Access dates for coaches'); ?></td>
<td><?php echo $sessionDates['coach'] ?></td>
</tr>
<?php } ?>
<tr> <tr>
<td> <td>
<?php echo api_ucfirst(get_lang('Visibility after end date')); ?> : <?php echo api_ucfirst(get_lang('Visibility after end date')); ?> :
</td> </td>
<td> <td>
<?php if (1 == $session['visibility']) { <?php echo SessionManager::getSessionVisibility($session); ?>
echo get_lang('Read only');
} elseif (2 == $session['visibility']) {
echo get_lang('Visible');
} elseif (3 == $session['visibility']) {
echo api_ucfirst(get_lang('invisible'));
} ?>
</td> </td>
</tr> </tr>
<?php <?php
@ -226,70 +173,32 @@ if ('true' === $allowTutors) {
<th width="20%"><?php echo get_lang('Users number'); ?></th> <th width="20%"><?php echo get_lang('Users number'); ?></th>
</tr> </tr>
<?php <?php
if (0 == $session['nbr_courses']) { if (0 == $session->getNbrCourses()) {
echo '<tr> echo '<tr>
<td colspan="4">'.get_lang('No course for this session').'</td> <td colspan="3">'.get_lang('No course for this session').'</td>
</tr>'; </tr>';
} else { } else {
// select the courses // select the courses
$sql = "SELECT c.id, code,title,visual_code, nbr_users foreach ($session->getCourses() as $sessionRelCourse) {
FROM $tbl_course c,$tbl_session_rel_course sc $course = $sessionRelCourse->getCourse();
WHERE c.id = sc.c_id
AND session_id='$id_session'
ORDER BY title";
$result = Database::query($sql);
$courses = Database::store_result($result);
foreach ($courses as $course) {
// Select the number of users
$sql = "SELECT count(*) FROM $tbl_session_rel_user sru, $tbl_session_rel_course_rel_user srcru
WHERE
srcru.user_id = sru.user_id AND
srcru.session_id = sru.session_id AND
srcru.c_id = '".Database::escape_string($course['id'])."'AND
sru.relation_type = ".Session::STUDENT." AND
srcru.session_id = '".intval($id_session)."'";
$rs = Database::query($sql);
$course['nbr_users'] = Database::result($rs, 0, 0);
// Get coachs of the courses in session
$sql = "SELECT user.lastname,user.firstname,user.username $coachSubscriptionList = $session->getSessionRelCourseRelUsersByStatus($course, Session::COURSE_COACH)
FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user ->map(
WHERE fn(SessionRelCourseRelUser $sessionCourseUser) => $nameConvention->getPersonName($sessionCourseUser->getUser())
session_rcru.user_id = user.id AND );
session_rcru.session_id = '".intval($id_session)."' AND
session_rcru.c_id ='".Database::escape_string($course['id'])."' AND
session_rcru.status = ".Session::COURSE_COACH;
$rs = Database::query($sql);
$coachs = [];
if (Database::num_rows($rs) > 0) {
while ($info_coach = Database::fetch_array($rs)) {
$coachs[] = api_get_person_name(
$info_coach['firstname'],
$info_coach['lastname']
).' ('.$info_coach['username'].')';
}
} else {
$coach = get_lang('none');
}
if (count($coachs) > 0) { $courseLink = Display::url(
$coach = implode('<br />', $coachs); $course->getTitle().' ('.$course->getVisualCode().')',
} else { api_get_course_url($course->getId(), $session->getId())
$coach = get_lang('none'); );
} $coaches = $coachSubscriptionList ? implode('<br>', $coachSubscriptionList->getValues()) : get_lang('None');
$nbrUsers = $sessionRelCourse->getNbrUsers();
$orig_param = '&origin=resume_session';
//hide_course_breadcrumb the parameter has been added to hide the
// name of the course, that appeared in the default $interbreadcrumb
echo ' echo '
<tr> <tr>
<td>'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session), '</td> <td>'.$courseLink.'</td>
<td>'.$coach.'</td> <td>'.$coaches.'</td>
<td>'.$course['nbr_users'].'</td> <td>'.$nbrUsers.'</td>
</tr>'; </tr>';
} }
} ?> } ?>
@ -309,7 +218,7 @@ if ('true' === $allowTutors) {
</tr> </tr>
<?php <?php
if (0 == $session['nbr_users']) { if (0 == $session->getNbrUsers()) {
echo '<tr> echo '<tr>
<td colspan="2">'.get_lang('No Users for this session').'</td> <td colspan="2">'.get_lang('No Users for this session').'</td>
</tr>'; </tr>';

Loading…
Cancel
Save