|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
use ChamiloSession as Session; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Thematic Controller script. |
|
8
|
|
|
* Prepares the common background variables to give to the scripts corresponding to |
|
9
|
|
|
* the requested action. |
|
10
|
|
|
* |
|
11
|
|
|
* This file contains class used like controller for thematic, |
|
12
|
|
|
* it should be included inside a dispatcher file (e.g: index.php) |
|
13
|
|
|
* |
|
14
|
|
|
* !!! WARNING !!! : ALL DATES IN THIS MODULE ARE STORED IN UTC ! |
|
15
|
|
|
* DO NOT CONVERT DURING THE TRANSITION FROM CHAMILO 1.8.x TO 2.0 |
|
16
|
|
|
* |
|
17
|
|
|
* @author Christian Fasanando <[email protected]> |
|
18
|
|
|
* @author Julio Montoya <[email protected]> token support improving UI |
|
19
|
|
|
*/ |
|
20
|
|
|
class ThematicController |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Constructor. |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->toolname = 'course_progress'; |
|
|
|
|
|
|
28
|
|
|
$this->view = new View($this->toolname); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* This method is used for thematic advance control (update, insert or listing) |
|
33
|
|
|
* render to thematic_advance.php. |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $action |
|
36
|
|
|
*/ |
|
37
|
|
|
public function thematic_advance($action) |
|
38
|
|
|
{ |
|
39
|
|
|
$thematic = new Thematic(); |
|
40
|
|
|
$attendance = new Attendance(); |
|
41
|
|
|
$data = []; |
|
42
|
|
|
$displayHeader = !empty($_REQUEST['display']) && 'no_header' === $_REQUEST['display'] ? false : true; |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
$thematic_id = intval($_REQUEST['thematic_id']); |
|
46
|
|
|
$thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? (int) $_REQUEST['thematic_advance_id'] : null; |
|
47
|
|
|
$thematic_advance_data = []; |
|
48
|
|
|
switch ($action) { |
|
49
|
|
|
case 'thematic_advance_delete': |
|
50
|
|
|
|
|
51
|
|
|
break; |
|
52
|
|
|
case 'thematic_advance_list': |
|
53
|
|
|
if (!api_is_allowed_to_edit(null, true)) { |
|
54
|
|
|
echo ''; |
|
55
|
|
|
exit; |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$data['action'] = $_REQUEST['action']; |
|
59
|
|
|
$data['thematic_id'] = $_REQUEST['thematic_id']; |
|
60
|
|
|
$data['attendance_select'] = $attendance_select; |
|
|
|
|
|
|
61
|
|
|
if (isset($_REQUEST['thematic_advance_id'])) { |
|
62
|
|
|
$data['thematic_advance_id'] = $_REQUEST['thematic_advance_id']; |
|
63
|
|
|
$thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']); |
|
64
|
|
|
$data['thematic_advance_data'] = $thematic_advance_data; |
|
65
|
|
|
} |
|
66
|
|
|
break; |
|
67
|
|
|
default: |
|
68
|
|
|
$thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id); |
|
69
|
|
|
break; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
// get calendar select by attendance id |
|
73
|
|
|
$calendar_select = []; |
|
74
|
|
|
if (!empty($thematic_advance_data)) { |
|
75
|
|
|
if (!empty($thematic_advance_data['attendance_id'])) { |
|
76
|
|
|
$attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']); |
|
77
|
|
|
if (!empty($attendance_calendar)) { |
|
78
|
|
|
foreach ($attendance_calendar as $calendar) { |
|
79
|
|
|
$calendar_select[$calendar['date_time']] = $calendar['date_time']; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
$data['action'] = $action; |
|
86
|
|
|
$data['thematic_id'] = $thematic_id; |
|
87
|
|
|
$data['thematic_advance_id'] = $thematic_advance_id; |
|
88
|
|
|
$data['attendance_select'] = $attendance_select; |
|
89
|
|
|
$data['thematic_advance_data'] = $thematic_advance_data; |
|
90
|
|
|
$data['calendar_select'] = $calendar_select; |
|
91
|
|
|
$layoutName = $displayHeader ? 'layout' : 'layout_no_header'; |
|
92
|
|
|
|
|
93
|
|
|
// render to the view |
|
94
|
|
|
$this->view->set_data($data); |
|
95
|
|
|
$this->view->set_layout($layoutName); |
|
96
|
|
|
$this->view->set_template('thematic_advance'); |
|
97
|
|
|
$this->view->render(); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|