Some fixes in the attendance/thematic

skala
Julio Montoya 14 years ago
parent b6fefb4f88
commit 717e7ca3b8
  1. 36
      main/attendance/attendance_calendar.php
  2. 9
      main/course_progress/index.php
  3. 6
      main/course_progress/thematic.php
  4. 2
      main/course_progress/thematic_advance.php
  5. 110
      main/course_progress/thematic_controller.php
  6. 21
      main/course_progress/thematic_plan.php
  7. 7
      main/inc/ajax/thematic.ajax.php
  8. 13
      main/inc/lib/thematic.lib.php

@ -48,43 +48,31 @@ if ($error_checkdate) {
if (isset($action) && $action == 'calendar_add') {
// calendar add form
echo '<div class="attendance-calendar-add">';
echo '<h4>'.get_lang('AddADateTime').'</h4>';
$form = new FormValidator('attendance_calendar_add','POST','index.php?action=calendar_add&attendance_id='.$attendance_id.$param_gradebook.'&'.api_get_cidreq(),'');
$form->addElement('datepicker', 'date_time', '', array('form_name'=>'attendance_calendar_add'), 5);
$defaults['date_time'] = date('Y-m-d H:i', api_strtotime(api_get_local_time()));
$form->addElement('html','<br /><br />');
$form->addElement('html', '<div id="repeat_check"><input id="repeat_id" type="checkbox" name="repeat" '.($repeat?'checked="checked"':'').' onclick="javascript: if(this.checked){document.getElementById(\'repeat-date-attendance\').style.display=\'block\';}else{document.getElementById(\'repeat-date-attendance\').style.display=\'none\';}"/> <label for="repeat_id">'. get_lang('RepeatDate').'</label>');
$form->addElement('checkbox', 'repeat', null, get_lang('RepeatDate'), array('onclick' => "javascript: if(this.checked){document.getElementById('repeat-date-attendance').style.display='block';}else{document.getElementById('repeat-date-attendance').style.display='none';}",
));
$defaults['repeat'] = $repeat;
if ($repeat) {
$form->addElement('html', '<div id="repeat-date-attendance" style="display:block">');
} else {
$form->addElement('html', '<div id="repeat-date-attendance" style="display:none">');
}
$form->addElement('html', '<table>');
$a_repeat_type = array('daily'=>get_lang('RepeatDaily'), 'weekly'=>get_lang('RepeatWeekly'), 'monthlyByDate'=>get_lang('RepeatMonthlyByDate'));
$form->addElement('html', '<tr><td>'.get_lang('RepeatType').'</td><td>');
$form->addElement('select', 'repeat_type', '', $a_repeat_type);
$form->addElement('html', '</td></tr>');
$form->addElement('html', '<tr><td>'.get_lang('RepeatEnd').'</td><td>');
$form->addElement('datepickerdate', 'end_date_time', '', array('form_name'=>'attendance_calendar_add'));
$defaults['end_date_time'] = date('Y-m-d 12:00:00');
$form->addElement('html', '</td></tr>');
$form->addElement('html', '</table>');
}
$a_repeat_type = array('daily'=>get_lang('RepeatDaily'), 'weekly'=>get_lang('RepeatWeekly'), 'monthlyByDate'=>get_lang('RepeatMonthlyByDate'));
$form->addElement('select', 'repeat_type', get_lang('RepeatType') , $a_repeat_type);
$form->addElement('datepickerdate', 'end_date_time', get_lang('RepeatEnd'), array('form_name'=>'attendance_calendar_add'));
$defaults['end_date_time'] = date('Y-m-d 12:00:00');
$form->addElement('html', '</div>');
$form->addElement('html', '</div>');
$form->addElement('html','<br /><br />');
$form->addElement('html','<div class="clear"></div>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
$form->setDefaults($defaults);
$form->display();
echo '</div>';
$form->display();
} else {
// calendar list
echo '<div class="attendance-calendar-list">';

@ -82,8 +82,9 @@ $htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready(function() {
//Second col
/*
$("#thematic_plan_add").live("submit", function() {
var serialize_form_content = $(this).serialize();
//Getting FCK content
@ -113,10 +114,10 @@ $(document).ready(function() {
});
//prevent the browser to follow the link
return false;
});
});*/
// Third col
/*
$("#thematic_advance").live("submit", function() {
var url = this.href;
var my_id = this.id;
@ -142,7 +143,7 @@ $(document).ready(function() {
});
//prevent the browser to follow the link
return false;
});
});*/
$(".thematic_advance_actions, .thematic_tools ").hide();

@ -119,7 +119,7 @@ if ($action == 'thematic_list') {
$actions_first_col = Display::div($actions_first_col, array('style'=>'height:20px'));
}
echo Display::tag('td', Display::tag('h2', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id'=>'thematic_td_content_'.$thematic['id'], 'class'=>'thematic_content'));
echo Display::tag('td', Display::tag('h3', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id'=>'thematic_td_content_'.$thematic['id'], 'class'=>'thematic_content'));
// Display 2nd column - thematic plan data
@ -135,8 +135,7 @@ if ($action == 'thematic_list') {
echo Display::div('', array('id' => "thematic_plan_".$thematic['id']));
} else {
echo $thematic_plan_div[$thematic['id']];
}
}
echo '</td>';
// Display 3rd column - thematic advance data
@ -144,7 +143,6 @@ if ($action == 'thematic_list') {
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) {
//echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_advance_list&thematic_id='.$thematic['id'].'">'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array('style'=>'vertical-align:middle'),ICON_SIZE_SMALL).'</a></div><br />';
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&action=thematic_advance_add&thematic_id='.$thematic['id'].'">'.Display::return_icon('add.png',get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).'</a></div>';
}

@ -25,7 +25,7 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
// display form
$form = new FormValidator('thematic_advance','POST','index.php?action=thematic_advance_list&thematic_id='.$thematic_id.'&'.api_get_cidreq(),'','style="width: 100%;"');
$form->addElement('header', '', $header_form);
$form->addElement('header', $header_form);
$form->addElement('hidden', 'thematic_advance_token',$token);
$form->addElement('hidden', 'action', $action);

@ -179,21 +179,23 @@ class ThematicController
$data = array();
$error = false;
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {
if (trim($_POST['title']) !== '') {
if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
if (api_is_allowed_to_edit(null, true)) {
$thematic_id = $_POST['thematic_id'];
$title = $_POST['title'];
$description = $_POST['description'];
$description_type = $_POST['description_type'];
$thematic->set_thematic_plan_attributes($thematic_id, $title, $description, $description_type);
$affected_rows = $thematic->thematic_plan_save();
unset($_SESSION['thematic_plan_token']);
if (api_is_allowed_to_edit(null, true)) {
$title_list = $_REQUEST['title'];
//$description_list = $_REQUEST['desc'];
$description_list = $_REQUEST['description'];
$description_type = $_REQUEST['description_type'];
for($i=1;$i<count($title_list)+1; $i++) {
$thematic->set_thematic_plan_attributes($_REQUEST['thematic_id'], $title_list[$i], $description_list[$i], $description_type[$i]);
$affected_rows = $thematic->thematic_plan_save();
}
unset($_SESSION['thematic_plan_token']);
$data['message'] = 'ok';
}
}
$data['action'] = 'thematic_plan_list';
}
} else {
@ -237,8 +239,7 @@ class ThematicController
}
$data['thematic_id'] = $thematic_id;
$data['description_type'] = $description_type;
} else if (!empty($thematic_id) && $action == 'thematic_plan_list') {
} else if (!empty($thematic_id) && $action == 'thematic_plan_list') {
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
$data['thematic_id'] = $thematic_id;
}
@ -278,21 +279,78 @@ class ThematicController
$attendance_select[$attendance_id] = $attendance_data['name'];
}
$thematic_id = intval($_GET['thematic_id']);
$thematic_advance_id = intval($_GET['thematic_advance_id']);
$thematic_id = intval($_REQUEST['thematic_id']);
$thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
$thematic_advance_data = array();
if (!empty($thematic_advance_id)) {
if ($action == 'thematic_advance_delete') {
if (api_is_allowed_to_edit(null, true)) {
$affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id);
}
$action = 'thematic_list';
header('Location: index.php');
exit;
} else {
switch ($action) {
case 'thematic_advance_delete':
if (!empty($thematic_advance_id)) {
if (api_is_allowed_to_edit(null, true)) {
$affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id);
}
$action = 'thematic_list';
header('Location: index.php');
exit;
}
break;
case 'thematic_advance_list':
if (!api_is_allowed_to_edit(null, true)) {
echo '';
exit;
}
if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) || (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) ) {
if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) {
$start_date_error = true;
$data['start_date_error'] = $start_date_error;
}
if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
$duration_error = true;
$data['duration_error'] = $duration_error;
}
$data['action'] = $_REQUEST['action'];
$data['thematic_id'] = $_REQUEST['thematic_id'];
$data['attendance_select'] = $attendance_select;
if (isset($_REQUEST['thematic_advance_id'])) {
$data['thematic_advance_id'] = $_REQUEST['thematic_advance_id'];
$thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']);
$data['thematic_advance_data'] = $thematic_advance_data;
}
} else {
if ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) {
$thematic_advance_id = $_REQUEST['thematic_advance_id'];
$thematic_id = $_REQUEST['thematic_id'];
$content = $_REQUEST['real_content'];
$duration = $_REQUEST['duration_in_hours'];
if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
$start_date = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']);
$attendance_id = 0;
} else {
$start_date = $_REQUEST['start_date_by_attendance'];
$attendance_id = $_REQUEST['attendance_select'];
}
$thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration);
$affected_rows = $thematic->thematic_advance_save();
if ($affected_rows) {
// get last done thematic advance before move thematic list
$last_done_thematic_advance = $thematic->get_last_done_thematic_advance();
// update done advances with de current thematic list
if (!empty($last_done_thematic_advance)) {
$update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance);
}
}
}
}
break;
default:
$thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);
}
}
break;
}
// get calendar select by attendance id
$calendar_select = array();

@ -25,27 +25,16 @@ foreach($thematic_simple_list as $item) {
}
$i=1;
/*
echo '<div class="actions" style="margin-bottom:30px">';
if ($action == 'thematic_plan_edit') {
echo '<a href="index.php?action=thematic_plan_list&'.api_get_cidreq().'&thematic_id='.$thematic_id.'">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>&nbsp;&nbsp;';
} else {
echo '<a href="index.php?action=thematic_plan_list&'.api_get_cidreq().'&action=thematic_details&'.api_get_cidreq().'">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>&nbsp;&nbsp;';
echo '<a href="index.php?action=thematic_plan_edit&'.api_get_cidreq().'&description_type='.$new_id.'&thematic_id='.$thematic_id.'">'.Display::return_icon('wizard.png', get_lang('NewBloc'), array(), 32).'</a>';
}
echo '</div>';
*/
echo Display::tag('h2', $thematic_data['title']);
echo $thematic_data['content'];
if ($message == 'ok') {
Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
}
if ($action == 'thematic_plan_list') {
if ($action == 'thematic_plan_list') {
$form = new FormValidator('thematic_plan_add','POST','index.php?action=thematic_plan_list&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
$form->addElement('hidden', 'action', $action);
$form->addElement('hidden', 'action', 'thematic_plan_add');
$form->addElement('hidden', 'thematic_plan_token', $token);
$form->addElement('hidden', 'thematic_id', $thematic_id);
@ -53,8 +42,7 @@ if ($action == 'thematic_plan_list') {
$form->addElement('hidden', 'description_type['.$id.']', $id);
$form->add_textfield('title['.$id.']', get_lang('Title'), true, array('size'=>'50'));
$form->add_html_editor('description['.$id.']', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
//$form->addElement('textarea', 'description['.$id.']', get_lang('Description'));
//$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
//$form->addElement('textarea', 'description['.$id.']', get_lang('Description'));
if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
$thematic_plan = $new_thematic_plan_data[$id];
// set default values
@ -71,7 +59,6 @@ if ($action == 'thematic_plan_list') {
$form->addElement('style_submit_button', null, get_lang('Save'), 'id="add_plan" class="save"');
$form->display();
} else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
if ($description_type >= ADD_THEMATIC_PLAN) {
$header_form = get_lang('NewBloc');
} else {

@ -15,7 +15,7 @@ $thematic = new Thematic();
switch ($action) {
case 'save_thematic_plan':
$title_list = $_REQUEST['title'];
/*$title_list = $_REQUEST['title'];
$description_list = $_REQUEST['desc'];
//$description_list = $_REQUEST['description'];
$description_type = $_REQUEST['description_type'];
@ -27,9 +27,8 @@ switch ($action) {
}
$thematic_plan_data = $thematic->get_thematic_plan_data();
$return = $thematic->get_thematic_plan_div($thematic_plan_data);
echo $return[$_REQUEST['thematic_id']];
break;
echo $return[$_REQUEST['thematic_id']];*/
break;
case 'save_thematic_advance':
if (!api_is_allowed_to_edit(null, true)) {
echo '';

@ -770,8 +770,7 @@ class Thematic
$title = Database::escape_string($this->thematic_plan_title);
$description = Database::escape_string($this->thematic_plan_description);
$description_type = intval($this->thematic_plan_description_type);
$user_id = api_get_user_id();
$session_id = api_get_session_id();
$user_id = api_get_user_id();
$course_id = api_get_course_int_id();
$list = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), api_get_session_id());
@ -785,8 +784,7 @@ class Thematic
$condition = "AND id IN (".implode(',', $elements_to_show).") ";
}
// check thematic plan type already exists
$sql = "SELECT id FROM $tbl_thematic_plan WHERE c_id = $course_id AND thematic_id = $thematic_id AND description_type = $description_type ";
$sql = "SELECT id FROM $tbl_thematic_plan WHERE c_id = $course_id AND thematic_id = $thematic_id AND description_type = '$description_type'";
$rs = Database::query($sql);
$affected_rows = 0;
@ -801,8 +799,7 @@ class Thematic
$update = false;
if (in_array($thematic_plan_id, $elements_to_show)) {
$update = true;
}
}
if ($update) {
// update
@ -901,7 +898,6 @@ class Thematic
return $next_description_type;
}
/**
* update done thematic advances from thematic details interface
* @param int Thematic id
@ -916,8 +912,7 @@ class Thematic
$affected_rows = 0;
$user_id = api_get_user_id();
$all = array();
//var_dump($thematic_advance_data);
$all = array();
if (!empty($thematic_data)) {
foreach ($thematic_data as $thematic) {
$thematic_id = $thematic['id'];

Loading…
Cancel
Save