From 0982dfe25f4607a21787a7e57a0d1c8af4076b0f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 22 Aug 2018 08:36:21 +0200 Subject: [PATCH] Minor - fix course creation when using bbb plugin --- main/inc/lib/plugin.class.php | 5 ++-- main/lp/learnpath.class.php | 8 +++++-- plugin/ims_lti/ImsLtiPlugin.php | 2 +- src/CourseBundle/Entity/CTool.php | 39 +++++-------------------------- src/CourseBundle/ToolChain.php | 2 +- 5 files changed, 16 insertions(+), 40 deletions(-) diff --git a/main/inc/lib/plugin.class.php b/main/inc/lib/plugin.class.php index 847016ef00..ac8de4bb21 100755 --- a/main/inc/lib/plugin.class.php +++ b/main/inc/lib/plugin.class.php @@ -963,17 +963,16 @@ class Plugin ->getRepository('ChamiloCourseBundle:CTool') ->findOneBy([ 'name' => $name, - 'cId' => $courseId, + 'course' => $courseId, ]); if (!$tool) { $cToolId = AddCourse::generateToolId($courseId); $pluginName = $this->get_name(); - $tool = new CTool(); $tool ->setId($cToolId) - ->setCId($courseId) + ->setCourse(api_get_course_entity($courseId)) ->setName($name.$visibilityPerStatus) ->setLink($link ?: "$pluginName/start.php") ->setImage($iconName ?: "$pluginName.png") diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index d4abbee908..9a746c5bdf 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -4627,6 +4627,10 @@ class learnpath return false; } + if (empty($courseId)) { + return false; + } + $link = self::getCategoryLinkForTool($id); /** @var CTool $tool */ @@ -4640,7 +4644,7 @@ class learnpath $sessionCondition ") ->setParameters([ - 'course' => (int) $courseId, + 'course' => $courseId, 'link1' => $link, 'link2' => "$link%", ]) @@ -4657,7 +4661,7 @@ class learnpath $tool = new CTool(); $tool ->setCategory('authoring') - ->setCId($courseId) + ->setCourse(api_get_course_entity($courseId)) ->setName(strip_tags($category->getName())) ->setLink($link) ->setImage('lp_category.gif') diff --git a/plugin/ims_lti/ImsLtiPlugin.php b/plugin/ims_lti/ImsLtiPlugin.php index d5e6dc03d0..28aa3c8364 100644 --- a/plugin/ims_lti/ImsLtiPlugin.php +++ b/plugin/ims_lti/ImsLtiPlugin.php @@ -196,7 +196,7 @@ class ImsLtiPlugin extends Plugin $em = Database::getManager(); $cTool = new CTool(); $cTool - ->setCId($course->getId()) + ->setCourse($course) ->setName($tool->getName()) ->setLink($this->get_name().'/start.php?'.http_build_query(['id' => $tool->getId()])) ->setImage($this->get_name().'.png') diff --git a/src/CourseBundle/Entity/CTool.php b/src/CourseBundle/Entity/CTool.php index d2b49e3834..b946f05734 100644 --- a/src/CourseBundle/Entity/CTool.php +++ b/src/CourseBundle/Entity/CTool.php @@ -40,13 +40,6 @@ class CTool */ protected $id; - /** - * @var int - * - * @ORM\Column(name="c_id", type="integer") - */ - protected $cId; - /** * @var string * @@ -172,16 +165,20 @@ class CTool /** * @param Course $course + * + * @return $this */ - public function setCourse($course) + public function setCourse(Course $course) { $this->course = $course; + + return $this; } /** * @return Course */ - public function getCourse() + public function getCourse(): Course { return $this->course; } @@ -466,30 +463,6 @@ class CTool return $this->id; } - /** - * Set cId. - * - * @param int $cId - * - * @return CTool - */ - public function setCId($cId) - { - $this->cId = $cId; - - return $this; - } - - /** - * Get cId. - * - * @return int - */ - public function getCId() - { - return $this->cId; - } - /** * @return string */ diff --git a/src/CourseBundle/ToolChain.php b/src/CourseBundle/ToolChain.php index 58492f49b5..e31c09124b 100644 --- a/src/CourseBundle/ToolChain.php +++ b/src/CourseBundle/ToolChain.php @@ -121,7 +121,7 @@ class ToolChain $visibility = in_array($tool->getName(), $toolVisibility) ? true : false; $toolEntity - ->setCId($course->getId()) + ->setCourse($course) ->setImage($tool->getImage()) ->setName($tool->getName()) ->setVisibility($visibility)