Minor - flint fixes

pull/3128/head
Julio Montoya 6 years ago
parent a565d2a935
commit 50c394b90d
  1. 1
      main/admin/course_list.php
  2. 8
      main/admin/settings.lib.php
  3. 1
      main/admin/user_information.php
  4. 3
      main/auth/okn/start.php
  5. 4
      main/course_home/course_home.php
  6. 1
      main/exercise/exercise_admin.php
  7. 1
      main/exercise/exercise_submit.php
  8. 2
      main/exercise/question_pool.php
  9. 1
      main/inc/ajax/sequence.ajax.php
  10. 8
      main/inc/ajax/statistics.ajax.php
  11. 14
      main/inc/lib/course.lib.php
  12. 1
      main/inc/lib/course_category.lib.php
  13. 4
      main/inc/lib/plugin.lib.php
  14. 159
      main/inc/lib/sessionmanager.lib.php
  15. 2
      main/inc/lib/system_announcements.lib.php
  16. 1
      main/inc/lib/thematic.lib.php
  17. 78
      main/inc/lib/webservices/Rest.php
  18. 2
      main/inc/lib/webservices/WebService.class.php
  19. 91
      main/lp/learnpath.class.php
  20. 2
      main/lp/lp_ajax_switch_item_toc.php
  21. 1
      main/lp/lp_edit.php
  22. 2
      main/lp/scorm_api.php
  23. 1
      main/mySpace/access_details_session.php
  24. 1
      main/session/resume_session.php
  25. 3
      main/session/session_list_custom.php
  26. 6
      main/survey/survey.lib.php
  27. 6
      main/survey/surveyUtil.class.php
  28. 1
      main/survey/survey_list.php
  29. 2
      main/tracking/lp_report.php
  30. 70
      src/Chamilo/CoreBundle/Entity/Repository/SequenceResourceRepository.php
  31. 4
      src/Chamilo/CoreBundle/Entity/Session.php
  32. 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;

@ -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;
} }

@ -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;

@ -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,7 +155,7 @@ 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) {
@ -167,7 +167,7 @@ if ($action == 'subscribe') {
} }
} 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()) {

@ -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')

@ -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
@ -592,6 +593,7 @@ class CourseManager
'warning' 'warning'
) )
); );
return false; return false;
} }
$endDate = new DateTime(); $endDate = new DateTime();
@ -616,6 +618,7 @@ class CourseManager
'warning' 'warning'
) )
); );
return false; return false;
} }
$accessUrlRelSession = new \Chamilo\CoreBundle\Entity\AccessUrlRelSession(); $accessUrlRelSession = new \Chamilo\CoreBundle\Entity\AccessUrlRelSession();
@ -631,6 +634,7 @@ class CourseManager
'warning' 'warning'
) )
); );
return false; return false;
} }
} else { } else {
@ -649,12 +653,15 @@ class CourseManager
'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,13 +1190,13 @@ 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)) {
@ -1200,6 +1207,7 @@ class CourseManager
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');
} }

@ -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()

@ -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'];

@ -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 = [])
{ {
@ -1723,9 +1705,9 @@ class Rest extends WebService
* @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';

@ -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},

@ -2196,7 +2196,7 @@ class SurveyManager
} }
$classToParse[] = [ $classToParse[] = [
'name' => $class['name'], 'name' => $class['name'],
'users' => $users 'users' => $users,
]; ];
} }
@ -2213,8 +2213,8 @@ class SurveyManager
$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;

@ -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