Fix entity annotations, add migrations, fix type hints

Use GradebookCategory.php entity instead of legacy category.class.php
pull/3844/head
Julio Montoya 5 years ago
parent 7e3711eb6c
commit 09deead67b
  1. 11
      public/main/cron/add_gradebook_certificates.php
  2. 12
      public/main/exercise/exercise_admin.php
  3. 2
      public/main/exercise/overview.php
  4. 15
      public/main/gradebook/gradebook_display_certificate.php
  5. 41
      public/main/gradebook/index.php
  6. 13
      public/main/gradebook/lib/GradebookUtils.php
  7. 122
      public/main/gradebook/lib/be/category.class.php
  8. 3
      public/main/gradebook/lib/fe/displaygradebook.php
  9. 14
      public/main/gradebook/lib/fe/gradebooktable.class.php
  10. 29
      public/main/inc/lib/certificate.lib.php
  11. 38
      public/main/inc/lib/exercise.lib.php
  12. 39
      public/main/inc/lib/skill.lib.php
  13. 33
      public/main/lp/lp_final_item.php
  14. 6
      public/main/lp/lp_view.php
  15. 13
      public/plugin/grading_electronic/generate.php
  16. 2
      src/CoreBundle/Entity/GradebookCategory.php
  17. 6
      src/CoreBundle/Entity/SkillRelProfile.php
  18. 6
      src/CoreBundle/Migrations/Schema/V200/Version20170904145500.php
  19. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201205102020.php

@ -1,12 +1,16 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
/**
* Adds gradebook certificates to gradebook_certificate table from users
* who have achieved the requirements but have not reviewed them yet.
*
* @author Imanol Losada <imanol.losada@beeznest.com>
*/
require_once __DIR__.'/../inc/global.inc.php';
/**
@ -27,10 +31,9 @@ function getAllCategoriesAndUsers()
}
if ($categoriesAndUsers = getAllCategoriesAndUsers()) {
$repo = Container::getGradeBookCategoryRepository();
foreach ($categoriesAndUsers as $categoryAndUser) {
Category::generateUserCertificate(
$categoryAndUser['category_id'],
$categoryAndUser['user_id']
);
$category = $repo->find($categoryAndUser['category_id']);
Category::generateUserCertificate($category, $categoryAndUser['user_id']);
}
}

@ -146,7 +146,6 @@ if (!empty($exerciseId)) {
$objExercise->createForm($form);
// VALIDATE FORM
if ($form->validate()) {
$objExercise->processCreation($form);
if ('true' === $form->getSubmitValue('edit')) {
@ -189,12 +188,13 @@ if ($form->validate()) {
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) {
if (!empty($_POST['lp_id'])) {
$lp_id = $_POST['lp_id'];
//TODO:this remains to be implemented after press the first post
} else {
//TODO:this remains to be implemented after press the first post
$lp_id = $_GET['lp_id'];
}
$lp_id = (int) $lp_id;
echo '<a href="../lp/lp_controller.php?'.api_get_cidreq().'&gradebook=&action=add_item&type=step&lp_id='.$lp_id.'#resource_tab-2">'.
echo '<a
href="../lp/lp_controller.php?'.api_get_cidreq().'&gradebook=&action=add_item&type=step&lp_id='.$lp_id.'#resource_tab-2">'.
Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Learning paths'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
echo '<a href="exercise.php?'.api_get_cidreq().'">'.
@ -205,7 +205,11 @@ if ($form->validate()) {
echo '</div>';
if (in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
echo Display::return_message(get_lang('The test type cannot be modified since it was set to self evaluation. Self evaluation gives you the possibility to give direct feedback to the user, but this is not compatible with all question types and, so this type quiz cannot be changed afterward.'));
echo Display::return_message(
get_lang(
'The test type cannot be modified since it was set to self evaluation. Self evaluation gives you the possibility to give direct feedback to the user, but this is not compatible with all question types and, so this type quiz cannot be changed afterward.'
)
);
}
if ('true' === api_get_setting('search_enabled') &&

@ -242,7 +242,7 @@ if (!empty($attempts)) {
$attempt_result['max_score'],
$objExercise,
$attempt_result['exe_user_id'],
$courseCode,
api_get_course_int_id(),
$sessionId
);
}

@ -2,6 +2,8 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;
@ -29,6 +31,11 @@ function confirmation() {
</script>";
$categoryId = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : 0;
$category = null;
$repo = Container::getGradeBookCategoryRepository();
if (!empty($categoryId)) {
$category = $repo->find($categoryId);
}
$action = isset($_GET['action']) && $_GET['action'] ? $_GET['action'] : null;
$filterOfficialCode = isset($_POST['filter']) ? Security::remove_XSS($_POST['filter']) : null;
$filterOfficialCodeGet = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
@ -162,17 +169,13 @@ switch ($action) {
}
exit;
case 'generate_all_certificates':
$userList = CourseManager::get_user_list_from_course_code(
api_get_course_id(),
api_get_session_id()
);
$userList = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id());
if (!empty($userList)) {
foreach ($userList as $userInfo) {
if (INVITEE == $userInfo['status']) {
continue;
}
Category::generateUserCertificate($categoryId, $userInfo['user_id']);
Category::generateUserCertificate($category, $userInfo['user_id']);
}
}
header('Location: '.$url);

@ -4,6 +4,8 @@
// $cidReset : This is the main difference with gradebook.php, here we say,
// basically, that we are inside a course, and many things depend from that
use Chamilo\CoreBundle\Framework\Container;
$_in_course = true;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;
@ -800,33 +802,30 @@ $no_qualification = false;
$certificate = [];
$actionsLeft = '';
$hideCertificateExport = api_get_setting('hide_certificate_export_link');
$category = null;
if (!empty($selectCat)) {
$cat = new Category();
$repo = Container::getGradeBookCategoryRepository();
if (!empty($categoryId)) {
$category = $repo->find($selectCat);
}
$course_id = CourseManager::get_course_by_category($selectCat);
$show_message = $cat->show_message_resource_delete($course_id);
$show_message = Category::show_message_resource_delete($course_id);
if ('' == $show_message) {
// Student
if (!api_is_allowed_to_edit() && !api_is_excluded_user_type()) {
$certificate = Category::generateUserCertificate(
$selectCat,
$stud_id
);
if ('true' !== $hideCertificateExport && isset($certificate['pdf_url'])) {
$actionsLeft .= Display::url(
Display::returnFontAwesomeIcon('file-pdf-o').get_lang('Download certificate in PDF'),
$certificate['pdf_url'],
['class' => 'btn btn-default']
);
}
if ($category) {
$certificate = Category::generateUserCertificate($category, $stud_id);
if ('true' !== $hideCertificateExport && isset($certificate['pdf_url'])) {
$actionsLeft .= Display::url(
Display::returnFontAwesomeIcon('file-pdf-o').get_lang('Download certificate in PDF'),
$certificate['pdf_url'],
['class' => 'btn btn-default']
);
}
$currentScore = Category::getCurrentScore(
$stud_id,
$cats[0],
true
);
Category::registerCurrentScore($currentScore, $stud_id, $selectCat);
$currentScore = Category::getCurrentScore($stud_id, $category, true);
Category::registerCurrentScore($currentScore, $stud_id, $selectCat);
}
}
}
}

@ -220,7 +220,7 @@ class GradebookUtils
*/
public static function build_edit_icons_cat($cat, $selectcat)
{
$show_message = $cat->show_message_resource_delete($cat->get_course_code());
$show_message = Category::show_message_resource_delete($cat->getCourseId());
$grade_model_id = $selectcat->get_grade_model_id();
$selectcat = $selectcat->get_id();
$modify_icons = null;
@ -357,8 +357,7 @@ class GradebookUtils
public static function build_edit_icons_eval($eval, $selectcat)
{
$is_locked = $eval->is_locked();
$cat = new Category();
$message_eval = $cat->show_message_resource_delete($eval->get_course_code());
$message_eval = Category::show_message_resource_delete($eval->getCourseId());
$courseParams = api_get_cidreq_params($eval->getCourseId(), $eval->getSessionId());
if (false === $message_eval && api_is_allowed_to_edit(null, true)) {
@ -443,8 +442,7 @@ class GradebookUtils
*/
public static function build_edit_icons_link($link, $selectcat)
{
$cat = new Category();
$message_link = $cat->show_message_resource_delete($link->get_course_code());
$message_link = Category::show_message_resource_delete($link->getCourseId());
$is_locked = $link->is_locked();
$modify_icons = null;
@ -452,10 +450,7 @@ class GradebookUtils
return null;
}
$courseParams = api_get_cidreq_params(
$link->getCourseId(),
$link->get_session_id()
);
$courseParams = api_get_cidreq_params($link->getCourseId(), $link->get_session_id());
if (false === $message_link) {
$visibility_icon = 0 == $link->is_visible() ? 'invisible' : 'visible';

@ -743,18 +743,21 @@ class Category implements GradebookItem
*
* @return bool|string
*/
public function show_message_resource_delete($course_id)
public static function show_message_resource_delete($course_id)
{
$course_id = (int) $course_id;
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT count(*) AS num
FROM '.$table.'
WHERE
c_id = "'.Database::escape_string($course_id).'" AND
c_id = "'.$course_id.'" AND
visible = 3';
$res = Database::query($sql);
$option = Database::fetch_array($res, 'ASSOC');
if ($option['num'] >= 1) {
return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('The resource has been deleted').'&nbsp;)</span>';
return '&nbsp;&nbsp;<span class="resource-deleted">
(&nbsp;'.get_lang('The resource has been deleted').'&nbsp;)
</span>';
}
return false;
@ -2026,7 +2029,6 @@ class Category implements GradebookItem
/**
* Generates a certificate for this user if everything matches.
*
* @param int $category_id gradebook id
* @param int $user_id
* @param bool $sendNotification
* @param bool $skipGenerationIfExists
@ -2034,68 +2036,30 @@ class Category implements GradebookItem
* @return array
*/
public static function generateUserCertificate(
$category_id,
GradebookCategory $category,
$user_id,
$sendNotification = false,
$skipGenerationIfExists = false
) {
$user_id = (int) $user_id;
$category_id = (int) $category_id;
// Generating the total score for a course
$category = self::load(
$category_id,
null,
null,
null,
null,
null,
false
);
/** @var Category $category */
$category = $category[0];
if (empty($category)) {
return false;
}
$sessionId = $category->get_session_id();
$courseCode = $category->get_course_code();
$categoryId = $category->getId();
$sessionId = $category->getSession() ? $category->getSession()->getId() : 0;
$courseCode = $category->getCourse()->getId();
$courseInfo = api_get_course_info($courseCode);
$courseId = $courseInfo['real_id'];
$userFinishedCourse = self::userFinishedCourse(
$user_id,
$category,
true
);
$userFinishedCourse = self::userFinishedCourse($user_id, $category, true);
if (!$userFinishedCourse) {
return false;
}
$skillToolEnabled = Skill::hasAccessToUserSkill(
api_get_user_id(),
$user_id
);
$skillToolEnabled = Skill::hasAccessToUserSkill(api_get_user_id(), $user_id);
$userHasSkills = false;
if ($skillToolEnabled) {
$skill = new Skill();
$skill->addSkillToUser(
$user_id,
$category,
$courseId,
$sessionId
);
$skill->addSkillToUser($user_id, $category, $courseId, $sessionId);
$objSkillRelUser = new SkillRelUser();
$userSkills = $objSkillRelUser->getUserSkills(
$user_id,
$courseId,
$sessionId
);
$userSkills = $objSkillRelUser->getUserSkills($user_id, $courseId, $sessionId);
$userHasSkills = !empty($userSkills);
}
@ -2113,37 +2077,31 @@ class Category implements GradebookItem
return false;
}
$my_certificate = GradebookUtils::get_certificate_by_user_id($categoryId, $user_id);
$scoretotal = $category->calc_score($user_id);
if ($skipGenerationIfExists && !empty($my_certificate)) {
return false;
}
$categoryLegacy = self::load($categoryId);
$categoryLegacy = $categoryLegacy[0];
/** @var Category $categoryLegacy */
$totalScore = $categoryLegacy->calc_score($user_id);
// Do not remove this the gradebook/lib/fe/gradebooktable.class.php
// file load this variable as a global
$scoredisplay = ScoreDisplay::instance();
$my_score_in_gradebook = $scoredisplay->display_score(
$scoretotal,
SCORE_SIMPLE
);
$my_certificate = GradebookUtils::get_certificate_by_user_id(
$category_id,
$user_id
);
if ($skipGenerationIfExists && !empty($my_certificate)) {
return false;
}
$my_score_in_gradebook = $scoredisplay->display_score($totalScore, SCORE_SIMPLE);
if (empty($my_certificate)) {
GradebookUtils::registerUserInfoAboutCertificate(
$category_id,
$categoryId,
$user_id,
$my_score_in_gradebook,
api_get_utc_datetime()
);
$my_certificate = GradebookUtils::get_certificate_by_user_id(
$category_id,
$user_id
);
$my_certificate = GradebookUtils::get_certificate_by_user_id($categoryId, $user_id);
}
$html = [];
@ -2209,19 +2167,6 @@ class Category implements GradebookItem
}
}
/**
* @param int $catId
* @param array $userList
*/
public static function generateCertificatesInUserList($catId, $userList)
{
if (!empty($userList)) {
foreach ($userList as $userInfo) {
self::generateUserCertificate($catId, $userInfo['user_id']);
}
}
}
/**
* @param int $catId
* @param array $userList
@ -2298,19 +2243,12 @@ class Category implements GradebookItem
/**
* Check whether a user has finished a course by its gradebook.
*
* @param int $userId The user ID
* @param GradebookCategory $category
* To check by the gradebook category
* @param bool $recalculateScore Whether recalculate the score
*
* @return bool
*/
public static function userFinishedCourse(
$userId,
int $userId,
GradebookCategory $category,
$recalculateScore = false
) {
bool $recalculateScore = false
): bool {
$currentScore = self::getCurrentScore(
$userId,
$category,

@ -292,9 +292,8 @@ class DisplayGradebook
);
}
$objcat = new Category();
$course_id = CourseManager::get_course_by_category($selectcat);
$message_resource = $objcat->show_message_resource_delete($course_id);
$message_resource = Category::show_message_resource_delete($course_id);
$grade_model_id = $catobj->get_grade_model_id();
$header = null;
if (isset($catobj) && !empty($catobj)) {

@ -468,8 +468,7 @@ class GradebookTable extends SortableTable
// Edit (for admins).
if ($this->teacherView) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
$show_message = Category::show_message_resource_delete($item->getCourseId());
if (false === $show_message) {
$row[] = $this->build_edit_column($item);
}
@ -644,8 +643,7 @@ class GradebookTable extends SortableTable
false == isset($_GET['user_id']) &&
(isset($_GET['action']) && 'export_all' != $_GET['action'] || !isset($_GET['action']))
) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
$show_message = Category::show_message_resource_delete($item->getCourseId());
if (false === $show_message) {
if (false == $this->exportToPdf) {
$row[] = $this->build_edit_column($item);
@ -1227,13 +1225,13 @@ class GradebookTable extends SortableTable
switch ($item->get_item_type()) {
case 'C':
// Category
/** @var Category $item */
$prms_uri = '?selectcat='.$item->get_id().'&view='.$view;
$isStudentView = api_is_student_view_active();
if (isset($is_student) || $isStudentView) {
$prms_uri = $prms_uri.'&amp;isStudentView=studentview';
}
$show_message = $cat->show_message_resource_delete($item->get_course_code());
$show_message = Category::show_message_resource_delete($item->getCourseId());
return '&nbsp;<a href="'.Category::getUrl().$prms_uri.'">'
.$item->get_name()
@ -1242,7 +1240,7 @@ class GradebookTable extends SortableTable
case 'E':
// Evaluation
$course_id = CourseManager::get_course_by_category($categoryId);
$show_message = $cat->show_message_resource_delete($course_id);
$show_message = Category::show_message_resource_delete($course_id);
// course/platform admin can go to the view_results page
if (api_is_allowed_to_edit() && false === $show_message) {
@ -1280,7 +1278,7 @@ class GradebookTable extends SortableTable
case 'L':
// Link
$course_id = CourseManager::get_course_by_category($categoryId);
$show_message = $cat->show_message_resource_delete($course_id);
$show_message = Category::show_message_resource_delete($course_id);
$url = $item->get_link();
$text = $item->get_name();

@ -906,10 +906,11 @@ class Certificate extends Model
{
$controller = new IndexManager(get_lang('My courses'));
$courseAndSessions = $controller->returnCoursesAndSessions($userId, true, null, true, false);
$repo = Container::getGradeBookCategoryRepository();
if (isset($courseAndSessions['courses']) && !empty($courseAndSessions['courses'])) {
foreach ($courseAndSessions['courses'] as $course) {
$cats = Category::load(
$category = $repo->findOneBy(['course' => $course['real_id']]);
/*$cats = Category::load(
null,
null,
$course['code'],
@ -917,13 +918,9 @@ class Certificate extends Model
null,
null,
false
);
if (isset($cats[0]) && !empty($cats[0])) {
Category::generateUserCertificate(
$cats[0]->get_id(),
$userId
);
);*/
if (null !== $category) {
Category::generateUserCertificate($category, $userId);
}
}
}
@ -935,7 +932,7 @@ class Certificate extends Model
if (!empty($sessionData['courses'])) {
$sessionId = $sessionData['session_id'];
foreach ($sessionData['courses'] as $courseData) {
$cats = Category:: load(
/*$cats = Category:: load(
null,
null,
$courseData['course_code'],
@ -943,13 +940,13 @@ class Certificate extends Model
null,
$sessionId,
false
);
);*/
if (isset($cats[0]) && !empty($cats[0])) {
Category::generateUserCertificate(
$cats[0]->get_id(),
$userId
);
$category = $repo->findOneBy(
['course' => $courseData['real_id'], 'session' => $sessionId]
);
if (null !== $category) {
Category::generateUserCertificate($category, $userId);
}
}
}

@ -3,6 +3,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\TrackEExercises;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
@ -983,7 +984,7 @@ class ExerciseLib
}
}
list($answer) = explode('@@', $answer);
[$answer] = explode('@@', $answer);
// $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]]
api_preg_match_all(
'/\[[^]]+\]/',
@ -4690,7 +4691,7 @@ EOT;
$total_weight,
$objExercise,
$studentInfo['id'],
$courseCode,
$courseId,
$sessionId
);
}
@ -5372,7 +5373,7 @@ EOT;
* @param float $totalScore
* @param float $totalWeight
* @param int $studentId
* @param string $courseCode
* @param int $courseId
* @param int $sessionId
*
* @return string
@ -5382,7 +5383,7 @@ EOT;
$totalWeight,
Exercise $objExercise,
$studentId,
$courseCode,
$courseId,
$sessionId = 0
) {
if (!api_get_configuration_value('quiz_generate_certificate_ending') ||
@ -5391,37 +5392,40 @@ EOT;
return '';
}
/** @var Category $category */
$category = Category::load(null, null, $courseCode, null, null, $sessionId, 'ORDER By id');
$repo = Container::getGradeBookCategoryRepository();
/** @var GradebookCategory $category */
$category = $repo->findOneBy(
['course' => $courseId, 'session' => $sessionId]
);
if (empty($category)) {
if (null === $category) {
return '';
}
/** @var Category $category */
$category = $category[0];
$categoryId = $category->get_id();
$link = LinkFactory::load(
/*$category = Category::load(null, null, $courseCode, null, null, $sessionId, 'ORDER By id');
if (empty($category)) {
return '';
}*/
$categoryId = $category->getId();
/*$link = LinkFactory::load(
null,
null,
$objExercise->getId(),
null,
$courseCode,
$categoryId
);
);*/
if (empty($link)) {
if (empty($category->getLinks()->count())) {
return '';
}
$resourceDeletedMessage = $category->show_message_resource_delete($courseCode);
$resourceDeletedMessage = Category::show_message_resource_delete($courseId);
if (false !== $resourceDeletedMessage || api_is_allowed_to_edit() || api_is_excluded_user_type()) {
return '';
}
$certificate = Category::generateUserCertificate($categoryId, $studentId);
$certificate = Category::generateUserCertificate($category, $studentId);
if (!is_array($certificate)) {
return '';
}

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\Skill as SkillEntity;
use Chamilo\CoreBundle\Entity\SkillRelCourse;
use Chamilo\CoreBundle\Entity\SkillRelItem;
@ -1149,49 +1150,38 @@ class Skill extends Model
}
/**
* @param int $userId
* @param Category $category
* @param int $courseId
* @param int $sessionId
* @param int $userId
* @param GradebookCategory $category
* @param int $courseId
* @param int $sessionId
*
* @return bool
*/
public function addSkillToUser(
$userId,
$category,
GradebookCategory $category,
$courseId,
$sessionId
) {
$skill_gradebook = new SkillRelGradebook();
$skill_rel_user = new SkillRelUser();
if (empty($category)) {
return false;
}
// Load subcategories
if (empty($category->get_parent_id())) {
$subCategories = $category->get_subcategories(
$userId,
$category->get_course_code(),
$category->get_session_id()
);
if ($category->hasSubCategories()) {
$subCategories = $category->getSubCategories();
if (!empty($subCategories)) {
/** @var Category $subCategory */
foreach ($subCategories as $subCategory) {
$this->addSkillToUser($userId, $subCategory, $courseId, $sessionId);
}
}
}
$gradebookId = $category->get_id();
$skill_gradebooks = $skill_gradebook->get_all(['where' => ['gradebook_id = ?' => $gradebookId]]);
if (!empty($skill_gradebooks)) {
foreach ($skill_gradebooks as $skill_gradebook) {
$skills = $category->getSkills();
if (!empty($skills)) {
foreach ($skills as $skill) {
$skillId = $skill->getSkill()->getId();
$hasSkill = $this->userHasSkill(
$userId,
$skill_gradebook['skill_id'],
$skillId,
$courseId,
$sessionId
);
@ -1199,12 +1189,11 @@ class Skill extends Model
if (!$hasSkill) {
$params = [
'user_id' => $userId,
'skill_id' => $skill_gradebook['skill_id'],
'skill_id' => $skillId,
'acquired_skill_at' => api_get_utc_datetime(),
'course_id' => (int) $courseId,
'session_id' => $sessionId ? (int) $sessionId : null,
];
$skill_rel_user->save($params);
}
}

@ -1,6 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
/**
* Print a learning path finish page with details.
*
@ -92,7 +95,9 @@ unset($currentItem);
// show a prerequisites warning
if (false == $accessGranted) {
echo Display::return_message(
get_lang('This learning object cannot display because the course prerequisites are not completed. This happens when a course imposes that you follow it step by step or get a minimum score in tests before you reach the next steps.'),
get_lang(
'This learning object cannot display because the course prerequisites are not completed. This happens when a course imposes that you follow it step by step or get a minimum score in tests before you reach the next steps.'
),
'warning'
);
$finalItemTemplate = '';
@ -131,14 +136,12 @@ if (false == $accessGranted) {
if ($link) {
$cat = new Category();
$catCourseCode = CourseManager::get_course_by_category($categoryId);
$show_message = $cat->show_message_resource_delete($catCourseCode);
$show_message = Category::show_message_resource_delete($courseId);
$repo = Container::getGradeBookCategoryRepository();
$category = $repo->find($categoryId);
if (false === $show_message && !api_is_allowed_to_edit() && !api_is_excluded_user_type()) {
$certificate = Category::generateUserCertificate(
$categoryId,
$userId
);
$certificate = Category::generateUserCertificate($category, $userId);
if (!empty($certificate['pdf_url']) ||
!empty($certificate['badge_link'])
@ -147,9 +150,7 @@ if (false == $accessGranted) {
$downloadCertificateLink = Category::getDownloadCertificateBlock($certificate);
}
if (is_array($certificate) &&
isset($certificate['badge_link'])
) {
if (is_array($certificate) && isset($certificate['badge_link'])) {
$courseId = api_get_course_int_id();
$badgeLink = generateLPFinalItemTemplateBadgeLinks(
$userId,
@ -159,16 +160,8 @@ if (false == $accessGranted) {
}
}
$currentScore = Category::getCurrentScore(
$userId,
$category,
true
);
Category::registerCurrentScore(
$currentScore,
$userId,
$categoryId
);
$currentScore = Category::getCurrentScore($userId, $category, true);
Category::registerCurrentScore($currentScore, $userId, $categoryId);
}
}

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLp;
use ChamiloSession as Session;
@ -33,6 +34,7 @@ $course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$course = api_get_course_entity($course_id);
$session = api_get_session_entity($sessionId);
$lpRepo = Container::getLpRepository();
/** @var learnpath $lp */
//$oLP = Session::read('oLP');
@ -446,9 +448,9 @@ if ($oLP->current == $oLP->get_last()) {
) {
$gradebookMinScore = $categories[0]->getCertificateMinScore();
$userScore = $gradebookLinks[0]->calc_score($user_id, 'best');
$categoryEntity = Container::getGradeBookCategoryRepository()->find($categories[0]->get_id());
if ($userScore[0] >= $gradebookMinScore) {
Category::generateUserCertificate($categories[0]->get_id(), $user_id);
Category::generateUserCertificate($categoryEntity, $user_id);
}
}
}

@ -7,6 +7,7 @@ use Chamilo\CoreBundle\Entity\CourseRelUser;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelUser;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container;
use Doctrine\Common\Collections\Criteria;
require_once '../../main/inc/global.inc.php';
@ -123,9 +124,7 @@ try {
if (!$userFinishedCourse) {
continue;
}
/** commented until we get clear understanding of how to use the dates refs BT#12404.
}
*/
/** commented until we get clear understanding of how to use the dates refs BT#12404. */
$fieldStudent = $uFieldValue->get_values_by_handler_and_field_variable(
$student->getId(),
GradingElectronicPlugin::EXTRAFIELD_STUDENT_ID
@ -157,11 +156,9 @@ try {
continue;
}
Category::generateUserCertificate(
$gradebook->get_id(),
$student->getId(),
true
);
$repo = Container::getGradeBookCategoryRepository();
$category = $repo->find($gradebook->get_id());
Category::generateUserCertificate($category, $student->getId(), true);
}
$fileName = implode('_', [

@ -543,6 +543,4 @@ class GradebookCategory
return $this;
}
}

@ -45,9 +45,6 @@ class SkillRelProfile
return $this->id;
}
/**
* @return Skill
*/
public function getSkill(): Skill
{
return $this->skill;
@ -71,7 +68,4 @@ class SkillRelProfile
return $this;
}
}

@ -78,10 +78,8 @@ class Version20170904145500 extends AbstractMigrationChamilo
}
if ($table->hasColumn('page_result_configuration')) {
$this->addSql('
UPDATE c_quiz SET page_result_configuration = "a:0:{}"
WHERE page_result_configuration IS NULL OR
page_result_configuration = "" '
$this->addSql(
'UPDATE c_quiz SET page_result_configuration = "a:0:{}" WHERE page_result_configuration IS NULL ORpage_result_configuration = "" '
);
$this->addSql(
"ALTER TABLE c_quiz CHANGE page_result_configuration page_result_configuration LONGTEXT NOT NULL COMMENT '(DC2Type:array)';"

@ -132,7 +132,5 @@ final class Version20201205102020 extends AbstractMigrationChamilo
if (!$table->hasIndex('IDX_4AC0B45EAD3ED51C')) {
$this->addSql('CREATE INDEX IDX_4AC0B45EAD3ED51C ON skill_rel_gradebook (gradebook_id)');
}
}
}

Loading…
Cancel
Save