New feature "Show student progress in My courses page"

This feature will display to the student's progress, rating and certificate below the title of each of his courses. By default the feature will be deactivated and it will be up to the admin to activate it or not.

1 - Admin: activate new option (Show course progress to student)
main/admin/settings.php?category=Course

2 - Student: Progress displayed for each course
user_portal.php
pull/2487/head
Rafa 9 years ago
parent 46c8b4b3df
commit dba07d6673
  1. 7
      main/inc/lib/course.lib.php
  2. 2
      main/inc/lib/usermanager.lib.php
  3. 69
      main/inc/lib/userportal.lib.php
  4. 12
      main/install/data.sql
  5. 5
      main/lang/catalan/trad4all.inc.php
  6. 5
      main/lang/english/trad4all.inc.php
  7. 5
      main/lang/spanish/trad4all.inc.php
  8. 11
      main/template/default/user_portal/classic_courses_with_category.tpl
  9. 10
      main/template/default/user_portal/classic_courses_without_category.tpl
  10. 11
      main/template/default/user_portal/classic_session.tpl
  11. 11
      main/template/default/user_portal/grid_courses_with_category.tpl
  12. 11
      main/template/default/user_portal/grid_courses_without_category.tpl
  13. 11
      main/template/default/user_portal/grid_session.tpl

@ -3501,6 +3501,8 @@ class CourseManager
}
$params = [];
//Param (course_code) needed to get the student process
$params['course_code'] = $course['code'];
// Get notifications.
$course_info['id_session'] = null;
$courseUserInfo = CourseManager::getUserCourseInfo($user_id, $courseId);
@ -3677,6 +3679,9 @@ class CourseManager
$iconName = basename($course_info['course_image']);
$params = array();
//Param (course_code) needed to get the student process
$params['course_code'] = $course['code'];
if ($showCustomIcon === 'true' && $iconName != 'course.png') {
$params['thumbnails'] = $course_info['course_image'];
$params['image'] = $course_info['course_image_large'];
@ -3820,6 +3825,8 @@ class CourseManager
}
$params = array();
//Param (course_code) needed to get the student process
$params['course_code'] = $course['code'];
$params['edit_actions'] = '';
$params['document'] = '';
if (api_is_platform_admin()) {

@ -3013,6 +3013,7 @@ class UserManager
$sql = "SELECT DISTINCT
c.visibility,
c.id as real_id,
c.code as course_code,
sc.position
FROM $tbl_session_course_user as scu
INNER JOIN $tbl_session_course sc
@ -3044,6 +3045,7 @@ class UserManager
$sql = "SELECT DISTINCT
c.visibility,
c.id as real_id,
c.code as course_code,
sc.position
FROM $tbl_session_course_user as scu
INNER JOIN $tbl_session as s

@ -1141,6 +1141,63 @@ class IndexManager
$this->load_directories_preview
);
//Course option (show student progress)
//This code will add a new variables (Progress, Score, Certificate)
if (api_get_setting('my_course_progress') === 'true' && api_is_student() === true) {
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']['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');
}
}
if(isset($courses['in_category']) && isset($courses['not_category'])){
foreach($courses['in_category'] as $key1 => $value) {
if(isset($courses['in_category'][$key1]['courses'])){
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']['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');
}
}
}
}
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']['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');
}
}
}
}
if ($viewGridCourses) {
$coursesWithoutCategoryTemplate = '/user_portal/grid_courses_without_category.tpl';
$coursesWithCategoryTemplate = '/user_portal/grid_courses_with_category.tpl';
@ -1260,6 +1317,18 @@ class IndexManager
if (isset($courseUserHtml[1])) {
$course_session = $courseUserHtml[1];
$course_session['skill'] = isset($courseUserHtml['skill']) ? $courseUserHtml['skill'] : '';
$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']['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');
}
$html_courses_session[] = $course_session;
}
}

@ -1960,3 +1960,15 @@ INSERT INTO settings_current (variable, type, category, selected_value, title, c
VALUES ('allow_download_documents_by_api_key', 'radio', 'WebServices', 'false', 'AllowDownloadDocumentsByApiKeyTitle', 'AllowDownloadDocumentsByApiKeyComment', '', NULL, 1);
INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_download_documents_by_api_key', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_download_documents_by_api_key', 'false', 'No');
UPDATE settings_current SET selected_value = '1.11.0.7' WHERE variable = 'chamilo_database_version';
INSERT INTO `settings_current` (`id`, `variable`, `subkey`, `type`, `category`, `selected_value`, `title`, `comment`, `scope`, `subkeytext`, `access_url`, `access_url_changeable`, `access_url_locked`) VALUES (NULL, 'my_course_progress', NULL, 'radio', 'Course', 'false', 'MyCourseProgressTitle', 'MyCourseProgressTemplateTitle', NULL, NULL, '1', '0', '0');
INSERT INTO `settings_options` (`id`, `variable`, `value`, `display_text`) VALUES (NULL, 'my_course_progress', 'true', 'Yes');
INSERT INTO `settings_options` (`id`, `variable`, `value`, `display_text`) VALUES (NULL, 'my_course_progress', 'false', 'No');
-- Version 1.11.0.7

@ -7986,4 +7986,9 @@ $Colors = "Colors";
$DesignWithBadgeStudio = "Dissenyar amb Badge Studio";
$DesignWithBadgeStudioComment = "Utilitzi Badge Studio per crear la seva pròpia insígnia dins de la seva plataforma";
$YouAlreadySentThisFile = "Ja va enviar aquest o un altre arxiu amb el mateix nom. Si us plau assegureu-vos d'enviar cada arxiu una sola vegada.";
$StudentCourseProgress = "Progrés: %s%";
$StudentCourseScore = "Puntuació: %s%";
$StudentCourseCertificate = "Certificat: %s";
$MyCourseProgressTitle = "Mostra progrés del curs a l'estudiant";
$MyCourseProgressTemplateComment = "En activar aquesta opció se'ls mostraran als estudiants el progrés dels seus cursos a la pàgina 'Els meus cursos'.";
?>

@ -7963,4 +7963,9 @@ $OnlyUsersFromCourseSession = "Only users from one course in a session";
$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 %";
$StudentCourseScore = "Rating: %s%";
$StudentCourseCertificate = "Certificate: %s";
$MyCourseProgressTitle = "Show course progress to student";
$MyCourseProgressTemplateComment = "By activating this option, the students will see their course progress in the page 'My Courses'.";
?>

@ -7978,4 +7978,9 @@ $OnlyUsersFromCourseSession = "Solo usuarios de un curso en una sesión";
$ServerXForwardedForInfo = "Si su servidor está detrás de un reverse proxy o un firewall (y únicamente en estos casos), podría usar la cabecera HTTP X_FORWARDED_FOR para mostrar la dirección IP del usuario distante (usted, en este caso).";
$GeolocalizationCoordinates = "Geolocalización por coordenadas";
$ExportUsersOfACourse = "Exportar usuarios de un curso";
$StudentCourseProgress = "Progreso: %s%";
$StudentCourseScore = "Puntuación: %s%";
$StudentCourseCertificate = "Certificado: %s";
$MyCourseProgressTitle = "Mostrar progreso del curso al estudiante";
$MyCourseProgressTemplateComment = "Al activar esta opción se les mostrarán a los estudiantes el progreso de sus cursos en la página 'Mis cursos'.";
?>

@ -59,6 +59,17 @@
{% endfor %}
{% endif %}
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -55,6 +55,16 @@
</a>
{% endfor %}
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -79,6 +79,17 @@
{% endfor %}
{% endif %}
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -64,6 +64,17 @@
{% endif %}
</h4>
<div class="notifications">{{ item.notifications }}</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -61,6 +61,17 @@
{% endif %}
</h4>
<div class="notifications">{{ item.notifications }}</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -58,6 +58,17 @@
{% endif %}
{% endfor %}
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{{ "StudentCourseProgress" | get_lang | format(item.student_info.progress) }}
{{ "StudentCourseScore" | get_lang | format(item.student_info.score) }}
{{ "StudentCourseCertificate" | get_lang | format(item.student_info.certificate) }}
</div>
</div>
{% endif %}
</div>
{% if item.edit_actions != '' %}
<div class="admin-actions">

Loading…
Cancel
Save