Merge branch 'master' of github.com:chamilo/chamilo-lms

pull/4004/head
Yannick Warnier 3 years ago
commit 394578957f
  1. 2
      public/main/lp/learnpathList.class.php
  2. 20
      src/CoreBundle/Entity/AbstractResource.php
  3. 17
      tests/CoreBundle/Controller/CourseControllerTest.php

@ -119,7 +119,7 @@ class LearnpathList
$lp->getId(),
$session_id
);*/
$visibility = $lp->isVisible($course, $session);
$visibility = $lp->isVisible($course);
// If option is not true then don't show invisible LP to user
if (false === $ignoreLpVisibility) {

@ -410,6 +410,12 @@ abstract class AbstractResource
public function isVisible(Course $course, Session $session = null): bool
{
$link = $this->getFirstResourceLinkFromCourseSession($course, $session);
if (null === $link) {
if ((new ReflectionClass($this))->hasProperty('loadCourseResourcesInSession')) {
$link = $this->getFirstResourceLinkFromCourseSession($course);
}
}
if (null === $link) {
return false;
}
@ -435,19 +441,7 @@ abstract class AbstractResource
$found = false;
$link = null;
foreach ($links as $link) {
if (null === $session) {
$found = $link->getCourse() === $course;
break;
}
if ((new ReflectionClass($this))->hasProperty('loadCourseResourcesInSession')) {
$found = $link->getSession() === $session || null === $link->getSession();
break;
}
if ($link->getSession() === $session) {
if ($link->getCourse() === $course && $link->getSession() === $session) {
$found = true;
break;

@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\Tests\CoreBundle\Controller;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
use Chamilo\CourseBundle\Entity\CCourseDescription;
use Chamilo\CourseBundle\Settings\SettingsCourseManager;
use Chamilo\Tests\ChamiloTestTrait;
@ -48,14 +49,20 @@ class CourseControllerTest extends WebTestCase
'/course/'.$course->getId().'/home.json'
);
$this->assertResponseIsSuccessful();
}
// Course is REGISTERED.
$course = $this->getCourse($course->getId());
public function testIndexJsonWithAccessRegistered()
{
$client = static::createClient();
$em = $this->getEntityManager();
$courseRepo = self::getContainer()->get(CourseRepository::class);
$course = $this->createCourse('course with acess for registered users');
$course->setVisibility(Course::REGISTERED);
$em->persist($course);
$em->flush();
$courseRepo->update($course);
$userTest1 = $this->createUser('test1');
$client->loginUser($userTest1);
$client->request(
'GET',

Loading…
Cancel
Save