|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
namespace Chamilo\CoreBundle\Controller; |
|
6
|
|
|
|
|
7
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
|
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
10
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class IndexController. |
|
14
|
|
|
*/ |
|
15
|
|
|
class IndexController extends BaseController |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Index home page. |
|
19
|
|
|
* |
|
20
|
|
|
* @Route("/", name="home", methods={"GET", "POST"}, options={"expose"=true}) |
|
21
|
|
|
* @Route("/login", name="login", methods={"GET", "POST"}, options={"expose"=true}) |
|
22
|
|
|
* @Route("/courses", name="courses", methods={"GET", "POST"}, options={"expose"=true}) |
|
23
|
|
|
* @Route("/sessions", name="sessions", methods={"GET", "POST"}, options={"expose"=true}) |
|
24
|
|
|
*/ |
|
25
|
|
|
public function indexAction(): Response |
|
26
|
|
|
{ |
|
27
|
|
|
return $this->render('@ChamiloCore/Index/vue.html.twig'); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Toggle the student view action. |
|
32
|
|
|
* |
|
33
|
|
|
* @Route("/toggle_student_view", methods={"GET"}) |
|
34
|
|
|
* |
|
35
|
|
|
* @Security("has_role('ROLE_TEACHER')") |
|
36
|
|
|
*/ |
|
37
|
|
|
public function toggleStudentViewAction(Request $request): Response |
|
38
|
|
|
{ |
|
39
|
|
|
if (!api_is_allowed_to_edit(false, false, false, false)) { |
|
40
|
|
|
return ''; |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
$studentView = $request->getSession()->get('studentview'); |
|
43
|
|
|
if (empty($studentView) || 'studentview' === $studentView) { |
|
44
|
|
|
$request->getSession()->set('studentview', 'teacherview'); |
|
45
|
|
|
|
|
46
|
|
|
return 'teacherview'; |
|
|
|
|
|
|
47
|
|
|
} else { |
|
48
|
|
|
$request->getSession()->set('studentview', 'studentview'); |
|
49
|
|
|
|
|
50
|
|
|
return 'studentview'; |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|