|
|
|
@ -1,9 +1,12 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1); |
|
|
|
|
|
|
|
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
|
|
namespace Chamilo\LtiBundle\Controller; |
|
|
|
namespace Chamilo\LtiBundle\Controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Category; |
|
|
|
use Chamilo\CoreBundle\Controller\BaseController; |
|
|
|
use Chamilo\CoreBundle\Controller\BaseController; |
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
|
|
use Chamilo\CoreBundle\Entity\Session; |
|
|
|
use Chamilo\CoreBundle\Entity\Session; |
|
|
|
@ -12,15 +15,22 @@ use Chamilo\CourseBundle\Entity\CTool; |
|
|
|
use Chamilo\LtiBundle\Entity\ExternalTool; |
|
|
|
use Chamilo\LtiBundle\Entity\ExternalTool; |
|
|
|
use Chamilo\LtiBundle\Form\ExternalToolType; |
|
|
|
use Chamilo\LtiBundle\Form\ExternalToolType; |
|
|
|
use Chamilo\LtiBundle\Util\Utils; |
|
|
|
use Chamilo\LtiBundle\Util\Utils; |
|
|
|
|
|
|
|
use DateTime; |
|
|
|
|
|
|
|
use Display; |
|
|
|
|
|
|
|
use EvalForm; |
|
|
|
|
|
|
|
use Evaluation; |
|
|
|
|
|
|
|
use Exception; |
|
|
|
|
|
|
|
use HTML_QuickForm_select; |
|
|
|
|
|
|
|
use OAuthConsumer; |
|
|
|
|
|
|
|
use OAuthRequest; |
|
|
|
|
|
|
|
use OAuthSignatureMethod_HMAC_SHA1; |
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
|
|
|
|
|
|
use UserManager; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Class CourseController. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
class CourseController extends BaseController |
|
|
|
class CourseController extends BaseController |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -73,10 +83,14 @@ class CourseController extends BaseController |
|
|
|
'course' => $course, |
|
|
|
'course' => $course, |
|
|
|
'link' => $this->generateUrl( |
|
|
|
'link' => $this->generateUrl( |
|
|
|
'chamilo_lti_show', |
|
|
|
'chamilo_lti_show', |
|
|
|
['code' => $course->getCode(), 'id' => $tool->getId()] |
|
|
|
[ |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
'id' => $tool->getId(), |
|
|
|
|
|
|
|
] |
|
|
|
), |
|
|
|
), |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
if (empty($courseTool)) { |
|
|
|
if (empty($courseTool)) { |
|
|
|
throw $this->createNotFoundException('Course tool not found.'); |
|
|
|
throw $this->createNotFoundException('Course tool not found.'); |
|
|
|
@ -93,7 +107,10 @@ class CourseController extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute( |
|
|
|
return $this->redirectToRoute( |
|
|
|
'chamilo_lti_edit', |
|
|
|
'chamilo_lti_edit', |
|
|
|
['id' => $tool->getId(), 'code' => $course->getCode()] |
|
|
|
[ |
|
|
|
|
|
|
|
'id' => $tool->getId(), |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -105,7 +122,7 @@ class CourseController extends BaseController |
|
|
|
public function launchAction($id): Response |
|
|
|
public function launchAction($id): Response |
|
|
|
{ |
|
|
|
{ |
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
|
|
/** @var ExternalTool|null $tool */ |
|
|
|
/** @var null|ExternalTool $tool */ |
|
|
|
$tool = $em->find('ChamiloLtiBundle:ExternalTool', $id); |
|
|
|
$tool = $em->find('ChamiloLtiBundle:ExternalTool', $id); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($tool)) { |
|
|
|
if (empty($tool)) { |
|
|
|
@ -135,7 +152,9 @@ class CourseController extends BaseController |
|
|
|
$params['lti_message_type'] = 'ContentItemSelectionRequest'; |
|
|
|
$params['lti_message_type'] = 'ContentItemSelectionRequest'; |
|
|
|
$params['content_item_return_url'] = $this->generateUrl( |
|
|
|
$params['content_item_return_url'] = $this->generateUrl( |
|
|
|
'chamilo_lti_return_item', |
|
|
|
'chamilo_lti_return_item', |
|
|
|
['code' => $course->getCode()], |
|
|
|
[ |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
], |
|
|
|
UrlGeneratorInterface::ABSOLUTE_URL |
|
|
|
UrlGeneratorInterface::ABSOLUTE_URL |
|
|
|
); |
|
|
|
); |
|
|
|
$params['accept_media_types'] = '*/*'; |
|
|
|
$params['accept_media_types'] = '*/*'; |
|
|
|
@ -153,7 +172,12 @@ class CourseController extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($toolEval)) { |
|
|
|
if (!empty($toolEval)) { |
|
|
|
$params['lis_result_sourcedid'] = json_encode( |
|
|
|
$params['lis_result_sourcedid'] = json_encode( |
|
|
|
['e' => $toolEval->getId(), 'u' => $user->getId(), 'l' => uniqid(), 'lt' => time()] |
|
|
|
[ |
|
|
|
|
|
|
|
'e' => $toolEval->getId(), |
|
|
|
|
|
|
|
'u' => $user->getId(), |
|
|
|
|
|
|
|
'l' => uniqid(), |
|
|
|
|
|
|
|
'lt' => time(), |
|
|
|
|
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
$params['lis_outcome_service_url'] = api_get_path(WEB_PATH).'lti/os'; |
|
|
|
$params['lis_outcome_service_url'] = api_get_path(WEB_PATH).'lti/os'; |
|
|
|
/* $params['lis_outcome_service_url'] = $this->generateUrl( |
|
|
|
/* $params['lis_outcome_service_url'] = $this->generateUrl( |
|
|
|
@ -161,8 +185,8 @@ class CourseController extends BaseController |
|
|
|
[], |
|
|
|
[], |
|
|
|
UrlGeneratorInterface::ABSOLUTE_URL |
|
|
|
UrlGeneratorInterface::ABSOLUTE_URL |
|
|
|
); */ |
|
|
|
); */ |
|
|
|
$params['lis_person_sourcedid'] = "$institutionDomain:$toolUserId"; |
|
|
|
$params['lis_person_sourcedid'] = "{$institutionDomain}:{$toolUserId}"; |
|
|
|
$params['lis_course_section_sourcedid'] = "$institutionDomain:".$course->getId(); |
|
|
|
$params['lis_course_section_sourcedid'] = "{$institutionDomain}:".$course->getId(); |
|
|
|
|
|
|
|
|
|
|
|
if ($session) { |
|
|
|
if ($session) { |
|
|
|
$params['lis_course_section_sourcedid'] .= ':'.$session->getId(); |
|
|
|
$params['lis_course_section_sourcedid'] .= ':'.$session->getId(); |
|
|
|
@ -173,7 +197,7 @@ class CourseController extends BaseController |
|
|
|
$params['user_id'] = $toolUserId; |
|
|
|
$params['user_id'] = $toolUserId; |
|
|
|
|
|
|
|
|
|
|
|
if ($tool->isSharingPicture()) { |
|
|
|
if ($tool->isSharingPicture()) { |
|
|
|
$params['user_image'] = \UserManager::getUserPicture($user->getId()); |
|
|
|
$params['user_image'] = UserManager::getUserPicture($user->getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$params['roles'] = Utils::generateUserRoles($user); |
|
|
|
$params['roles'] = Utils::generateUserRoles($user); |
|
|
|
@ -223,14 +247,14 @@ class CourseController extends BaseController |
|
|
|
Utils::trimParams($params); |
|
|
|
Utils::trimParams($params); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($tool->getConsumerKey()) && !empty($tool->getSharedSecret())) { |
|
|
|
if (!empty($tool->getConsumerKey()) && !empty($tool->getSharedSecret())) { |
|
|
|
$consumer = new \OAuthConsumer( |
|
|
|
$consumer = new OAuthConsumer( |
|
|
|
$tool->getConsumerKey(), |
|
|
|
$tool->getConsumerKey(), |
|
|
|
$tool->getSharedSecret(), |
|
|
|
$tool->getSharedSecret(), |
|
|
|
null |
|
|
|
null |
|
|
|
); |
|
|
|
); |
|
|
|
$hmacMethod = new \OAuthSignatureMethod_HMAC_SHA1(); |
|
|
|
$hmacMethod = new OAuthSignatureMethod_HMAC_SHA1(); |
|
|
|
|
|
|
|
|
|
|
|
$request = \OAuthRequest::from_consumer_and_token( |
|
|
|
$request = OAuthRequest::from_consumer_and_token( |
|
|
|
$consumer, |
|
|
|
$consumer, |
|
|
|
'', |
|
|
|
'', |
|
|
|
'POST', |
|
|
|
'POST', |
|
|
|
@ -277,7 +301,9 @@ class CourseController extends BaseController |
|
|
|
$course = $this->getCourse(); |
|
|
|
$course = $this->getCourse(); |
|
|
|
$url = $this->generateUrl( |
|
|
|
$url = $this->generateUrl( |
|
|
|
'chamilo_lti_return_item', |
|
|
|
'chamilo_lti_return_item', |
|
|
|
['code' => $course->getCode()], |
|
|
|
[ |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
], |
|
|
|
UrlGeneratorInterface::ABSOLUTE_URL |
|
|
|
UrlGeneratorInterface::ABSOLUTE_URL |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
@ -297,7 +323,7 @@ class CourseController extends BaseController |
|
|
|
$supportedItemTypes = ['LtiLinkItem']; |
|
|
|
$supportedItemTypes = ['LtiLinkItem']; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($contentItems as $contentItem) { |
|
|
|
foreach ($contentItems as $contentItem) { |
|
|
|
if (!in_array($contentItem['@type'], $supportedItemTypes)) { |
|
|
|
if (!in_array($contentItem['@type'], $supportedItemTypes, true)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -316,7 +342,9 @@ class CourseController extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
return $this->render( |
|
|
|
return $this->render( |
|
|
|
'@ChamiloCore/Lti/item_return.html.twig', |
|
|
|
'@ChamiloCore/Lti/item_return.html.twig', |
|
|
|
['course' => $course] |
|
|
|
[ |
|
|
|
|
|
|
|
'course' => $course, |
|
|
|
|
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -331,7 +359,7 @@ class CourseController extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
|
|
|
|
|
|
|
|
|
|
/** @var ExternalTool|null $externalTool */ |
|
|
|
/** @var null|ExternalTool $externalTool */ |
|
|
|
$externalTool = $em->find('ChamiloLtiBundle:ExternalTool', $id); |
|
|
|
$externalTool = $em->find('ChamiloLtiBundle:ExternalTool', $id); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($externalTool)) { |
|
|
|
if (empty($externalTool)) { |
|
|
|
@ -348,7 +376,9 @@ class CourseController extends BaseController |
|
|
|
[ |
|
|
|
[ |
|
|
|
'uri' => $this->generateUrl( |
|
|
|
'uri' => $this->generateUrl( |
|
|
|
'chamilo_course_home_home_index', |
|
|
|
'chamilo_course_home_home_index', |
|
|
|
['course' => $course->getCode()] |
|
|
|
[ |
|
|
|
|
|
|
|
'course' => $course->getCode(), |
|
|
|
|
|
|
|
] |
|
|
|
), |
|
|
|
), |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
@ -358,7 +388,10 @@ class CourseController extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
return $this->render( |
|
|
|
return $this->render( |
|
|
|
'ChamiloCoreBundle:Lti:iframe.html.twig', |
|
|
|
'ChamiloCoreBundle:Lti:iframe.html.twig', |
|
|
|
['tool' => $externalTool, 'course' => $course] |
|
|
|
[ |
|
|
|
|
|
|
|
'tool' => $externalTool, |
|
|
|
|
|
|
|
'course' => $course, |
|
|
|
|
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -379,7 +412,10 @@ class CourseController extends BaseController |
|
|
|
$parentTool = null; |
|
|
|
$parentTool = null; |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($id)) { |
|
|
|
if (!empty($id)) { |
|
|
|
$parentTool = $repo->findOneBy(['id' => $id, 'course' => null]); |
|
|
|
$parentTool = $repo->findOneBy([ |
|
|
|
|
|
|
|
'id' => $id, |
|
|
|
|
|
|
|
'course' => null, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($parentTool)) { |
|
|
|
if (empty($parentTool)) { |
|
|
|
throw $this->createNotFoundException('External tool not found'); |
|
|
|
throw $this->createNotFoundException('External tool not found'); |
|
|
|
@ -400,15 +436,18 @@ class CourseController extends BaseController |
|
|
|
if (!$form->isSubmitted() || !$form->isValid()) { |
|
|
|
if (!$form->isSubmitted() || !$form->isValid()) { |
|
|
|
$this->setConfigureBreadcrumb($course); |
|
|
|
$this->setConfigureBreadcrumb($course); |
|
|
|
|
|
|
|
|
|
|
|
$categories = \Category::load(null, null, $course->getCode()); |
|
|
|
$categories = Category::load(null, null, $course->getCode()); |
|
|
|
$actions = ''; |
|
|
|
$actions = ''; |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($categories)) { |
|
|
|
if (!empty($categories)) { |
|
|
|
$actions .= \Display::url( |
|
|
|
$actions .= Display::url( |
|
|
|
\Display::return_icon('gradebook.png', get_lang('Add to gradebook'), [], ICON_SIZE_MEDIUM), |
|
|
|
Display::return_icon('gradebook.png', get_lang('Add to gradebook'), [], ICON_SIZE_MEDIUM), |
|
|
|
$this->generateUrl( |
|
|
|
$this->generateUrl( |
|
|
|
'chamilo_lti_grade', |
|
|
|
'chamilo_lti_grade', |
|
|
|
['catId' => $categories[0]->get_id(), 'code' => $course->getCode()] |
|
|
|
[ |
|
|
|
|
|
|
|
'catId' => $categories[0]->get_id(), |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
] |
|
|
|
) |
|
|
|
) |
|
|
|
//'./gradebook/add_eval.php?selectcat='.$categories[0]->get_id().'&'.api_get_cidreq() |
|
|
|
//'./gradebook/add_eval.php?selectcat='.$categories[0]->get_id().'&'.api_get_cidreq() |
|
|
|
); |
|
|
|
); |
|
|
|
@ -418,8 +457,13 @@ class CourseController extends BaseController |
|
|
|
'@ChamiloCore/Lti/course_configure.twig', |
|
|
|
'@ChamiloCore/Lti/course_configure.twig', |
|
|
|
[ |
|
|
|
[ |
|
|
|
'title' => $this->trans('Add external tool'), |
|
|
|
'title' => $this->trans('Add external tool'), |
|
|
|
'added_tools' => $repo->findBy(['course' => $course]), |
|
|
|
'added_tools' => $repo->findBy([ |
|
|
|
'global_tools' => $repo->findBy(['parent' => null, 'course' => null]), |
|
|
|
'course' => $course, |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
'global_tools' => $repo->findBy([ |
|
|
|
|
|
|
|
'parent' => null, |
|
|
|
|
|
|
|
'course' => null, |
|
|
|
|
|
|
|
]), |
|
|
|
'form' => $form->createView(), |
|
|
|
'form' => $form->createView(), |
|
|
|
'course' => $course, |
|
|
|
'course' => $course, |
|
|
|
'actions' => $actions, |
|
|
|
'actions' => $actions, |
|
|
|
@ -448,22 +492,30 @@ class CourseController extends BaseController |
|
|
|
->setLink( |
|
|
|
->setLink( |
|
|
|
$this->generateUrl( |
|
|
|
$this->generateUrl( |
|
|
|
'chamilo_lti_show', |
|
|
|
'chamilo_lti_show', |
|
|
|
['code' => $course->getCode(), 'id' => $tool->getId()] |
|
|
|
[ |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
'id' => $tool->getId(), |
|
|
|
|
|
|
|
] |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
$em->persist($courseTool); |
|
|
|
$em->persist($courseTool); |
|
|
|
$em->flush(); |
|
|
|
$em->flush(); |
|
|
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute( |
|
|
|
return $this->redirectToRoute( |
|
|
|
'chamilo_course_home_home_index', |
|
|
|
'chamilo_course_home_home_index', |
|
|
|
['course' => $course->getCode()] |
|
|
|
[ |
|
|
|
|
|
|
|
'course' => $course->getCode(), |
|
|
|
|
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute( |
|
|
|
return $this->redirectToRoute( |
|
|
|
'chamilo_lti_configure', |
|
|
|
'chamilo_lti_configure', |
|
|
|
['course' => $course->getCode()] |
|
|
|
[ |
|
|
|
|
|
|
|
'course' => $course->getCode(), |
|
|
|
|
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -474,7 +526,7 @@ class CourseController extends BaseController |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $catId |
|
|
|
* @param string $catId |
|
|
|
* |
|
|
|
* |
|
|
|
* @throws \Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function gradeAction($catId) |
|
|
|
public function gradeAction($catId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -484,13 +536,13 @@ class CourseController extends BaseController |
|
|
|
/** @var User $user */ |
|
|
|
/** @var User $user */ |
|
|
|
$user = $this->getUser(); |
|
|
|
$user = $this->getUser(); |
|
|
|
|
|
|
|
|
|
|
|
$categories = \Category::load(null, null, $course->getCode()); |
|
|
|
$categories = Category::load(null, null, $course->getCode()); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($categories)) { |
|
|
|
if (empty($categories)) { |
|
|
|
throw $this->createNotFoundException(); |
|
|
|
throw $this->createNotFoundException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$evaladd = new \Evaluation(); |
|
|
|
$evaladd = new Evaluation(); |
|
|
|
$evaladd->set_user_id($user->getId()); |
|
|
|
$evaladd->set_user_id($user->getId()); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($catId)) { |
|
|
|
if (!empty($catId)) { |
|
|
|
@ -500,25 +552,31 @@ class CourseController extends BaseController |
|
|
|
$evaladd->set_category_id(0); |
|
|
|
$evaladd->set_category_id(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$form = new \EvalForm( |
|
|
|
$form = new EvalForm( |
|
|
|
\EvalForm::TYPE_ADD, |
|
|
|
EvalForm::TYPE_ADD, |
|
|
|
$evaladd, |
|
|
|
$evaladd, |
|
|
|
null, |
|
|
|
null, |
|
|
|
'add_eval_form', |
|
|
|
'add_eval_form', |
|
|
|
null, |
|
|
|
null, |
|
|
|
$this->generateUrl( |
|
|
|
$this->generateUrl( |
|
|
|
'chamilo_lti_grade', |
|
|
|
'chamilo_lti_grade', |
|
|
|
['catId' => $catId, 'code' => $course->getCode()] |
|
|
|
[ |
|
|
|
|
|
|
|
'catId' => $catId, |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
] |
|
|
|
).'?'.api_get_cidreq() |
|
|
|
).'?'.api_get_cidreq() |
|
|
|
); |
|
|
|
); |
|
|
|
$form->removeElement('name'); |
|
|
|
$form->removeElement('name'); |
|
|
|
$form->removeElement('addresult'); |
|
|
|
$form->removeElement('addresult'); |
|
|
|
/** @var \HTML_QuickForm_select $slcLtiTools */ |
|
|
|
/** @var HTML_QuickForm_select $slcLtiTools */ |
|
|
|
$slcLtiTools = $form->createElement('select', 'name', $this->trans('External tool')); |
|
|
|
$slcLtiTools = $form->createElement('select', 'name', $this->trans('External tool')); |
|
|
|
$form->insertElementBefore($slcLtiTools, 'hid_category_id'); |
|
|
|
$form->insertElementBefore($slcLtiTools, 'hid_category_id'); |
|
|
|
$form->addRule('name', get_lang('Required field'), 'required'); |
|
|
|
$form->addRule('name', get_lang('Required field'), 'required'); |
|
|
|
|
|
|
|
|
|
|
|
$tools = $toolRepo->findBy(['course' => $course, 'gradebookEval' => null]); |
|
|
|
$tools = $toolRepo->findBy([ |
|
|
|
|
|
|
|
'course' => $course, |
|
|
|
|
|
|
|
'gradebookEval' => null, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
/** @var ExternalTool $tool */ |
|
|
|
/** @var ExternalTool $tool */ |
|
|
|
foreach ($tools as $tool) { |
|
|
|
foreach ($tools as $tool) { |
|
|
|
@ -544,7 +602,7 @@ class CourseController extends BaseController |
|
|
|
throw $this->createNotFoundException(); |
|
|
|
throw $this->createNotFoundException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$eval = new \Evaluation(); |
|
|
|
$eval = new Evaluation(); |
|
|
|
$eval->set_name($tool->getName()); |
|
|
|
$eval->set_name($tool->getName()); |
|
|
|
$eval->set_description($values['description']); |
|
|
|
$eval->set_description($values['description']); |
|
|
|
$eval->set_user_id($values['hid_user_id']); |
|
|
|
$eval->set_user_id($values['hid_user_id']); |
|
|
|
@ -575,7 +633,7 @@ class CourseController extends BaseController |
|
|
|
return $this->redirect(api_get_course_url()); |
|
|
|
return $this->redirect(api_get_course_url()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function setConfigureBreadcrumb(Course $course) |
|
|
|
private function setConfigureBreadcrumb(Course $course): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$breadcrumb = $this->get('chamilo_core.block.breadcrumb'); |
|
|
|
$breadcrumb = $this->get('chamilo_core.block.breadcrumb'); |
|
|
|
$breadcrumb->addChild( |
|
|
|
$breadcrumb->addChild( |
|
|
|
@ -583,7 +641,9 @@ class CourseController extends BaseController |
|
|
|
[ |
|
|
|
[ |
|
|
|
'uri' => $this->generateUrl( |
|
|
|
'uri' => $this->generateUrl( |
|
|
|
'chamilo_course_home_home_index', |
|
|
|
'chamilo_course_home_home_index', |
|
|
|
['course' => $course->getCode()] |
|
|
|
[ |
|
|
|
|
|
|
|
'course' => $course->getCode(), |
|
|
|
|
|
|
|
] |
|
|
|
), |
|
|
|
), |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
@ -598,12 +658,12 @@ class CourseController extends BaseController |
|
|
|
User $user, |
|
|
|
User $user, |
|
|
|
Course $course, |
|
|
|
Course $course, |
|
|
|
Session $session = null |
|
|
|
Session $session = null |
|
|
|
) { |
|
|
|
): void { |
|
|
|
$replaceable = self::getReplaceableVariables($user, $course, $session); |
|
|
|
$replaceable = self::getReplaceableVariables($user, $course, $session); |
|
|
|
$variables = array_keys($replaceable); |
|
|
|
$variables = array_keys($replaceable); |
|
|
|
|
|
|
|
|
|
|
|
foreach ($customParams as $customKey => $customValue) { |
|
|
|
foreach ($customParams as $customKey => $customValue) { |
|
|
|
if (!in_array($customValue, $variables)) { |
|
|
|
if (!in_array($customValue, $variables, true)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -616,9 +676,8 @@ class CourseController extends BaseController |
|
|
|
$customParams[$customKey] = $params[$val]; |
|
|
|
$customParams[$customKey] = $params[$val]; |
|
|
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
|
|
|
|
$val = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$val = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (false === $val) { |
|
|
|
if (false === $val) { |
|
|
|
@ -656,14 +715,16 @@ class CourseController extends BaseController |
|
|
|
'$Person.address.statepr' => false, |
|
|
|
'$Person.address.statepr' => false, |
|
|
|
'$Person.address.country' => false, |
|
|
|
'$Person.address.country' => false, |
|
|
|
'$Person.address.postcode' => false, |
|
|
|
'$Person.address.postcode' => false, |
|
|
|
'$Person.address.timezone' => false, //$user->getTimezone(), |
|
|
|
'$Person.address.timezone' => false, |
|
|
|
|
|
|
|
//$user->getTimezone(), |
|
|
|
'$Person.phone.mobile' => false, |
|
|
|
'$Person.phone.mobile' => false, |
|
|
|
'$Person.phone.primary' => $user->getPhone(), |
|
|
|
'$Person.phone.primary' => $user->getPhone(), |
|
|
|
'$Person.phone.home' => false, |
|
|
|
'$Person.phone.home' => false, |
|
|
|
'$Person.phone.work' => false, |
|
|
|
'$Person.phone.work' => false, |
|
|
|
'$Person.email.primary' => $user->getEmail(), |
|
|
|
'$Person.email.primary' => $user->getEmail(), |
|
|
|
'$Person.email.personal' => false, |
|
|
|
'$Person.email.personal' => false, |
|
|
|
'$Person.webaddress' => false, //$user->getWebsite(), |
|
|
|
'$Person.webaddress' => false, |
|
|
|
|
|
|
|
//$user->getWebsite(), |
|
|
|
'$Person.sms' => false, |
|
|
|
'$Person.sms' => false, |
|
|
|
|
|
|
|
|
|
|
|
'$CourseTemplate.sourcedId' => false, |
|
|
|
'$CourseTemplate.sourcedId' => false, |
|
|
|
@ -696,10 +757,10 @@ class CourseController extends BaseController |
|
|
|
'$CourseSection.numberofStudents' => false, |
|
|
|
'$CourseSection.numberofStudents' => false, |
|
|
|
'$CourseSection.dept' => false, |
|
|
|
'$CourseSection.dept' => false, |
|
|
|
'$CourseSection.timeFrame.begin' => $session && $session->getDisplayStartDate() |
|
|
|
'$CourseSection.timeFrame.begin' => $session && $session->getDisplayStartDate() |
|
|
|
? $session->getDisplayStartDate()->format(\DateTime::ATOM) |
|
|
|
? $session->getDisplayStartDate()->format(DateTime::ATOM) |
|
|
|
: false, |
|
|
|
: false, |
|
|
|
'$CourseSection.timeFrame.end' => $session && $session->getDisplayEndDate() |
|
|
|
'$CourseSection.timeFrame.end' => $session && $session->getDisplayEndDate() |
|
|
|
? $session->getDisplayEndDate()->format(\DateTime::ATOM) |
|
|
|
? $session->getDisplayEndDate()->format(DateTime::ATOM) |
|
|
|
: false, |
|
|
|
: false, |
|
|
|
'$CourseSection.enrollControl.accept' => false, |
|
|
|
'$CourseSection.enrollControl.accept' => false, |
|
|
|
'$CourseSection.enrollControl.allowed' => false, |
|
|
|
'$CourseSection.enrollControl.allowed' => false, |
|
|
|
@ -792,9 +853,13 @@ class CourseController extends BaseController |
|
|
|
->setLink( |
|
|
|
->setLink( |
|
|
|
$this->generateUrl( |
|
|
|
$this->generateUrl( |
|
|
|
'chamilo_lti_show', |
|
|
|
'chamilo_lti_show', |
|
|
|
['code' => $course->getCode(), 'id' => $newTool->getId()] |
|
|
|
[ |
|
|
|
|
|
|
|
'code' => $course->getCode(), |
|
|
|
|
|
|
|
'id' => $newTool->getId(), |
|
|
|
|
|
|
|
] |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
$em->persist($courseTool); |
|
|
|
$em->persist($courseTool); |
|
|
|
$em->flush(); |
|
|
|
$em->flush(); |
|
|
|
|