123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?php
- require_once __DIR__.'/../global.inc.php';
- api_protect_course_script(true);
- $action = $_GET['a'];
- $thematic = new Thematic();
- switch ($action) {
- case 'save_thematic_plan':
-
- break;
- case 'save_thematic_advance':
- if (!api_is_allowed_to_edit(null, true)) {
- echo '';
- exit;
- }
-
- break;
- case 'get_datetime_by_attendance':
- $attendance_id = intval($_REQUEST['attendance_id']);
- $thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
- $label = '';
- $input_select = '';
- if (!empty($attendance_id)) {
- $attendance = new Attendance();
- $thematic = new Thematic();
- $thematic_list = $thematic->get_thematic_list();
- $my_list = $thematic_list_temp = [];
- foreach ($thematic_list as $item) {
- $my_list = $thematic->get_thematic_advance_by_thematic_id($item['id']);
- $thematic_list_temp = array_merge($my_list, $thematic_list_temp);
- }
- $new_thematic_list = [];
- foreach ($thematic_list_temp as $item) {
- if (!empty($item['attendance_id'])) {
- $new_thematic_list[$item['id']] = [
- 'attendance_id' => $item['attendance_id'],
- 'start_date' => $item['start_date'],
- ];
- }
- }
- $attendance_calendar = $attendance->get_attendance_calendar($attendance_id);
- $label = get_lang('StartDate');
- if (!empty($attendance_calendar)) {
- $input_select .= '<select id="start_date_select_calendar" name="start_date_by_attendance" size="7" class="form-control">';
- foreach ($attendance_calendar as $calendar) {
- $selected = null;
- $insert = true;
-
- foreach ($new_thematic_list as $key => $thematic_item) {
- if ($calendar['db_date_time'] == $thematic_item['start_date']) {
- $insert = false;
- if ($thematic_advance_id == $key) {
- $insert = true;
- $selected = 'selected';
- }
- break;
- }
- }
- if ($insert == true) {
- $input_select .= '<option '.$selected.' value="'.$calendar['date_time'].'">'.$calendar['date_time'].'</option>';
- }
- }
- $input_select .= '</select>';
- } else {
- $input_select .= '<em>'.get_lang('ThereAreNoRegisteredDatetimeYet').'</em>';
- }
- }
- ?>
- <div class="form-group">
- <label class="col-sm-2 control-label"><?php echo $label; ?></label>
- <div class="col-sm-8"><?php echo $input_select; ?></div>
- </div>
- <?php
- break;
- case 'update_done_thematic_advance':
- $thematic_advance_id = intval($_GET['thematic_advance_id']);
- $total_average = 0;
- if (!empty($thematic_advance_id)) {
- $thematic = new Thematic();
- $affected_rows = $thematic->update_done_thematic_advances($thematic_advance_id);
- $total_average = $thematic->get_total_average_of_thematic_advances(
- api_get_course_id(),
- api_get_session_id()
- );
- }
- echo $total_average;
- break;
- default:
- echo '';
- }
- exit;
|