diff --git a/main/inc/ajax/course_home.ajax.php b/main/inc/ajax/course_home.ajax.php index 8cf18d82b4..1579d187ca 100755 --- a/main/inc/ajax/course_home.ajax.php +++ b/main/inc/ajax/course_home.ajax.php @@ -21,7 +21,7 @@ switch ($action) { $repository = $em->getRepository('ChamiloCourseBundle:CTool'); if (api_is_allowed_to_edit(null, true)) { $criteria = [ - 'cId' => $course_id, + 'course' => $course_id, 'sessionId' => 0, 'iid' => (int) $_GET['id'], ]; diff --git a/main/inc/lib/course_home.lib.php b/main/inc/lib/course_home.lib.php index aee9c540da..3e75a788b9 100755 --- a/main/inc/lib/course_home.lib.php +++ b/main/inc/lib/course_home.lib.php @@ -29,11 +29,12 @@ class CourseHome $all_tools = []; $course_id = api_get_course_int_id(); + $studentView = api_is_student_view_active(); switch ($cat) { case 'Basic': $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND t.position="basic" '; - if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') { + if ((api_is_coach() || api_is_course_tutor()) && !$studentView) { $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND @@ -265,10 +266,11 @@ class CourseHome $web_code_path = api_get_path(WEB_CODE_PATH); $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST); $course_id = api_get_course_int_id(); + $studentView = api_is_student_view_active(); switch ($course_tool_category) { case TOOL_PUBLIC: $condition_display_tools = ' WHERE c_id = '.$course_id.' AND visibility = 1 '; - if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') { + if ((api_is_coach() || api_is_course_tutor()) && !$studentView) { $condition_display_tools = ' WHERE c_id = '.$course_id.' AND (visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'")) '; @@ -509,6 +511,7 @@ class CourseHome ); $lpTable = Database::get_course_table(TABLE_LP_MAIN); + $studentView = api_is_student_view_active(); $orderBy = ' ORDER BY id '; switch ($course_tool_category) { @@ -516,7 +519,7 @@ class CourseHome $conditions = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") AND t.name <> "notebookteacher" '; - if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') { + if ((api_is_coach() || api_is_course_tutor()) && !$studentView) { $conditions = ' WHERE ( visibility = 1 AND ( category = "authoring" OR @@ -631,7 +634,7 @@ class CourseHome if ($allowEditionInSession && !empty($sessionId)) { // Checking if exist row in session $criteria = [ - 'cId' => $course_id, + 'course' => $course_id, 'name' => $temp_row['name'], 'sessionId' => $sessionId, ]; @@ -895,7 +898,7 @@ class CourseHome } } elseif ($allowEditionInSession) { $criteria = [ - 'cId' => api_get_course_int_id(), + 'course' => api_get_course_int_id(), 'name' => $tool['name'], 'sessionId' => $session_id, ]; diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 9a746c5bdf..3b8feb2609 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -4637,7 +4637,7 @@ class learnpath $tool = $em->createQuery(" SELECT t FROM ChamiloCourseBundle:CTool t WHERE - t.cId = :course AND + t.course = :course AND t.link = :link1 AND t.image = 'lp_category.gif' AND t.link LIKE :link2 @@ -4793,7 +4793,7 @@ class learnpath $tools = $em ->createQuery(" SELECT t FROM ChamiloCourseBundle:CTool t - WHERE t.cId = :course AND + WHERE t.course = :course AND t.name = :name AND t.image = 'lp_category.gif' AND t.link LIKE :link diff --git a/src/CourseBundle/Controller/Home/HomeController.php b/src/CourseBundle/Controller/Home/HomeController.php index fc6fee63d4..d8d7deeaae 100644 --- a/src/CourseBundle/Controller/Home/HomeController.php +++ b/src/CourseBundle/Controller/Home/HomeController.php @@ -229,9 +229,7 @@ class HomeController extends ToolBaseController public function iconListAction(Request $request) { $em = $this->getDoctrine()->getManager(); - $repo = $this->getDoctrine()->getRepository( - 'ChamiloCourseBundle:CTool' - ); + $repo = $this->getDoctrine()->getRepository('ChamiloCourseBundle:CTool'); $sessionId = intval($request->get('id_session')); $itemsFromSession = []; @@ -242,7 +240,7 @@ class HomeController extends ToolBaseController $query->where('s.cId = :courseId AND s.sessionId = :sessionId') ->setParameters( [ - 'courseId' => $this->getCourse()->getId(), + 'course' => $this->getCourse()->getId(), 'sessionId' => $sessionId, ] ); diff --git a/tests/scripts/fix_restored_learnpaths.php b/tests/scripts/fix_restored_learnpaths.php index 117e95d474..da05aa783a 100644 --- a/tests/scripts/fix_restored_learnpaths.php +++ b/tests/scripts/fix_restored_learnpaths.php @@ -15,7 +15,7 @@ $qb1 = $em->createQueryBuilder(); $result1 = $qb1 ->select('lp') ->from('ChamiloCourseBundle:CLp', 'lp') - ->innerJoin('ChamiloCourseBundle:CTool', 't', JOIN::WITH, 'lp.cId = t.cId AND lp.name = t.name') + ->innerJoin('ChamiloCourseBundle:CTool', 't', JOIN::WITH, 'lp.cId = t.course AND lp.name = t.name') ->where( $qb1->expr()->eq('t.link', ':link') ) @@ -37,7 +37,7 @@ foreach ($result1 as $i => $lp) { $qb2->expr()->andX( $qb2->expr()->eq('t.link', ':link'), $qb2->expr()->eq('t.name', ':name'), - $qb2->expr()->eq('t.cId', ':cid') + $qb2->expr()->eq('t.course', ':cid') ) ) ->setParameters([