|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
namespace Chamilo\CoreBundle\Controller; |
|
5
|
|
|
|
|
6
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
7
|
|
|
use Chamilo\CoreBundle\Form\Type\CourseType; |
|
8
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity; |
|
9
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; |
|
10
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
11
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
14
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class CourseController. |
|
18
|
|
|
* |
|
19
|
|
|
* @Route("/courses") |
|
20
|
|
|
*/ |
|
21
|
|
|
class CourseController extends AbstractController |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @Route("/add") |
|
25
|
|
|
* |
|
26
|
|
|
* @Security("has_role('ROLE_TEACHER')") |
|
27
|
|
|
* |
|
28
|
|
|
* @return Response |
|
29
|
|
|
*/ |
|
30
|
|
|
public function addAction(Request $request) |
|
31
|
|
|
{ |
|
32
|
|
|
$form = $this->createForm(new CourseType()); |
|
33
|
|
|
|
|
34
|
|
|
$form->handleRequest($request); |
|
35
|
|
|
|
|
36
|
|
|
if ($form->isValid()) { |
|
37
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
38
|
|
|
$course = $form->getData(); |
|
39
|
|
|
$em->persist($course); |
|
40
|
|
|
$em->flush(); |
|
41
|
|
|
|
|
42
|
|
|
$this->addFlash('sonata_flash_success', 'Course created'); |
|
43
|
|
|
|
|
44
|
|
|
return $this->redirectToRoute( |
|
45
|
|
|
'chamilo_core_course_welcome', |
|
46
|
|
|
['cid' => $course->getId()] |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/*return [ |
|
51
|
|
|
'form' => $form->createView(), |
|
52
|
|
|
];*/ |
|
53
|
|
|
//return $this->render('ChamiloThemeBundle:Default:index.html.twig'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @Route("/{courseCode}", name="chamilo_core_course_home") |
|
58
|
|
|
* |
|
59
|
|
|
* @Entity("course", expr="repository.findOneByCode(courseCode)") |
|
60
|
|
|
*/ |
|
61
|
|
|
public function homeAction(Course $course): Response |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->render('@ChamiloTheme/Course/welcome.html.twig', ['course' => $course]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @Route("{courseCode}/welcome/", name="chamilo_core_course_welcome") |
|
68
|
|
|
* |
|
69
|
|
|
* @Entity("course", expr="repository.find(cid)") |
|
70
|
|
|
*/ |
|
71
|
|
|
public function welcomeAction(Course $course): Response |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->render('@ChamiloTheme/Course/welcome.html.twig', ['course' => $course]); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|