Minor - fix query use course instead of c_id for entity CTool

pull/2650/head
Julio Montoya 6 years ago
parent 34bdad759e
commit 05374f9d0c
  1. 2
      main/inc/ajax/course_home.ajax.php
  2. 13
      main/inc/lib/course_home.lib.php
  3. 4
      main/lp/learnpath.class.php
  4. 6
      src/CourseBundle/Controller/Home/HomeController.php
  5. 4
      tests/scripts/fix_restored_learnpaths.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'],
];

@ -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,
];

@ -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

@ -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,
]
);

@ -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([

Loading…
Cancel
Save