Merge student homepage progress PR 1668. Fix issues with double language variables. Factorize calls to api_get_configuration_value()

remotes/angel/1.11.x
Yannick Warnier 8 years ago
commit 096d2b000a
  1. 10
      main/inc/lib/course.lib.php
  2. 2
      main/inc/lib/usermanager.lib.php
  3. 188
      main/inc/lib/userportal.lib.php
  4. 6
      main/install/configuration.dist.php
  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. 21
      main/template/default/user_portal/classic_courses_with_category.tpl
  9. 20
      main/template/default/user_portal/classic_courses_without_category.tpl
  10. 21
      main/template/default/user_portal/classic_session.tpl
  11. 21
      main/template/default/user_portal/grid_courses_with_category.tpl
  12. 21
      main/template/default/user_portal/grid_courses_without_category.tpl
  13. 20
      main/template/default/user_portal/grid_session.tpl

@ -3562,6 +3562,8 @@ class CourseManager
}
$params = [];
//Param (course_code) needed to get the student info in page "My courses"
$params['course_code'] = $course['code'];
// Get notifications.
$course_info['id_session'] = null;
$courseUserInfo = self::getUserCourseInfo($user_id, $courseId);
@ -3707,7 +3709,8 @@ class CourseManager
$sql = "SELECT DISTINCT
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)
@ -3753,6 +3756,9 @@ class CourseManager
$iconName = basename($course_info['course_image']);
$params = array();
//Param (course_code) needed to get the student process
$params['course_code'] = $row['course_code'];
if ($showCustomIcon === 'true' && $iconName != 'course.png') {
$params['thumbnails'] = $course_info['course_image'];
$params['image'] = $course_info['course_image_large'];
@ -3909,6 +3915,8 @@ class CourseManager
}
$params = array();
//Param (course_code) needed to get the student process
$params['course_code'] = $row['code'];
$params['edit_actions'] = '';
$params['document'] = '';
if (api_is_platform_admin()) {

@ -3041,6 +3041,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
@ -3072,6 +3073,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

@ -1164,6 +1164,145 @@ class IndexManager
$this->load_directories_preview
);
//Course option (show student progress)
//This code will add new variables (Progress, Score, Certificate)
if (isset(api_get_configuration_value('course_student_info')['progress']) ||
isset(api_get_configuration_value('course_student_info')['score']) ||
isset(api_get_configuration_value('course_student_info')['certificate'])) {
foreach ($specialCourses as $key => $specialCourseInfo) {
if (isset(api_get_configuration_value('course_student_info')['progress']) &&
api_get_configuration_value('course_student_info')['progress'] === true) {
$progress = Tracking::get_avg_student_progress(
$user_id,
$specialCourseInfo['course_code']
);
$specialCourses[$key]['student_info']['progress'] = ($progress === false)? null : $progress;
}
if (isset(api_get_configuration_value('course_student_info')['score']) &&
api_get_configuration_value('course_student_info')['score'] === true) {
$percentage_score = Tracking::get_avg_student_score(
$user_id,
$specialCourseInfo['course_code'],
array()
);
$specialCourses[$key]['student_info']['score'] = $percentage_score;
}
if (isset(api_get_configuration_value('course_student_info')['certificate']) &&
api_get_configuration_value('course_student_info')['certificate'] === true) {
$category = Category::load(
null,
null,
$specialCourseInfo['course_code'],
null,
null,
null
);
$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'));
}
}
}
}
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) {
if (isset(api_get_configuration_value('course_student_info')['progress']) &&
api_get_configuration_value('course_student_info')['progress'] === true) {
$progress = Tracking::get_avg_student_progress(
$user_id,
$courseInCatInfo['course_code']
);
$courses['in_category'][$key1]['courses'][$key2]['student_info']['progress'] = ($progress === false)? null : $progress;
}
if (isset(api_get_configuration_value('course_student_info')['score']) &&
api_get_configuration_value('course_student_info')['score'] === true) {
$percentage_score = Tracking::get_avg_student_score(
$user_id,
$specialCourseInfo['course_code'],
array()
);
$courses['in_category'][$key1]['courses'][$key2]['student_info']['score'] = $percentage_score;
}
if (isset(api_get_configuration_value('course_student_info')['certificate']) &&
api_get_configuration_value('course_student_info')['certificate'] === true) {
$category = Category::load(
null,
null,
$courseInCatInfo['course_code'],
null,
null,
null
);
$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'));
}
}
}
}
}
}
foreach ($courses['not_category'] as $key => $courseNotInCatInfo) {
if (isset(api_get_configuration_value('course_student_info')['progress']) &&
api_get_configuration_value('course_student_info')['progress'] === true) {
$progress = Tracking::get_avg_student_progress(
$user_id,
$courseNotInCatInfo['course_code']
);
$courses['not_category'][$key]['student_info']['progress'] = ($progress === false)? null : $progress;
}
if (isset(api_get_configuration_value('course_student_info')['score']) &&
api_get_configuration_value('course_student_info')['score'] === true) {
$percentage_score = Tracking::get_avg_student_score(
$user_id,
$courseNotInCatInfo['course_code'],
array()
);
$courses['not_category'][$key]['student_info']['score'] = $percentage_score;
}
if (isset(api_get_configuration_value('course_student_info')['certificate']) &&
api_get_configuration_value('course_student_info')['certificate'] === true) {
$category = Category::load(
null,
null,
$courseNotInCatInfo['course_code'],
null,
null,
null
);
$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'));
}
}
}
}
}
}
if ($viewGridCourses) {
$coursesWithoutCategoryTemplate = '/user_portal/grid_courses_without_category.tpl';
$coursesWithCategoryTemplate = '/user_portal/grid_courses_with_category.tpl';
@ -1283,6 +1422,55 @@ class IndexManager
if (isset($courseUserHtml[1])) {
$course_session = $courseUserHtml[1];
$course_session['skill'] = isset($courseUserHtml['skill']) ? $courseUserHtml['skill'] : '';
//Course option (show student progress)
//This code will add new variables (Progress, Score, Certificate)
if (isset(api_get_configuration_value('course_student_info')['progress']) ||
isset(api_get_configuration_value('course_student_info')['score']) ||
isset(api_get_configuration_value('course_student_info')['certificate'])) {
if (isset(api_get_configuration_value('course_student_info')['progress']) &&
api_get_configuration_value('course_student_info')['progress'] === true) {
$progress = Tracking::get_avg_student_progress(
$user_id,
$course['course_code'],
array(),
$session_id
);
$course_session['student_info']['progress'] = ($progress === false)? null : $progress;
}
if (isset(api_get_configuration_value('course_student_info')['score']) &&
api_get_configuration_value('course_student_info')['score'] === true) {
$percentage_score = Tracking::get_avg_student_score(
$user_id,
$course['course_code'],
array(),
$session_id
);
$course_session['student_info']['score'] = $percentage_score;
}
if (isset(api_get_configuration_value('course_student_info')['certificate']) &&
api_get_configuration_value('course_student_info')['certificate'] === true) {
$category = Category::load(
null,
null,
$course['course_code'],
null,
null,
$session_id
);
$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'));
}
}
}
}
$html_courses_session[] = $course_session;
}
}

@ -287,7 +287,11 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
// $_configuration['course_introduction_html_strict_filtering'] = true;
// Prevents the duplicate upload in assignments
// $_configuration['assignment_prevent_duplicate_upload'] = false;
// Set ConsideredWorkingTime work extra field variable from main/admin/extra_fields.php?type=work
//Show student progress in My courses page
//$_configuration['course_student_info']['score'] = false;
//$_configuration['course_student_info']['progress'] = false;
//$_configuration['course_student_info']['certificate'] = false;
// Set ConsideredWorkingTime work extra field variable to show in MyStudents page works report
// (with internal id 'work_time' as below) and enable the following line to show in MyStudents page works report
// $_configuration['considered_working_time'] = 'work_time';
// During CSV special imports update users emails to x@example.com

@ -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,6 +7963,11 @@ $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";
$StudentCourseProgressX = "Progress: %s%";
$StudentCourseScoreX = "Rating: %s%";
$StudentCourseCertificateX = "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'.";
$PauseRecordingAudio = "Pause recording";
$PlayRecordingAudio = "Resume recording";
$YourSessionTimeHasExpired = "You are already registered but your allowed access time has expired.";

@ -7978,6 +7978,11 @@ $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'.";
$PauseRecordingAudio = "Pausar grabación";
$PlayRecordingAudio = "Reanudar grabación";
$YourSessionTimeHasExpired = "Usted ya está registrado pero su periodo de permanencia en este curso ya expiró.";

@ -70,6 +70,27 @@
{% endfor %}
{% endif %}
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
{% endif %}
{% if (item.student_info.score is not null) %}
{{ "StudentCourseScoreX" | get_lang | format(item.student_info.score) }}
{% endif %}
{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificateX" | get_lang | format(item.student_info.certificate) }}
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -67,6 +67,26 @@
</a>
{% endfor %}
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
{% endif %}
{% if (item.student_info.score is not null) %}
{{ "StudentCourseScoreX" | get_lang | format(item.student_info.score) }}
{% endif %}
{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificateX" | get_lang | format(item.student_info.certificate) }}
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -78,6 +78,27 @@
{% endif %}
</div>
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
{% endif %}
{% if (item.student_info.score is not null) %}
{{ "StudentCourseScoreX" | get_lang | format(item.student_info.score) }}
{% endif %}
{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificateX" | get_lang | format(item.student_info.certificate) }}
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}

@ -64,6 +64,27 @@
{% endif %}
</h4>
<div class="notifications">{{ item.notifications }}</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
{% endif %}
{% if (item.student_info.score is not null) %}
{{ "StudentCourseScoreX" | get_lang | format(item.student_info.score) }}
{% endif %}
{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificateX" | get_lang | format(item.student_info.certificate) }}
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -61,6 +61,27 @@
{% endif %}
</h4>
<div class="notifications">{{ item.notifications }}</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
{% endif %}
{% if (item.student_info.score is not null) %}
{{ "StudentCourseScoreX" | get_lang | format(item.student_info.score) }}
{% endif %}
{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificateX" | get_lang | format(item.student_info.certificate) }}
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -29,6 +29,26 @@
{% endif %}
{% endfor %}
</div>
{% if item.student_info %}
<div class="course-student-info">
<div class="student-info">
{% if (item.student_info.progress is not null) %}
{{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
{% endif %}
{% if (item.student_info.score is not null) %}
{{ "StudentCourseScoreX" | get_lang | format(item.student_info.score) }}
{% endif %}
{% if (item.student_info.certificate is not null) %}
{{ "StudentCourseCertificateX" | get_lang | format(item.student_info.certificate) }}
{% endif %}
</div>
</div>
{% endif %}
</div>
{% if course.edit_actions != '' %}
<div class="admin-actions">

Loading…
Cancel
Save