minor - cosmetic changes

skala
Cristian Fasanando 16 years ago
parent 9ce61f4698
commit 646477b3c9
  1. 9
      main/attendance/index.php
  2. 183
      main/attendance/thematic.php
  3. 28
      main/attendance/thematic_advance.php
  4. 194
      main/attendance/thematic_controller.php
  5. 38
      main/attendance/thematic_plan.php
  6. 2
      main/inc/ajax/thematic.ajax.php
  7. 55
      main/inc/lib/thematic.lib.php

@ -259,7 +259,7 @@ if ($action == 'thematic_details') {
//$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_list', 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
}
if ($action == 'thematic_plan_list') {
if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
if (isset($_GET['origin']) && $_GET['origin'] == 'thematic_details') {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_details', 'name' => get_lang('ThematicControl'));
} else {
@ -270,7 +270,12 @@ if ($action == 'thematic_plan_list') {
if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_list', 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));
$interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
if ($description_type >= ADD_THEMATIC_PLAN) {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
} else {
$interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
}
}
if ($action == 'thematic_advance_list') {
if (isset($_GET['origin']) && $_GET['origin'] == 'thematic_details') {

@ -25,126 +25,135 @@ if (api_is_allowed_to_edit(null, true)) {
echo '</div>';
}
$token = md5(uniqid(rand(),TRUE));
$_SESSION['thematic_token'] = $token;
if ($action == 'thematic_list') {
/*
if (api_is_allowed_to_edit(null, true)) {
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
}
echo '<div class="actions" style="margin-bottom:30px">';
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_add">'.Display::return_icon('introduction_add.gif',get_lang('NewThematicSection')).' '.get_lang('NewThematicSection').'</a>';
echo '</div>';
}
*/
echo '<div><strong>'.get_lang('ThematicList').'</strong></div>';
echo '<div><strong>'.get_lang('ThematicList').'</strong></div><br />';
$table = new SortableTable('thematic_list', array('Thematic', 'get_number_of_thematics'), array('Thematic', 'get_thematic_data'));
$table->set_additional_parameters($parameters);
$table->set_header(0, '', false, array('style'=>'width:20px;'));
$table->set_header(1, get_lang('Title'), false );
$table->set_header(1, get_lang('Title'), false );
if (api_is_allowed_to_edit(null, true)) {
$table->set_header(2, get_lang('Actions'), false,array('style'=>'text-align:center;width:40%;'));
$table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics')));
}
}
$table->display();
} else if ($action == 'thematic_details') {
// display title
if (!empty($thematic_id)) {
echo '<div><strong>'.$thematic_data[$thematic_id]['title'].': '.get_lang('Details').'</strong></div><br />';
echo '<div>'.get_lang('Progress').': '.$total_average_of_advances.'%</div><br />';
echo '<div><strong>'.$thematic_data[$thematic_id]['title'].': '.get_lang('Details').'</strong></div><br />';
} else {
echo '<div><strong>'.get_lang('ThematicDetails').'</strong></div><br />';
echo '<div>'.get_lang('Progress').': <span id="div_result">'.$total_average_of_advances.'</span>%</div><br />';
echo '<div><strong>'.get_lang('ThematicDetails').'</strong></div><br />';
}
echo '<table width="100%" class="data_table">';
echo '<tr><th width="35%">'.get_lang('Thematic').'</th><th width="30%">'.get_lang('ThematicPlan').'</th><th width="25%">'.get_lang('ThematicAdvance').'</th></tr>';
foreach ($thematic_data as $thematic) {
echo '<tr>';
// display thematic data
echo '<td><div><strong>'.$thematic['title'].'</strong></div><div>'.$thematic['content'].'</div></td>';
// display thematic plan data
echo '<td>';
//echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('info.gif',get_lang('ThematicPlan'),array('style'=>'vertical-align:middle')).' '.get_lang('EditThematicPlan').'</a></div><br />';
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_plan_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('edit.gif',get_lang('EditThematicPlan'),array('style'=>'vertical-align:middle')).'</a></div><br />';
}
if (!empty($thematic_plan_data[$thematic['id']])) {
foreach ($thematic_plan_data[$thematic['id']] as $thematic_plan) {
echo '<div><strong>'.$thematic_plan['title'].'</strong></div><div>'.$thematic_plan['description'].'</div>';
// display information
$message = '<strong>'.get_lang('Information').'</strong><br />';
$message .= get_lang('ThematicDetailsDescription');
Display::display_normal_message($message, false);
echo '<br />';
// display progress
if (!empty($thematic_id)) {
echo '<div style="text-align:right;">'.get_lang('Progress').': <strong>'.$total_average_of_advances.'</strong>%</div><br />';
} else {
echo '<div style="text-align:right;">'.get_lang('Progress').': <span id="div_result"><strong>'.$total_average_of_advances.'</strong></span>%</div><br />';
}
// display thematic data
if (!empty($thematic_data)) {
echo '<table width="100%" class="data_table">';
echo '<tr><th width="35%">'.get_lang('Thematic').'</th><th width="30%">'.get_lang('ThematicPlan').'</th><th width="25%">'.get_lang('ThematicAdvance').'</th></tr>';
foreach ($thematic_data as $thematic) {
echo '<tr>';
// display thematic data
echo '<td><div><strong>'.$thematic['title'].'</strong></div><div>'.$thematic['content'].'</div></td>';
// display thematic plan data
echo '<td>';
//echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('info.gif',get_lang('ThematicPlan'),array('style'=>'vertical-align:middle')).' '.get_lang('EditThematicPlan').'</a></div><br />';
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_plan_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('lp_quiz.png',get_lang('EditThematicPlan'),array('style'=>'vertical-align:middle')).'</a></div><br />';
}
} else {
echo '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>';
}
echo '</td>';
// display thematic advance data
echo '<td>';
//echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_advance_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('porcent.png',get_lang('ThematicAdvance'),array('style'=>'vertical-align:middle')).' '.get_lang('EditThematicAdvance').'</a></div><br />';
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'].$param_gradebook.'">'.Display::return_icon('edit.gif',get_lang('EditThematicAdvance'),array('style'=>'vertical-align:middle')).'</a></div><br />';
}
if (!empty($thematic_advance_data[$thematic['id']])) {
echo '<table width="100%">';
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
echo '<tr>';
echo '<td width="90%">';
echo '<div><strong>'.api_get_local_time($thematic_advance['start_date']).'</strong></div>';
echo '<div>'.$thematic_advance['content'].'</div>';
echo '<div>'.get_lang('Hours').' : '.$thematic_advance['duration'].'</div>';
echo '</td>';
if (empty($thematic_id) && api_is_allowed_to_edit(null, true)) {
$checked = '';
if ($last_done_thematic_advance == $thematic_advance['id']) {
$checked = 'checked';
}
echo '<td><center><input type="radio" name="thematic_done" value="'.$thematic_advance['id'].'" '.$checked.' onclick="update_done_thematic_advance(this.value)"></center></td>';
} else {
if ($thematic_advance['done_advance'] == 1) {
echo '<td><center>'.get_lang('Done').'</center></td>';
if (!empty($thematic_plan_data[$thematic['id']])) {
foreach ($thematic_plan_data[$thematic['id']] as $thematic_plan) {
echo '<div><strong>'.$thematic_plan['title'].'</strong></div><div>'.$thematic_plan['description'].'</div>';
}
} else {
echo '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>';
}
echo '</td>';
// display thematic advance data
echo '<td>';
//echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_advance_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('porcent.png',get_lang('ThematicAdvance'),array('style'=>'vertical-align:middle')).' '.get_lang('EditThematicAdvance').'</a></div><br />';
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'].$param_gradebook.'">'.Display::return_icon('lp_quiz.png',get_lang('EditThematicAdvance'),array('style'=>'vertical-align:middle')).'</a></div><br />';
}
if (!empty($thematic_advance_data[$thematic['id']])) {
echo '<table width="100%">';
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
echo '<tr>';
echo '<td width="90%">';
echo '<div><strong>'.api_get_local_time($thematic_advance['start_date']).'</strong></div>';
echo '<div>'.$thematic_advance['content'].'</div>';
echo '<div>'.get_lang('Hours').' : '.$thematic_advance['duration'].'</div>';
echo '</td>';
if (empty($thematic_id) && api_is_allowed_to_edit(null, true)) {
$checked = '';
if ($last_done_thematic_advance == $thematic_advance['id']) {
$checked = 'checked';
}
echo '<td><center><input type="radio" name="thematic_done" value="'.$thematic_advance['id'].'" '.$checked.' onclick="update_done_thematic_advance(this.value)"></center></td>';
} else {
echo '<td><center>-</center></td>';
if ($thematic_advance['done_advance'] == 1) {
echo '<td><center>'.get_lang('Done').'</center></td>';
} else {
echo '<td><center>-</center></td>';
}
}
echo '</tr>';
}
echo '</tr>';
}
echo '</table>';
} else {
echo '<div><em>'.get_lang('StillDoNotHaveAThematicAdvance').'</em></div>';
}
echo '</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo '<div><em>'.get_lang('StillDoNotHaveAThematicAdvance').'</em></div>';
}
echo '</td>';
echo '</tr>';
}
echo '</table>';
echo '</table>';
} else {
echo '<div><em>'.get_lang('ThereIsStillAthematicSection').'</em></div>';
}
} else if ($action == 'thematic_add' || $action == 'thematic_edit') {
if (!$error) {
$token = md5(uniqid(rand(),TRUE));
$_SESSION['thematic_token'] = $token;
}
// error messages
if ($error) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
}
$header_form = get_lang('NewThematicSection');
if ($action == 'thematic_edit') {
$header_form = get_lang('EditThematicSection');
}
// display form
$form = new FormValidator('thematic_add','POST','index.php?action='.$action.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
$form = new FormValidator('thematic_add','POST','index.php?action=thematic_list&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
$form->addElement('header', '', $header_form);
$form->addElement('hidden', 'thematic_token',$token);
$form->addElement('hidden', 'action', $action);
if (!empty($thematic_id)) {
$form->addElement('hidden', 'thematic_id',$thematic_id);

@ -10,8 +10,7 @@
// protect a course script
api_protect_course_script(true);
$token = md5(uniqid(rand(),TRUE));
$_SESSION['thematic_advance_token'] = $token;
if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
@ -20,10 +19,16 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$header_form = get_lang('EditThematicAdvance');
}
if (!$error) {
$token = md5(uniqid(rand(),TRUE));
$_SESSION['thematic_advance_token'] = $token;
}
// display form
$form = new FormValidator('thematic_advance','POST','index.php?action='.$action.'&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
$form = new FormValidator('thematic_advance','POST','index.php?action=thematic_advance_list&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
$form->addElement('header', '', $header_form);
$form->addElement('hidden', 'thematic_advance_token',$token);
$form->addElement('hidden', 'action', $action);
if (!empty($thematic_advance_id)) {
$form->addElement('hidden', 'thematic_advance_id',$thematic_advance_id);
@ -36,7 +41,7 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$radios[] = FormValidator::createElement('radio', 'start_date_type', null, get_lang('StartDateFromAnAttendance'),'1',array('onclick' => 'check_per_attendance(this)', 'id'=>'from_attendance'));
$radios[] = FormValidator::createElement('radio', 'start_date_type', null, get_lang('StartDateCustom'),'2',array('onclick' => 'check_per_custom_date(this)', 'id'=>'custom_date'));
$form->addGroup($radios, null, get_lang('StartDateOption'));
$form->addGroup($radios, null, get_lang('StartDateOptions'));
if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
$form->addElement('html', '<div id="div_custom_datetime" style="display:block">');
@ -52,9 +57,13 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
} else {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:block">');
}
$form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)'));
if (count($attendance_select) > 1) {
$form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)'));
} else {
$form->addElement('html', '<div class="row"><div class="label">'.get_lang('Attendances').'</div><div class="formw"><em>'.get_lang('ThereAreNoAttendancesInsideCourse').'</em></div></div>');
}
$form->addElement('html', '<div id="div_datetime_attendance">');
if (!empty($calendar_select)) {
$form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select);
@ -88,6 +97,11 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
}
$form->setDefaults($default);
// error messages
if ($error) {
Display::display_error_message(get_lang('YouMustSelectAtleastAStartDate'),false);
}
$form->display();
} else if ($action == 'thematic_advance_list') {

@ -26,27 +26,45 @@ class ThematicController
$this->toolname = 'attendance';
$this->view = new View($this->toolname);
}
/**
* This method is used for thematic control (update, insert or listing)
* @param string Action
* render to thematic.php
*/
public function thematic($action) {
$thematic= new Thematic();
$data = array();
// insert or update a thematic
if ($action == 'thematic_add' || $action == 'thematic_edit') {
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if ($_POST['thematic_token'] == $_SESSION['thematic_token']) {
$id = $_POST['thematic_id'];
$title = $_POST['title'];
$content = $_POST['content'];
$session_id = api_get_session_id();
$thematic->set_thematic_attributes($id, $title, $content, $session_id);
$affected_rows = $thematic->thematic_save();
unset($_SESSION['thematic_token']);
$action = 'thematic_list';
}
}
}
$error = false;
// insert or update a thematic
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_add' || $_POST['action'] == 'thematic_edit')) {
if (!empty($_POST['title'])) {
if ($_POST['thematic_token'] == $_SESSION['thematic_token']) {
$id = $_POST['thematic_id'];
$title = $_POST['title'];
$content = $_POST['content'];
$session_id = api_get_session_id();
$thematic->set_thematic_attributes($id, $title, $content, $session_id);
$affected_rows = $thematic->thematic_save();
$action = 'thematic_list';
unset($_SESSION['thematic_token']);
}
} else {
$error = true;
$data['error'] = $error;
$data['action'] = $_POST['action'];
$data['thematic_id'] = $_POST['thematic_id'];
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('thematic');
$this->view->render();
}
}
}
// delete many thematics
if ($action == 'thematic_delete_select') {
@ -107,43 +125,69 @@ class ThematicController
}
/**
* This method is used for thematic plant control (update, insert or listing)
* @param string Action
* render to thematic_plan.php
*/
public function thematic_plan($action) {
$thematic= new Thematic();
$data = array();
$error = false;
if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
$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']);
$action = 'thematic_plan_list';
}
}
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {
if (!empty($_POST['title'])) {
if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
$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']);
$action = 'thematic_plan_list';
}
} else {
$error = true;
$action = $_POST['action'];
$data['error'] = $error;
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']);
$data['thematic_id'] = $_POST['thematic_id'];
$data['description_type'] = $_POST['description_type'];
$data['action'] = $action;
$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
$data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
$data['default_thematic_plan_question'] = $thematic->get_default_question();
$data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']);
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('thematic_plan');
$this->view->render();
}
}
}
if ($action == 'thematic_plan_list') {
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
}
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
$thematic_id = intval($_GET['thematic_id']);
$description_type = intval($_GET['description_type']);
if (!empty($thematic_id) && !empty($description_type)) {
if ($action == 'thematic_plan_delete') {
$affected_rows = $thematic->thematic_plan_destroy($thematic_id, $description_type);
$action = 'thematic_plan_list';
$affected_rows = $thematic->thematic_plan_destroy($thematic_id, $description_type);
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
$action = 'thematic_plan_list';
} else {
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type);
}
$data['thematic_id'] = $thematic_id;
$data['description_type'] = $description_type;
} else if (!empty($thematic_id)) {
} 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;
}
@ -151,7 +195,9 @@ class ThematicController
$data['thematic_id'] = $thematic_id;
$data['action'] = $action;
$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
$data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
$data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
$data['next_description_type'] = $thematic->get_next_description_type($thematic_id);
$data['default_thematic_plan_question'] = $thematic->get_default_question();
// render to the view
$this->view->set_data($data);
@ -173,32 +219,56 @@ class ThematicController
foreach ($attendance_list as $attendance_id => $attendance_data) {
$attendance_select[$attendance_id] = $attendance_data['name'];
}
if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if ($_POST['thematic_advance_token'] == $_SESSION['thematic_advance_token']) {
$thematic_advance_id = $_POST['thematic_advance_id'];
$thematic_id = $_POST['thematic_id'];
$content = $_POST['content'];
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_advance_add' || $_POST['action'] == 'thematic_advance_edit')) {
if ($_POST['start_date_type'] == 1 && empty($_POST['start_date_by_attendance'])) {
if (isset($_POST['start_date_type']) && $_POST['start_date_type'] == 2) {
$start_date = $thematic->build_datetime_from_array($_POST['custom_start_date']);
$attendance_id = 0;
} else {
$start_date = $_POST['start_date_by_attendance'];
$attendance_id = $_POST['attendance_select'];
}
$error = true;
$data['error'] = $error;
$data['action'] = $_POST['action'];
$data['thematic_id'] = $_POST['thematic_id'];
$data['attendance_select'] = $attendance_select;
if (isset($_POST['thematic_advance_id'])) {
$data['thematic_advance_id'] = $_POST['thematic_advance_id'];
$thematic_advance_data = $thematic->get_thematic_advance_list($_POST['thematic_advance_id']);
$data['thematic_advance_data'] = $thematic_advance_data;
}
$duration = $_POST['duration_in_hours'];
$thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration);
$affected_rows = $thematic->thematic_advance_save();
unset($_SESSION['thematic_advance_token']);
$action = 'thematic_advance_list';
}
}
}
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('thematic_advance');
$this->view->render();
} else {
if ($_POST['thematic_advance_token'] == $_SESSION['thematic_advance_token']) {
$thematic_advance_id = $_POST['thematic_advance_id'];
$thematic_id = $_POST['thematic_id'];
$content = $_POST['content'];
if (isset($_POST['start_date_type']) && $_POST['start_date_type'] == 2) {
$start_date = $thematic->build_datetime_from_array($_POST['custom_start_date']);
$attendance_id = 0;
} else {
$start_date = $_POST['start_date_by_attendance'];
$attendance_id = $_POST['attendance_select'];
}
$duration = $_POST['duration_in_hours'];
$thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration);
$affected_rows = $thematic->thematic_advance_save();
unset($_SESSION['thematic_advance_token']);
$action = 'thematic_advance_list';
}
}
}
}
$thematic_id = intval($_GET['thematic_id']);
$thematic_advance_id = intval($_GET['thematic_advance_id']);

@ -19,7 +19,7 @@ echo '<div class="actions" style="margin-bottom:30px">';
ksort($categories);
foreach ($categories as $id => $title) {
if ($i == ADD_THEMATIC_PLAN) {
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_add&thematic_id='.$thematic_id.'&description_type='.$i.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_add&thematic_id='.$thematic_id.'&description_type='.$next_description_type.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
break;
} else {
echo '<a href="index.php?action=thematic_plan_edit&'.api_get_cidreq().'&description_type='.$id.'&thematic_id='.$thematic_id.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>&nbsp;&nbsp;';
@ -28,9 +28,6 @@ foreach ($categories as $id => $title) {
}
echo '</div>';
$token = md5(uniqid(rand(),TRUE));
$_SESSION['thematic_plan_token'] = $token;
if ($action == 'thematic_plan_list') {
if (isset($thematic_plan_data) && count($thematic_plan_data) > 0) {
@ -55,19 +52,27 @@ if ($action == 'thematic_plan_list') {
}
} else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
if ($description_type >= ADD_THEMATIC_PLAN) {
$header_form = get_lang('NewBloc');
} else {
$header_form = $default_thematic_plan_title[$description_type];
if (!empty($thematic_plan_data)) {
$header_form = $thematic_plan_data[0]['title'];
}
$header_form = $default_thematic_plan_title[$description_type];
}
if (!$error) {
$token = md5(uniqid(rand(),TRUE));
$_SESSION['thematic_plan_token'] = $token;
}
// error messages
if ($error) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
}
// display form
$form = new FormValidator('thematic_plan_add','POST','index.php?action='.$action.'&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
$form->addElement('header', '', $header_form);
$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('header', '', $header_form);
$form->addElement('hidden', 'action', $action);
$form->addElement('hidden', 'thematic_plan_token', $token);
if (!empty($thematic_id)) {
@ -82,13 +87,22 @@ if ($action == 'thematic_plan_list') {
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
$default['title'] = $default_thematic_plan_title[$description_type];
if ($description_type < ADD_THEMATIC_PLAN) {
$default['title'] = $default_thematic_plan_title[$description_type];
}
if (!empty($thematic_plan_data)) {
// set default values
$default['title'] = $thematic_plan_data[0]['title'];
$default['description'] = $thematic_plan_data[0]['description'];
}
$form->setDefaults($default);
if (isset($default_thematic_plan_question[$description_type])) {
$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
$message .= $default_thematic_plan_question[$description_type];
Display::display_normal_message($message, false);
}
$form->display();
}

@ -27,7 +27,7 @@ switch ($action) {
}
$input_select .= '</select>';
} else {
$input_select .= get_lang('ThereAreNoRegisteredDatetimeYet');
$input_select .= '<em>'.get_lang('ThereAreNoRegisteredDatetimeYet').'</em>';
}
}
?>

@ -112,13 +112,12 @@ class Thematic
* Get the maximum display order of the thematic item
* @return int Maximum display order
*/
function get_max_thematic_item()
{
public function get_max_thematic_item() {
// Database table definition
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, false);
$sql = "SELECT MAX(display_order) FROM $tbl_thematic $condition_session";
$condition_session = api_get_session_condition($session_id);
$sql = "SELECT MAX(display_order) FROM $tbl_thematic WHERE active = 1 $condition_session";
$rs = Database::query($sql);
$dsp=0;
$row = Database::fetch_array($rs);
@ -131,8 +130,7 @@ class Thematic
* @param string Direction (up, down)
* @param int Thematic id
*/
function move_thematic($direction, $thematic_id)
{
public function move_thematic($direction, $thematic_id) {
// Database table definition
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
@ -143,7 +141,10 @@ class Thematic
$sortorder = 'ASC';
}
$sql = "SELECT * FROM $tbl_thematic ORDER BY display_order $sortorder";
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$sql = "SELECT * FROM $tbl_thematic WHERE active = 1 $condition_session ORDER BY display_order $sortorder";
$res = Database::query($sql);
$found = false;
while ($row = Database::fetch_array($res)) {
@ -256,7 +257,7 @@ class Thematic
* @param int|array One or many thematic ids
* @return int Affected rows
*/
function thematic_destroy($thematic_id) {
public function thematic_destroy($thematic_id) {
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
$affected_rows = 0;
@ -561,6 +562,38 @@ class Thematic
return $affected_rows;
}
/**
* Get next description type for a new thematic plan description (option 'others')
* @param int Thematic id
* @return int New Description type
*/
public function get_next_description_type($thematic_id) {
// definition database table
$tbl_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
// protect data
$thematic_id = intval($thematic_id);
$description_type = intval($description_type);
$next_description_type = 0;
$sql = "SELECT MAX(description_type) as max FROM $tbl_thematic_plan WHERE thematic_id = $thematic_id AND description_type >= ".ADD_THEMATIC_PLAN." ";
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
$last_description_type = $row['max'];
if (isset($last_description_type)) {
$row = Database::fetch_array($rs);
$next_description_type = $last_description_type + 1;
} else {
$next_description_type = ADD_THEMATIC_PLAN;
}
return $next_description_type;
}
/**
* update done thematic advances from thematic details interface
* @param int Thematic id
@ -797,10 +830,10 @@ class Thematic
public function get_default_question() {
$question = array();
$question[1]= get_lang('ObjectivesQuestions');
$question[2]= get_lang('DestrezaQuestions');
$question[3]= get_lang('InfraestructuraQuestions');
$question[2]= get_lang('SkillToAcquireQuestions');
$question[3]= get_lang('InfrastructureQuestions');
$question[4]= get_lang('MethodologyQuestions');
$question[5]= get_lang('AditionalsNotesQuestions');
$question[5]= get_lang('AditionalNotesQuestions');
return $question;
}

Loading…
Cancel
Save