Merge branch 'B9442' of https://github.com/AngelFQC/chamilo-lms into AngelFQC-B9442

1.10.x
Yannick Warnier 11 years ago
commit b51161b096
  1. 32
      main/gradebook/certificate_report.php
  2. 4
      main/template/default/gradebook/certificate_report.tpl

@ -5,6 +5,8 @@
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.gradebook * @package chamilo.gradebook
*/ */
use \ChamiloSession as Session;
$language_file = array('gradebook', 'exercice'); $language_file = array('gradebook', 'exercice');
$cidReset = true; $cidReset = true;
@ -28,6 +30,13 @@ $userId = api_get_user_id();
$sessions = SessionManager::getSessionsCoachedByUser($userId); $sessions = SessionManager::getSessionsCoachedByUser($userId);
if ($selectedSession > 0) { if ($selectedSession > 0) {
if (!SessionManager::isValidId($selectedSession)) {
Session::write('reportErrorMessage', get_lang('NoSession'));
header("Location: $selfUrl");
exit;
}
$courses = SessionManager::get_course_list_by_session_id($selectedSession); $courses = SessionManager::get_course_list_by_session_id($selectedSession);
if (is_array($courses)) { if (is_array($courses)) {
@ -65,10 +74,22 @@ $searchCourseOnly = $selectedSession <= 0 && $selectedCourse > 0;
if ($searchSessionAndCourse || $searchCourseOnly) { if ($searchSessionAndCourse || $searchCourseOnly) {
$selectedCourseInfo = api_get_course_info_by_id($selectedCourse); $selectedCourseInfo = api_get_course_info_by_id($selectedCourse);
if (empty($selectedCourseInfo)) {
Session::write('reportErrorMessage', get_lang('NoCourse'));
header("Location: $selfUrl");
exit;
}
$gradebookCategories = Category::load(null, null, $selectedCourseInfo['code'], null, false, $selectedSession); $gradebookCategories = Category::load(null, null, $selectedCourseInfo['code'], null, false, $selectedSession);
$gradebook = null;
if (!empty($gradebookCategories)) {
$gradebook = current($gradebookCategories); $gradebook = current($gradebookCategories);
}
if (!is_null($gradebook)) {
$exportAllLink = api_get_path(WEB_CODE_PATH) . "gradebook/gradebook_display_certificate.php?"; $exportAllLink = api_get_path(WEB_CODE_PATH) . "gradebook/gradebook_display_certificate.php?";
$exportAllLink .= http_build_query(array( $exportAllLink .= http_build_query(array(
"action" => "export_all_certificates", "action" => "export_all_certificates",
@ -82,7 +103,7 @@ if ($searchSessionAndCourse || $searchCourseOnly) {
$certificateStudents = array(); $certificateStudents = array();
if (is_array($studentList)) { if (is_array($studentList) && !empty($studentList)) {
foreach ($studentList as $student) { foreach ($studentList as $student) {
$certificateStudent = array( $certificateStudent = array(
'fullName' => api_get_person_name($student['firstname'], $student['lastname']), 'fullName' => api_get_person_name($student['firstname'], $student['lastname']),
@ -94,7 +115,7 @@ if ($searchSessionAndCourse || $searchCourseOnly) {
$gradebook->get_id() $gradebook->get_id()
); );
if (!is_array($studentCertificates)) { if (!is_array($studentCertificates) || empty($studentCertificates)) {
continue; continue;
} }
@ -130,10 +151,15 @@ if ($searchSessionAndCourse || $searchCourseOnly) {
} }
} }
} }
}
/* View */ /* View */
$template = new Template(get_lang('GradebookListOfStudentsCertificates')); $template = new Template(get_lang('GradebookListOfStudentsCertificates'));
if (Session::has('reportErrorMessage')) {
$template->assign('errorMessage', Session::read('reportErrorMessage'));
}
$template->assign('selectedSession', $selectedSession); $template->assign('selectedSession', $selectedSession);
$template->assign('selectedCourse', $selectedCourse); $template->assign('selectedCourse', $selectedCourse);
$template->assign('selectedMonth', $selectedMonth); $template->assign('selectedMonth', $selectedMonth);
@ -148,3 +174,5 @@ $content = $template->fetch("default/gradebook/certificate_report.tpl");
$template->assign('content', $content); $template->assign('content', $content);
$template->display_one_col_template(); $template->display_one_col_template();
Session::erase('reportErrorMessage');

@ -74,6 +74,10 @@
<h1 class="page-header">{{ 'GradebookListOfStudentsCertificates' | get_lang }}</h1> <h1 class="page-header">{{ 'GradebookListOfStudentsCertificates' | get_lang }}</h1>
{% if errorMessage is defined %}
<div class="alert alert-error">{{ errorMessage }}</div>
{% endif %}
{% if not certificateStudents is empty %} {% if not certificateStudents is empty %}
<p> <p>
<a href="{{ exportAllLink }}" class="btn btn-info">{{ 'ExportAllCertificatesToPDF' | get_lang }}</a> <a href="{{ exportAllLink }}" class="btn btn-info">{{ 'ExportAllCertificatesToPDF' | get_lang }}</a>

Loading…
Cancel
Save