Navigation Menu

Skip to content

Commit

Permalink
- Fix missing sql data & wrong variable name
Browse files Browse the repository at this point in the history
- Show Progress, Rating and Certificate only if they have been assigned
  • Loading branch information
rafatga committed Mar 22, 2017
1 parent 918150c commit c274cd8
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 25 deletions.
7 changes: 4 additions & 3 deletions main/inc/lib/course.lib.php
Expand Up @@ -3643,7 +3643,8 @@ public static function returnCoursesCategories($user_category_id, $load_dirs = f

$sql = "SELECT
course.id,
course_rel_user.status status
course_rel_user.status status,
course.code as course_code
FROM $TABLECOURS course
INNER JOIN $TABLECOURSUSER course_rel_user
ON (course.id = course_rel_user.c_id)
Expand Down Expand Up @@ -3683,7 +3684,7 @@ public static function returnCoursesCategories($user_category_id, $load_dirs = f

$params = array();
//Param (course_code) needed to get the student process
$params['course_code'] = $course['code'];
$params['course_code'] = $row['course_code'];

if ($showCustomIcon === 'true' && $iconName != 'course.png') {
$params['thumbnails'] = $course_info['course_image'];
Expand Down Expand Up @@ -3829,7 +3830,7 @@ public static function returnCoursesWithoutCategories($user_category_id, $load_d

$params = array();
//Param (course_code) needed to get the student process
$params['course_code'] = $course['code'];
$params['course_code'] = $row['code'];
$params['edit_actions'] = '';
$params['document'] = '';
if (api_is_platform_admin()) {
Expand Down
57 changes: 36 additions & 21 deletions main/inc/lib/userportal.lib.php
Expand Up @@ -1149,13 +1149,17 @@ public function returnCoursesAndSessions($user_id)
foreach($specialCourses as $key => $specialCourseInfo) {
$progress = Tracking::get_avg_student_progress( $user_id, $specialCourseInfo['course_code'] );
$percentage_score = Tracking :: get_avg_student_score( $user_id, $specialCourseInfo['course_code'], array());
$specialCourses[$key]['student_info']['progress'] = $progress;
$specialCourses[$key]['student_info']['progress'] = ($progress === false)? null : $progress;
$specialCourses[$key]['student_info']['score'] = $percentage_score;

$category = Category::load( null, null, $specialCourseInfo['course_code'], null, null, null );
$specialCourses[$key]['student_info']['certificate'] = Display::label(get_lang('No'));
if (isset($category[0]) && $category[0]->is_certificate_available($user_id)) {
$specialCourses[$key]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
$specialCourses[$key]['student_info']['certificate'] = null;
if (isset($category[0])) {
if($category[0]->is_certificate_available($user_id)){
$specialCourses[$key]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
}else {
$specialCourses[$key]['student_info']['certificate'] = Display::label(get_lang('No'));
}
}
}

Expand All @@ -1166,13 +1170,17 @@ public function returnCoursesAndSessions($user_id)
foreach($courses['in_category'][$key1]['courses'] as $key2 => $courseInCatInfo) {
$progress = Tracking::get_avg_student_progress( $user_id, $courseInCatInfo['course_code'] );
$percentage_score = Tracking :: get_avg_student_score( $user_id, $courseInCatInfo['course_code'], array());
$courses['in_category'][$key1]['courses'][$key2]['student_info']['progress'] = $progress;
$courses['in_category'][$key1]['courses'][$key2]['student_info']['progress'] = ($progress === false)? null : $progress;
$courses['in_category'][$key1]['courses'][$key2]['student_info']['score'] = $percentage_score;

$category = Category::load( null, null, $courseInCatInfo['course_code'], null, null, null );
$courses['in_category'][$key1]['courses'][$key2]['student_info']['certificate'] = Display::label(get_lang('No'));
if (isset($category[0]) && $category[0]->is_certificate_available($user_id)) {
$courses['in_category'][$key1]['courses'][$key2]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
$courses['in_category'][ $key1 ]['student_info']['certificate'] = null;
if (isset($category[0])) {
if($category[0]->is_certificate_available($user_id)){
$courses['in_category'][ $key1 ]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
}else {
$courses['in_category'][ $key1 ]['student_info']['certificate'] = Display::label(get_lang('No'));
}
}

}
Expand All @@ -1182,16 +1190,19 @@ public function returnCoursesAndSessions($user_id)
foreach ( $courses['not_category'] as $key => $courseNotInCatInfo ) {
$progress = Tracking::get_avg_student_progress( $user_id, $courseNotInCatInfo['course_code'] );
$percentage_score = Tracking :: get_avg_student_score( $user_id, $courseNotInCatInfo['course_code'], array());
$courses['not_category'][ $key ]['student_info']['progress'] = $progress;
$courses['not_category'][ $key ]['student_info']['progress'] = ($progress === false)? null : $progress;
$courses['not_category'][ $key ]['student_info']['score'] = $percentage_score;

$category = Category::load( null, null, $courseNotInCatInfo['course_code'], null, null, null );
$courses['not_category'][ $key ]['student_info']['certificate'] = Display::label(get_lang('No'));
if (isset($category[0]) && $category[0]->is_certificate_available($user_id)) {
$courses['not_category'][ $key ]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
$courses['not_category'][ $key ]['student_info']['certificate'] = null;
if (isset($category[0])) {
if($category[0]->is_certificate_available($user_id)){
$courses['not_category'][ $key ]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
}else {
$courses['not_category'][ $key ]['student_info']['certificate'] = Display::label(get_lang('No'));
}
}


}
}

Expand Down Expand Up @@ -1322,13 +1333,17 @@ public function returnCoursesAndSessions($user_id)
if (api_get_configuration_value('my_course_progress') === true && api_is_student() === true) {
$progress = Tracking::get_avg_student_progress( $user_id, $course['course_code'], array(), $session_id );
$percentage_score = Tracking::get_avg_student_score( $user_id, $course['course_code'], array(), $session_id);
$course_session['student_info']['progress'] = $progress;
$course_session['student_info']['progress'] = ($progress === false)? null : $progress;
$course_session['student_info']['score'] = $percentage_score;

$category = Category::load( null, null, $course['course_code'], null, null, $session_id );
$course_session['student_info']['certificate'] = Display::label(get_lang('No'));
if (isset($category[0]) && $category[0]->is_certificate_available($user_id)) {
$course_session['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
$course_session['student_info']['certificate'] = null;
if (isset($category[0])) {
if($category[0]->is_certificate_available($user_id)){
$course_session['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
}else {
$course_session['student_info']['certificate'] = Display::label(get_lang('No'));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion main/lang/english/trad4all.inc.php
Expand Up @@ -7963,7 +7963,7 @@
$ServerXForwardedForInfo = "If the server is behind a proxy or firewall (and only in those cases), it might be using the X_FORWARDED_FOR HTTP header to show the remote user IP (yours, in this case).";
$GeolocalizationCoordinates = "Geolocalization by coordinates";
$ExportUsersOfACourse = "Export users of a course";
$StudentCourseProgress = "Progress: %s %";
$StudentCourseProgress = "Progress: %s%";
$StudentCourseScore = "Rating: %s%";
$StudentCourseCertificate = "Certificate: %s";
$MyCourseProgressTitle = "Show course progress to student";
Expand Down
Expand Up @@ -74,9 +74,19 @@
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">

{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{% endif %}

{% if (item.student_info.score is not null) %}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{% endif %}

{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
{% endif %}

</div>
</div>
{% endif %}
Expand Down
Expand Up @@ -71,9 +71,19 @@
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">

{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{% endif %}

{% if (item.student_info.score is not null) %}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{% endif %}

{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
{% endif %}

</div>
</div>
{% endif %}
Expand Down
10 changes: 10 additions & 0 deletions main/template/default/user_portal/classic_session.tpl
Expand Up @@ -83,9 +83,19 @@
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">

{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{% endif %}

{% if (item.student_info.score is not null) %}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{% endif %}

{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
{% endif %}

</div>
</div>
{% endif %}
Expand Down
10 changes: 10 additions & 0 deletions main/template/default/user_portal/grid_courses_with_category.tpl
Expand Up @@ -68,9 +68,19 @@
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">

{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{% endif %}

{% if (item.student_info.score is not null) %}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{% endif %}

{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
{% endif %}

</div>
</div>
{% endif %}
Expand Down
Expand Up @@ -65,9 +65,19 @@
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">

{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{% endif %}

{% if (item.student_info.score is not null) %}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{% endif %}

{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
{% endif %}

</div>
</div>
{% endif %}
Expand Down
10 changes: 10 additions & 0 deletions main/template/default/user_portal/grid_session.tpl
Expand Up @@ -62,9 +62,19 @@
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">

{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{% endif %}

{% if (item.student_info.score is not null) %}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{% endif %}

{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
{% endif %}

</div>
</div>
{% endif %}
Expand Down

0 comments on commit c274cd8

Please sign in to comment.