Gradebook: Display certificate with course language - refs BT#15811

pull/2990/head
Angel Fernando Quiroz Campos 6 years ago
parent dd483f98ec
commit cf6f667fef
  1. 18
      certificates/index.php
  2. 28
      main/gradebook/lib/be/category.class.php

@ -10,6 +10,24 @@ require_once '../main/inc/global.inc.php';
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
$userId = isset($_GET['user_id']) ? $_GET['user_id'] : 0; $userId = isset($_GET['user_id']) ? $_GET['user_id'] : 0;
$category = Category::findByCertificate($_GET['id']);
// Check if the certificate should use the course language
if (!empty($category) && !empty($category->get_course_code())) {
$courseInfo = api_get_course_info($category->get_course_code());
$language = $courseInfo['language'];
$languageFilesToLoad = api_get_language_files_to_load($language);
foreach ($languageFilesToLoad as $languageFile) {
include $languageFile;
}
// Overwrite the interface language with the course language
$language_interface = $language;
$language_interface_initial_value = $language_interface;
}
$certificate = new Certificate($_GET['id'], $userId); $certificate = new Certificate($_GET['id'], $userId);
CustomCertificatePlugin::redirectCheck($certificate, $_GET['id'], $userId); CustomCertificatePlugin::redirectCheck($certificate, $_GET['id'], $userId);

@ -2774,4 +2774,32 @@ class Category implements GradebookItem
return api_float_val($categoryScore); return api_float_val($categoryScore);
} }
/**
* Find a gradebook category by the certificate ID.
*
* @param int $id
*
* @return Category|null
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public static function findByCertificate($id)
{
$categoryId = Database::getManager()
->createQuery("SELECT c.catId FROM ChamiloCoreBundle:GradebookCertificate c WHERE c.id = :id")
->setParameters(['id' => $id])
->getOneOrNullResult();
if (empty($categoryId)) {
return null;
}
$category = self::load($categoryId['catId']);
if (empty($category)) {
return $category;
}
return $category[0];
}
} }

Loading…
Cancel
Save