|
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
|
|
|
* author Julio Montoya <[email protected]>. |
|
15
|
|
|
*/ |
|
16
|
|
|
class IndexController extends BaseController |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* The Chamilo index home page. |
|
20
|
|
|
* |
|
21
|
|
|
* @Route("/", name="home", methods={"GET", "POST"}, options={"expose"=true}) |
|
22
|
|
|
*/ |
|
23
|
|
|
public function indexAction(): Response |
|
24
|
|
|
{ |
|
25
|
|
|
return $this->render( |
|
26
|
|
|
'@ChamiloCore/Index/index.html.twig', |
|
27
|
|
|
[ |
|
28
|
|
|
'content' => '', |
|
29
|
|
|
] |
|
30
|
|
|
); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function courses(): Response |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->render( |
|
36
|
|
|
'@ChamiloCore/Index/courses.html.twig', |
|
37
|
|
|
[ |
|
38
|
|
|
'content' => '', |
|
39
|
|
|
] |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Toggle the student view action. |
|
45
|
|
|
* |
|
46
|
|
|
* @Route("/toggle_student_view", methods={"GET"}) |
|
47
|
|
|
* |
|
48
|
|
|
* @Security("has_role('ROLE_TEACHER')") |
|
49
|
|
|
*/ |
|
50
|
|
|
public function toggleStudentViewAction(Request $request): Response |
|
51
|
|
|
{ |
|
52
|
|
|
if (!api_is_allowed_to_edit(false, false, false, false)) { |
|
53
|
|
|
return ''; |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
$studentView = $request->getSession()->get('studentview'); |
|
56
|
|
|
if (empty($studentView) || 'studentview' === $studentView) { |
|
57
|
|
|
$request->getSession()->set('studentview', 'teacherview'); |
|
58
|
|
|
|
|
59
|
|
|
return 'teacherview'; |
|
|
|
|
|
|
60
|
|
|
} else { |
|
61
|
|
|
$request->getSession()->set('studentview', 'studentview'); |
|
62
|
|
|
|
|
63
|
|
|
return 'studentview'; |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|