Use "course" URL instead of "courses"

pull/3064/head
Julio 5 years ago
parent df731ba2d3
commit c189f77c7a
  1. 2
      config/packages/sonata_page.yaml
  2. 2
      src/CoreBundle/Controller/CourseController.php
  3. 73
      src/CoreBundle/Controller/CourseHomeController.php
  4. 13
      src/CourseBundle/Resources/config/routing.yml
  5. 2
      src/LtiBundle/Resources/config/routing.yml

@ -17,7 +17,7 @@ sonata_page:
- ^/admin(.*) # chamilo admin
- ^/api/(.*)
- ^/contact(.*) # sonata admin
- ^/courses/(.*)
- ^/course/(.*)
- ^/connect/(.*)
- ^/editor/(.*)
- ^/login/(.*)

@ -19,7 +19,7 @@ use UserManager;
/**
* Class CourseController.
*
* @Route("/courses")
* @Route("/course")
*/
class CourseController extends AbstractController
{

@ -3,9 +3,11 @@
namespace Chamilo\CoreBundle\Controller;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\ToolChain;
use Chamilo\CourseBundle\Controller\ToolBaseController;
use Chamilo\CourseBundle\Entity\CTool;
use Chamilo\CourseBundle\Manager\SettingsManager;
use Chamilo\CourseBundle\Repository\CToolRepository;
use Chamilosession as Session;
use CourseManager;
@ -15,16 +17,19 @@ use Event;
use ExtraFieldValue;
use Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Exception\ValidatorException;
/**
* Class CourseHomeController.
*
* @author Julio Montoya <gugli100@gmail.com>
*
* @Route("/courses")
* @Route("/course")
*/
class CourseHomeController extends ToolBaseController
{
@ -381,4 +386,70 @@ class CourseHomeController extends ToolBaseController
));
}
}
/**
* Edit configuration with given namespace.
*
* @param string $namespace
* @Route("/{cid}/settings/{namespace}", name="chamilo_core_course_settings")
* @Entity("course", expr="repository.find(cid)")
*
*
* @return Response
*/
public function updateAction(Request $request, Course $course, $namespace, SettingsManager $manager, SettingsFormFactory $formFactory)
{
$schemaAlias = $manager->convertNameSpaceToService($namespace);
$settings = $manager->load($namespace);
$form = $formFactory->create($schemaAlias);
$form->setData($settings);
if ($form->handleRequest($request)->isValid()) {
$messageType = 'success';
try {
$manager->setCourse($course);
$manager->saveSettings($namespace, $form->getData());
$message = $this->trans(
'sylius.settings.update',
[],
'flashes'
);
} catch (ValidatorException $exception) {
$message = $this->trans(
$exception->getMessage(),
[],
'validators'
);
$messageType = 'error';
}
$request->getSession()->getBag('flashes')->add(
$messageType,
$message
);
if ($request->headers->has('referer')) {
return $this->redirect($request->headers->get('referer'));
}
}
$schemas = $manager->getSchemas();
return $this->render(
$request->attributes->get(
'template',
'ChamiloCourseBundle:Settings:update.html.twig'
),
[
'course' => $course,
'schemas' => $schemas,
'settings' => $settings,
'form' => $form->createView(),
'keyword' => '',
'search_form' => '',
]
);
}
}

@ -1,13 +0,0 @@
#chamilo_course.c_tool_intro:
# resource: |
# alias: chamilo_course.c_tool_intro
# path: /courses/{course}/introduction/{tool}
# templates: :Admin/Book
# type: sylius.resource_api
# Course settings
#chamilo_course_settings:
# path: /course/{cid}/settings/{namespace}
# defaults:
# _controller: Chamilo\CourseBundle\Controller\SettingsController::updateAction
# template: ChamiloCourseBundle:Settings:default.html.twig

@ -6,7 +6,7 @@ chamilo_lti_admin_controller:
chamilo_lti_teacher_controller:
resource: '@ChamiloLtiBundle/Controller/CourseController.php'
type: annotation
prefix: '/lti/courses/{code}/lti'
prefix: '/lti/course/{code}/lti'
chamilo_lti_service_controller:
path: /lti/os

Loading…
Cancel
Save