Skip to content

Commit

Permalink
Show career diagram if allow_career_users is active BT#18720
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed May 14, 2021
1 parent f8e0033 commit 945d0c4
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 17 deletions.
4 changes: 2 additions & 2 deletions main/admin/career_diagram.php
Expand Up @@ -53,10 +53,10 @@

$action = isset($_GET['action']) ? $_GET['action'] : '';

if ($action == 'add') {
if ($action === 'add') {
$interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
$toolName = get_lang('Add');
} elseif ($action == 'edit') {
} elseif ($action === 'edit') {
$interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')];
$toolName = get_lang('Edit');
Expand Down
13 changes: 8 additions & 5 deletions main/auth/my_progress.php
Expand Up @@ -39,6 +39,7 @@
$dates = $issues = '';
$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
$courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null;
$allowCareerUser = api_get_configuration_value('allow_career_users');

if (!empty($courseUserList)) {
$items = MySpace::get_connections_from_course_list(
Expand Down Expand Up @@ -79,14 +80,18 @@
}

$content = Tracking::show_user_progress($user_id, $sessionId);

$showAllSessionCourses = api_get_configuration_value('my_progress_session_show_all_courses');

if ($showAllSessionCourses && !empty($sessionId) && empty($courseCode)) {
$userSessionCourses = UserManager::get_courses_list_by_session($user_id, $sessionId);

foreach ($userSessionCourses as $userSessionCourse) {
$content .= Tracking::show_course_detail($user_id, $userSessionCourse['course_code'], $sessionId);
$content .= Tracking::show_course_detail(
$user_id,
$userSessionCourse['course_code'],
$sessionId,
$allowCareerUser
);
}
} else {
$content .= Tracking::show_course_detail($user_id, $courseCode, $sessionId);
Expand Down Expand Up @@ -123,9 +128,7 @@
$message = Display::return_message(get_lang('NoDataAvailable'), 'warning');
}

$show = api_get_configuration_value('allow_career_users');

if ($show) {
if ($allowCareerUser) {
$careers = UserManager::getUserCareers($user_id);

if (!empty($careers)) {
Expand Down
2 changes: 1 addition & 1 deletion main/inc/lib/career.lib.php
Expand Up @@ -866,7 +866,7 @@ class="group'.$newGroup.' group_class"
*
* @return string
*/
public static function parseVertexList($groupCourseList, $vertexList, $addRow = 0, &$graph, $group, &$connections, $userResult)
public static function parseVertexList($groupCourseList, $vertexList, $addRow, &$graph, $group, &$connections, $userResult)
{
if (empty($vertexList)) {
return '';
Expand Down
10 changes: 9 additions & 1 deletion main/inc/lib/tracking.lib.php
Expand Up @@ -5434,10 +5434,11 @@ function ($value, $key) use ($trackingColumns) {
* @param int $user_id
* @param string $course_code
* @param int $session_id
* @param bool $showDiagram
*
* @return string html code
*/
public static function show_course_detail($user_id, $course_code, $session_id)
public static function show_course_detail($user_id, $course_code, $session_id, $showDiagram = false)
{
$html = '';
if (isset($course_code)) {
Expand All @@ -5451,6 +5452,13 @@ public static function show_course_detail($user_id, $course_code, $session_id)
$html .= '<a name="course_session_data"></a>';
$html .= Display::page_subheader2($course_info['title']);

if ($showDiagram && !empty($session_id)) {
$visibility = api_get_session_visibility($session_id);
if (SESSION_AVAILABLE === $visibility) {
$html .= Display::page_subheader2($course_info['title']);

This comment has been minimized.

Copy link
@AngelFQC

AngelFQC May 21, 2021

Member

$course_info['title'] will be shown two times if $showDiagram and !empty($session_id)
🤔

This comment has been minimized.

Copy link
@jmontoyaa

jmontoyaa May 24, 2021

Author Member

Bien visto 👍 acabo de eliminar ese código pues ya no era necesario :)

e36f7e1

}
}

// Course details

// Show exercise results of invisible exercises? see BT#4091
Expand Down
44 changes: 37 additions & 7 deletions main/mySpace/myStudents.php
Expand Up @@ -14,7 +14,7 @@
require_once '../work/work.lib.php';

api_block_anonymous_users();
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_PUBLIC_PATH)
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_PUBLIC_PATH)
.'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>';

$export = isset($_GET['export']) ? $_GET['export'] : false;
Expand Down Expand Up @@ -448,10 +448,7 @@
}
}

$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($student_id)) {
Expand Down Expand Up @@ -859,7 +856,6 @@
<tr>
<th>'.get_lang('DateExo').'</th>
<th>'.get_lang('Training').'</th>
<th>'.get_lang('Present').'</th>
</tr>
</thead>
Expand Down Expand Up @@ -944,7 +940,6 @@

// Careers.
echo MyStudents::getBlockForCareers($student_id);

echo MyStudents::getBlockForSkills(
$student_id,
$courseInfo ? $courseInfo['real_id'] : 0,
Expand All @@ -971,6 +966,9 @@
];

$attendance = new Attendance();
$extraFieldValueSession = new ExtraFieldValue('session');
$extraFieldValueCareer = new ExtraFieldValue('career');

foreach ($courses_in_session as $sId => $courses) {
$session_name = '';
$access_start_date = '';
Expand All @@ -996,6 +994,38 @@
.' '.$session_name.($date_session ? ' ('.$date_session.')' : '');
}

if (api_get_configuration_value('allow_career_users')) {
$visibility = api_get_session_visibility($sId);
if (SESSION_AVAILABLE === $visibility) {
$value = $extraFieldValueSession->get_values_by_handler_and_field_variable($sId, 'careerid');
if (isset($value['value']) && !empty($value['value'])) {
$careerList = str_replace(['[', ']'], '', $value['value']);
$careerList = explode(',', $careerList);

foreach ($careerList as $career) {
$careerIdValue = $extraFieldValueCareer->get_item_id_from_field_variable_and_field_value(
'external_career_id',
$career
);
if (isset($careerIdValue['item_id']) && !empty($careerIdValue['item_id'])) {
$finalCareerId = $careerIdValue['item_id'];
$career = new Career();
$careerInfo = $career->get($finalCareerId);
if (!empty($careerInfo)) {
$careerUrl = api_get_path(WEB_PATH).
'main/user/career_diagram.php?iframe=1&career_id='.$finalCareerId;
echo '<iframe
style="width:100%; height:500px"
border="0"
frameborder="0"
src="'.$careerUrl.'"></iframe>';
}
}
}
}
}
}

// Courses
echo '<h3>'.$title.'</h3>';
echo '<div class="table-responsive">';
Expand Down
3 changes: 2 additions & 1 deletion main/user/career_diagram.php
Expand Up @@ -79,7 +79,8 @@
}
}

$tpl = new Template(get_lang('Diagram'));
$showFullPage = isset($_REQUEST['iframe']) && 1 === (int) $_REQUEST['iframe'] ? false : true;
$tpl = new Template(get_lang('Diagram'), $showFullPage, $showFullPage, !$showFullPage);
$html = Display::page_subheader2($careerInfo['name'].$urlToString);
$diagram = Career::renderDiagramByColumn($careerInfo, $tpl, $userId);

Expand Down

0 comments on commit 945d0c4

Please sign in to comment.