Minor - flint fixes

pull/3128/head
Julio Montoya 6 years ago
parent a565d2a935
commit 50c394b90d
  1. 1
      main/admin/course_list.php
  2. 2
      main/admin/resource_sequence.php
  3. 12
      main/admin/settings.lib.php
  4. 1
      main/admin/user_information.php
  5. 2
      main/admin/user_list.php
  6. 4
      main/admin/user_move_stats.php
  7. 2
      main/auth/courses_controller.php
  8. 3
      main/auth/okn/start.php
  9. 8
      main/course_home/course_home.php
  10. 2
      main/exercise/exercise.class.php
  11. 1
      main/exercise/exercise_admin.php
  12. 1
      main/exercise/exercise_submit.php
  13. 2
      main/exercise/question_pool.php
  14. 2
      main/gradebook/lib/fe/catform.class.php
  15. 2
      main/inc/ajax/model.ajax.php
  16. 1
      main/inc/ajax/sequence.ajax.php
  17. 8
      main/inc/ajax/statistics.ajax.php
  18. 24
      main/inc/lib/course.lib.php
  19. 1
      main/inc/lib/course_category.lib.php
  20. 2
      main/inc/lib/display.lib.php
  21. 8
      main/inc/lib/extra_field_value.lib.php
  22. 2
      main/inc/lib/formvalidator/Element/SelectAjax.php
  23. 4
      main/inc/lib/plugin.lib.php
  24. 209
      main/inc/lib/sessionmanager.lib.php
  25. 2
      main/inc/lib/system_announcements.lib.php
  26. 1
      main/inc/lib/thematic.lib.php
  27. 2
      main/inc/lib/tracking.lib.php
  28. 4
      main/inc/lib/usermanager.lib.php
  29. 80
      main/inc/lib/webservices/Rest.php
  30. 2
      main/inc/lib/webservices/WebService.class.php
  31. 91
      main/lp/learnpath.class.php
  32. 2
      main/lp/lp_ajax_switch_item_toc.php
  33. 1
      main/lp/lp_edit.php
  34. 2
      main/lp/scorm_api.php
  35. 1
      main/mySpace/access_details_session.php
  36. 1
      main/session/resume_session.php
  37. 2
      main/session/session_list.php
  38. 3
      main/session/session_list_custom.php
  39. 2
      main/survey/create_new_survey.php
  40. 8
      main/survey/survey.lib.php
  41. 6
      main/survey/surveyUtil.class.php
  42. 1
      main/survey/survey_list.php
  43. 2
      main/tracking/courseLog.php
  44. 2
      main/tracking/lp_report.php
  45. 70
      src/Chamilo/CoreBundle/Entity/Repository/SequenceResourceRepository.php
  46. 4
      src/Chamilo/CoreBundle/Entity/Session.php
  47. 24
      src/Chamilo/UserBundle/Entity/User.php

@ -6,7 +6,6 @@
* This script shows a list of courses and allows searching for courses codes * This script shows a list of courses and allows searching for courses codes
* and names. * and names.
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -133,7 +133,7 @@ $headers[] = [
'content' => get_lang('Courses'), 'content' => get_lang('Courses'),
]; ];
$tabs = Display::tabsOnlyLink($headers,$type === SequenceResource::COURSE_TYPE ? 2 : 1); $tabs = Display::tabsOnlyLink($headers, $type === SequenceResource::COURSE_TYPE ? 2 : 1);
$tpl->assign('create_sequence', $formSequence->returnForm()); $tpl->assign('create_sequence', $formSequence->returnForm());
$tpl->assign('select_sequence', $selectSequence->returnForm()); $tpl->assign('select_sequence', $selectSequence->returnForm());

@ -118,9 +118,11 @@ function handleExtensions()
} }
/** /**
* Show form for plugin and validates inputs. Calls uploadPlugin() if everything OK * Show form for plugin and validates inputs. Calls uploadPlugin() if everything OK.
* @return string|void The HTML form, or displays a message and returns nothing on error *
* @throws Exception * @throws Exception
*
* @return string|void The HTML form, or displays a message and returns nothing on error
*/ */
function handlePluginUpload() function handlePluginUpload()
{ {
@ -131,6 +133,7 @@ function handlePluginUpload()
'error', 'error',
false false
); );
return; return;
} }
$pluginPath = api_get_path(SYS_PLUGIN_PATH); $pluginPath = api_get_path(SYS_PLUGIN_PATH);
@ -140,6 +143,7 @@ function handlePluginUpload()
'error', 'error',
false false
); );
return; return;
} }
@ -742,8 +746,8 @@ function uploadStylesheet($values, $picture)
* Creates the folder (if needed) and uploads the plugin in it. If the plugin * Creates the folder (if needed) and uploads the plugin in it. If the plugin
* is already there and the folder is writeable, overwrite. * is already there and the folder is writeable, overwrite.
* *
* @param array $values the values of the form * @param array $values the values of the form
* @param array $file the file passed to the upload form * @param array $file the file passed to the upload form
* @param array $officialPlugins A list of official plugins that cannot be uploaded * @param array $officialPlugins A list of official plugins that cannot be uploaded
* *
* @return bool * @return bool

@ -10,7 +10,6 @@ use Chamilo\UserBundle\Entity\User;
* *
* @author Bart Mollet * @author Bart Mollet
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -356,7 +356,7 @@ function prepare_user_sql_query($getCount)
$_GET['extra_'.$variable] = Security::remove_XSS($_GET['keyword']); $_GET['extra_'.$variable] = Security::remove_XSS($_GET['keyword']);
} }
} }
$variables = array_merge( $extraFieldList, $variables); $variables = array_merge($extraFieldList, $variables);
} }
if (!empty($variables)) { if (!empty($variables)) {

@ -270,7 +270,7 @@ if (isset($_REQUEST['load_ajax'])) {
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
// Checking if the LP exist in the new session // Checking if the LP exist in the new session
//if (in_array($row['lp_id'], array_keys($flat_list))) { //if (in_array($row['lp_id'], array_keys($flat_list))) {
$list[$row['id']] = $row; $list[$row['id']] = $row;
//} //}
} }
@ -323,7 +323,7 @@ if (isset($_REQUEST['load_ajax'])) {
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
//Checking if the LP exist in the new session //Checking if the LP exist in the new session
//if (in_array($row['lp_id'], array_keys($flat_list))) { //if (in_array($row['lp_id'], array_keys($flat_list))) {
$list[$row['id']] = $row; $list[$row['id']] = $row;
//} //}
} }

@ -361,7 +361,7 @@ class CoursesController
/** /**
* Return Session catalog rendered view. * Return Session catalog rendered view.
* *
* @param array $limit * @param array $limit
*/ */
public function sessionList($limit = []) public function sessionList($limit = [])
{ {

@ -165,15 +165,12 @@ if (isset($_GET['email'])) {
} }
header('Location: '.api_get_path(WEB_PATH).'user_portal.php'); header('Location: '.api_get_path(WEB_PATH).'user_portal.php');
exit; exit;
/*$result = Tracking::getCourseLpProgress($userId, 0);
echo json_encode($result);*/
} else { } else {
echo 'User not found'; echo 'User not found';
} }
exit; exit;
if (!empty($userId)) { if (!empty($userId)) {
} else { } else {
Display::addFlash(Display::return_message(get_lang('InvalidId'))); Display::addFlash(Display::return_message(get_lang('InvalidId')));
} }

@ -155,19 +155,19 @@ if ($action == 'subscribe') {
if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) { if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) {
// append session id to redirect URL // append session id to redirect URL
/** /**
* @var $user Chamilo\UserBundle\Entity\User * @var Chamilo\UserBundle\Entity\User
*/ */
$user = UserManager::getRepository()->find(api_get_user_id()); $user = UserManager::getRepository()->find(api_get_user_id());
if ($user) { if ($user) {
foreach ($user->getCurrentlyAccessibleSessions() as $session) { foreach ($user->getCurrentlyAccessibleSessions() as $session) {
$redirectionTarget = api_get_self() . '?id_session=' . $session->getId(); $redirectionTarget = api_get_self().'?id_session='.$session->getId();
break; break;
} }
} }
} }
} elseif (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) { } elseif (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) {
/** /**
* @var $user Chamilo\UserBundle\Entity\User * @var Chamilo\UserBundle\Entity\User
*/ */
$user = UserManager::getRepository()->find(api_get_user_id()); $user = UserManager::getRepository()->find(api_get_user_id());
if ($user && !$user->getCurrentlyAccessibleSessions()) { if ($user && !$user->getCurrentlyAccessibleSessions()) {
@ -175,7 +175,7 @@ if ($action == 'subscribe') {
$redirectionTarget = api_get_path(WEB_PATH).'course/'.$courseId.'/about'; $redirectionTarget = api_get_path(WEB_PATH).'course/'.$courseId.'/about';
} }
} }
header('Location: ' . $redirectionTarget); header('Location: '.$redirectionTarget);
exit; exit;
} }
} }

@ -8530,7 +8530,7 @@ class Exercise
$hiddenFromSessionCondition = ' 1=1 '; $hiddenFromSessionCondition = ' 1=1 ';
if (!empty($result)) { if (!empty($result)) {
$hiddenFromSession = implode("','", array_column($result, 'iid')); $hiddenFromSession = implode("','", array_column($result, 'iid'));
$hiddenFromSessionCondition = " e.iid not in ('$hiddenFromSession')"; $hiddenFromSessionCondition = " e.iid not in ('$hiddenFromSession')";
} }
$condition_session = " AND ( $condition_session = " AND (

@ -8,6 +8,7 @@ use ChamiloSession as Session;
* Exercise administration * Exercise administration
* This script allows to manage an exercise. It is included from * This script allows to manage an exercise. It is included from
* the script admin.php. * the script admin.php.
*
* @author Olivier Brouckaert, Julio Montoya * @author Olivier Brouckaert, Julio Montoya
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';

@ -1416,7 +1416,6 @@ if (!empty($error)) {
break; break;
} }
} }
} }
} }

@ -521,8 +521,6 @@ echo '<script>$(function () {
<?php <?php
/** /**
* @param array $formValues
*
* @return array * @return array
*/ */
function getExtraFieldConditions(array $formValues, $queryType = 'from') function getExtraFieldConditions(array $formValues, $queryType = 'from')

@ -393,7 +393,7 @@ class CatForm extends FormValidator
} }
//if (!empty($session_id)) { //if (!empty($session_id)) {
$isRequirementCheckbox = $this->addCheckBox( $isRequirementCheckbox = $this->addCheckBox(
'is_requirement', 'is_requirement',
[ [
null, null,

@ -1667,7 +1667,7 @@ switch ($action) {
$columns = $sessionColumns['simple_column_name']; $columns = $sessionColumns['simple_column_name'];
switch ($listType) { switch ($listType) {
case 'complete' : case 'complete':
$result = SessionManager::get_sessions_admin_complete( $result = SessionManager::get_sessions_admin_complete(
[ [
'where' => $whereCondition, 'where' => $whereCondition,

@ -440,7 +440,6 @@ switch ($action) {
$view->assign('sequence_type', $type); $view->assign('sequence_type', $type);
$view->assign('allow_subscription', $allowSubscription); $view->assign('allow_subscription', $allowSubscription);
if ($allowSubscription) { if ($allowSubscription) {
$view->assign( $view->assign(
'subscribe_button', 'subscribe_button',

@ -428,13 +428,13 @@ switch ($action) {
$years = (int) $interval->y; $years = (int) $interval->y;
if ($years >= 16 && $years <= 17) { if ($years >= 16 && $years <= 17) {
$all['16-17'] += 1; $all['16-17']++;
} }
if ($years >= 18 && $years <= 25) { if ($years >= 18 && $years <= 25) {
$all['18-25'] += 1; $all['18-25']++;
} }
if ($years >= 26 && $years <= 30) { if ($years >= 26 && $years <= 30) {
$all['26-30'] += 1; $all['26-30']++;
} }
/*if ($years >= 31) { /*if ($years >= 31) {
$all[get_lang('N/A')] += 1; $all[get_lang('N/A')] += 1;
@ -658,7 +658,7 @@ switch ($action) {
if (!isset($all[$language])) { if (!isset($all[$language])) {
$all[$language] = 0; $all[$language] = 0;
} }
$all[$language] += 1; $all[$language]++;
} }
break; break;
case 'course_in_session': case 'course_in_session':

@ -565,7 +565,7 @@ class CourseManager
if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) { if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) {
/** /**
* @var $user Chamilo\UserBundle\Entity\User * @var Chamilo\UserBundle\Entity\User
*/ */
$user = UserManager::getRepository()->find($userId); $user = UserManager::getRepository()->find($userId);
$sessions = $user->getCurrentlyAccessibleSessions(); $sessions = $user->getCurrentlyAccessibleSessions();
@ -579,6 +579,7 @@ class CourseManager
'warning' 'warning'
) )
); );
return false; return false;
} }
// user has no session at all, create one starting now // user has no session at all, create one starting now
@ -588,10 +589,11 @@ class CourseManager
} catch (Exception $exception) { } catch (Exception $exception) {
Display::addFlash( Display::addFlash(
Display::return_message( Display::return_message(
get_lang('WrongNumberOfDays') . ': ' . $numberOfDays . ': ' . $exception->getMessage(), get_lang('WrongNumberOfDays').': '.$numberOfDays.': '.$exception->getMessage(),
'warning' 'warning'
) )
); );
return false; return false;
} }
$endDate = new DateTime(); $endDate = new DateTime();
@ -612,10 +614,11 @@ class CourseManager
} catch (\Doctrine\ORM\OptimisticLockException $exception) { } catch (\Doctrine\ORM\OptimisticLockException $exception) {
Display::addFlash( Display::addFlash(
Display::return_message( Display::return_message(
get_lang('InternalDatabaseError') . ': ' . $exception->getMessage(), get_lang('InternalDatabaseError').': '.$exception->getMessage(),
'warning' 'warning'
) )
); );
return false; return false;
} }
$accessUrlRelSession = new \Chamilo\CoreBundle\Entity\AccessUrlRelSession(); $accessUrlRelSession = new \Chamilo\CoreBundle\Entity\AccessUrlRelSession();
@ -627,10 +630,11 @@ class CourseManager
} catch (\Doctrine\ORM\OptimisticLockException $exception) { } catch (\Doctrine\ORM\OptimisticLockException $exception) {
Display::addFlash( Display::addFlash(
Display::return_message( Display::return_message(
get_lang('InternalDatabaseError') . ': ' . $exception->getMessage(), get_lang('InternalDatabaseError').': '.$exception->getMessage(),
'warning' 'warning'
) )
); );
return false; return false;
} }
} else { } else {
@ -645,16 +649,19 @@ class CourseManager
} catch (\Doctrine\ORM\OptimisticLockException $exception) { } catch (\Doctrine\ORM\OptimisticLockException $exception) {
Display::addFlash( Display::addFlash(
Display::return_message( Display::return_message(
get_lang('InternalDatabaseError') . ': ' . $exception->getMessage(), get_lang('InternalDatabaseError').': '.$exception->getMessage(),
'warning' 'warning'
) )
); );
return false; return false;
} }
// subscribe user to course within this session // subscribe user to course within this session
SessionManager::subscribe_users_to_session_course([$userId], $session->getId(), $course->getCode()); SessionManager::subscribe_users_to_session_course([$userId], $session->getId(), $course->getCode());
return true; return true;
} }
return self::subscribeUser($userId, $course->getCode(), $status); return self::subscribeUser($userId, $course->getCode(), $status);
} }
@ -1183,23 +1190,24 @@ class CourseManager
if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) { if (api_get_configuration_value('catalog_course_subscription_in_user_s_session')) {
// with this option activated, only check whether the course is in one of the users' sessions // with this option activated, only check whether the course is in one of the users' sessions
$course = Database::getManager()->getRepository('ChamiloCoreBundle:Course')->findOneBy([ $course = Database::getManager()->getRepository('ChamiloCoreBundle:Course')->findOneBy([
'code' => $course_code 'code' => $course_code,
]); ]);
if (is_null($course)) { if (is_null($course)) {
return false; return false;
} }
/** /**
* @var $user \Chamilo\UserBundle\Entity\User * @var \Chamilo\UserBundle\Entity\User
*/ */
$user = UserManager::getRepository()->find($user_id); $user = UserManager::getRepository()->find($user_id);
if (is_null($user)) { if (is_null($user)) {
return false; return false;
} }
foreach($user->getStudentSessions() as $session) { foreach ($user->getStudentSessions() as $session) {
if ($session->isRelatedToCourse($course)) { if ($session->isRelatedToCourse($course)) {
return true; return true;
} }
} }
return false; return false;
} }

@ -156,6 +156,7 @@ class CourseCategory
ORDER BY t1.parent_id, t1.tree_pos"; ORDER BY t1.parent_id, t1.tree_pos";
$result = Database::query($sql); $result = Database::query($sql);
return Database::store_result($result, 'ASSOC'); return Database::store_result($result, 'ASSOC');
} }

@ -2583,7 +2583,7 @@ class Display
* @param string $content * @param string $content
* @param string $title * @param string $title
* @param string $footer * @param string $footer
* @param string $type primary|success|info|warning|danger * @param string $type primary|success|info|warning|danger
* @param string $extra * @param string $extra
* @param string $id * @param string $id
* @param string $backgroundColor * @param string $backgroundColor

@ -812,10 +812,10 @@ class ExtraFieldValue extends Model
* Gets the ID from the item (course, session, etc) for which * Gets the ID from the item (course, session, etc) for which
* the given field is defined with the given value. * the given field is defined with the given value.
* *
* @param string $variable Field (type of data) we want to check * @param string $variable Field (type of data) we want to check
* @param string $value Data we are looking for in the given field * @param string $value Data we are looking for in the given field
* @param bool $transform Whether to transform the result to a human readable strings * @param bool $transform Whether to transform the result to a human readable strings
* @param bool $last Whether to return the last element or simply the first one we get * @param bool $last Whether to return the last element or simply the first one we get
* @param bool $useLike * @param bool $useLike
* *
* @return mixed Give the ID if found, or false on failure or not found * @return mixed Give the ID if found, or false on failure or not found

@ -44,7 +44,7 @@ class SelectAjax extends HTML_QuickForm_select
$plHolder = $this->getAttribute('placeholder'); $plHolder = $this->getAttribute('placeholder');
if (empty($plHolder)) { if (empty($plHolder)) {
$plHolder = preg_replace("/'/","\\'",get_lang('SelectAnOption')); $plHolder = preg_replace("/'/", "\\'", get_lang('SelectAnOption'));
} }
$id = $this->getAttribute('id'); $id = $this->getAttribute('id');

@ -126,7 +126,8 @@ class AppPlugin
} }
/** /**
* Returns a list of all installed plugins * Returns a list of all installed plugins.
*
* @param bool $fromDatabase * @param bool $fromDatabase
* *
* @return array * @return array
@ -164,6 +165,7 @@ class AppPlugin
* Returns a list of all official (delivered with the Chamilo package) * Returns a list of all official (delivered with the Chamilo package)
* plugins. This list is maintained manually and updated with every new * plugins. This list is maintained manually and updated with every new
* release to avoid hacking. * release to avoid hacking.
*
* @return array * @return array
*/ */
public function getOfficialPlugins() public function getOfficialPlugins()

@ -130,27 +130,27 @@ class SessionManager
* *
* @author Carlos Vargas <carlos.vargas@beeznest.com>, from existing code * @author Carlos Vargas <carlos.vargas@beeznest.com>, from existing code
* *
* @param string $name * @param string $name
* @param string $startDate (YYYY-MM-DD hh:mm:ss) * @param string $startDate (YYYY-MM-DD hh:mm:ss)
* @param string $endDate (YYYY-MM-DD hh:mm:ss) * @param string $endDate (YYYY-MM-DD hh:mm:ss)
* @param string $displayStartDate (YYYY-MM-DD hh:mm:ss) * @param string $displayStartDate (YYYY-MM-DD hh:mm:ss)
* @param string $displayEndDate (YYYY-MM-DD hh:mm:ss) * @param string $displayEndDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachStartDate (YYYY-MM-DD hh:mm:ss) * @param string $coachStartDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachEndDate (YYYY-MM-DD hh:mm:ss) * @param string $coachEndDate (YYYY-MM-DD hh:mm:ss)
* @param mixed $coachId If int, this is the session coach id, * @param mixed $coachId If int, this is the session coach id,
* if string, the coach ID will be looked for from the user table * if string, the coach ID will be looked for from the user table
* @param int $sessionCategoryId ID of the session category in which this session is registered * @param int $sessionCategoryId ID of the session category in which this session is registered
* @param int $visibility Visibility after end date (0 = read-only, 1 = invisible, 2 = accessible) * @param int $visibility Visibility after end date (0 = read-only, 1 = invisible, 2 = accessible)
* @param bool $fixSessionNameIfExists * @param bool $fixSessionNameIfExists
* @param string $duration * @param string $duration
* @param string $description Optional. The session description * @param string $description Optional. The session description
* @param int $showDescription Optional. Whether show the session description * @param int $showDescription Optional. Whether show the session description
* @param array $extraFields * @param array $extraFields
* @param int $sessionAdminId Optional. If this sessions was created by a session admin, assign it to him * @param int $sessionAdminId Optional. If this sessions was created by a session admin, assign it to him
* @param bool $sendSubscriptionNotification Optional. * @param bool $sendSubscriptionNotification Optional.
* Whether send a mail notification to users being subscribed * Whether send a mail notification to users being subscribed
* @param int $accessUrlId Optional. * @param int $accessUrlId Optional.
* @param int $status * @param int $status
* *
* @return mixed Session ID on success, error message otherwise * @return mixed Session ID on success, error message otherwise
* *
@ -667,10 +667,10 @@ class SessionManager
/** /**
* Gets the admin session list callback of the session/session_list.php page. * Gets the admin session list callback of the session/session_list.php page.
* *
* @param array $options order and limit keys * @param array $options order and limit keys
* @param bool $getCount Whether to get all the results or only the count * @param bool $getCount Whether to get all the results or only the count
* @param array $columns * @param array $columns
* @param array $extraFieldsToLoad * @param array $extraFieldsToLoad
* @param string $listType * @param string $listType
* *
* @return mixed Integer for number of rows, or array of results * @return mixed Integer for number of rows, or array of results
@ -9408,6 +9408,85 @@ class SessionManager
return $result; return $result;
} }
public static function getStatusList()
{
return [
self::STATUS_PLANNED => get_lang('Planned'),
self::STATUS_PROGRESS => get_lang('InProgress'),
self::STATUS_FINISHED => get_lang('Finished'),
self::STATUS_CANCELLED => get_lang('Cancelled'),
];
}
public static function getStatusLabel($status)
{
$list = self::getStatusList();
if (!isset($list[$status])) {
return get_lang('NoStatus');
}
return $list[$status];
}
public static function getDefaultSessionTab()
{
$default = 'all';
$view = api_get_configuration_value('default_session_list_view');
if (!empty($view)) {
$default = $view;
}
return $default;
}
/**
* @return array
*/
public static function getSessionListTabs($listType)
{
$tabs = [
[
'content' => get_lang('AllSessionsShort'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=all',
],
[
'content' => get_lang('ActiveSessionsShort'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=active',
],
[
'content' => get_lang('ClosedSessionsShort'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=close',
],
[
'content' => get_lang('SessionListCustom'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=custom',
],
/*[
'content' => get_lang('Complete'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list_simple.php?list_type=complete',
],*/
];
switch ($listType) {
case 'all':
$default = 1;
break;
case 'active':
$default = 2;
break;
case 'close':
$default = 3;
break;
case 'custom':
$default = 4;
break;
}
return Display::tabsOnlyLink($tabs, $default);
}
/** /**
* @param int $id * @param int $id
* *
@ -9545,84 +9624,4 @@ class SessionManager
return -1; return -1;
} }
} }
public static function getStatusList()
{
return [
self::STATUS_PLANNED => get_lang('Planned'),
self::STATUS_PROGRESS => get_lang('InProgress'),
self::STATUS_FINISHED => get_lang('Finished'),
self::STATUS_CANCELLED => get_lang('Cancelled'),
];
}
public static function getStatusLabel($status)
{
$list = self::getStatusList();
if (!isset($list[$status])) {
return get_lang('NoStatus');
}
return $list[$status];
}
public static function getDefaultSessionTab()
{
$default = 'all';
$view = api_get_configuration_value('default_session_list_view');
if (!empty($view)) {
$default = $view;
}
return $default;
}
/**
* @return array
*/
public static function getSessionListTabs($listType)
{
$tabs = [
[
'content' => get_lang('AllSessionsShort'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=all',
],
[
'content' => get_lang('ActiveSessionsShort'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=active',
],
[
'content' => get_lang('ClosedSessionsShort'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=close',
],
[
'content' => get_lang('SessionListCustom'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php?list_type=custom',
],
/*[
'content' => get_lang('Complete'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list_simple.php?list_type=complete',
],*/
];
switch ($listType) {
case 'all':
$default = 1;
break;
case 'active':
$default = 2;
break;
case 'close':
$default = 3;
break;
case 'custom':
$default = 4;
break;
}
return Display::tabsOnlyLink($tabs, $default);
}
} }

@ -2,8 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\SessionRelUser;
/** /**
* Class SystemAnnouncementManager. * Class SystemAnnouncementManager.
*/ */

@ -1189,7 +1189,6 @@ class Thematic
$all = []; $all = [];
if (!empty($thematic_data)) { if (!empty($thematic_data)) {
foreach ($thematic_data as $thematic) { foreach ($thematic_data as $thematic) {
$thematic_id = $thematic['id'];
if (!empty($thematic_advance_data[$thematic['id']])) { if (!empty($thematic_advance_data[$thematic['id']])) {
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) { foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
$all[] = $thematic_advance['id']; $all[] = $thematic_advance['id'];

@ -1995,7 +1995,7 @@ class Tracking
* @param int User id * @param int User id
* @param array $courseInfo real_id and code are used * @param array $courseInfo real_id and code are used
* @param int Session id (optional, default=0) * @param int Session id (optional, default=0)
* @param bool $convert_date * @param bool $convert_date
* *
* @return string|bool Date with format long without day or false if there is no date * @return string|bool Date with format long without day or false if there is no date
*/ */

@ -3179,8 +3179,8 @@ class UserManager
/** /**
* Get extra user data by value. * Get extra user data by value.
* *
* @param string $variable the internal variable name of the field * @param string $variable the internal variable name of the field
* @param string $value the internal value of the field * @param string $value the internal value of the field
* @param bool $useLike * @param bool $useLike
* *
* @return array with extra data info of a user i.e array('field_variable'=>'value'); * @return array with extra data info of a user i.e array('field_variable'=>'value');

@ -91,9 +91,9 @@ class Rest extends WebService
* @param string $username * @param string $username
* @param string $apiKeyToValidate * @param string $apiKeyToValidate
* *
* @return Rest
* @throws Exception * @throws Exception
* *
* @return Rest
*/ */
public static function validate($username, $apiKeyToValidate) public static function validate($username, $apiKeyToValidate)
{ {
@ -309,11 +309,11 @@ class Rest extends WebService
/** /**
* Get the user courses. * Get the user courses.
* *
* @return array
* @throws \Doctrine\ORM\TransactionRequiredException * @throws \Doctrine\ORM\TransactionRequiredException
* @throws \Doctrine\ORM\ORMException * @throws \Doctrine\ORM\ORMException
*
* @throws \Doctrine\ORM\OptimisticLockException * @throws \Doctrine\ORM\OptimisticLockException
*
* @return array
*/ */
public function getUserCourses() public function getUserCourses()
{ {
@ -342,9 +342,9 @@ class Rest extends WebService
} }
/** /**
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseInfo() public function getCourseInfo()
{ {
@ -374,9 +374,9 @@ class Rest extends WebService
/** /**
* Get the course descriptions. * Get the course descriptions.
* *
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseDescriptions() public function getCourseDescriptions()
{ {
@ -398,9 +398,9 @@ class Rest extends WebService
/** /**
* @param int $directoryId * @param int $directoryId
* *
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseDocuments($directoryId = 0) public function getCourseDocuments($directoryId = 0)
{ {
@ -476,9 +476,9 @@ class Rest extends WebService
} }
/** /**
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseAnnouncements() public function getCourseAnnouncements()
{ {
@ -517,9 +517,9 @@ class Rest extends WebService
/** /**
* @param int $announcementId * @param int $announcementId
* *
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseAnnouncement($announcementId) public function getCourseAnnouncement($announcementId)
{ {
@ -552,9 +552,9 @@ class Rest extends WebService
} }
/** /**
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseAgenda() public function getCourseAgenda()
{ {
@ -609,9 +609,9 @@ class Rest extends WebService
} }
/** /**
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseNotebooks() public function getCourseNotebooks()
{ {
@ -639,9 +639,9 @@ class Rest extends WebService
} }
/** /**
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseForumCategories() public function getCourseForumCategories()
{ {
@ -712,9 +712,9 @@ class Rest extends WebService
/** /**
* @param int $forumId * @param int $forumId
* *
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseForum($forumId) public function getCourseForum($forumId)
{ {
@ -837,9 +837,9 @@ class Rest extends WebService
} }
/** /**
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function getCourseLearnPaths() public function getCourseLearnPaths()
{ {
@ -951,24 +951,6 @@ class Rest extends WebService
return $categoryData; return $categoryData;
} }
/**
* @param array $additionalParams Optional
*
* @return string
*/
private function encodeParams(array $additionalParams = [])
{
$params = array_merge(
$additionalParams,
[
'api_key' => $this->apiKey,
'username' => $this->user->getUsername(),
]
);
return json_encode($params);
}
/** /**
* Start login for a user. Then make a redirect to show the learnpath. * Start login for a user. Then make a redirect to show the learnpath.
* *
@ -1304,9 +1286,9 @@ class Rest extends WebService
/** /**
* @param $userParam * @param $userParam
* *
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function addUser($userParam) public function addUser($userParam)
{ {
@ -1558,9 +1540,9 @@ class Rest extends WebService
} }
/** /**
* @return array
* @throws Exception * @throws Exception
* *
* @return array
*/ */
public function addCoursesSession(array $params) public function addCoursesSession(array $params)
{ {
@ -1620,9 +1602,9 @@ class Rest extends WebService
* @param $startDate * @param $startDate
* @param $endDate * @param $endDate
* *
* @return int, the id of the new session
* @throws Exception * @throws Exception
* *
* @return int, the id of the new session
*/ */
public function createSessionFromModel($modelSessionId, $sessionName, $startDate, $endDate, array $extraFields = []) public function createSessionFromModel($modelSessionId, $sessionName, $startDate, $endDate, array $extraFields = [])
{ {
@ -1720,12 +1702,12 @@ class Rest extends WebService
/** /**
* subscribes a user to a session. * subscribes a user to a session.
* *
* @param int $sessionId the session id * @param int $sessionId the session id
* @param string $loginName the user's login name * @param string $loginName the user's login name
* *
* @return boolean, whether it worked
* @throws Exception * @throws Exception
* *
* @return boolean, whether it worked
*/ */
public function subscribeUserToSessionFromUsername($sessionId, $loginName) public function subscribeUserToSessionFromUsername($sessionId, $loginName)
{ {
@ -1757,9 +1739,9 @@ class Rest extends WebService
* @param $fieldName * @param $fieldName
* @param $fieldValue * @param $fieldValue
* *
* @return int, the matching session id
* @throws Exception when no session matched or more than one session matched * @throws Exception when no session matched or more than one session matched
* *
* @return int, the matching session id
*/ */
public function getSessionFromExtraField($fieldName, $fieldValue) public function getSessionFromExtraField($fieldName, $fieldValue)
{ {
@ -1792,9 +1774,9 @@ class Rest extends WebService
* *
* @param array $parameters * @param array $parameters
* *
* @return boolean, true on success
* @throws Exception on failure * @throws Exception on failure
* *
* @return boolean, true on success
*/ */
public function updateUserFromUserName($parameters) public function updateUserFromUserName($parameters)
{ {
@ -1927,9 +1909,7 @@ class Rest extends WebService
$fieldValue = $field['field_value']; $fieldValue = $field['field_value'];
if (!isset($fieldName) || !isset($fieldValue) || if (!isset($fieldName) || !isset($fieldValue) ||
!UserManager::update_extra_field_value($userId, $fieldName, $fieldValue)) { !UserManager::update_extra_field_value($userId, $fieldName, $fieldValue)) {
throw new Exception( throw new Exception(get_lang('CouldNotUpdateExtraFieldValue').': '.print_r($field, true));
get_lang('CouldNotUpdateExtraFieldValue').': '.print_r($field, true)
);
} }
} }
} else { } else {
@ -1998,4 +1978,22 @@ class Rest extends WebService
{ {
return false !== api_get_user_info_from_username($loginname); return false !== api_get_user_info_from_username($loginname);
} }
/**
* @param array $additionalParams Optional
*
* @return string
*/
private function encodeParams(array $additionalParams = [])
{
$params = array_merge(
$additionalParams,
[
'api_key' => $this->apiKey,
'username' => $this->user->getUsername(),
]
);
return json_encode($params);
}
} }

@ -77,9 +77,9 @@ class WebService
* @param string $username * @param string $username
* @param string $password * @param string $password
* *
* @return bool Return true if the password belongs to the username. Otherwise return false
* @throws Exception * @throws Exception
* *
* @return bool Return true if the password belongs to the username. Otherwise return false
*/ */
public static function isValidUser($username, $password) public static function isValidUser($username, $password)
{ {

@ -2571,6 +2571,7 @@ class learnpath
$percentage = $score; $percentage = $score;
$text = '/'.$maxScore; $text = '/'.$maxScore;
} }
return [$percentage, $text]; return [$percentage, $text];
} }
} }
@ -13671,6 +13672,53 @@ EOD;
return $arrLP; return $arrLP;
} }
/**
* Gets whether this SCORM learning path has been marked to use the score
* as progress. Takes into account whether the learnpath matches (SCORM
* content + less than 2 items).
*
* @return bool True if the score should be used as progress, false otherwise
*/
public function getUseScoreAsProgress()
{
// If not a SCORM, we don't care about the setting
if ($this->get_type() != 2) {
return false;
}
// If more than one step in the SCORM, we don't care about the setting
if ($this->get_total_items_count() > 1) {
return false;
}
$extraFieldValue = new ExtraFieldValue('lp');
$doUseScore = false;
$useScore = $extraFieldValue->get_values_by_handler_and_field_variable($this->get_id(), 'use_score_as_progress');
if (!empty($useScore) && isset($useScore['value'])) {
$doUseScore = $useScore['value'];
}
return $doUseScore;
}
/**
* Get the user identifier (user_id or username
* Depends on scorm_api_username_as_student_id in app/config/configuration.php.
*
* @return string User ID or username, depending on configuration setting
*/
public static function getUserIdentifierForExternalServices()
{
if (api_get_configuration_value('scorm_api_username_as_student_id')) {
return api_get_user_info(api_get_user_id())['username'];
} elseif (api_get_configuration_value('scorm_api_extrafield_to_use_as_student_id') != null) {
$extraFieldValue = new ExtraFieldValue('user');
$extrafield = $extraFieldValue->get_values_by_handler_and_field_variable(api_get_user_id(), api_get_configuration_value('scorm_api_extrafield_to_use_as_student_id'));
return $extrafield['value'];
} else {
return api_get_user_id();
}
}
/** /**
* Get the depth level of LP item. * Get the depth level of LP item.
* *
@ -13775,47 +13823,4 @@ EOD;
return ''; return '';
} }
/**
* Gets whether this SCORM learning path has been marked to use the score
* as progress. Takes into account whether the learnpath matches (SCORM
* content + less than 2 items).
* @return bool True if the score should be used as progress, false otherwise
*/
public function getUseScoreAsProgress()
{
// If not a SCORM, we don't care about the setting
if ($this->get_type() != 2) {
return false;
}
// If more than one step in the SCORM, we don't care about the setting
if ($this->get_total_items_count() > 1) {
return false;
}
$extraFieldValue = new ExtraFieldValue('lp');
$doUseScore = false;
$useScore = $extraFieldValue->get_values_by_handler_and_field_variable($this->get_id(), 'use_score_as_progress');
if (!empty($useScore) && isset($useScore['value'])) {
$doUseScore = $useScore['value'];
}
return $doUseScore;
}
/**
* Get the user identifier (user_id or username
* Depends on scorm_api_username_as_student_id in app/config/configuration.php
*
* @return string User ID or username, depending on configuration setting
*/
public static function getUserIdentifierForExternalServices()
{
if (api_get_configuration_value('scorm_api_username_as_student_id')) {
return api_get_user_info(api_get_user_id())['username'];
} elseif (api_get_configuration_value('scorm_api_extrafield_to_use_as_student_id') != null) {
$extraFieldValue = new ExtraFieldValue('user');
$extrafield = $extraFieldValue->get_values_by_handler_and_field_variable(api_get_user_id(), api_get_configuration_value('scorm_api_extrafield_to_use_as_student_id'));
return $extrafield['value'];
} else {
return api_get_user_id();
}
}
} }

@ -168,8 +168,6 @@ function switch_item_toc($lpId, $userId, $viewId, $currentItem, $nextItem)
$return .= "update_progress_bar('$completedItems','$totalItems','$progressMode');"; $return .= "update_progress_bar('$completedItems','$totalItems','$progressMode');";
} }
$myLP->set_error_msg(''); $myLP->set_error_msg('');
$myLP->prerequisites_match(); // Check the prerequisites are all complete. $myLP->prerequisites_match(); // Check the prerequisites are all complete.
if ($debug > 1) { if ($debug > 1) {

@ -273,7 +273,6 @@ $extra = $extraField->addElements(
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, $lpId); $skillList = Skill::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, $lpId);
// Submit button // Submit button
$form->addButtonSave(get_lang('SaveLPSettings')); $form->addButtonSave(get_lang('SaveLPSettings'));

@ -54,7 +54,7 @@ header('Content-type: text/javascript');
?>var scorm_logs=<?php echo (empty($oLP->scorm_debug) or (!api_is_course_admin() && !api_is_platform_admin())) ? '0' : '3'; ?>; //debug log level for SCORM. 0 = none, 1=light, 2=a lot, 3=all - displays logs in log frame ?>var scorm_logs=<?php echo (empty($oLP->scorm_debug) or (!api_is_course_admin() && !api_is_platform_admin())) ? '0' : '3'; ?>; //debug log level for SCORM. 0 = none, 1=light, 2=a lot, 3=all - displays logs in log frame
var lms_logs = 0; //debug log level for LMS actions. 0=none, 1=light, 2=a lot, 3=all var lms_logs = 0; //debug log level for LMS actions. 0=none, 1=light, 2=a lot, 3=all
var score_as_progress = <?php echo (empty($oLP->getUseScoreAsProgress())? 'false':'true'); ?>; var score_as_progress = <?php echo empty($oLP->getUseScoreAsProgress()) ? 'false' : 'true'; ?>;
// API Object initialization (eases access later on) // API Object initialization (eases access later on)
function APIobject() { function APIobject() {

@ -390,7 +390,6 @@ if ($form->validate()) {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AccessDetails')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AccessDetails')];
$userInfo = api_get_user_info($userId); $userInfo = api_get_user_info($userId);
$form->setDefaults(['from' => $startDate, 'to' => $endDate]); $form->setDefaults(['from' => $startDate, 'to' => $endDate]);
$formByDay = new FormValidator( $formByDay = new FormValidator(

@ -12,7 +12,6 @@ use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
/** /**
* @author Bart Mollet, Julio Montoya lot of fixes * @author Bart Mollet, Julio Montoya lot of fixes
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';

@ -289,7 +289,7 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
original_cols = grid.jqGrid('getGridParam', 'colModel'); original_cols = grid.jqGrid('getGridParam', 'colModel');
<?php if ($allowOrder) { <?php if ($allowOrder) {
?> ?>
options = { options = {
update: function (e, ui) { update: function (e, ui) {
var rowNum = jQuery("#sessions").getGridParam('rowNum'); var rowNum = jQuery("#sessions").getGridParam('rowNum');

@ -273,7 +273,8 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
// Sortable rows // Sortable rows
grid.jqGrid('sortableRows', options); grid.jqGrid('sortableRows', options);
<?php } ?> <?php
} ?>
grid.jqGrid('navGrid','#sessions_pager', grid.jqGrid('navGrid','#sessions_pager',
{edit:false,add:false,del:false}, {edit:false,add:false,del:false},

@ -209,7 +209,7 @@ $form->addElement(
$extraField = new ExtraField('survey'); $extraField = new ExtraField('survey');
$extraField->addElements($form, $survey_id, ['group_id']); $extraField->addElements($form, $survey_id, ['group_id']);
if ($extraField->get_handler_field_info_by_field_variable('group_id') ) { if ($extraField->get_handler_field_info_by_field_variable('group_id')) {
$extraFieldValue = new ExtraFieldValue('survey'); $extraFieldValue = new ExtraFieldValue('survey');
$groupData = $extraFieldValue->get_values_by_handler_and_field_variable($survey_id, 'group_id'); $groupData = $extraFieldValue->get_values_by_handler_and_field_variable($survey_id, 'group_id');
$groupValue = []; $groupValue = [];

@ -2196,7 +2196,7 @@ class SurveyManager
} }
$classToParse[] = [ $classToParse[] = [
'name' => $class['name'], 'name' => $class['name'],
'users' => $users 'users' => $users,
]; ];
} }
@ -2212,9 +2212,9 @@ class SurveyManager
$users = array_column($users, 'id'); $users = array_column($users, 'id');
$classToParse = [ $classToParse = [
[ [
'name' => $groupInfo['name'], 'name' => $groupInfo['name'],
'users'=> $users 'users' => $users,
] ],
]; ];
self::parseMultiplicateUserList($classToParse, $questions, $courseId, $surveyData); self::parseMultiplicateUserList($classToParse, $questions, $courseId, $surveyData);
} }

@ -2250,12 +2250,6 @@ class SurveyUtil
return $counter; return $counter;
} }
/**
* @param CSurvey $survey
* @param $content
* @param $subject
* @param $remind
*/
public static function saveInviteMail(CSurvey $survey, $content, $subject, $remind) public static function saveInviteMail(CSurvey $survey, $content, $subject, $remind)
{ {
// Reminder or not // Reminder or not

@ -10,7 +10,6 @@ use ChamiloSession as Session;
* *
* @todo use quickforms for the forms * @todo use quickforms for the forms
*/ */
if (!isset($_GET['cidReq'])) { if (!isset($_GET['cidReq'])) {
$_GET['cidReq'] = 'none'; // Prevent sql errors $_GET['cidReq'] = 'none'; // Prevent sql errors
$cidReset = true; $cidReset = true;

@ -546,7 +546,7 @@ if ($nbStudents > 0) {
if (empty($sessionId)) { if (empty($sessionId)) {
$table->set_header(12, get_lang('Survey'), false); $table->set_header(12, get_lang('Survey'), false);
$headers['survey'] = get_lang('Survey'); $headers['survey'] = get_lang('Survey');
} else { } else {
$table->set_header(12, get_lang('RegisteredDate'), false); $table->set_header(12, get_lang('RegisteredDate'), false);
$headers['registered_at'] = get_lang('RegisteredDate'); $headers['registered_at'] = get_lang('RegisteredDate');

@ -25,7 +25,6 @@ $htmlHeadXtra[] = '<script>
}); });
</script>'; </script>';
$lps = learnpath::getLpList($courseId); $lps = learnpath::getLpList($courseId);
Session::write('lps', $lps); Session::write('lps', $lps);
@ -274,7 +273,6 @@ function getCount()
} }
return $count; return $count;
} }
/** /**

@ -10,7 +10,7 @@ use Fhaculty\Graph\Set\Vertices;
use Fhaculty\Graph\Vertex; use Fhaculty\Graph\Vertex;
/** /**
* Class SequenceResourceRepository * Class SequenceResourceRepository.
*/ */
class SequenceResourceRepository extends EntityRepository class SequenceResourceRepository extends EntityRepository
{ {
@ -198,40 +198,6 @@ class SequenceResourceRepository extends EntityRepository
return $result; return $result;
} }
/**
* Get sessions from vertices.
*
* @param Vertices $verticesEdges The vertices
* @param int $type
*
* @return array
*/
protected function findVerticesEdges(Vertices $verticesEdges, $type)
{
$sessionVertices = [];
$em = $this->getEntityManager();
foreach ($verticesEdges as $supVertex) {
$vertexId = $supVertex->getId();
switch ($type) {
case SequenceResource::SESSION_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Session')->find($vertexId);
break;
case SequenceResource::COURSE_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Course')->find($vertexId);
break;
}
if (empty($resource)) {
continue;
}
$sessionVertices[$vertexId] = $resource;
}
return $sessionVertices;
}
/** /**
* Check if the ser has completed the requirements for the sequences. * Check if the ser has completed the requirements for the sequences.
* *
@ -405,4 +371,38 @@ class SequenceResourceRepository extends EntityRepository
return false; return false;
} }
/**
* Get sessions from vertices.
*
* @param Vertices $verticesEdges The vertices
* @param int $type
*
* @return array
*/
protected function findVerticesEdges(Vertices $verticesEdges, $type)
{
$sessionVertices = [];
$em = $this->getEntityManager();
foreach ($verticesEdges as $supVertex) {
$vertexId = $supVertex->getId();
switch ($type) {
case SequenceResource::SESSION_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Session')->find($vertexId);
break;
case SequenceResource::COURSE_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Course')->find($vertexId);
break;
}
if (empty($resource)) {
continue;
}
$sessionVertices[$vertexId] = $resource;
}
return $sessionVertices;
}
} }

@ -412,9 +412,8 @@ class Session
} }
/** /**
* Check for existence of a relation (SessionRelCourse) between a course and this session * Check for existence of a relation (SessionRelCourse) between a course and this session.
* *
* @param Course $course
* @return bool whether the course is related to this session * @return bool whether the course is related to this session
*/ */
public function isRelatedToCourse(Course $course) public function isRelatedToCourse(Course $course)
@ -928,6 +927,7 @@ class Session
} catch (\Exception $exception) { } catch (\Exception $exception) {
return false; return false;
} }
return (is_null($this->accessStartDate) || $this->accessStartDate < $now) return (is_null($this->accessStartDate) || $this->accessStartDate < $now)
&& (is_null($this->accessEndDate) || $now < $this->accessEndDate); && (is_null($this->accessEndDate) || $now < $this->accessEndDate);
} }

@ -2587,12 +2587,14 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser
} }
/** /**
* Retreives this user's related sessions * Retreives this user's related sessions.
* *
* @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key * @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key
*
* @return \Chamilo\CoreBundle\Entity\Session[] * @return \Chamilo\CoreBundle\Entity\Session[]
*/ */
public function getSessions($relationType) { public function getSessions($relationType)
{
$sessions = []; $sessions = [];
foreach (\Database::getManager()->getRepository('ChamiloCoreBundle:SessionRelUser')->findBy([ foreach (\Database::getManager()->getRepository('ChamiloCoreBundle:SessionRelUser')->findBy([
'user' => $this, 'user' => $this,
@ -2601,40 +2603,46 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser
$sessions[] = $sessionRelUser->getSession(); $sessions[] = $sessionRelUser->getSession();
} }
} }
return $sessions; return $sessions;
} }
/** /**
* Retreives this user's related student sessions * Retreives this user's related student sessions.
* *
* @return \Chamilo\CoreBundle\Entity\Session[] * @return \Chamilo\CoreBundle\Entity\Session[]
*/ */
public function getStudentSessions() { public function getStudentSessions()
{
return $this->getSessions(0); return $this->getSessions(0);
} }
/** /**
* Retreives this user's related DRH sessions * Retreives this user's related DRH sessions.
* *
* @return \Chamilo\CoreBundle\Entity\Session[] * @return \Chamilo\CoreBundle\Entity\Session[]
*/ */
public function getDRHSessions() { public function getDRHSessions()
{
return $this->getSessions(1); return $this->getSessions(1);
} }
/** /**
* Retreives this user's related accessible sessions of a type, student by default * Retreives this user's related accessible sessions of a type, student by default.
* *
* @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key * @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key
*
* @return \Chamilo\CoreBundle\Entity\Session[] * @return \Chamilo\CoreBundle\Entity\Session[]
*/ */
public function getCurrentlyAccessibleSessions($relationType = 0) { public function getCurrentlyAccessibleSessions($relationType = 0)
{
$sessions = []; $sessions = [];
foreach ($this->getSessions($relationType) as $session) { foreach ($this->getSessions($relationType) as $session) {
if ($session->isCurrentlyAccessible()) { if ($session->isCurrentlyAccessible()) {
$sessions[] = $session; $sessions[] = $session;
} }
} }
return $sessions; return $sessions;
} }
} }

Loading…
Cancel
Save