Fix entity annotations, fix LP CRUD

pull/3844/head
Julio Montoya 5 years ago
parent 493da3a670
commit d89cdc38b5
  1. 16
      public/main/inc/ajax/lp.ajax.php
  2. 10
      public/main/inc/lib/tracking.lib.php
  3. 12
      public/main/lp/learnpath.class.php
  4. 1
      public/main/lp/learnpathList.class.php
  5. 8
      public/main/lp/lp_controller.php
  6. 2
      src/CourseBundle/Entity/CLpItem.php

@ -10,11 +10,13 @@ require_once __DIR__.'/../global.inc.php';
api_protect_course_script(true);
$debug = false;
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$action = $_REQUEST['a'] ?? '';
$lpId = $_REQUEST['lp_id'] ?? 0;
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
switch ($action) {
case 'get_lp_list_by_course':
$course_id = (isset($_GET['course_id']) && !empty($_GET['course_id'])) ? (int) $_GET['course_id'] : 0;
@ -37,7 +39,6 @@ switch ($action) {
if (empty($folderId)) {
exit;
}
$lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : false;
$url = isset($_GET['url']) ? $_GET['url'] : '';
$addMove = isset($_GET['add_move_button']) && 1 == $_GET['add_move_button'] ? true : false;
@ -60,8 +61,15 @@ switch ($action) {
exit;
}
$lpRepo = Container::getLpRepository();
$lp = $lpRepo->find($lpId);
if (null === $lp) {
exit;
}
/** @var learnpath $learningPath */
$learningPath = Session::read('oLP');
//$learningPath = learnpath::read('oLP');
$learningPath = new learnpath($lp, api_get_course_info(), api_get_user_id());
if ($learningPath) {
$learningPath->set_modified_on();
$title = $_REQUEST['title'] ?? '';
@ -89,7 +97,7 @@ switch ($action) {
$type,
$id,
$title,
null
''
);
echo $learningPath->returnLpItemList(null);

@ -369,11 +369,10 @@ class Tracking
path
FROM $TBL_LP_ITEM as i
INNER JOIN $TBL_LP_ITEM_VIEW as iv
ON (i.iid = iv.lp_item_id AND i.c_id = iv.c_id)
ON (i.iid = iv.lp_item_id)
INNER JOIN $TBL_LP_VIEW as v
ON (iv.lp_view_id = v.iid AND v.c_id = iv.c_id)
ON (iv.lp_view_id = v.iid)
WHERE
v.c_id = $course_id AND
i.iid = $my_item_id AND
i.lp_id = $lp_id AND
v.user_id = $user_id AND
@ -810,7 +809,6 @@ class Tracking
$sql = "SELECT iid, score
FROM $TBL_LP_ITEM_VIEW
WHERE
c_id = $course_id AND
lp_item_id = '".(int) $my_id."' AND
lp_view_id = '".(int) $my_lp_view_id."'
ORDER BY view_count DESC
@ -821,7 +819,6 @@ class Tracking
$sql = "SELECT SUM(total_time) as total_time
FROM $TBL_LP_ITEM_VIEW
WHERE
c_id = $course_id AND
lp_item_id = '".(int) $my_id."' AND
lp_view_id = '".(int) $my_lp_view_id."'";
$res_time = Database::query($sql);
@ -842,7 +839,7 @@ class Tracking
question_id, marks, ponderation
FROM $tbl_stats_attempts as at
INNER JOIN $tbl_quiz_questions as q
ON (q.iid = at.question_id AND q.c_id = $course_id)
ON (q.iid = at.question_id)
WHERE exe_id ='$id_last_attempt'
) as t";
@ -1095,7 +1092,6 @@ class Tracking
) {
$sql = "SELECT path FROM $TBL_LP_ITEM
WHERE
c_id = $course_id AND
iid = '$lp_item_id' AND
lp_id = '$lp_id'";
$res_path = Database::query($sql);

@ -2166,7 +2166,7 @@ class learnpath
);*/
$visibility = $lp->isVisible($course, $session);
var_dump($visibility);
// If the item was deleted.
if (false === $visibility) {
return false;
@ -2176,11 +2176,15 @@ class learnpath
if ($lp->hasCategory()) {
$category = $lp->getCategory();
if (false === self::categoryIsVisibleForStudent($category, api_get_user_entity($student_id), $course, $session)) {
if (false === self::categoryIsVisibleForStudent(
$category,
api_get_user_entity($student_id),
$course,
$session
)) {
return false;
}
$prerequisite = $lp->getPrerequisite();
$is_visible = true;
@ -2273,7 +2277,7 @@ class learnpath
return $is_visible;
}
return false;
return true;
}
/**

@ -129,7 +129,6 @@ class LearnpathList
$user_id,
$course
);
var_dump($lpVisibility);
if (false === $lpVisibility) {
continue;
}

@ -54,7 +54,11 @@ $(window).on("load", function () {
setFocus();
});
</script>';
$ajax_url = api_get_path(WEB_AJAX_PATH).'lp.ajax.php?'.api_get_cidreq();
$lpItemId = $_REQUEST['id'] ?? 0;
$lpId = $_REQUEST['lp_id'] ?? 0;
$ajax_url = api_get_path(WEB_AJAX_PATH).'lp.ajax.php?lp_id='.(int) $lpId.'&'.api_get_cidreq();
$listUrl = api_get_self().'?action=list&'.api_get_cidreq();
$htmlHeadXtra[] = '
<script>
@ -317,8 +321,6 @@ if (!empty($lpObject)) {
}
}
$lpItemId = $_REQUEST['id'] ?? 0;
$lpId = $_REQUEST['lp_id'] ?? 0;
$lpItem = null;
$lp = null;
if (!empty($lpItemId)) {

@ -30,7 +30,7 @@ class CLpItem
protected ?int $iid = null;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="items")
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="items", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="lp_id", referencedColumnName="iid")
*/
protected CLp $lp;

Loading…
Cancel
Save