From 5c080a9113eb6c0069d985fcaa8536cae3c8d8a7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 26 Aug 2020 12:40:34 +0200 Subject: [PATCH] Internal: Fix queries, use iid instead of id --- public/main/exercise/question.class.php | 11 +++---- public/main/forum/forumfunction.inc.php | 5 +-- public/main/gradebook/gradebook_add_link.php | 4 +-- public/main/gradebook/gradebook_edit_link.php | 10 +++--- public/main/gradebook/gradebook_flatview.php | 27 ++++++---------- .../main/gradebook/gradebook_view_result.php | 1 - public/main/gradebook/index.php | 2 +- public/main/gradebook/lib/GradebookUtils.php | 10 +++--- .../gradebook/lib/be/attendancelink.class.php | 19 ++++++------ .../gradebook/lib/be/exerciselink.class.php | 4 +-- .../lib/be/forumthreadlink.class.php | 18 +++++------ .../gradebook/lib/be/learnpathlink.class.php | 6 ++-- public/main/gradebook/lib/be/result.class.php | 4 +-- .../lib/be/studentpublicationlink.class.php | 2 +- public/main/inc/lib/AnnouncementManager.php | 31 ++++++++++--------- public/main/inc/lib/api.lib.php | 9 ++---- public/main/inc/lib/document.lib.php | 14 +++++---- public/main/inc/lib/usermanager.lib.php | 7 +++-- src/CoreBundle/Entity/AbstractResource.php | 4 +++ src/CoreBundle/Entity/GradebookCategory.php | 6 ++-- src/CoreBundle/Resources/config/services.yml | 3 +- 21 files changed, 94 insertions(+), 103 deletions(-) diff --git a/public/main/exercise/question.class.php b/public/main/exercise/question.class.php index 4d0e1e51a9..bb378b99a4 100644 --- a/public/main/exercise/question.class.php +++ b/public/main/exercise/question.class.php @@ -581,6 +581,7 @@ abstract class Question $current_position = Database::result($result, 0, 0); $this->updatePosition($current_position + 1); $position = $this->position; + $exerciseEntity = $exerciseRepo->find($exerciseId); $question = new CQuizQuestion(); $question @@ -593,15 +594,13 @@ abstract class Question ->setExtra($this->extra) ->setLevel($this->level) ->setFeedback($this->feedback) - ; - - $exerciseEntity = $exerciseRepo->find($exerciseId); - $question->setParent($exerciseEntity); - $question->addCourseLink( + ->setParent($exerciseEntity) + ->addCourseLink( api_get_course_entity(), api_get_session_entity(), api_get_group_entity() - ); + ) + ; $em->persist($question); $em->flush(); diff --git a/public/main/forum/forumfunction.inc.php b/public/main/forum/forumfunction.inc.php index 80826531b9..6b0c821ccc 100644 --- a/public/main/forum/forumfunction.inc.php +++ b/public/main/forum/forumfunction.inc.php @@ -952,8 +952,9 @@ function store_forum($values, $courseInfo = [], $returnId = false) if ($image_moved) { $new_file_name = isset($new_file_name) ? $new_file_name : ''; } - $forum->setParent($course); - $forum->addCourseLink($course, $session); + $forum + ->setParent($course) + ->addCourseLink($course, $session); $repo->getEntityManager()->persist($forum); $repo->getEntityManager()->flush(); diff --git a/public/main/gradebook/gradebook_add_link.php b/public/main/gradebook/gradebook_add_link.php index 86ba191b1c..9533bd2428 100644 --- a/public/main/gradebook/gradebook_add_link.php +++ b/public/main/gradebook/gradebook_add_link.php @@ -102,7 +102,7 @@ if (isset($typeSelected) && '0' != $typeSelected) { $sql1 = 'SELECT thread_title from '.$tbl_forum_thread.' WHERE c_id = '.$course_info['real_id'].' AND - thread_id = '.$addvalues['select_link']; + iid = '.$addvalues['select_link']; $res1 = Database::query($sql1); $rowtit = Database::fetch_row($res1); $course_id = api_get_course_id(); @@ -120,7 +120,7 @@ if (isset($typeSelected) && '0' != $typeSelected) { thread_weight= "'.api_float_val($addvalues['weight']).'", thread_title_qualify = "'.$rowtit[0].'" WHERE - thread_id='.$addvalues['select_link'].' AND + iid ='.$addvalues['select_link'].' AND c_id = '.$course_info['real_id'].' '; Database::query($sql); } diff --git a/public/main/gradebook/gradebook_edit_link.php b/public/main/gradebook/gradebook_edit_link.php index 70ed43f1a8..32770d0f68 100644 --- a/public/main/gradebook/gradebook_edit_link.php +++ b/public/main/gradebook/gradebook_edit_link.php @@ -73,11 +73,11 @@ if ($form->validate()) { } //Update weight into forum thread - $sql = 'UPDATE '.$tbl_forum_thread.' SET + $sql = 'UPDATE '.$tbl_forum_thread.' SET thread_weight = '.api_float_val($final_weight).' - WHERE - c_id = '.$course_id.' AND - thread_id = ( + WHERE + c_id = '.$course_id.' AND + iid = ( SELECT ref_id FROM '.$tbl_grade_links.' WHERE id='.intval($_GET['editlink']).' AND type = 5 )'; @@ -89,7 +89,7 @@ if ($form->validate()) { UPDATE ChamiloCourseBundle:CStudentPublication w SET w.weight = :final_weight WHERE w.cId = :course - AND w.id = ( + AND w.iid = ( SELECT l.refId FROM ChamiloCoreBundle:GradebookLink l WHERE l.id = :link AND l.type = :type ) diff --git a/public/main/gradebook/gradebook_flatview.php b/public/main/gradebook/gradebook_flatview.php index 1d15f9592b..95f6be11e6 100644 --- a/public/main/gradebook/gradebook_flatview.php +++ b/public/main/gradebook/gradebook_flatview.php @@ -269,24 +269,17 @@ if (isset($_GET['exportpdf'])) { } else { Display::display_header(get_lang('List View')); } -if (isset($_GET['isStudentView']) && 'false' === $_GET['isStudentView']) { - DisplayGradebook::display_header_reduce_flatview( - $cat[0], - $showeval, - $showlink, - $simple_search_form - ); - $flatViewTable->display(); -} elseif (isset($_GET['selectcat']) && ($_SESSION['studentview'] === 'teacherview')) { - DisplayGradebook::display_header_reduce_flatview( - $cat[0], - $showeval, - $showlink, - $simple_search_form - ); +$studentView = api_is_student_view_active(); + +DisplayGradebook::display_header_reduce_flatview( + $cat[0], + $showeval, + $showlink, + $simple_search_form +); +$flatViewTable->display(); - // Table - $flatViewTable->display(); +if (false === $studentView) { //@todo load images with jquery echo '
'; $flatViewTable->display_graph_by_resource(); diff --git a/public/main/gradebook/gradebook_view_result.php b/public/main/gradebook/gradebook_view_result.php index 212bbd93cd..3aa743cd0c 100644 --- a/public/main/gradebook/gradebook_view_result.php +++ b/public/main/gradebook/gradebook_view_result.php @@ -2,7 +2,6 @@ /* For licensing terms, see /license.txt */ - require_once __DIR__.'/../inc/global.inc.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php'; diff --git a/public/main/gradebook/index.php b/public/main/gradebook/index.php index 2e6c41df9b..647f0787e6 100644 --- a/public/main/gradebook/index.php +++ b/public/main/gradebook/index.php @@ -457,7 +457,7 @@ if (isset($_GET['deletelink'])) { thread_qualify_max = 0, thread_weight = 0, thread_title_qualify = "" - WHERE c_id = '.$course_id.' AND thread_id = ( + WHERE c_id = '.$course_id.' AND iid = ( SELECT ref_id FROM '.$tbl_grade_links.' WHERE id='.$get_delete_link.' AND type = '.LINK_FORUM_THREAD.' )'; diff --git a/public/main/gradebook/lib/GradebookUtils.php b/public/main/gradebook/lib/GradebookUtils.php index 1615b27b4e..533877ba60 100644 --- a/public/main/gradebook/lib/GradebookUtils.php +++ b/public/main/gradebook/lib/GradebookUtils.php @@ -744,17 +744,17 @@ class GradebookUtils { $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); $table_user = Database::get_main_table(TABLE_MAIN_USER); - $sql = 'SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username, gc.created_at + $sql = 'SELECT DISTINCT u.id as user_id, u.lastname, u.firstname, u.username, gc.created_at FROM '.$table_user.' u INNER JOIN '.$table_certificate.' gc - ON u.user_id=gc.user_id '; + ON u.id = gc.user_id '; if (!is_null($cat_id) && $cat_id > 0) { $sql .= ' WHERE cat_id='.intval($cat_id); } if (!empty($userList)) { $userList = array_map('intval', $userList); $userListCondition = implode("','", $userList); - $sql .= " AND u.user_id IN ('$userListCondition')"; + $sql .= " AND u.id IN ('$userListCondition')"; } $sql .= ' ORDER BY '.(api_sort_by_first_name() ? 'u.firstname' : 'u.lastname'); $rs = Database::query($sql); @@ -1355,7 +1355,7 @@ class GradebookUtils thread_weight = '.api_float_val($weight).' WHERE c_id = '.$course_id.' AND - thread_id = ( + iid = ( SELECT ref_id FROM '.$table_link.' WHERE id='.$linkId.' AND type='.LINK_FORUM_THREAD.' ) @@ -1367,7 +1367,7 @@ class GradebookUtils UPDATE ChamiloCourseBundle:CStudentPublication w SET w.weight = :final_weight WHERE w.cId = :course - AND w.id = ( + AND w.iid = ( SELECT l.refId FROM ChamiloCoreBundle:GradebookLink l WHERE l.id = :link AND l.type = :type ) diff --git a/public/main/gradebook/lib/be/attendancelink.class.php b/public/main/gradebook/lib/be/attendancelink.class.php index e01f206c5e..7c36d77151 100644 --- a/public/main/gradebook/lib/be/attendancelink.class.php +++ b/public/main/gradebook/lib/be/attendancelink.class.php @@ -49,7 +49,7 @@ class AttendanceLink extends AbstractLink $tbl_attendance = $this->get_attendance_table(); $sessionId = $this->get_session_id(); - $sql = 'SELECT att.id, att.name, att.attendance_qualify_title + $sql = 'SELECT att.iid, att.name, att.attendance_qualify_title FROM '.$tbl_attendance.' att WHERE att.c_id = '.$this->course_id.' AND @@ -60,14 +60,13 @@ class AttendanceLink extends AbstractLink while ($data = Database::fetch_array($result)) { if (isset($data['attendance_qualify_title']) && '' != $data['attendance_qualify_title']) { - $cats[] = [$data['id'], $data['attendance_qualify_title']]; + $cats[] = [$data['iid'], $data['attendance_qualify_title']]; } else { - $cats[] = [$data['id'], $data['name']]; + $cats[] = [$data['iid'], $data['name']]; } } - $my_cats = isset($cats) ? $cats : []; - return $my_cats; + return isset($cats) ? $cats : []; } /** @@ -104,7 +103,7 @@ class AttendanceLink extends AbstractLink FROM '.$this->get_attendance_table().' att WHERE att.c_id = '.$this->course_id.' AND - att.id = '.$this->get_ref_id().' AND + att.iid = '.$this->get_ref_id().' AND att.session_id = '.$sessionId; $query = Database::query($sql); $attendance = Database::fetch_array($query, 'ASSOC'); @@ -216,8 +215,8 @@ class AttendanceLink extends AbstractLink */ public function is_valid_link() { - $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att - WHERE att.c_id = '.$this->course_id.' AND att.id = '.$this->get_ref_id(); + $sql = 'SELECT count(att.iid) FROM '.$this->get_attendance_table().' att + WHERE att.c_id = '.$this->course_id.' AND att.iid = '.$this->get_ref_id(); $result = Database::query($sql); $number = Database::fetch_row($result); @@ -229,7 +228,7 @@ class AttendanceLink extends AbstractLink // it was extracts the attendance id $sessionId = $this->get_session_id(); $sql = 'SELECT * FROM '.$this->get_attendance_table().' att - WHERE att.c_id = '.$this->course_id.' AND att.id = '.$this->get_ref_id(); + WHERE att.c_id = '.$this->course_id.' AND att.iid = '.$this->get_ref_id(); $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); $attendance_id = $row['id']; @@ -266,7 +265,7 @@ class AttendanceLink extends AbstractLink return false; } elseif (!isset($this->attendance_data)) { $sql = 'SELECT * FROM '.$this->get_attendance_table().' att - WHERE att.c_id = '.$this->course_id.' AND att.id = '.$this->get_ref_id(); + WHERE att.c_id = '.$this->course_id.' AND att.iid = '.$this->get_ref_id(); $query = Database::query($sql); $this->attendance_data = Database::fetch_array($query); } diff --git a/public/main/gradebook/lib/be/exerciselink.class.php b/public/main/gradebook/lib/be/exerciselink.class.php index 7b72dc4254..8283e91c13 100644 --- a/public/main/gradebook/lib/be/exerciselink.class.php +++ b/public/main/gradebook/lib/be/exerciselink.class.php @@ -60,7 +60,7 @@ class ExerciseLink extends AbstractLink $sqlLp = "SELECT e.iid, e.title FROM $exerciseTable e INNER JOIN $lpItemTable i - ON (e.c_id = i.c_id AND e.id = i.path) + ON (e.c_id = i.c_id AND e.iid = i.path) WHERE e.c_id = $this->course_id AND active = 0 AND @@ -253,7 +253,7 @@ class ExerciseLink extends AbstractLink ON (hp.exe_name = doc.path AND doc.c_id = hp.c_id) WHERE hp.c_id = $courseId AND - doc.id = $exerciseId"; + doc.iid = $exerciseId"; if (!empty($stud_id)) { $sql .= " AND hp.exe_user_id = $stud_id "; diff --git a/public/main/gradebook/lib/be/forumthreadlink.class.php b/public/main/gradebook/lib/be/forumthreadlink.class.php index 46d5efae88..851d77bd28 100644 --- a/public/main/gradebook/lib/be/forumthreadlink.class.php +++ b/public/main/gradebook/lib/be/forumthreadlink.class.php @@ -58,7 +58,7 @@ class ForumThreadLink extends AbstractLink $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; } - $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify + $sql = 'SELECT tl.iid as thread_id, tl.thread_title, tl.thread_title_qualify FROM '.$tbl_grade_links.' tl WHERE tl.c_id = '.$this->course_id.' AND @@ -90,7 +90,7 @@ class ForumThreadLink extends AbstractLink $sql = "SELECT count(*) AS number FROM $table WHERE c_id = ".$this->course_id." AND - thread_id = '".$this->get_ref_id()."' + iid = '".$this->get_ref_id()."' "; $result = Database::query($sql); $number = Database::fetch_row($result); @@ -121,7 +121,7 @@ class ForumThreadLink extends AbstractLink FROM '.Database::get_course_table(TABLE_FORUM_THREAD)." WHERE c_id = ".$this->course_id." AND - thread_id = '".$this->get_ref_id()."' + iid = '".$this->get_ref_id()."' $sessionCondition "; $query = Database::query($sql); @@ -130,7 +130,7 @@ class ForumThreadLink extends AbstractLink $sql = "SELECT * FROM $thread_qualify WHERE c_id = ".$this->course_id." AND - thread_id = ".$this->get_ref_id()." + iid = ".$this->get_ref_id()." $sessionCondition "; if (isset($stud_id)) { @@ -264,7 +264,7 @@ class ForumThreadLink extends AbstractLink $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' WHERE c_id = '.$this->course_id.' AND - thread_id = '.$this->get_ref_id().' AND + iid = '.$this->get_ref_id().' AND session_id='.$sessionId; $result = Database::query($sql); $number = Database::fetch_row($result); @@ -279,7 +279,7 @@ class ForumThreadLink extends AbstractLink $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." WHERE c_id = '.$this->course_id.' AND - thread_id = '".$this->get_ref_id()."' AND + iid = '".$this->get_ref_id()."' AND session_id = $sessionId "; $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); @@ -303,7 +303,7 @@ class ForumThreadLink extends AbstractLink if (!empty($ref_id)) { $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.api_float_val($weight).' - WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; + WHERE c_id = '.$this->course_id.' AND iid = '.$ref_id; Database::query($sql); } } @@ -317,7 +317,7 @@ class ForumThreadLink extends AbstractLink thread_qualify_max = 0, thread_weight = 0, thread_title_qualify = "" - WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; + WHERE c_id = '.$this->course_id.' AND iid = '.$ref_id; Database::query($sql); } } @@ -343,7 +343,7 @@ class ForumThreadLink extends AbstractLink $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' WHERE c_id = '.$this->course_id.' AND - thread_id = '.$this->get_ref_id().' AND + iid = '.$this->get_ref_id().' AND '.$session_condition; $query = Database::query($sql); $this->exercise_data = Database::fetch_array($query); diff --git a/public/main/gradebook/lib/be/learnpathlink.class.php b/public/main/gradebook/lib/be/learnpathlink.class.php index 539dbbb549..4de8632be7 100644 --- a/public/main/gradebook/lib/be/learnpathlink.class.php +++ b/public/main/gradebook/lib/be/learnpathlink.class.php @@ -40,7 +40,7 @@ class LearnpathLink extends AbstractLink $session_condition = api_get_session_condition($session_id, true, true); } - $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' + $sql = 'SELECT iid, name FROM '.$this->get_learnpath_table().' WHERE c_id = '.$this->course_id.' '.$session_condition.' '; $result = Database::query($sql); @@ -192,7 +192,7 @@ class LearnpathLink extends AbstractLink */ public function is_valid_link() { - $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' + $sql = 'SELECT count(iid) FROM '.$this->get_learnpath_table().' WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; $result = Database::query($sql); $number = Database::fetch_row($result, 'NUM'); @@ -247,7 +247,7 @@ class LearnpathLink extends AbstractLink { if (!isset($this->learnpath_data)) { $sql = 'SELECT * FROM '.$this->get_learnpath_table().' - WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; + WHERE c_id = '.$this->course_id.' AND iid = '.$this->get_ref_id().' '; $result = Database::query($sql); $this->learnpath_data = Database::fetch_array($result); } diff --git a/public/main/gradebook/lib/be/result.class.php b/public/main/gradebook/lib/be/result.class.php index 4b2deb042e..2bf5d50751 100644 --- a/public/main/gradebook/lib/be/result.class.php +++ b/public/main/gradebook/lib/be/result.class.php @@ -150,10 +150,10 @@ class Result $sql = "SELECT lastname, gr.id, gr.user_id, gr.evaluation_id, gr.created_at, gr.score FROM $tbl_grade_results gr INNER JOIN $tbl_user u - ON gr.user_id = u.user_id "; + ON gr.user_id = u.id "; if (!empty($userIdList)) { - $sql .= " AND u.user_id IN ('$userIdListToString')"; + $sql .= " AND u.id IN ('$userIdListToString')"; } $paramcount = 0; diff --git a/public/main/gradebook/lib/be/studentpublicationlink.class.php b/public/main/gradebook/lib/be/studentpublicationlink.class.php index f66c471d9a..3017faad98 100644 --- a/public/main/gradebook/lib/be/studentpublicationlink.class.php +++ b/public/main/gradebook/lib/be/studentpublicationlink.class.php @@ -216,7 +216,7 @@ class StudentPublicationLink extends AbstractLink case 'first': default: // first attempt - $dql .= ' ORDER BY a.id'; + $dql .= ' ORDER BY a.iid'; break; } diff --git a/public/main/inc/lib/AnnouncementManager.php b/public/main/inc/lib/AnnouncementManager.php index 32967b80ab..4f41bab896 100644 --- a/public/main/inc/lib/AnnouncementManager.php +++ b/public/main/inc/lib/AnnouncementManager.php @@ -483,6 +483,8 @@ class AnnouncementManager $html .= ""; $html .= ""; + $isVisible = $announcement->isVisible($course, $session); + if (api_is_allowed_to_edit(false, true) || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) ) { @@ -492,7 +494,7 @@ class AnnouncementManager $image_visibility = 'invisible'; $alt_visibility = get_lang('Visible'); $setNewStatus = 'visible'; - if ($announcement->isVisible($course, $session)) { + if ($isVisible) { $image_visibility = 'visible'; $alt_visibility = get_lang('Hide'); $setNewStatus = 'invisible'; @@ -507,6 +509,10 @@ class AnnouncementManager ""; } $html .= ""; + } else { + if (false === $isVisible) { + api_not_allowed(true); + } } // The user id is always the current one. @@ -647,25 +653,22 @@ class AnnouncementManager $session = api_get_session_entity($sessionId); $group = api_get_group_entity(); + $em = Database::getManager(); + $announcement = new CAnnouncement(); $announcement ->setContent($newContent) ->setTitle($title) ->setEndDate(new DateTime($end_date)) ->setDisplayOrder($order) - ; - - $announcement + ->setParent($course) ->addCourseLink( $course, $session, $group ) - ->setParent($course) ; - $em = Database::getManager(); - $em->persist($announcement); $em->flush(); $last_id = $announcement->getIid(); @@ -2074,9 +2077,6 @@ class AnnouncementManager { // Maximum title messages to display $maximum = '12'; - // Database Table Definitions - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); - $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $session_id = api_get_session_id(); $courseInfo = api_get_course_info(); @@ -2124,18 +2124,19 @@ class AnnouncementManager $qb = $repo->getResourcesByCourse($course, $session, $group); $qb->select('count(resource)'); - $count = $qb->getQuery()->getSingleScalarResult(); - - return $count; + return $qb->getQuery()->getSingleScalarResult(); } } else { $user = api_get_user_entity($userId); + if (null === $user) { + return 0; + } + $qb = $repo->getResourcesByCourseLinkedToUser($user, $course, $session, $group); $qb->select('count(resource)'); - $count = $qb->getQuery()->getSingleScalarResult(); - return $count; + return $qb->getQuery()->getSingleScalarResult(); // students only get to see the visible announcements if (empty($_GET['origin']) || 'learnpath' !== $_GET['origin']) { diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php index 4fe997fd79..ff264c8480 100644 --- a/public/main/inc/lib/api.lib.php +++ b/public/main/inc/lib/api.lib.php @@ -2221,13 +2221,8 @@ function api_get_course_info($course_code = null) { if (!empty($course_code)) { $course = Container::getCourseRepository()->findOneByCode($course_code); - if (empty($course)) { - return []; - } - - $courseInfo = api_format_course_array($course); - return $courseInfo; + return api_format_course_array($course); } /*$course_code = Database::escape_string($course_code); @@ -2358,7 +2353,7 @@ function api_get_course_info_by_id($id = 0) * * @todo eradicate the false "id"=code field of the $_course array and use the int id */ -function api_format_course_array(Course $course) +function api_format_course_array(Course $course = null) { if (empty($course)) { return []; diff --git a/public/main/inc/lib/document.lib.php b/public/main/inc/lib/document.lib.php index 7fc8dbde0e..80acc5aaf9 100644 --- a/public/main/inc/lib/document.lib.php +++ b/public/main/inc/lib/document.lib.php @@ -1,4 +1,5 @@ getParent()) { + throw new \Exception('addCourseLink requires to set the parent.'); + } + $resourceLink = new ResourceLink(); $resourceLink ->setVisibility(ResourceLink::VISIBILITY_PUBLISHED) diff --git a/src/CoreBundle/Entity/GradebookCategory.php b/src/CoreBundle/Entity/GradebookCategory.php index 24461ac51b..1e32922705 100644 --- a/src/CoreBundle/Entity/GradebookCategory.php +++ b/src/CoreBundle/Entity/GradebookCategory.php @@ -277,12 +277,10 @@ class GradebookCategory * Set weight. * * @param float $weight - * - * @return GradebookCategory */ - public function setWeight($weight) + public function setWeight($weight): self { - $this->weight = $weight; + $this->weight = (float) $weight; return $this; } diff --git a/src/CoreBundle/Resources/config/services.yml b/src/CoreBundle/Resources/config/services.yml index 74137d7f44..cd3309df85 100644 --- a/src/CoreBundle/Resources/config/services.yml +++ b/src/CoreBundle/Resources/config/services.yml @@ -149,8 +149,7 @@ services: - {name: kernel.event_listener, event: kernel.controller, method: onKernelController} # Locale listener - chamilo_core.listener.locale: - class: Chamilo\CoreBundle\EventListener\LocaleListener + Chamilo\CoreBundle\EventListener\LocaleListener: arguments: ['%kernel.default_locale%', '@chamilo.settings.manager', '@parameter_bag'] tags: - {name: kernel.event_subscriber, priority: 15}

".$title."

$modify_icons