Use course id instead of course code, use course/session entity

Use repositories to get exercises/student publications.
pull/3844/head
Julio Montoya 5 years ago
parent ac5fd9244f
commit 346910d1a8
  1. 4
      public/main/admin/dashboard_add_users_to_user.php
  2. 6
      public/main/auth/my_progress.php
  3. 3
      public/main/dropbox/dropbox_functions.inc.php
  4. 2
      public/main/exercise/exercise_show.php
  5. 2
      public/main/exercise/recalculate_all.php
  6. 10
      public/main/group/group.php
  7. 11
      public/main/group/group_overview.php
  8. 5
      public/main/inc/ajax/announcement.ajax.php
  9. 16
      public/main/inc/ajax/course.ajax.php
  10. 4
      public/main/inc/ajax/group.ajax.php
  11. 13
      public/main/inc/ajax/model.ajax.php
  12. 1
      public/main/inc/lib/add_course.lib.inc.php
  13. 52
      public/main/inc/lib/agenda.lib.php
  14. 70
      public/main/inc/lib/api.lib.php
  15. 92
      public/main/inc/lib/exercise.lib.php
  16. 51
      public/main/inc/lib/groupmanager.lib.php
  17. 4
      public/main/inc/lib/internationalization.lib.php
  18. 260
      public/main/inc/lib/myspace.lib.php
  19. 13
      public/main/inc/lib/redirect.class.php
  20. 28
      public/main/inc/lib/sessionmanager.lib.php
  21. 959
      public/main/inc/lib/tracking.lib.php
  22. 3
      public/main/lp/lp_report.php
  23. 15
      public/main/mySpace/company_reports.php
  24. 14
      public/main/mySpace/company_reports_resumed.php
  25. 9
      public/main/mySpace/course.php
  26. 48
      public/main/mySpace/myStudents.php
  27. 15
      public/main/mySpace/question_stats_global.php
  28. 15
      public/main/mySpace/question_stats_global_detail.php
  29. 2
      public/main/mySpace/session_admin_teachers.php
  30. 2
      public/main/mySpace/teachers.php
  31. 2
      public/main/session/index.php
  32. 75
      public/main/tracking/courseLog.php
  33. 47
      public/main/tracking/course_log_tools.php
  34. 24
      public/main/tracking/exams.php
  35. 2
      public/plugin/azure_active_directory/src/callback.php

@ -34,9 +34,7 @@ $user_id = isset($_GET['user']) ? (int) $_GET['user'] : 0;
$user_info = api_get_user_info($user_id);
$user_anonymous = api_get_anonymous_id();
$current_user_id = api_get_user_id();
$userStatus = api_get_user_status($user_id);
$userStatus = $user_info['status'];
$firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null;
// setting the name of the tool

@ -36,8 +36,8 @@ if ($pluginCalendar) {
$user_id = api_get_user_id();
$courseUserList = CourseManager::get_courses_list_by_user_id($user_id);
$dates = $issues = '';
$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
$courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null;
$sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0;
$courseId = isset($_GET['cid']) ? (int) $_GET['cid'] : 0;
if (!empty($courseUserList)) {
$items = MySpace::get_connections_from_course_list(
@ -78,7 +78,7 @@ if (!empty($courseUserList)) {
}
$content = Tracking::show_user_progress($user_id, $sessionId);
$content .= Tracking::show_course_detail($user_id, $courseCode, $sessionId);
$content .= Tracking::show_course_detail($user_id, $courseId, $sessionId);
if (!empty($dates)) {
if (!empty($content)) {

@ -509,6 +509,7 @@ function display_addcategory_form($category_name = '', $id = 0, $action = '')
function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = 0)
{
$course_info = api_get_course_info();
$course = api_get_course_entity();
$_user = api_get_user_info();
$is_courseAdmin = api_is_course_admin();
$is_courseTutor = api_is_course_tutor();
@ -687,7 +688,7 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id =
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin)
&& 'true' == $allowGroups || 'true' === $allowStudentToStudent
) {
$complete_group_list_for_dropbox = GroupManager::get_group_list(null, $course_info);
$complete_group_list_for_dropbox = GroupManager::get_group_list(null, $course);
if (count($complete_group_list_for_dropbox) > 0) {
foreach ($complete_group_list_for_dropbox as $current_group) {

@ -1078,7 +1078,7 @@ if ('student_progress' == $origin) {
} elseif ('myprogress' == $origin) {
?>
<button type="button" class="save"
onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id(); ?>'"
onclick="top.location.href='../auth/my_progress.php?cid=<?php echo api_get_course_int_id(); ?>'"
value="<?php echo get_lang('Quit test'); ?>">
<?php echo get_lang('Quit test'); ?>
</button>

@ -31,7 +31,7 @@ $result = ExerciseLib::get_exam_results_data(
$exerciseId,
'',
false,
null,
api_get_course_int_id(),
false,
false,
[],

@ -239,13 +239,15 @@ if ('true' === api_get_setting('allow_group_categories')) {
'title' => get_lang('Default groups'),
];
$categories = array_merge([$defaultCategory], $categories);
$course = api_get_course_entity();
foreach ($categories as $index => $category) {
$categoryId = $category['iid'];
$groupList = GroupManager::get_group_list($categoryId, [],
null,
$groupList = GroupManager::get_group_list(
$categoryId,
$course,
null,
null,
false,
false,
null,
true
);

@ -21,8 +21,7 @@ $current_course_tool = TOOL_GROUP;
api_protect_course_script(true);
$nameTools = get_lang('Groups overview');
$courseId = api_get_course_int_id();
$courseInfo = api_get_course_info();
$course = api_get_course_entity();
$groupId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$keyword = $_GET['keyword'] ?? '';
@ -80,10 +79,10 @@ if (isset($_GET['action'])) {
break;
case 'export_pdf':
$content = GroupManager::getOverview($courseInfo, $keyword);
$content = GroupManager::getOverview($course, $keyword);
$pdf = new PDF();
$extra = '<div style="text-align:center"><h2>'.get_lang('Groups list').'</h2></div>';
$extra .= '<strong>'.get_lang('Course').': </strong>'.$courseInfo['title'].' ('.$courseInfo['code'].')';
$extra .= '<strong>'.get_lang('Course').': </strong>'.$course->getTitle().' ('.$course->getCode().')';
$content = $extra.$content;
$pdf->content_to_pdf($content, null, null, api_get_course_id());
@ -112,7 +111,7 @@ if (isset($_GET['action'])) {
$interbreadcrumb[] = ['url' => 'group.php?'.api_get_cidreq(), 'name' => get_lang('Groups')];
$origin = api_get_origin();
if ('learnpath' != $origin) {
if ('learnpath' !== $origin) {
// So we are not in learnpath tool
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
@ -157,7 +156,7 @@ Display::return_icon('user.png', get_lang('Go to').' '.get_lang('Users'), '', IC
// Action links
echo Display::toolbarAction('actions', [$actions, GroupManager::getSearchForm()]);
echo GroupManager::getOverview($courseInfo, $keyword);
echo GroupManager::getOverview($course, $keyword);
if ('learnpath' !== $origin) {
Display::display_footer();

@ -6,10 +6,11 @@ use Chamilo\CoreBundle\Framework\Container;
require_once __DIR__.'/../global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$action = $_REQUEST['a'] ?? null;
$isAllowedToEdit = api_is_allowed_to_edit();
$courseInfo = api_get_course_info();
$course = api_get_course_entity();
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
$groupId = api_get_group_id();
@ -78,7 +79,7 @@ switch ($action) {
$previewUsers[] = $student['user_id'];
}
$groupList = GroupManager::get_group_list(null, $courseInfo, null, $sessionId);
$groupList = GroupManager::get_group_list(null, $course, null, $sessionId);
foreach ($groupList as $group) {
$previewGroups[] = $group['iid'];
}

@ -2,6 +2,8 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
/**
* Responses to AJAX calls.
@ -310,16 +312,22 @@ switch ($action) {
break;
case 'search_exercise_by_course':
if (api_is_platform_admin()) {
$course = api_get_course_info_by_id($_GET['course_id']);
$session_id = (!empty($_GET['session_id'])) ? (int) $_GET['session_id'] : 0;
$exercises = ExerciseLib::get_all_exercises(
$course = api_get_course_entity($_GET['course_id']);
$session_id = !empty($_GET['session_id']) ? $_GET['session_id'] : 0;
$session = api_get_session_entity($session_id);
$qb = Container::getQuizRepository()->findAllByCourse($course, $session, $_GET['q'], 2, false);
/** @var CQuiz[] $exercises */
$exercises = $qb->getQuery()->getResult();
/*$exercises = ExerciseLib::get_all_exercises(
$course,
$session_id,
false,
$_GET['q'],
true,
3
);
);*/
foreach ($exercises as $exercise) {
$data[] = ['id' => $exercise->getIid(), 'text' => html_entity_decode($exercise->getTitle())];

@ -4,13 +4,13 @@
require_once __DIR__.'/../global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$action = $_REQUEST['a'] ?? '';
$isAllowedToEdit = api_is_allowed_to_edit();
switch ($action) {
case 'search':
if ($isAllowedToEdit) {
$groups = GroupManager::get_group_list(null, api_get_course_info(), null, 0, false, $_REQUEST['q']);
$groups = GroupManager::get_group_list(null, api_get_course_entity(), null, 0, false, $_REQUEST['q']);
$list = [];
foreach ($groups as $group) {
$list[] = [

@ -654,7 +654,8 @@ switch ($action) {
$count = ExerciseLib::get_count_exam_results(
$exercise_id,
$whereCondition
$whereCondition,
api_get_course_int_id()
);
break;
case 'get_exercise_results_report':
@ -687,7 +688,7 @@ switch ($action) {
$count = ExerciseLib::get_count_exam_results(
$exerciseId,
$whereCondition,
$courseInfo['code'],
$courseInfo['real_id'],
true
);
break;
@ -1519,7 +1520,9 @@ switch ($action) {
$sidx,
$sord,
$exercise_id,
$whereCondition
$whereCondition,
false,
api_get_course_int_id()
);
break;
case 'get_exercise_results_report':
@ -1579,7 +1582,7 @@ switch ($action) {
if (!empty($categoryList)) {
foreach ($categoryList as $categoryInfo) {
$label = 'category_'.$categoryInfo['id'];
if ('excel' == $operation) {
if ('excel' === $operation) {
$columns[] = $label.'_score_percentage';
$columns[] = $label.'_only_score';
$columns[] = $label.'_total';
@ -1610,7 +1613,7 @@ switch ($action) {
$exerciseId,
$whereCondition,
false,
$courseInfo['code'],
$courseInfo['real_id'],
true,
true,
$extraFieldsToAdd,

@ -756,7 +756,6 @@ class AddCourse
$course = new Course();
$course
->setCode($code)
->setDirectory($directory)
->setCourseLanguage($course_language)
->setTitle($title)
->setDescription(get_lang('Course Description'))

@ -8,7 +8,7 @@ use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CCalendarEvent;
use Chamilo\CourseBundle\Entity\CCalendarEventAttachment;
use Chamilo\CourseBundle\Entity\CGroup;
use Doctrine\DBAL\Types\Types;
use Chamilo\CoreBundle\Entity\Course;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
@ -954,7 +954,7 @@ class Agenda
$this->getPlatformEvents($start, $end);
break;
case 'course':
$courseInfo = api_get_course_info_by_id($courseId);
$course = api_get_course_entity($courseId);
// Session coach can see all events inside a session.
if (api_is_coach()) {
@ -962,7 +962,7 @@ class Agenda
$this->getCourseEvents(
$start,
$end,
$courseInfo,
$course,
$groupId,
$this->sessionId,
$user_id
@ -980,7 +980,7 @@ class Agenda
$this->getCourseEvents(
$start,
$end,
$courseInfo,
$course,
$groupId,
$this->sessionId,
$user_id
@ -1056,13 +1056,11 @@ class Agenda
if (!empty($my_courses)) {
foreach ($my_courses as $course_item) {
$courseInfo = api_get_course_info_by_id(
$course_item['real_id']
);
$course = api_get_course_entity($course_item['real_id']);
$this->getCourseEvents(
$start,
$end,
$courseInfo,
$course,
0,
$my_session_id
);
@ -1073,15 +1071,13 @@ class Agenda
if (!empty($my_course_list) && false == $sessionFilterActive) {
foreach ($my_course_list as $courseInfoItem) {
$courseInfo = api_get_course_info_by_id(
$courseInfoItem['real_id']
);
$course = api_get_course_entity($courseInfoItem['real_id']);
if (isset($courseId) && !empty($courseId)) {
if ($courseInfo['real_id'] == $courseId) {
if ($course->getId() == $courseId) {
$this->getCourseEvents(
$start,
$end,
$courseInfo,
$course,
0,
0,
$user_id
@ -1091,7 +1087,7 @@ class Agenda
$this->getCourseEvents(
$start,
$end,
$courseInfo,
$course,
0,
0,
$user_id
@ -1399,6 +1395,7 @@ class Agenda
if (!empty($courses)) {
foreach ($courses as $course) {
$course = api_get_course_entity($course['real_id']);
$this->getCourseEvents(
$start,
$end,
@ -1415,7 +1412,7 @@ class Agenda
/**
* @param int $start
* @param int $end
* @param array $courseInfo
* @param Course $course
* @param int $groupId
* @param int $sessionId
* @param int $user_id
@ -1426,7 +1423,7 @@ class Agenda
public function getCourseEvents(
$start,
$end,
$courseInfo,
Course $course,
$groupId = 0,
$sessionId = 0,
$user_id = 0,
@ -1438,23 +1435,18 @@ class Agenda
$start = !empty($start) ? api_get_utc_datetime($start) : null;
$end = !empty($end) ? api_get_utc_datetime($end) : null;
if (empty($courseInfo)) {
return [];
}
$courseId = $courseInfo['real_id'];
if (empty($courseId)) {
if (null === $course) {
return [];
}
$courseId = $course->getId();
$userId = api_get_user_id();
$sessionId = (int) $sessionId;
$user_id = (int) $user_id;
$groupList = GroupManager::get_group_list(
null,
$courseInfo,
$course,
null,
$sessionId
);
@ -1462,10 +1454,7 @@ class Agenda
if (api_is_platform_admin() || api_is_allowed_to_edit()) {
$isAllowToEdit = true;
} else {
$isAllowToEdit = CourseManager::isCourseTeacher(
$userId,
$courseId
);
$isAllowToEdit = CourseManager::isCourseTeacher($userId, $courseId);
}
$isAllowToEditByHrm = false;
@ -1494,9 +1483,8 @@ class Agenda
}
$repo = Container::getCalendarEventRepository();
$courseEntity = api_get_course_entity($courseId);
$session = api_get_session_entity($sessionId);
$qb = $repo->getResourcesByCourseOnly($courseEntity, $courseEntity->getResourceNode());
$qb = $repo->getResourcesByCourseOnly($course, $course->getResourceNode());
$userCondition = '';
if ($isAllowToEdit) {
@ -1685,7 +1673,7 @@ class Agenda
}*/
$event['session_name'] = $sessionInfo['name'] ?? '';
$event['course_name'] = $courseInfo['title'] ?? '';
$event['course_name'] = $course->getTitle();
/*if (isset($row['to_group_id']) && !empty($row['to_group_id'])) {
$event['borderColor'] = $event['backgroundColor'] = $this->event_group_color;
@ -1799,7 +1787,7 @@ class Agenda
}*/
$event['sent_to'] = implode('<br />', $sentTo);
$event['description'] = $row->getContent();
$event['visibility'] = $row->isVisible($courseEntity, $session) ? 1 : 0;
$event['visibility'] = $row->isVisible($course, $session) ? 1 : 0;
$event['real_id'] = $eventId;
$event['allDay'] = $row->getAllDay();
$event['parent_event_id'] = $row->getParentEvent() ? $row->getParentEvent()->getIid() : null;

@ -1033,7 +1033,7 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
}
//If password is set and user is not registered to the course then the course is not visible
if (false == $isAllowedInCourse &&
if (false === $isAllowedInCourse &&
isset($course_info['registration_code']) &&
!empty($course_info['registration_code'])
) {
@ -2416,7 +2416,7 @@ function api_format_course_array(Course $course = null)
$courseData['code'] = $courseData['sysCode'] = $course->getCode();
$courseData['name'] = $courseData['title'] = $course->getTitle();
$courseData['official_code'] = $courseData['visual_code'] = $course->getVisualCode();
$courseData['path'] = $courseData['directory'] = $course->getDirectory(); // Use as key in path.
//$courseData['path'] = $courseData['directory'] = $course->getDirectory(); // Use as key in path.
$courseData['creation_date'] = $course->getCreationDate()->format('Y-m-d H:i:s');
$courseData['titular'] = $course->getTutorName();
$courseData['language'] = $courseData['course_language'] = $course->getCourseLanguage();
@ -2631,27 +2631,27 @@ function get_status_from_code($status_code)
{
switch ($status_code) {
case STUDENT:
return get_lang('Student', '');
return get_lang('Student');
case COURSEMANAGER:
return get_lang('Teacher', '');
return get_lang('Teacher');
case SESSIONADMIN:
return get_lang('SessionsAdmin', '');
return get_lang('SessionsAdmin');
case DRH:
return get_lang('Drh', '');
return get_lang('Drh');
case ANONYMOUS:
return get_lang('Anonymous', '');
return get_lang('Anonymous');
case PLATFORM_ADMIN:
return get_lang('Administrator', '');
return get_lang('Administrator');
case SESSION_COURSE_COACH:
return get_lang('SessionCourseCoach', '');
return get_lang('SessionCourseCoach');
case SESSION_GENERAL_COACH:
return get_lang('SessionGeneralCoach', '');
return get_lang('SessionGeneralCoach');
case COURSE_TUTOR:
return get_lang('CourseAssistant', '');
return get_lang('CourseAssistant');
case STUDENT_BOSS:
return get_lang('StudentBoss', '');
return get_lang('StudentBoss');
case INVITEE:
return get_lang('Invitee', '');
return get_lang('Invitee');
}
}
@ -3398,38 +3398,6 @@ function api_is_invitee()
return isset($user['status']) && INVITEE == $user['status'];
}
/**
* This function checks whether a session is assigned into a category.
*
* @param int - session id
* @param string - category name
*
* @return bool - true if is found, otherwise false
*/
function api_is_session_in_category($session_id, $category_name)
{
$session_id = (int) $session_id;
$category_name = Database::escape_string($category_name);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sql = "SELECT 1
FROM $tbl_session
WHERE $session_id IN (
SELECT s.id FROM $tbl_session s, $tbl_session_category sc
WHERE
s.session_category_id = sc.id AND
sc.name LIKE '%$category_name'
)";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
return true;
} else {
return false;
}
}
/**
* Displays the title of a tool.
* Normal use: parameter is a string:
@ -3855,18 +3823,6 @@ function api_is_allowed($tool, $action, $task_id = 0)
*/
function api_is_anonymous($user_id = null, $db_check = false)
{
/*if ($db_check) {
if (!isset($user_id)) {
$user_id = api_get_user_id();
}
$info = api_get_user_info($user_id);
if (6 == $info['status'] || 0 == $user_id || empty($info)) {
return true;
}
}*/
return !Container::getAuthorizationChecker()->isGranted('IS_AUTHENTICATED_FULLY');
}

@ -1866,12 +1866,12 @@ HOTSPOT;
*
* @param int $exerciseId
* @param array $conditions
* @param string $courseCode
* @param int $courseId
* @param bool $showSession
*
* @return array
*/
public static function get_count_exam_results($exerciseId, $conditions, $courseCode = '', $showSession = false)
public static function get_count_exam_results($exerciseId, $conditions, $courseId, $showSession = false)
{
$count = self::get_exam_results_data(
null,
@ -1881,7 +1881,7 @@ HOTSPOT;
$exerciseId,
$conditions,
true,
$courseCode,
$courseId,
$showSession
);
@ -1900,7 +1900,7 @@ HOTSPOT;
* @param int $exercise_id
* @param null $extra_where_conditions
* @param bool $get_count
* @param string $courseCode
* @param int $courseId
* @param bool $showSessionField
* @param bool $showExerciseCategories
* @param array $userExtraFieldsToAdd
@ -1918,7 +1918,7 @@ HOTSPOT;
$exercise_id,
$extra_where_conditions = null,
$get_count = false,
$courseCode = null,
$courseId = null,
$showSessionField = false,
$showExerciseCategories = false,
$userExtraFieldsToAdd = [],
@ -1928,16 +1928,12 @@ HOTSPOT;
) {
//@todo replace all this globals
global $filter;
$courseCode = empty($courseCode) ? api_get_course_id() : $courseCode;
$courseInfo = api_get_course_info($courseCode);
if (empty($courseInfo)) {
$courseId = (int) $courseId;
$course = api_get_course_entity($courseId);
if (null === $course) {
return [];
}
//$documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document';
$course_id = $courseInfo['real_id'];
$sessionId = api_get_session_id();
$exercise_id = (int) $exercise_id;
@ -1974,7 +1970,7 @@ HOTSPOT;
LEFT JOIN $TBL_TRACK_ATTEMPT_RECORDING tr
ON (ttte.exe_id = tr.exe_id)
WHERE
c_id = $course_id AND
c_id = $courseId AND
exe_exo_id = $exercise_id
$sessionCondition
)";
@ -1997,9 +1993,9 @@ HOTSPOT;
g.id as group_id
FROM $TBL_USER u
INNER JOIN $TBL_GROUP_REL_USER gru
ON (gru.user_id = u.id AND gru.c_id= $course_id )
ON (gru.user_id = u.id AND gru.c_id= $courseId )
INNER JOIN $TBL_GROUP g
ON (gru.group_id = g.id AND g.c_id= $course_id )
ON (gru.group_id = g.id AND g.c_id= $courseId )
)";
}
@ -2060,9 +2056,9 @@ HOTSPOT;
g.iid as group_id
FROM $TBL_USER u
LEFT OUTER JOIN $TBL_GROUP_REL_USER gru
ON (gru.user_id = u.id AND gru.c_id= $course_id )
ON (gru.user_id = u.id AND gru.c_id= $courseId )
LEFT OUTER JOIN $TBL_GROUP g
ON (gru.group_id = g.id AND g.c_id = $course_id )
ON (gru.group_id = g.id AND g.c_id = $courseId )
)";
}
@ -2079,7 +2075,7 @@ HOTSPOT;
}
$sqlFromOption = " , $TBL_GROUP_REL_USER AS gru ";
$sqlWhereOption = " AND gru.c_id = $course_id AND gru.user_id = user.id ";
$sqlWhereOption = " AND gru.c_id = $courseId AND gru.user_id = user.id ";
$first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname";
if ($get_count) {
@ -2118,7 +2114,7 @@ HOTSPOT;
INNER JOIN $sql_inner_join_tbl_user AS user
ON (user.user_id = exe_user_id)
WHERE
te.c_id = $course_id $session_id_and AND
te.c_id = $courseId $session_id_and AND
ce.active <> -1
$exercise_where
$extra_where_conditions
@ -2136,7 +2132,7 @@ HOTSPOT;
return $rowx[0];
}
$teacher_list = CourseManager::get_teacher_list_from_course_code($courseCode);
$teacher_list = CourseManager::get_teacher_list_from_course_code($course->getCode());
$teacher_id_list = [];
if (!empty($teacher_list)) {
foreach ($teacher_list as $teacher) {
@ -2172,7 +2168,7 @@ HOTSPOT;
$results[] = $rowx;
}
$group_list = GroupManager::get_group_list(null, $courseInfo);
$group_list = GroupManager::get_group_list(null, $course);
$clean_group_list = [];
if (!empty($group_list)) {
foreach ($group_list as $group) {
@ -2187,7 +2183,7 @@ HOTSPOT;
if (is_array($results)) {
$users_array_id = [];
$from_gradebook = false;
if (isset($_GET['gradebook']) && 'view' == $_GET['gradebook']) {
if (isset($_GET['gradebook']) && 'view' === $_GET['gradebook']) {
$from_gradebook = true;
}
$sizeof = count($results);
@ -2200,7 +2196,7 @@ HOTSPOT;
// Looping results
for ($i = 0; $i < $sizeof; $i++) {
$revised = $results[$i]['revised'];
if ('incomplete' == $results[$i]['completion_status']) {
if ('incomplete' === $results[$i]['completion_status']) {
// If the exercise was incomplete, we need to determine
// if it is still into the time allowed, or if its
// allowed time has expired and it can be closed
@ -2244,7 +2240,8 @@ HOTSPOT;
}
$lp_name = null;
if ($lp_obj) {
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$results[$i]['orig_lp_id'];
$url = api_get_path(WEB_CODE_PATH).
'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$results[$i]['orig_lp_id'];
$lp_name = Display::url(
$lp_obj['lp_name'],
$url,
@ -2469,7 +2466,7 @@ HOTSPOT;
}
}
$objExercise = new Exercise($course_id);
$objExercise = new Exercise($courseId);
if ($showExerciseCategories) {
// Getting attempt info
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId);
@ -3065,30 +3062,9 @@ EOT;
return [];
}
/*$activeFilter = 0;
if (2 !== $active) {
$activeFilter = (int) $active;
}*/
/*$now = api_get_utc_datetime();
$timeConditions = '';
if ($check_publication_dates) {
// Start and end are set
$timeConditions = " AND ((start_time <> '' AND start_time < '$now' AND end_time <> '' AND end_time > '$now' ) OR ";
// only start is set
$timeConditions .= " (start_time <> '' AND start_time < '$now' AND end_time is NULL) OR ";
// only end is set
$timeConditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
// nothing is set
$timeConditions .= ' (start_time IS NULL AND end_time IS NULL)) ';
}
$needle_where = !empty($search) ? " AND title LIKE '?' " : '';
$needle = !empty($search) ? "%".$search."%" : '';*/
$repo = Container::getQuizRepository();
return $repo->findQuizzes($course, $session, (string) $search, $active);
return $repo->findAllByCourse($course, $session, (string) $search, $active);
// Show courses by active status
/*if (true == $search_all_sessions) {
@ -3602,28 +3578,6 @@ EOT;
return $avg_score;
}
/**
* @param string $course_code
* @param int $session_id
*
* @return CQuiz
*/
public static function get_exercises_to_be_taken($course_code, $session_id)
{
$course_info = api_get_course_info($course_code);
$exercises = self::get_all_exercises($course_info, $session_id);
$result = [];
$now = time() + 15 * 24 * 60 * 60;
foreach ($exercises as $exercise_item) {
$endTime = $exercise_item->getEndTime() ?: null;
if (null !== $endTime && $endTime->getTimestamp() < $now) {
$result[] = $exercise_item;
}
}
return $result;
}
/**
* Get student results (only in completed exercises) stats by question.
*

@ -92,59 +92,38 @@ class GroupManager
/**
* Get list of groups for current course.
*
* @param int $categoryId The id of the category from which the groups are
* @param int $categoryId The id of the category from which the groups are
* requested
* @param array $course_info Default is current course
* @param int $status group status
* @param int $sessionId
* @param bool $getCount
* @param bool $notInGroup Get groups not in a category
* @param Course $course Default is current course
* @param int $status group status
* @param int $sessionId
* @param bool $getCount
* @param bool $notInGroup Get groups not in a category
*
* @return array an array with all information about the groups
*/
public static function get_group_list(
$categoryId = null,
$course_info = [],
$course = null,
$status = null,
$sessionId = 0,
$getCount = false,
$filterByKeyword = '',
$returnEntityList = false
) {
$course_info = empty($course_info) ? api_get_course_info() : $course_info;
$course = $course ?? api_get_course_entity();
if (empty($course_info)) {
if (null === $course) {
return [];
}
$sessionId = empty($sessionId) ? api_get_session_id() : (int) $sessionId;
$course_id = $course_info['real_id'];
$repo = Container::getGroupRepository();
$course = api_get_course_entity($course_id);
$session = api_get_session_entity($sessionId);
//$group = api_get_group_entity(api_get_group_id());
$group = null;
$qb = $repo->getResourcesByCourse($course, $session, $group);
if (null === $categoryId) {
$qb
->andWhere('resource.category is NULL');
} else {
$qb
->andWhere('resource.category = :category')
->setParameter('category', $categoryId);
}
if (!empty($filterByKeyword)) {
$qb->andWhere($qb->expr()->like('resource.name', ':keyword'));
$qb->setParameter('keyword', "%$filterByKeyword%");
}
$qb = $repo->findAllByCourse($course, $session, $filterByKeyword, $status);
if ($getCount) {
$qb->select('count(resource)');
return $qb->getQuery()->getSingleScalarResult();
return $repo->getCount($qb);
}
if ($returnEntityList) {
@ -2851,12 +2830,12 @@ class GroupManager
}
/**
* @param array $courseInfo
* @param Course $course
* @param string $keyword
*
* @return string
*/
public static function getOverview($courseInfo, $keyword = '')
public static function getOverview(Course $course, $keyword = '')
{
$content = null;
$categories = self::get_categories();
@ -2866,7 +2845,7 @@ class GroupManager
if ('true' === api_get_setting('allow_group_categories')) {
$content .= '<h2>'.$category['title'].'</h2>';
}
$groups = self::get_group_list($category['iid'], $courseInfo, null, 0, false, $keyword);
$groups = self::get_group_list($category['iid'], $course, null, 0, false, $keyword);
$content .= '<ul>';
if (!empty($groups)) {
foreach ($groups as $group) {
@ -2878,7 +2857,7 @@ class GroupManager
}
// Check groups with no categories.
$groups = self::get_group_list(null, api_get_course_info(), null, api_get_session_id(), false, true);
$groups = self::get_group_list(null, $course, null, api_get_session_id(), false, true);
if (!empty($groups)) {
$content .= '<h2>'.get_lang('NoCategorySelected').'</h2>';
$content .= '<ul>';

@ -760,10 +760,6 @@ function api_get_person_name(
switch ($format) {
case PERSON_NAME_COMMON_CONVENTION:
$valid[$format][$language] = _api_get_person_name_convention($language, 'format');
$usernameOrderFromDatabase = api_get_setting('user_name_order');
if (isset($usernameOrderFromDatabase) && !empty($usernameOrderFromDatabase)) {
$valid[$format][$language] = $usernameOrderFromDatabase;
}
break;
case PERSON_NAME_WESTERN_ORDER:
$valid[$format][$language] = '%t %f %l';

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container;
use ChamiloSession as Session;
use CpChart\Cache as pCache;
use CpChart\Data as pData;
@ -117,7 +119,7 @@ class MySpace
'',
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
);
$menuItems[] = Display::url(
Display::return_icon(
@ -294,38 +296,32 @@ class MySpace
/**
* Creates a small table in the last column of the table with the user overview.
*
* @param int $user_id the id of the user
*
* @return array List course
*/
public static function returnCourseTracking($user_id)
public static function returnCourseTracking(User $user)
{
$user_id = (int) $user_id;
if (empty($user_id)) {
return [];
}
$userId = $user->getId();
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
// getting all the courses of the user
$sql = "SELECT * FROM $tbl_course_user
WHERE
user_id = $user_id AND
user_id = $userId AND
relation_type <> ".COURSE_RELATION_TYPE_RRHH;
$result = Database::query($sql);
$list = [];
while ($row = Database::fetch_array($result)) {
$courseInfo = api_get_course_info_by_id($row['c_id']);
$courseId = $courseInfo['real_id'];
$courseCode = $courseInfo['code'];
$course = api_get_course_entity($row['c_id']);
if (empty($courseInfo)) {
if (null === $course) {
continue;
}
$avg_score = Tracking::get_avg_student_score($user_id, $courseCode);
$courseId = $course->getId();
$courseCode = $course->getCode();
$avg_score = Tracking::get_avg_student_score($userId, $courseCode);
if (is_numeric($avg_score)) {
$avg_score = round($avg_score, 2);
} else {
@ -333,29 +329,34 @@ class MySpace
}
// Student exercises results (obtained score, maximum score, number of exercises answered, score percentage)
$exercisesResults = self::exercises_results($user_id, $courseCode);
$exercisesResults = self::exercises_results($userId, $courseCode);
$resultToString = '';
if (!is_null($exercisesResults['percentage'])) {
$resultToString = $exercisesResults['score_obtained'].'/'.$exercisesResults['score_possible'].' ( '.$exercisesResults['percentage'].'% )';
$resultToString =
$exercisesResults['score_obtained'].'/'.$exercisesResults['score_possible'].
' ( '.$exercisesResults['percentage'].'% )';
}
$item = [
'code' => $courseInfo['code'],
'real_id' => $courseInfo['real_id'],
'title' => $courseInfo['title'],
'code' => $courseCode,
'real_id' => $courseId,
'title' => $course->getTitle(),
'category' => '',
//'category' => $courseInfo['categoryName'], // @todo show categories instead of 1 category
'image_small' => $courseInfo['course_image'],
'image_large' => $courseInfo['course_image_large'],
'time_spent' => api_time_to_hms(Tracking::get_time_spent_on_the_course($user_id, $courseId)),
'student_progress' => round(Tracking::get_avg_student_progress($user_id, $courseCode)),
//'image_small' => $courseInfo['course_image'],
//'image_large' => $courseInfo['course_image_large'],
'time_spent' => api_time_to_hms(Tracking::get_time_spent_on_the_course($userId, $courseId)),
'student_progress' => round(Tracking::get_avg_student_progress($userId, $courseCode)),
'student_score' => $avg_score,
'student_message' => Tracking::count_student_messages($user_id, $courseCode),
'student_assignments' => Tracking::count_student_assignments($user_id, $courseCode),
'student_message' => Container::getForumPostRepository()->countUserForumPosts($user, $course),
'student_assignments' => Container::getStudentPublicationRepository()->countUserPublications($user, $course),
'student_exercises' => $resultToString,
'questions_answered' => $exercisesResults['questions_answered'],
'last_connection' => Tracking::get_last_connection_date_on_the_course($user_id, $courseInfo),
'last_connection' => Tracking::get_last_connection_date_on_the_course(
$user_id,
['real_id' => $courseId]
),
];
$list[] = $item;
}
@ -374,26 +375,25 @@ class MySpace
*
* @since April 2019
*/
public static function returnTrackingUserOverviewFilter($user_id)
public static function returnTrackingUserOverviewFilter($userId)
{
$tpl = new Template('', false, false, false, false, false, false);
$userInfo = api_get_user_info($user_id);
$avatar = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_SMALL);
$user = [
'id' => $user_id,
'code_user' => $userInfo['official_code'],
'complete_name' => $userInfo['complete_name'],
'username' => $userInfo['username'],
'course' => self::returnCourseTracking($user_id),
'avatar' => $avatar,
$user = api_get_user_entity($userId);
$url = Container::getIllustrationRepository()->getIllustrationUrl($user);
$item = [
'id' => $user->getId(),
'code_user' => $user->getOfficialCode(),
'complete_name' => UserManager::formatUserFullName($user),
'username' => $user->getUsername(),
'course' => self::returnCourseTracking($user),
'avatar' => $url,
];
$tpl->assign('item', $user);
$tpl->assign('item', $item);
$templateName = $tpl->get_template('my_space/partials/tracking_user_overview.tpl');
$content = $tpl->fetch($templateName);
return $content;
return $tpl->fetch($templateName);
}
/**
@ -1512,8 +1512,8 @@ class MySpace
$list = [];
foreach ($courses as $course) {
$list[] = [
'0' => $course['code'],
'col0' => $course['code'],
'0' => $course['real_id'],
'col0' => $course['real_id'],
];
}
@ -1531,24 +1531,14 @@ class MySpace
*/
public static function course_tracking_filter($course_code, $url_params, $row)
{
$course_code = $row[0];
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$courseId = $row[0];
$course = api_get_course_entity($courseId);
$courseCode = $course->getCode();
$tpl = new Template('', false, false, false, false, false, false);
$data = null;
// database table definition
$tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
// getting all the courses of the user
$sql = "SELECT *
FROM $tbl_user AS u
INNER JOIN $tbl_course_rel_user AS cu
ON cu.user_id = u.user_id
WHERE cu.c_id = '".$courseId."'";
$result = Database::query($sql);
$time_spent = 0;
$progress = 0;
$nb_progress_lp = 0;
@ -1560,15 +1550,22 @@ class MySpace
$total_score_obtained = 0;
$total_score_possible = 0;
$total_questions_answered = 0;
while ($row = Database::fetch_object($result)) {
$courseId = $course->getId();
$courseCode = $course->getCode();
$courseRelUsers = $course->getUsers();
foreach ($courseRelUsers as $courseRelUser) {
$user = $courseRelUser->getUser();
$userId = $user->getId();
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course(
$row->user_id,
$courseInfo['real_id']
$userId,
$courseId
);
$progress_tmp = Tracking::get_avg_student_progress(
$row->user_id,
$course_code,
$userId,
$courseCode,
[],
null,
true
@ -1576,8 +1573,8 @@ class MySpace
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
$score_tmp = Tracking::get_avg_student_score(
$row->user_id,
$course_code,
$userId,
$courseCode,
[],
null,
true
@ -1586,17 +1583,12 @@ class MySpace
$score += $score_tmp[0];
$nb_score_lp += $score_tmp[1];
}
$nb_messages += Tracking::count_student_messages(
$row->user_id,
$course_code
);
$nb_assignments += Tracking::count_student_assignments(
$row->user_id,
$course_code
);
$nb_messages += Container::getForumPostRepository($user, $course);
$nb_assignments += Container::getStudentPublicationRepository($user, $course);
$last_login_date_tmp = Tracking::get_last_connection_date_on_the_course(
$row->user_id,
$courseInfo,
$userId,
['real_id' => $courseId],
null,
false
);
@ -1612,7 +1604,7 @@ class MySpace
}
}
$exercise_results_tmp = self::exercises_results($row->user_id, $course_code);
$exercise_results_tmp = self::exercises_results($userId, $courseCode);
$total_score_obtained += $exercise_results_tmp['score_obtained'];
$total_score_possible += $exercise_results_tmp['score_possible'];
$total_questions_answered += $exercise_results_tmp['questions_answered'];
@ -1648,13 +1640,13 @@ class MySpace
}
$data = [
'course_code' => $course_code,
'course_code' => $courseCode,
'id' => $courseId,
'image' => $courseInfo['course_image_large'],
'image_small' => $courseInfo['course_image'],
'title' => $courseInfo['title'],
'url' => $courseInfo['course_public_url'],
'category' => $courseInfo['categoryName'],
//'image' => $courseInfo['course_image_large'],
//'image_small' => $courseInfo['course_image'],
'title' => $course->getTitle(),
//'url' => $courseInfo['course_public_url'],
//'category' => $courseInfo['categoryName'],
'time_spent' => api_time_to_hms($time_spent),
'avg_progress' => $avg_progress,
'avg_score' => $avg_score,
@ -1667,9 +1659,8 @@ class MySpace
$tpl->assign('data', $data);
$layout = $tpl->get_template('my_space/partials/tracking_course_overview.tpl');
$content = $tpl->fetch($layout);
return $content;
return $tpl->fetch($layout);
}
/**
@ -1725,21 +1716,15 @@ class MySpace
// the other lines (the data)
foreach ($course_data as $key => $course) {
$course_code = $course[0];
$courseInfo = api_get_course_info($course_code);
$course_title = $courseInfo['title'];
$courseId = $courseInfo['real_id'];
$courseId = $course[0];
$course = api_get_course_entity($courseId);
$courseCode = $course->getCode();
$course_title = $course->getTitle();
$csv_row = [];
$csv_row[] = $course_title;
// getting all the courses of the session
$sql = "SELECT *
FROM $tbl_user AS u
INNER JOIN $tbl_course_rel_user AS cu
ON cu.user_id = u.user_id
WHERE cu.c_id = '".$courseId."'";
$result = Database::query($sql);
$time_spent = 0;
$progress = 0;
$nb_progress_lp = 0;
@ -1751,15 +1736,20 @@ class MySpace
$total_score_obtained = 0;
$total_score_possible = 0;
$total_questions_answered = 0;
while ($row = Database::fetch_object($result)) {
$courseRelUsers = $course->getUsers();
foreach ($courseRelUsers as $courseRelUser) {
$user = $courseRelUser->getUser();
$userId = $user->getId();
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course(
$row->user_id,
$userId,
$courseId
);
$progress_tmp = Tracking::get_avg_student_progress(
$row->user_id,
$course_code,
$userId,
$courseCode,
[],
null,
true
@ -1767,8 +1757,8 @@ class MySpace
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
$score_tmp = Tracking::get_avg_student_score(
$row->user_id,
$course_code,
$userId,
$courseCode,
[],
null,
true
@ -1777,18 +1767,12 @@ class MySpace
$score += $score_tmp[0];
$nb_score_lp += $score_tmp[1];
}
$nb_messages += Tracking::count_student_messages(
$row->user_id,
$course_code
);
$nb_assignments += Tracking::count_student_assignments(
$row->user_id,
$course_code
);
$nb_messages += Container::getForumPostRepository()->countUserForumPosts($user, $course);
$nb_assignments += Container::getStudentPublicationRepository()->countUserPublications($user, $course);
$last_login_date_tmp = Tracking::get_last_connection_date_on_the_course(
$row->user_id,
$courseInfo,
$userId,
['real_id' => $courseId],
null,
false
);
@ -1803,7 +1787,7 @@ class MySpace
}
}
$exercise_results_tmp = self::exercises_results($row->user_id, $course_code);
$exercise_results_tmp = self::exercises_results($userId, $courseCode);
$total_score_obtained += $exercise_results_tmp['score_obtained'];
$total_score_possible += $exercise_results_tmp['score_possible'];
$total_questions_answered += $exercise_results_tmp['questions_answered'];
@ -1967,28 +1951,25 @@ class MySpace
*/
public static function session_tracking_filter($session_id, $url_params, $row)
{
$session_id = $row[0];
$sessionId = $row[0];
$url = api_get_url_entity();
$session = api_get_session_entity($sessionId);
// the table header
$return = '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$return = '<table
class="data_table"
style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
// database table definition
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
// getting all the courses of the user
$sql = "SELECT * FROM $tbl_course AS c
INNER JOIN $tbl_session_rel_course AS sc
ON sc.c_id = c.id
WHERE sc.session_id = '".$session_id."'";
$result = Database::query($sql);
while ($row = Database::fetch_object($result)) {
$courseId = $row->c_id;
$courseInfo = api_get_course_info_by_id($courseId);
$sessionRelCourses = $session->getCourses();
foreach ($sessionRelCourses as $sessionRelCourse) {
$course = $sessionRelCourse->getCourse();
$courseId = $course->getId();
$courseCode = $course->getCode();
$return .= '<tr>';
// course code
$return .= ' <td width="157px" >'.$row->title.'</td>';
$return .= '<td>'.$course->getTitle().'</td>';
//$users = Container::getSessionRepository()->getUsersByCourse($session, $course, $url);
// get the users in the course
$sql = "SELECT u.user_id
FROM $tbl_user AS u
@ -2008,21 +1989,32 @@ class MySpace
$total_score_possible = 0;
$total_questions_answered = 0;
while ($row_user = Database::fetch_object($result_users)) {
$user = api_get_user_entity($row_user->user_id);
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
$progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, [], $session_id, true);
$progress_tmp = Tracking::get_avg_student_progress(
$row_user->user_id,
$courseCode,
[],
$session_id,
true
);
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
$score_tmp = Tracking::get_avg_student_score($row_user->user_id, $row->code, [], $session_id, true);
$score_tmp = Tracking::get_avg_student_score($row_user->user_id, $courseCode, [], $session_id, true);
if (is_array($score_tmp)) {
$score += $score_tmp[0];
$nb_score_lp += $score_tmp[1];
}
$nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id);
$nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id);
$nb_messages += Container::getForumPostRepository()->countUserForumPosts($user, $course, $session);
$nb_assignments += Container::getStudentPublicationRepository()->countUserPublications(
$user,
$course,
$session
);
$last_login_date_tmp = Tracking::get_last_connection_date_on_the_course(
$row_user->user_id,
$courseInfo,
['real_id' => $courseId],
$session_id,
false
);
@ -2991,7 +2983,7 @@ class MySpace
$sql_select = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_course_rel_user
WHERE session_id='$id_session' AND c_id='$enreg_course'";
$rs = Database::query($sql_select);
list($nbr_users) = Database::fetch_array($rs);
[$nbr_users] = Database::fetch_array($rs);
$sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users
WHERE session_id='$id_session' AND c_id='$enreg_course'";
Database::query($sql_update);

@ -51,7 +51,7 @@ class Redirect
* @param bool Whether the user just logged in (in this case, use page_after_login rules)
* @param int The user_id, if defined. Otherwise just send to where the page_after_login setting says
*/
public static function session_request_uri($logging_in = false, $user_id = null)
public static function session_request_uri($logging_in = false, $userInfo = null)
{
$no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;
@ -75,17 +75,18 @@ class Redirect
} elseif ($logging_in ||
(isset($_REQUEST['sso_referer']) && !empty($_REQUEST['sso_referer']))
) {
if (isset($user_id)) {
if (isset($userInfo) && !empty($userInfo)) {
$userId = $userInfo['user_id'];
$allow = api_get_configuration_value('plugin_redirection_enabled');
if ($allow) {
$allow = api_get_configuration_value('plugin_redirection_enabled');
if ($allow) {
RedirectionPlugin::redirectUser($user_id);
RedirectionPlugin::redirectUser($userId);
}
}
// Make sure we use the appropriate role redirection in case one has been defined
$user_status = api_get_user_status($user_id);
$user_status = $userInfo['status'];
switch ($user_status) {
case COURSEMANAGER:
$redir = api_get_setting('teacher_page_after_login');
@ -122,12 +123,12 @@ class Redirect
// if multiple URLs are enabled, make sure he's admin of the
// current URL before redirecting
$url = api_get_current_access_url_id();
if (api_is_platform_admin_by_id($user_id, $url)) {
if (api_is_platform_admin_by_id($userId, $url)) {
self::navigate(api_get_path(WEB_CODE_PATH).'admin/index.php');
}
} else {
// if no multiple URL, then it's enough to be platform admin
if (api_is_platform_admin_by_id($user_id)) {
if (api_is_platform_admin_by_id($userId)) {
self::navigate(api_get_path(WEB_CODE_PATH).'admin/index.php');
}
}

@ -1132,18 +1132,19 @@ class SessionManager
$arrLesson[$row['session_id']]['lessons_total']++;
}
}
$session = api_get_session_entity($sessionId);
$qb = Container::getQuizRepository()->findAllByCourse($course, $session, null, 2);
$exercises = $qb->getQuery()->getResult();
$exercises_total = count($exercises);
/**
* Exercises.
*/
$exercises = ExerciseLib::get_all_exercises(
/*$exercises = ExerciseLib::get_all_exercises(
$course,
$sessionId,
false,
'',
$getAllSessions
);
$exercises_total = count($exercises);
$exercises_total = count($exercises);*/
/**
* Assignments.
@ -1246,7 +1247,8 @@ class SessionManager
}
//Lessons
//TODO: Lessons done and left is calculated by progress per item in lesson, maybe we should calculate it only per completed lesson?
//TODO: Lessons done and left is calculated by progress per item in lesson,
// maybe we should calculate it only per completed lesson?
$lessons_progress = Tracking::get_avg_student_progress(
$user['user_id'],
$course['code'],
@ -1271,7 +1273,11 @@ class SessionManager
$exercises_left = $exercises_total - $exercises_done;
//Assignments
$assignments_done = Tracking::count_student_assignments($user['user_id'], $course['code'], $user['id_session']);
$assignments_done = Container::getStudentPublicationRepository()->countUserPublications(
$user['user_id'],
$course['code'],
$user['id_session']
);
$assignments_left = $assignments_total - $assignments_done;
if (!empty($assignments_total)) {
$assignments_progress = round((($assignments_done * 100) / $assignments_total), 2);
@ -1673,11 +1679,8 @@ class SessionManager
} else {
$sessionInfo = self::get_session_by_name($name);
$exists = false;
if (!empty($sessionInfo)) {
if ($sessionInfo['id'] != $id) {
$exists = true;
}
if (!empty($sessionInfo) && $sessionInfo['id'] !== $id) {
$exists = true;
}
if ($exists) {
@ -1687,7 +1690,6 @@ class SessionManager
return false;
} else {
/** @var Session $sessionEntity */
$sessionEntity = api_get_session_entity($id);
$sessionEntity
->setName($name)

File diff suppressed because it is too large Load Diff

@ -18,6 +18,7 @@ if (!$isAllowedToEdit) {
}
$lpTable = Database::get_course_table(TABLE_LP_MAIN);
$course = api_get_course_entity();
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$courseId = api_get_course_int_id();
@ -157,7 +158,7 @@ $lpInfo = Database::select(
'first'
);
$groups = GroupManager::get_group_list(null, $courseInfo, null, $sessionId);
$groups = GroupManager::get_group_list(null, $course, null, $sessionId);
$label = get_lang('Groups');
$classes = [];
if ($allowUserGroups) {

@ -227,35 +227,34 @@ $actions = null;
if (api_is_student_boss()) {
$actions .= Display::url(
Display::return_icon('statistics.png', get_lang('View my progress'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
);
$actions .= Display::url(
Display::return_icon('user.png', get_lang('Learners'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."mySpace/student.php"
api_get_path(WEB_CODE_PATH).'mySpace/student.php'
);
$actions .= Display::url(
Display::return_icon("statistics.png", get_lang("Corporate report"), [], ICON_SIZE_MEDIUM),
Display::return_icon('statistics.png', get_lang('Corporate report'), [], ICON_SIZE_MEDIUM),
"#"
);
$actions .= Display::url(
Display::return_icon(
"certificate_list.png",
get_lang("GradebookSeeListOfLearnersCertificates"),
'certificate_list.png',
get_lang('GradebookSeeListOfLearnersCertificates'),
[],
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php"
api_get_path(WEB_CODE_PATH).'gradebook/certificate_report.php'
);
}
$content = '<div class="actions">';
if (!empty($actions)) {
$content .= $actions;
}
$content .= Display::url(
get_lang("Corporate reportResumed"),
api_get_path(WEB_CODE_PATH)."mySpace/company_reports_resumed.php",
api_get_path(WEB_CODE_PATH).'mySpace/company_reports_resumed.php',
[
'class' => 'btn btn-success',
]

@ -86,24 +86,24 @@ $actions = null;
if (api_is_student_boss()) {
$actions .= Display::url(
Display::return_icon('statistics.png', get_lang('View my progress'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
);
$actions .= Display::url(
Display::return_icon('user.png', get_lang('Learners'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."mySpace/student.php"
api_get_path(WEB_CODE_PATH).'mySpace/student.php'
);
$actions .= Display::url(
Display::return_icon("statistics.png", get_lang("Corporate report"), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."mySpace/company_reports.php"
Display::return_icon('statistics.png', get_lang('Corporate report'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php'
);
$actions .= Display::url(
Display::return_icon(
"certificate_list.png",
get_lang("GradebookSeeListOfLearnersCertificates"),
'certificate_list.png',
get_lang('GradebookSeeListOfLearnersCertificates'),
[],
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php"
api_get_path(WEB_CODE_PATH).'gradebook/certificate_report.php'
);
}

@ -86,11 +86,11 @@ if (api_is_platform_admin(true, true)) {
if (!api_is_session_admin()) {
$menu_items[] = Display::url(
Display::return_icon('statistics.png', get_lang('View my progress'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
);
$menu_items[] = Display::url(
Display::return_icon('user.png', get_lang('Learners'), [], ICON_SIZE_MEDIUM),
"index.php?view=drh_students&amp;display=yourstudents"
'index.php?view=drh_students&display=yourstudents'
);
$menu_items[] = Display::url(
Display::return_icon('teacher.png', get_lang('Teachers'), [], ICON_SIZE_MEDIUM),
@ -114,7 +114,8 @@ if (api_is_platform_admin(true, true)) {
api_get_path(WEB_CODE_PATH).'mySpace/question_stats_global_detail.php'
);
if (api_can_login_as($user_id)) {
$link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&amp;user_id='.$user_id.'&amp;sec_token='.Security::get_existing_token().'">'.
$link = '<a
href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.Security::get_existing_token().'">'.
Display::return_icon('login_as.png', get_lang('Login as'), null, ICON_SIZE_MEDIUM).'</a>&nbsp;&nbsp;';
$menu_items[] = $link;
}
@ -143,7 +144,7 @@ if (api_is_platform_admin(true, true)) {
if ($showImportIcon) {
echo "<div align=\"right\">";
echo '<a href="user_import.php?id_session='.$sessionId.'&action=export&amp;type=xml">'.
echo '<a href="user_import.php?id_session='.$sessionId.'&action=export&type=xml">'.
Display::return_icon('excel.gif', get_lang('Import users list')).'&nbsp;'.get_lang('Import users list').'</a>';
echo "</div><br />";
}

@ -15,9 +15,8 @@ require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
//$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>';
$htmlHeadXtra[] = null;
$export = isset($_GET['export']) ? $_GET['export'] : false;
$export = $_GET['export'] ?? false;
$sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0;
$origin = api_get_origin();
$courseId = isset($_GET['cid']) ? (int) $_GET['cid'] : '';
@ -129,7 +128,7 @@ if (!empty($details)) {
} else {
if ('resume_session' === $origin) {
$interbreadcrumb[] = [
'url' => "../session/session_list.php",
'url' => '../session/session_list.php',
'name' => get_lang('Session list'),
];
$interbreadcrumb[] = [
@ -210,15 +209,15 @@ if (!empty($details)) {
// Database Table Definitions
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$action = isset($_GET['action']) ? $_GET['action'] : '';
$action = $_GET['action'] ?? '';
switch ($action) {
case 'add_work_time':
if (false === $workingTimeEdit) {
api_not_allowed(true);
}
$workingTime = isset($_GET['time']) ? $_GET['time'] : '';
$workId = isset($_GET['work_id']) ? $_GET['work_id'] : '';
$workingTime = $_GET['time'] ?? '';
$workId = $_GET['work_id'] ?? '';
Event::eventAddVirtualCourseTime($courseInfo['real_id'], $studentId, $sessionId, $workingTime, $workId);
Display::addFlash(Display::return_message(get_lang('Updated')));
@ -228,8 +227,8 @@ switch ($action) {
if (false === $workingTimeEdit) {
api_not_allowed(true);
}
$workingTime = isset($_GET['time']) ? $_GET['time'] : '';
$workId = isset($_GET['work_id']) ? $_GET['work_id'] : '';
$workingTime = $_GET['time'] ?? '';
$workId = $_GET['work_id'] ?? '';
Event::eventRemoveVirtualCourseTime($courseInfo['real_id'], $studentId, $sessionId, $workingTime, $workId);
Display::addFlash(Display::return_message(get_lang('Updated')));
@ -461,8 +460,8 @@ switch ($action) {
break;
case 'send_message':
if (true === $allowMessages) {
$subject = isset($_POST['subject']) ? $_POST['subject'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
$subject = $_POST['subject'] ?? '';
$message = $_POST['message'] ?? '';
$userInfo = api_get_user_info($studentId);
if (!empty($subject) && !empty($message)) {
@ -574,7 +573,6 @@ switch ($action) {
}
$courses_in_session = [];
// See #4676
$drh_can_access_all_courses = false;
if (api_is_drh() || api_is_platform_admin() || api_is_student_boss() || api_is_session_admin()) {
@ -650,10 +648,7 @@ while ($row = Database::fetch_array($rs, 'ASSOC')) {
}
}
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
$courseInfo
);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(api_get_user_id(), $courseInfo);
if (api_is_drh() && !api_is_platform_admin()) {
if (!empty($studentId)) {
@ -1078,8 +1073,6 @@ if (isset($_GET['action']) && 'all_attendance' === $_GET['action']) {
}
echo '</tbody>
</table></div>';
/** Display dates */
/*Display all attendances */
Display::display_footer();
exit();
}
@ -1874,16 +1867,13 @@ if (empty($details)) {
$result_exercices = Database::query($sql);
$i = 0;*/
$repo = Container::getQuizRepository();
$course = api_get_course_entity($courseInfo['real_id']);
$session = api_get_session_entity($sessionId);
// 2. Get query builder from repo.
$qb = $repo->getResourcesByCourse($course, $session);
$qb->andWhere('resource.active = 1 OR resource.active = 0');
$repo = Container::getQuizRepository();
$qb = $repo->findAllByCourse($course, $session, null, 2, false);
$exerciseList = $qb->getQuery()->getResult();
if ($exerciseList) {
//while ($exercices = Database::fetch_array($result_exercices)) {
/** @var CQuiz $exercise */
foreach ($exerciseList as $exercise) {
$exercise_id = (int) $exercise->getIid();
@ -1928,10 +1918,8 @@ if (empty($details)) {
if ($i % 2) {
$css_class = 'row_odd';
}
echo '<tr class="'.$css_class.'"><td>'.Exercise::get_formated_title_variable(
$exercise->getTitle()
).'</td>';
$exerciseTitle = Exercise::get_formated_title_variable($exercise->getTitle());
echo '<tr class="'.$css_class.'"><td>'.$exerciseTitle.'</td>';
echo '<td>';
if (!empty($lp_name)) {
@ -2121,9 +2109,8 @@ if (empty($details)) {
echo '<td class="text-center"><a href="'.$url.'">('.$documentNumber.')</a></td>';
$qualification = !empty($results['qualification']) ? $results['qualification'] : '-';
echo '<td class="text-center">'.$qualification.'</td>';
echo '<td class="text-center">'.api_convert_and_format_date(
$results['sent_date_from_db']
).' '.$results['expiry_note'].'</td>';
echo '<td class="text-center">'.
api_convert_and_format_date($results['sent_date_from_db']).' '.$results['expiry_note'].'</td>';
$assignment = get_work_assignment_by_id($work->iid, $courseInfo['real_id']);
echo '<td class="text-center">';
@ -2169,7 +2156,6 @@ if (empty($details)) {
';
$csv_content[] = [];
$csv_content[] = [
get_lang('OTI (Online Training Interaction) settings report'),
];
@ -2198,7 +2184,7 @@ if (empty($details)) {
get_lang('Latest chat connection'),
$chat_last_connection,
];
} //end details
}
if (true === $allowMessages) {
// Messages

@ -2,6 +2,9 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_TRACKING;
@ -24,15 +27,19 @@ $exerciseList = [];
$selectedExercises = [];
if (!empty($courseIdList)) {
foreach ($courseIdList as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$courseExerciseList = ExerciseLib::get_all_exercises(
$course = api_get_course_entity($courseId);
/*$courseExerciseList = ExerciseLib::get_all_exercises(
$courseInfo,
0,
false,
null,
false,
3
);
);*/
$qb = Container::getQuizRepository()->findAllByCourse($course, null, null, 2, false);
/** @var CQuiz[] $courseExerciseList */
$courseExerciseList = $qb->getQuery()->getResult();
if (!empty($courseExerciseList)) {
foreach ($courseExerciseList as $exercise) {
@ -43,7 +50,7 @@ if (!empty($courseIdList)) {
}
$exerciseList += array_column($courseExerciseList, 'title', 'iid');
}
$courseOptions[$courseId] = $courseInfo['name'];
$courseOptions[$courseId] = $course->getTitle();
}
}

@ -2,6 +2,9 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_TRACKING;
@ -24,15 +27,19 @@ $exerciseList = [];
$selectedExercises = [];
if (!empty($courseIdList)) {
foreach ($courseIdList as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$courseExerciseList = ExerciseLib::get_all_exercises(
$course = api_get_course_entity($courseId);
/*$courseExerciseList = ExerciseLib::get_all_exercises(
$courseInfo,
0,
false,
null,
false,
3
);
);*/
$qb = Container::getQuizRepository()->findAllByCourse($course, null, null, 2, false);
/** @var CQuiz[] $courseExerciseList */
$courseExerciseList = $qb->getQuery()->getResult();
if (!empty($courseExerciseList)) {
foreach ($courseExerciseList as $exercise) {
@ -43,7 +50,7 @@ if (!empty($courseIdList)) {
}
$exerciseList += array_column($courseExerciseList, 'title', 'iid');
}
$courseOptions[$courseId] = $courseInfo['name'];
$courseOptions[$courseId] = $course->getTitle();
}
}

@ -181,7 +181,7 @@ if (api_is_drh()) {
$menu_items = [
Display::url(
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
),
Display::url(Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM), 'student.php'),
Display::url(

@ -193,7 +193,7 @@ if (api_is_drh()) {
$menu_items = [
Display::url(
Display::return_icon('statistics.png', get_lang('View my progress'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
),
Display::url(Display::return_icon('user.png', get_lang('Learners'), [], ICON_SIZE_MEDIUM), 'student.php'),
Display::url(

@ -631,7 +631,7 @@ if (!api_is_anonymous()) {
$reportingTab .= '<br />';
$reportingTab .= Tracking::show_course_detail(
api_get_user_id(),
$courseCode,
$course_id,
$session_id
);
}

@ -4,13 +4,14 @@
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
use ChamiloSession as Session;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
$course = api_get_course_entity();
if (null === $course) {
api_not_allowed(true);
}
$sessionId = api_get_session_id();
@ -21,20 +22,19 @@ if (!$is_allowedToTrack) {
}
//keep course_code form as it is loaded (global) by the table's get_user_data
$courseCode = $courseInfo['code'];
$courseId = $courseInfo['real_id'];
$courseCode = $course->getCode();
$courseId = $course->getId();
// PERSON_NAME_DATA_EXPORT is buggy
$sortByFirstName = api_sort_by_first_name();
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
$from = $_GET['from'] ?? null;
$origin = api_get_origin();
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'] ? true : false;
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'];
$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
$htmlHeadXtra[] = ' ';
$this_section = SECTION_COURSES;
if ('myspace' === $from) {
@ -50,8 +50,8 @@ if (api_is_drh()) {
$coursesFromSession = SessionManager::getAllCoursesFollowedByUser(api_get_user_id(), null);
$coursesFromSessionCodeList = [];
if (!empty($coursesFromSession)) {
foreach ($coursesFromSession as $course) {
$coursesFromSessionCodeList[$course['code']] = $course['code'];
foreach ($coursesFromSession as $courseItem) {
$coursesFromSessionCodeList[$courseItem['code']] = $courseItem['code'];
}
}
@ -213,7 +213,8 @@ if (isset($_GET['users_tracking_per_page'])) {
$users_tracking_per_page = '&users_tracking_per_page='.intval($_GET['users_tracking_per_page']);
}
$actionsRight .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$additionalParams.$users_tracking_per_page.'">
$actionsRight .= '<a
href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$additionalParams.$users_tracking_per_page.'">
'.Display::return_icon('export_csv.png', get_lang('CSV export'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsRight .= '</div>';
// Create a search-box.
@ -236,7 +237,7 @@ echo Display::toolbarAction(
[$actionsLeft, $form_search->returnForm(), $actionsRight]
);
$course_name = get_lang('Course').' '.$courseInfo['name'];
$course_name = get_lang('Course').' '.$course->getTitle();
if ($sessionId) {
$titleSession = Display::return_icon(
@ -257,11 +258,11 @@ if ($sessionId) {
get_lang('Course'),
[],
ICON_SIZE_SMALL
).' '.$courseInfo['name'];
).' '.$course->getTitle();
}
$teacherList = CourseManager::getTeacherListFromCourseCodeToString(
$courseInfo['code'],
$courseCode,
',',
true,
true
@ -271,7 +272,7 @@ $coaches = null;
if (!empty($sessionId)) {
$coaches = CourseManager::get_coachs_from_course_to_string(
$sessionId,
$courseInfo['real_id'],
$courseId,
',',
true,
true
@ -290,7 +291,7 @@ if (!empty($coaches)) {
$showReporting = false === api_get_configuration_value('hide_reporting_session_list');
if ($showReporting) {
$sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
$sessionList = SessionManager::get_session_by_course($courseId);
if (!empty($sessionList)) {
$html .= Display::page_subheader2(get_lang('Session list'));
$icon = Display::return_icon(
@ -306,30 +307,30 @@ if ($showReporting) {
foreach ($sessionList as $session) {
if (!$isAdmin) {
// Check session visibility
$visibility = api_get_session_visibility($session['id'], api_get_course_int_id());
$visibility = api_get_session_visibility($session['id'], $courseId);
if (SESSION_INVISIBLE == $visibility) {
continue;
}
// Check if is coach
$isCoach = api_is_coach($session['id'], api_get_course_int_id());
$isCoach = api_is_coach($session['id'], $courseId);
if (!$isCoach) {
continue;
}
}
$url = $urlWebCode.'mySpace/course.php?session_id='.$session['id'].'&cidReq='.$courseInfo['code'];
$url = $urlWebCode.'mySpace/course.php?sid='.$session['id'].'&cid='.$courseId;
$html .= Display::tag('li', $icon.' '.Display::url($session['name'], $url));
}
$html .= '</ul>';
}
}
$trackingColumn = isset($_GET['users_tracking_column']) ? $_GET['users_tracking_column'] : null;
$trackingDirection = isset($_GET['users_tracking_direction']) ? $_GET['users_tracking_direction'] : null;
$trackingColumn = $_GET['users_tracking_column'] ?? null;
$trackingDirection = $_GET['users_tracking_direction'] ?? null;
$hideReports = api_get_configuration_value('hide_course_report_graph');
$conditions = [];
$groupList = GroupManager::get_group_list(null, $courseInfo, 1, $sessionId);
$groupList = GroupManager::get_group_list(null, $course, 1, $sessionId);
$class = new UserGroup();
//$options['where'] = [' usergroup.course_id = ? ' => $courseId];
//$classes = $class->getUserGroupInCourse($options);
@ -463,6 +464,7 @@ if ($nbStudents > 0) {
}
if (false === $hideReports) {
$conditions['course_id'] = $courseId;
$conditions['include_invited_users'] = false;
$usersTracking = TrackingCourseLog::get_user_data(
null,
@ -582,7 +584,7 @@ if ($nbStudents > 0) {
$el->setSelected(7);
$form->addElement('hidden', 'action', 'add');
$form->addElement('hidden', 'remindallinactives', 'true');
$form->addElement('hidden', 'cidReq', $courseInfo['code']);
$form->addElement('hidden', 'cidReq', $course->getCode());
$form->addElement('hidden', 'id_session', api_get_session_id());
$form->addButtonSend(get_lang('Notify'));
@ -609,6 +611,7 @@ if ($nbStudents > 0) {
$table->total_number_of_items = $nbStudents;
} else {
$conditions['include_invited_users'] = true;
$conditions['course_id'] = $courseId;
$table = new SortableTable(
'users_tracking',
['TrackingCourseLog', 'get_number_of_users'],
@ -790,14 +793,20 @@ $groupTable->setHeaderContents(0, $column++, get_lang('AverageTrainingTime'));
$groupTable->setHeaderContents(0, $column++, get_lang('CourseProgress'));
$groupTable->setHeaderContents(0, $column++, get_lang('ExerciseAverage'));
$exerciseList = ExerciseLib::get_all_exercises(
/*$exerciseList = ExerciseLib::get_all_exercises(
$courseInfo,
$sessionId,
false,
null,
false,
3
);
);*/
$session = api_get_session_entity($sessionId);
$qb = Container::getQuizRepository()->findAllByCourse($course, $session, null, 2, false);
/** @var CQuiz[] $exercises */
$exercises = $qb->getQuery()->getResult();
if (!empty($groupList)) {
$totalTime = null;
$totalLpProgress = null;
@ -849,12 +858,12 @@ if (!empty($groupList)) {
$totalLpProgress += $totalGroupLpProgress;
}
if (!empty($exerciseList)) {
foreach ($exerciseList as $exerciseData) {
if (!empty($exercises)) {
foreach ($exercises as $exerciseData) {
foreach ($usersInGroup as $userId) {
$results = Event::get_best_exercise_results_by_user(
$exerciseData->getIid(),
$courseInfo['real_id'],
$courseId,
0,
$userId
);
@ -873,7 +882,7 @@ if (!empty($groupList)) {
}
}
$bestScoreAverageNotInLP = round(
$bestScoreAverageNotInLP / count($exerciseList) * 100 / $userInGroupCount,
$bestScoreAverageNotInLP / count($exercises) * 100 / $userInGroupCount,
2
);
@ -946,12 +955,12 @@ if (!empty($groupList)) {
}
$totalBestScoreAverageNotInLP = 0;
$bestScoreAverageNotInLP = 0;
if (!empty($exerciseList)) {
foreach ($exerciseList as $exerciseData) {
if (!empty($exercises)) {
foreach ($exercises as $exerciseData) {
foreach ($studentIdList as $userId) {
$results = Event::get_best_exercise_results_by_user(
$exerciseData['iid'],
$courseInfo['real_id'],
$exerciseData->getIid(),
$courseId,
$sessionId,
$userId
);
@ -972,7 +981,7 @@ if (!empty($groupList)) {
}
if (!empty($nbStudents)) {
$bestScoreAverageNotInLP = round(
$bestScoreAverageNotInLP / count($exerciseList) * 100 / $nbStudents,
$bestScoreAverageNotInLP / count($exercises) * 100 / $nbStudents,
2
).' %';
}

@ -2,16 +2,20 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
use ChamiloSession as Session;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$course_info = api_get_course_info();
$course = api_get_course_entity();
$groupId = api_get_group_id();
$session_id = api_get_session_id();
$session = api_get_session_entity($session_id);
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
$from = $_GET['from'] ?? null;
$this_section = SECTION_COURSES;
if ('myspace' === $from) {
@ -57,7 +61,7 @@ if ($export_csv) {
$csv_content = [];
// Breadcrumbs.
if (isset($_GET['origin']) && 'resume_session' == $_GET['origin']) {
if (isset($_GET['origin']) && 'resume_session' === $_GET['origin']) {
$interbreadcrumb[] = ['url' => '../admin/index.php', 'name' => get_lang('Administration')];
$interbreadcrumb[] = ['url' => '../session/session_list.php', 'name' => get_lang('Session list')];
$interbreadcrumb[] = [
@ -66,7 +70,7 @@ if (isset($_GET['origin']) && 'resume_session' == $_GET['origin']) {
];
}
$view = isset($_REQUEST['view']) ? $_REQUEST['view'] : '';
$view = $_REQUEST['view'] ?? '';
$nameTools = get_lang('Reporting');
// Display the header.
@ -75,7 +79,7 @@ Display::display_header($nameTools, 'Tracking');
// getting all the students of the course
if (empty($session_id)) {
// Registered students in a course outside session.
$a_students = CourseManager:: get_student_list_from_course_code(
$a_students = CourseManager::get_student_list_from_course_code(
api_get_course_id(),
false,
0,
@ -86,7 +90,7 @@ if (empty($session_id)) {
);
} else {
// Registered students in session.
$a_students = CourseManager:: get_student_list_from_course_code(
$a_students = CourseManager::get_student_list_from_course_code(
api_get_course_id(),
true,
api_get_session_id()
@ -114,7 +118,7 @@ $course_code = api_get_course_id();
$course_id = api_get_course_int_id();
if ($lpReporting) {
$list = new LearnpathList(null, $course_info, $session_id);
$list = new LearnpathList(null, ['real_id' => $course->getId(), 'code' => $course->getCode()], $session_id);
$flat_list = $list->get_flat_list();
if (count($flat_list) > 0) {
@ -181,10 +185,6 @@ if ($exerciseReporting) {
).' '.get_lang('Tests score')
);
echo '<table class="data_table">';
$course_id = api_get_course_int_id();
$sql = "SELECT iid, title FROM $TABLEQUIZ
WHERE c_id = $course_id AND active <> -1 AND session_id = $session_id";
$rs = Database::query($sql);
if ($export_csv) {
$temp = [get_lang('Progress in courses'), ''];
@ -192,17 +192,28 @@ if ($exerciseReporting) {
$csv_content[] = $temp;
}
$course_path_params = '&cidReq='.$course_code.'&id_session='.$session_id;
$course_path_params = '&cid='.$course_id.'&sid='.$session_id;
/*$course_id = api_get_course_int_id();
$sql = "SELECT iid, title FROM $TABLEQUIZ
WHERE c_id = $course_id AND active <> -1 AND session_id = $session_id";
$rs = Database::query($sql);*/
$session = api_get_session_entity($session_id);
$qb = Container::getQuizRepository()->findAllByCourse($course, $session, null, 2, false);
/** @var CQuiz[] $exercises */
$exercises = $qb->getQuery()->getResult();
if (Database::num_rows($rs) > 0) {
while ($quiz = Database::fetch_array($rs)) {
if (!empty($exercises)) {
foreach ($exercises as $exercise) {
$exerciseId = $exercise->getIid();
$quiz_avg_score = 0;
if ($studentCount > 0) {
foreach ($student_ids as $student_id) {
$avg_student_score = Tracking::get_avg_student_exercise_score(
$student_id,
$course_code,
$quiz['iid'],
$exerciseId,
$session_id
);
$quiz_avg_score += $avg_student_score;
@ -210,16 +221,16 @@ if ($exerciseReporting) {
}
$studentCount = (0 == $studentCount || is_null($studentCount) || '' == $studentCount) ? 1 : $studentCount;
$quiz_avg_score = round(($quiz_avg_score / $studentCount), 2).'%';
$url = api_get_path(WEB_CODE_PATH).'exercise/overview.php?exerciseId='.$quiz['iid'].$course_path_params;
$url = api_get_path(WEB_CODE_PATH).'exercise/overview.php?exerciseId='.$exerciseId.$course_path_params;
echo '<tr><td>';
echo Display::url(
$quiz['title'],
$exercise->getTitle(),
$url
);
echo '</td><td align="right">'.$quiz_avg_score.'</td></tr>';
if ($export_csv) {
$temp = [$quiz['title'], $quiz_avg_score];
$temp = [$exercise->getTitle(), $quiz_avg_score];
$csv_content[] = $temp;
}
}

@ -32,11 +32,10 @@ $courseList = [];
if ($global) {
$temp = CourseManager::get_courses_list();
foreach ($temp as $tempCourse) {
$courseInfo = api_get_course_info($tempCourse['code']);
$courseList[] = $courseInfo;
$courseList[] = api_get_course_entity($tempCourse['real_id']);
}
} else {
$courseList = [api_get_course_info()];
$courseList = [api_get_course_entity()];
}
$sessionId = api_get_session_id();
@ -157,9 +156,10 @@ if ($global) {
$export_array_global = $export_array = [];
$s_css_class = null;
if (!empty($courseList) && is_array($courseList)) {
foreach ($courseList as $courseInfo) {
$sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
if (!empty($courseList)) {
foreach ($courseList as $course) {
$courseId = $course->getId();
$sessionList = SessionManager::get_session_by_course($courseId);
$newSessionList = [];
if (!empty($sessionList)) {
@ -168,9 +168,8 @@ if (!empty($courseList) && is_array($courseList)) {
}
}
$courseId = $courseInfo['real_id'];
if ($global) {
// @todo use CQuizRepository
$sql = "SELECT count(iid) as count
FROM $quizTable AS quiz
WHERE c_id = $courseId AND active = 1 AND (session_id = 0 OR session_id IS NULL)";
@ -184,7 +183,6 @@ if (!empty($courseList) && is_array($courseList)) {
$result = Database::query($sql);
$countExercises = Database::store_result($result);
$exerciseSessionCount = $countExercises[0]['count'];
$exerciseCount = $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount;
// Add course and session list.
@ -193,7 +191,7 @@ if (!empty($courseList) && is_array($courseList)) {
}
$html .= "<tr>
<td rowspan=$exerciseCount>";
$html .= $courseInfo['title'];
$html .= $course->getTitle();
$html .= "</td>";
}
@ -206,9 +204,9 @@ if (!empty($courseList) && is_array($courseList)) {
// Getting the exam list.
if ($global) {
$sql = "SELECT quiz.title, iid, session_id
FROM $quizTable AS quiz
WHERE c_id = $courseId AND active = 1
ORDER BY session_id, quiz.title ASC";
FROM $quizTable AS quiz
WHERE c_id = $courseId AND active = 1
ORDER BY session_id, quiz.title ASC";
} else {
//$sessionCondition = api_get_session_condition($sessionId, true, false);
if (!empty($exerciseId)) {

@ -104,4 +104,4 @@ $_user['uidReset'] = true;
ChamiloSession::write('_user', $_user);
ChamiloSession::write('_user_auth_source', 'azure_active_directory');
Redirect::session_request_uri(true, $userInfo['user_id']);
Redirect::session_request_uri(true, $userInfo);

Loading…
Cancel
Save