added new features for thematic advance - partial BT#578

skala
Cristian Fasanando 16 years ago
parent e329442edb
commit 1074583f0c
  1. 3
      main/attendance/attendance_calendar.php
  2. 4
      main/attendance/attendance_list.php
  3. 3
      main/attendance/attendance_sheet.php
  4. 175
      main/attendance/index.php
  5. 169
      main/attendance/thematic.php
  6. 125
      main/attendance/thematic_advance.php
  7. 245
      main/attendance/thematic_controller.php
  8. 96
      main/attendance/thematic_plan.php
  9. 21
      main/course_description/course_description_controller.php
  10. 14
      main/course_description/listing.php
  11. 55
      main/inc/ajax/thematic.ajax.php
  12. 18
      main/inc/lib/attendance.lib.php
  13. 16
      main/inc/lib/course_description.lib.php
  14. 12
      main/inc/lib/main_api.lib.php
  15. 833
      main/inc/lib/thematic.lib.php
  16. 12
      plugin/dashboard/block_course/block_course.class.php

@ -7,6 +7,9 @@
* @package chamilo.attendance
*/
// protect a course script
api_protect_course_script(true);
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);

@ -7,6 +7,9 @@
* @package chamilo.attendance
*/
// protect a course script
api_protect_course_script(true);
if (api_is_allowed_to_edit(null, true)) {
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
@ -14,6 +17,7 @@ if (api_is_allowed_to_edit(null, true)) {
}
echo '<div class="actions" style="margin-bottom:30px">';
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=attendance_add">'.Display::return_icon('adherir.png',get_lang('CreateANewAttendance')).' '.get_lang('CreateANewAttendance').'</a>';
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_details">'.Display::return_icon('defaut.gif',get_lang('ThematicControl')).' '.get_lang('ThematicControl').'</a>';
echo '</div>';
}
$table = new SortableTable('attendance_list', array('Attendance', 'get_number_of_attendances'), array('Attendance', 'get_attendance_data'), $default_column);

@ -7,6 +7,9 @@
* @package chamilo.attendance
*/
// protect a course script
api_protect_course_script(true);
if (api_is_allowed_to_edit(null, true)) {
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {

@ -9,27 +9,31 @@
*/
// name of the language file that needs to be included
$language_file = array ('userInfo', 'admin');
$language_file = array ('course_description', 'pedaSuggest', 'userInfo', 'admin');
// including files
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
require_once api_get_path(LIBRARY_PATH).'thematic.lib.php';
require_once api_get_path(LIBRARY_PATH).'app_view.php';
require_once 'attendance_controller.php';
require_once 'thematic_controller.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
// current section
$this_section = SECTION_COURSES;
// protect a course script
api_protect_course_script(true);
// defining constants and variables
// defining constants
define('ADD_THEMATIC_PLAN', 6);
$calendar_id = '';
if (isset($_GET['calendar_id'])) {
$calendar_id = intval($_GET['calendar_id']);
@ -38,27 +42,58 @@ if (isset($_GET['calendar_id'])) {
// get actions
$actions = array('attendance_list', 'attendance_sheet_list', 'attendance_sheet_add', 'attendance_add', 'attendance_edit', 'attendance_delete', 'attendance_delete_select');
$actions_calendar = array('calendar_list', 'calendar_add', 'calendar_edit', 'calendar_delete', 'calendar_all_delete');
$actions_thematic = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_delete', 'moveup', 'movedown',
'thematic_plan_list', 'thematic_plan_add', 'thematic_plan_edit', 'thematic_plan_delete',
'thematic_advance_list', 'thematic_advance_add', 'thematic_advance_edit', 'thematic_advance_delete');
$action = 'attendance_list';
if (isset($_GET['action']) && (in_array($_GET['action'],$actions) || in_array($_GET['action'],$actions_calendar))) {
if (isset($_GET['action']) && (in_array($_GET['action'],$actions) || in_array($_GET['action'],$actions_calendar) || in_array($_GET['action'],$actions_thematic))) {
$action = $_GET['action'];
}
if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') {
$action = 'thematic_delete_select';
}
// get attendance id
$attendance_id = 0;
if (isset($_GET['attendance_id'])) {
$attendance_id = intval($_GET['attendance_id']);
}
// instance object attendance for using like library here
// get thematic id
if (isset($_GET['thematic_id'])) {
$thematic_id = intval($_GET['thematic_id']);
}
// get thematic plan description type
if (isset($_GET['description_type'])) {
$description_type = intval($_GET['description_type']);
}
// instance attendance object for using like library here
$attendance = new Attendance();
// instance thematic object for using like library here
$thematic = new Thematic();
// attendance controller object
$attendance_controller = new AttendanceController();
// thematic controller object
$thematic_controller = new ThematicController();
if (!empty($attendance_id)) {
// attendance data by id
$attendance_data = $attendance->get_attendance_by_id($attendance_id);
}
if (!empty($thematic_id)) {
// thematic data by id
$thematic_data = $thematic->get_thematic_list($thematic_id);
}
// get default thematic plan title
$default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
@ -125,9 +160,57 @@ $htmlHeadXtra[] = '<script language="javascript">
$("#id_qualify").css("display","none");
$("#img_plus_and_minus").html(\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\');
}
});
});
});
function datetime_by_attendance(selected_value) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {},
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
data: "attendance_id="+selected_value,
success: function(datos) {
$("#div_datetime_attendance").html(datos);
}
});
}
function update_done_thematic_advance(selected_value) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {},
type: "GET",
url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance&thematic_advance_id="+selected_value,
data: "thematic_advance_id="+selected_value,
success: function(datos) {
$("#div_result").html(datos);
}
});
}
function check_per_attendance(obj) {
if (obj.checked == true) {
document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
document.getElementById(\'div_custom_datetime\').style.display=\'none\';
} else {
document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
document.getElementById(\'div_custom_datetime\').style.display=\'block\';
}
}
function check_per_custom_date(obj) {
if (obj.checked == true) {
document.getElementById(\'div_custom_datetime\').style.display=\'block\';
document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
} else {
document.getElementById(\'div_custom_datetime\').style.display=\'none\';
document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
}
}
</script>';
@ -158,14 +241,61 @@ if (!empty($gradebook)) {
$interbreadcrumb[] = array ('url' => '/main/gradebook/index.php', 'name' => get_lang('ToolGradebook'));
}
$interbreadcrumb[] = array ('url' => 'index.php?action=attendance_list'.$param_gradebook.$student_param, 'name' => get_lang('ToolAttendance'));
if($action == 'attendance_add') $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('CreateANewAttendance'));
if($action == 'attendance_edit') $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('Edit'));
if($action == 'attendance_sheet_list' || $action == 'attendance_sheet_add') $interbreadcrumb[] = array ('url' => '#', 'name' => $attendance_data['name']);
if($action == 'calendar_list' || $action == 'calendar_edit' || $action == 'calendar_delete' || $action == 'calendar_all_delete') {
if ($action == 'attendance_add') {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('CreateANewAttendance'));
}
if ($action == 'thematic_list') {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
}
if ($action == 'thematic_add') {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_list', 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
}
if ($action == 'thematic_edit') {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_list', 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
}
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 (isset($_GET['origin']) && $_GET['origin'] == 'thematic_details') {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_details', 'name' => get_lang('ThematicControl'));
} else {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_list', 'name' => get_lang('ThematicControl'));
}
$interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));
}
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 ($action == 'thematic_advance_list') {
if (isset($_GET['origin']) && $_GET['origin'] == 'thematic_details') {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_details', 'name' => get_lang('ThematicControl'));
} else {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_list', 'name' => get_lang('ThematicControl'));
}
$interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
}
if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_list', 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
}
if ($action == 'attendance_edit') {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('Edit'));
}
if ($action == 'attendance_sheet_list' || $action == 'attendance_sheet_add') {
$interbreadcrumb[] = array ('url' => '#', 'name' => $attendance_data['name']);
}
if ($action == 'calendar_list' || $action == 'calendar_edit' || $action == 'calendar_delete' || $action == 'calendar_all_delete') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance_id.$param_gradebook, 'name' => $attendance_data['name']);
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('AttendanceCalendar'));
}
if($action == 'calendar_add') {
if ($action == 'calendar_add') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance_id.$param_gradebook, 'name' => $attendance_data['name']);
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('AddDateAndTime'));
}
@ -175,8 +305,6 @@ if (isset($_POST['action']) && $_POST['action'] == 'attendance_delete_select') {
$attendance_controller->attendance_delete($_POST['id']);
}
// distpacher actions to controller
switch ($action) {
case 'attendance_list' : $attendance_controller->attendance_list();
@ -197,6 +325,27 @@ switch ($action) {
case 'calendar_all_delete' :
case 'calendar_delete' : $attendance_controller->attendance_calendar($action, $attendance_id, $calendar_id);
break;
case 'thematic_add' :
case 'thematic_edit' :
case 'thematic_delete' :
case 'thematic_delete_select' :
case 'thematic_details' :
case 'moveup' :
case 'movedown' :
case 'thematic_list' : $thematic_controller->thematic($action);
break;
case 'thematic_plan_list' :
case 'thematic_plan_add' :
case 'thematic_plan_edit' :
case 'thematic_plan_delete' : $thematic_controller->thematic_plan($action);
break;
case 'thematic_advance_list' :
case 'thematic_advance_add' :
case 'thematic_advance_edit' :
case 'thematic_advance_delete' : $thematic_controller->thematic_advance($action);
break;
default : $attendance_controller->attendance_list();
}

@ -0,0 +1,169 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for thematic control
* @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.attendance
*/
// protect a course script
api_protect_course_script(true);
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_details">'.Display::return_icon('view_table.gif',get_lang('ThematicDetails')).' '.get_lang('ThematicDetails').'</a>';
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_list">'.Display::return_icon('view_list.gif',get_lang('ThematicList')).' '.get_lang('ThematicList').'</a>';
if ($action == 'thematic_list') {
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>';
}
$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>';
$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 );
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') {
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 />';
} 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 '<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>';
}
} 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>';
} else {
echo '<td><center>-</center></td>';
}
}
echo '</tr>';
}
echo '</table>';
} else {
echo '<div><em>'.get_lang('StillDoNotHaveAThematicAdvance').'</em></div>';
}
echo '</td>';
echo '</tr>';
}
echo '</table>';
} else if ($action == 'thematic_add' || $action == 'thematic_edit') {
$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->addElement('header', '', $header_form);
$form->addElement('hidden', 'thematic_token',$token);
if (!empty($thematic_id)) {
$form->addElement('hidden', 'thematic_id',$thematic_id);
}
$form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '250'));
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
if (!empty($thematic_data)) {
// set default values
$default['title'] = $thematic_data['title'];
$default['content'] = $thematic_data['content'];
$form->setDefaults($default);
}
$form->display();
}
?>

@ -0,0 +1,125 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for thematic advance
* @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.attendance
*/
// 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') {
$header_form = get_lang('NewThematicAdvance');
if ($action == 'thematic_advance_edit') {
$header_form = get_lang('EditThematicAdvance');
}
// 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->addElement('header', '', $header_form);
$form->addElement('hidden', 'thematic_advance_token',$token);
if (!empty($thematic_advance_id)) {
$form->addElement('hidden', 'thematic_advance_id',$thematic_advance_id);
}
if (!empty($thematic_id)) {
$form->addElement('hidden', 'thematic_id',$thematic_id);
}
$radios = array();
$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'));
if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
$form->addElement('html', '<div id="div_custom_datetime" style="display:block">');
} else {
$form->addElement('html', '<div id="div_custom_datetime" style="display:none">');
}
$form->addElement('datepicker', 'custom_start_date', get_lang('StartDate'), array('form_name'=>'thematic_advance'));
$form->addElement('html', '</div>');
if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:none">');
} 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)'));
$form->addElement('html', '<div id="div_datetime_attendance">');
if (!empty($calendar_select)) {
$form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select);
}
$form->addElement('html', '</div>');
$form->addElement('html', '</div>');
$hours = range(0,24);
$form->addElement('select', 'duration_in_hours', get_lang('DurationInHours'), $hours);
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '150'));
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
$default['start_date_type'] = 1;
if (!empty($thematic_advance_data)) {
// set default values
$default['content'] = $thematic_advance_data['content'];
$default['duration_in_hours'] = $thematic_advance_data['duration'];
if (empty($thematic_advance_data['attendance_id'])) {
$default['start_date_type'] = 2;
$default['custom_start_date'] = date('d-F-Y H:i', api_strtotime(api_get_local_time($thematic_advance_data['start_date'])));
} else {
$default['start_date_type'] = 1;
if (!empty($calendar_select)) {
$default['start_date_by_attendance'] = $thematic_advance_data['start_date'];
}
$default['attendance_select'] = $thematic_advance_data['attendance_id'];
}
}
$form->setDefaults($default);
$form->display();
} else if ($action == 'thematic_advance_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_advance_add&thematic_id='.$thematic_id.'">'.Display::return_icon('template_add.gif',get_lang('NewThematicAdvance')).' '.get_lang('NewThematicAdvance').'</a>';
echo '</div>';
}
// thematic advance list
//echo '<br /><strong>'.get_lang('ThematicAdvancesList').'</strong>';
$table = new SortableTable('thematic_advance_list', array('Thematic', 'get_number_of_thematic_advances'), array('Thematic', 'get_thematic_advance_data'));
$table->set_additional_parameters($parameters);
$table->set_header(0, '', false, array('style'=>'width:20px;'));
$table->set_header(1, get_lang('StartDate'), true );
$table->set_header(2, get_lang('DurationInHours'), true, array('style'=>'width:80px;'));
$table->set_header(3, get_lang('Content'), true);
if (api_is_allowed_to_edit(null, true)) {
$table->set_header(4, get_lang('Actions'), false,array('style'=>'text-align:center'));
//$table->set_form_actions(array ('thematic_advance_delete_select' => get_lang('DeleteAllThematicAdvances')));
}
$table->display();
}
?>

@ -0,0 +1,245 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains class used like controller for thematic, it should be included inside a dispatcher file (e.g: index.php)
*
* !!! WARNING !!! : ALL DATES IN THIS MODULE ARE STORED IN UTC ! DO NOT CONVERT DURING THE TRANSITION FROM CHAMILO 1.8.x TO 2.0
*
* @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.attendance
*/
/**
* Thematic Controller script. Prepares the common background variables to give to the scripts corresponding to
* the requested action
* @package chamilo.attendance
*/
class ThematicController
{
/**
* Constructor
*/
public function __construct() {
$this->toolname = 'attendance';
$this->view = new View($this->toolname);
}
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';
}
}
}
// delete many thematics
if ($action == 'thematic_delete_select') {
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
$thematic_ids = $_POST['id'];
$affected_rows = $thematic->thematic_destroy($thematic_ids);
$action = 'thematic_list';
}
}
$thematic_id = isset($_GET['thematic_id'])?intval($_GET['thematic_id']):null;
if (isset($thematic_id)) {
// delete a thematic
if ($action == 'thematic_delete') {
$affected_rows = $thematic->thematic_destroy($thematic_id);
$action = 'thematic_list';
}
// move thematic
if ($action == 'moveup') {
$thematic->move_thematic('up', $thematic_id);
$action = 'thematic_list';
} else if ($action == 'movedown') {
$thematic->move_thematic('down', $thematic_id);
$action = 'thematic_list';
}
$data['thematic_data'] = $thematic->get_thematic_list($thematic_id);
$data['thematic_id'] = $thematic_id;
}
if ($action == 'thematic_details') {
if (isset($thematic_id)) {
$thematic_data[$thematic_id] = $thematic->get_thematic_list($thematic_id);
$data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id);
} else {
$thematic_data = $thematic->get_thematic_list();
$data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance();
$data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances();
}
$thematic_plan_data = $thematic->get_thematic_plan_data();
$thematic_advance_data = $thematic->get_thematic_advance_list();
$data['thematic_plan_data'] = $thematic_plan_data;
$data['thematic_advance_data'] = $thematic_advance_data;
$data['thematic_data'] = $thematic_data;
}
$data['action'] = $action;
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('thematic');
$this->view->render();
}
public function thematic_plan($action) {
$thematic= new Thematic();
$data = array();
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';
}
}
}
$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';
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
} 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)) {
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
$data['thematic_id'] = $thematic_id;
}
$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();
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('thematic_plan');
$this->view->render();
}
public function thematic_advance($action) {
$thematic= new Thematic();
$attendance = new Attendance();
$data = array();
// get data for attendance input select
$attendance_list = $attendance->get_attendances_list();
$attendance_select = array();
$attendance_select[0] = get_lang('SelectAnAttendance');
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 (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']);
$thematic_advance_data = array();
if (!empty($thematic_advance_id)) {
if ($action == 'thematic_advance_delete') {
$affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id);
$action = 'thematic_advance_list';
} else {
$thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);
}
}
// get calendar select by attendance id
$calendar_select = array();
if (!empty($thematic_advance_data)) {
if (!empty($thematic_advance_data['attendance_id'])) {
$attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']);
if (!empty($attendance_calendar)) {
foreach ($attendance_calendar as $calendar) {
$calendar_select[$calendar['date_time']] = $calendar['date_time'];
}
}
}
}
$data['action'] = $action;
$data['thematic_id'] = $thematic_id;
$data['thematic_advance_id'] = $thematic_advance_id;
$data['attendance_select'] = $attendance_select;
$data['thematic_advance_data'] = $thematic_advance_data;
$data['calendar_select'] = $calendar_select;
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('thematic_advance');
$this->view->render();
}
}
?>

@ -0,0 +1,96 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for thematic plan
* @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.attendance
*/
// actions menu
$categories = array ();
foreach ($default_thematic_plan_title as $id => $title) {
$categories[$id] = $title;
}
$categories[ADD_THEMATIC_PLAN] = get_lang('NewBloc');
$i=1;
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>';
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;';
$i++;
}
}
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) {
foreach ($thematic_plan_data as $thematic_plan) {
echo '<div class="sectiontitle">';
//delete
echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_delete&description_type='.$thematic_plan['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
echo Display::return_icon('delete.gif', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'));
echo '</a> ';
//edit
echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_edit&description_type='.$thematic_plan['description_type'].'">';
echo Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'));
echo '</a> ';
echo $thematic_plan['title'];
echo '</div>';
echo '<div class="sectioncomment">';
echo text_filter($thematic_plan['description']);
echo '</div>';
}
} else {
echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
}
} 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'];
}
}
// 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->addElement('hidden', 'thematic_plan_token', $token);
if (!empty($thematic_id)) {
$form->addElement('hidden', 'thematic_id', $thematic_id);
}
if (!empty($description_type)) {
$form->addElement('hidden', 'description_type', $description_type);
}
$form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
$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 (!empty($thematic_plan_data)) {
// set default values
$default['title'] = $thematic_plan_data[0]['title'];
$default['description'] = $thematic_plan_data[0]['description'];
}
$form->setDefaults($default);
$form->display();
}
?>

@ -84,8 +84,13 @@ class CourseDescriptionController { // extends Controller {
$course_description->set_title($title);
$course_description->set_content($content);
$course_description->set_progress($progress);
if ($description_type >= ADD_BLOCK) {
$affected_rows = $course_description->update();
if ($description_type >= ADD_BLOCK) {
$thematic_advance = $course_description->get_data_by_description_type($description_type);
if (!empty($thematic_advance)) {
$affected_rows = $course_description->update();
} else {
$affected_rows = $course_description->insert();
}
} else {
$thematic_advance = $course_description->get_data_by_description_type($description_type);
if (!empty($thematic_advance)) {
@ -131,8 +136,12 @@ class CourseDescriptionController { // extends Controller {
$this->view->render();
}
} else {
if (!empty($description_type)) {
$course_description_data = $course_description->get_data_by_description_type($description_type);
if (!empty($description_type)) {
if (isset($_GET['id_session'])) {
$session_id = intval($_GET['id_session']);
}
$course_description_data = $course_description->get_data_by_description_type($description_type, null, $session_id);
$data['default_description_titles'] = $course_description->get_default_description_title();
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
$data['default_description_icon'] = $course_description->get_default_description_icon();
@ -141,8 +150,8 @@ class CourseDescriptionController { // extends Controller {
$data['description_title'] = $course_description_data['description_title'];
$data['description_content'] = $course_description_data['description_content'];
$data['description_type'] = $description_type;
$data['progress'] = $course_description_data['progress'];
$data['descriptions'] = $course_description->get_data_by_description_type($description_type);
$data['progress'] = $course_description_data['progress'];
$data['descriptions'] = $course_description->get_data_by_description_type($description_type, null, $session_id);
}
// render to the view
$this->view->set_data($data);

@ -49,14 +49,16 @@ if (isset($descriptions) && count($descriptions) > 0) {
echo '<div class="sectiontitle">';
if (api_is_allowed_to_edit(null,true) && !$history) {
//delete
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
echo Display::return_icon('delete.gif', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'));
echo '</a> ';
if (api_get_session_id() == $description['session_id']) {
//delete
echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
echo Display::return_icon('delete.gif', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'));
echo '</a> ';
}
//edit
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&&description_type='.$description['description_type'].'">';
echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=edit&description_type='.$description['description_type'].'">';
echo Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'));
echo '</a> ';

@ -0,0 +1,55 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
/**
* Responses to AJAX calls for thematic
*/
require_once '../global.inc.php';
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
require_once api_get_path(LIBRARY_PATH).'thematic.lib.php';
$action = $_GET['a'];
switch ($action) {
case 'get_datetime_by_attendance':
$attendance_id = intval($_POST['attendance_id']);
$label = '';
$input_select = '';
if (!empty($attendance_id)) {
$attendance = new Attendance();
$attendance_calendar = $attendance->get_attendance_calendar($attendance_id);
$calendar_select = array();
$label = get_lang('StartDate');
if (!empty($attendance_calendar)) {
$input_select .= '<select name="start_date_by_attendance">';
foreach ($attendance_calendar as $calendar) {
$input_select .= '<option value="'.api_get_local_time($calendar['date_time']).'">'.api_get_local_time($calendar['date_time']).'</option>';
}
$input_select .= '</select>';
} else {
$input_select .= get_lang('ThereAreNoRegisteredDatetimeYet');
}
}
?>
<div class="row">
<div class="label"><?php echo $label ?></div>
<div class="formw"><?php echo $input_select ?></div>
</div>
<?php
break;
case 'update_done_thematic_advance':
$thematic_advance_id = intval($_GET['thematic_advance_id']);
$total_avererage = 0;
if (!empty($thematic_advance_id)) {
$thematic = new Thematic();
$affected_rows = $thematic->update_done_thematic_advances($thematic_advance_id);
$total_avererage = $thematic->get_total_average_of_thematic_advances();
}
echo $total_avererage;
break;
default:
echo '';
}
exit;
?>

@ -32,7 +32,8 @@ class Attendance
function get_number_of_attendances() {
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
$session_id = api_get_session_id();
$sql = "SELECT COUNT(att.id) AS total_number_of_items FROM $tbl_attendance att WHERE att.active = 1 = att.session_id = '$session_id' ";
$condition_session = api_get_session_condition($session_id);
$sql = "SELECT COUNT(att.id) AS total_number_of_items FROM $tbl_attendance att WHERE att.active = 1 $condition_session ";
$res = Database::query($sql);
$res = Database::query($sql);
$obj = Database::fetch_object($res);
@ -59,11 +60,14 @@ class Attendance
$condition_session = '';
if (isset($session_id)) {
$session_id = intval($session_id);
$condition_session = ' WHERE session_id = '.$session_id;
$condition_session = ' WHERE session_id = '.$session_id;
} else {
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
}
// get attendance data
$sql = "SELECT * FROM $tbl_attendance $condition_session ";
$sql = "SELECT * FROM $tbl_attendance WHERE active = 1 $condition_session ";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0){
while ($row = Database::fetch_array($rs)) {
@ -84,6 +88,7 @@ class Attendance
function get_attendance_data($from, $number_of_items, $column, $direction) {
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
@ -96,7 +101,7 @@ class Attendance
att.description AS col2,
att.attendance_qualify_max AS col3
FROM $tbl_attendance att
WHERE att.session_id = '$session_id' AND att.active = 1
WHERE att.active = 1 $condition_session
ORDER BY col$column $direction LIMIT $from,$number_of_items ";
$res = Database::query($sql);
$attendances = array ();
@ -135,7 +140,6 @@ class Attendance
*/
public function get_attendance_by_id($attendance_id) {
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
$sesion_id = api_get_session_id();
$attendance_id = intval($attendance_id);
$attendance_data = array();
$sql = "SELECT * FROM $tbl_attendance WHERE id = '$attendance_id'";
@ -238,8 +242,8 @@ class Attendance
/**
* delete attendaces
* @param int attendance id
* @return int affected rows
* @param int|array one or many attendances id
* @return int affected rows
*/
public function attendance_delete($attendance_id) {
global $_course;

@ -32,7 +32,8 @@ class CourseDescription
*/
public function get_description_data() {
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$sql = "SELECT * FROM $tbl_course_description WHERE session_id = '".$this->session_id."' ORDER BY id ";
$condition_session = api_get_session_condition($this->session_id, false, true);
$sql = "SELECT * FROM $tbl_course_description $condition_session ORDER BY id ";
$rs = Database::query($sql);
$data = array();
while ($description = Database::fetch_array($rs)) {
@ -74,20 +75,25 @@ class CourseDescription
/**
* Get all data by description and session id,
* first you must set session_id property with the object CourseDescription
* @param int description type
* @param int description type
* @param string course code (optional)
* @param int session id (optional)
* @return array
*/
public function get_data_by_description_type($description_type, $course_code = '') {
public function get_data_by_description_type($description_type, $course_code = '', $session_id = null) {
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
if (!isset($session_id)) {
$session_id = $this->session_id;
}
$condition_session = api_get_session_condition($session_id);
if (!empty($course_code)) {
$course_info = api_get_course_info($course_code);
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION, $course_info['dbName']);
}
$sql = "SELECT * FROM $tbl_course_description WHERE description_type='$description_type' AND session_id='".$this->session_id."'";
$sql = "SELECT * FROM $tbl_course_description WHERE description_type='$description_type' $condition_session ";
$rs = Database::query($sql);
$data = array();
if ($description = Database::fetch_array($rs)) {

@ -1499,16 +1499,18 @@ function api_get_session_image($session_id, $status_id) {
* @param bool optional, true if condition is only with session_id = current session id, false if condition is with 0 else
* @return string condition of the session
*/
function api_get_session_condition($session_id, $state = true, $both = false) {
function api_get_session_condition($session_id, $and = true, $with_base_content = false) {
$session_id = intval($session_id);
//condition to show resources by session
$condition_session = '';
$condition_add = $state == false ? " WHERE " : " AND ";
if ($session_id > 0) {
$condition_session = $condition_add." (session_id = ".(int)$session_id." OR session_id = 0) ";
$condition_add = $and == false ? " WHERE " : " AND ";
if ($with_base_content) {
$condition_session = $condition_add." (session_id = $session_id OR session_id = 0) ";
} else {
$condition_session = $condition_add." session_id = 0 ";
$condition_session = $condition_add." session_id = $session_id ";
}
return $condition_session;
}

@ -0,0 +1,833 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains class used like library, provides functions for thematic option inside attendance tool. It's also used like model to thematic_controller (MVC pattern)
* @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.attendance
*/
/**
* Thematic class can be used to instanciate objects or as a library for thematic control
* @package chamilo.attendance
*/
class Thematic
{
private $session_id;
private $thematic_id;
private $thematic_title;
private $thematic_content;
private $thematic_plan_id;
private $thematic_plan_title;
private $thematic_plan_description;
private $thematic_plan_description_type;
private $thematic_advance_id;
private $attendance_id;
private $thematic_advance_content;
private $start_date;
private $duration;
public function __construct() {}
/**
* Get the total number of thematic inside current course and current session
* @see SortableTable#get_total_number_of_items()
*/
public function get_number_of_thematics() {
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$sql = "SELECT COUNT(id) AS total_number_of_items FROM $tbl_thematic WHERE active = 1 $condition_session ";
$res = Database::query($sql);
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
/**
* Get the thematics to display on the current page (fill the sortable-table)
* @param int offset of first user to recover
* @param int Number of users to get
* @param int Column to sort on
* @param string Order (ASC,DESC)
* @see SortableTable#get_table_data($from)
*/
public function get_thematic_data($from, $number_of_items, $column, $direction) {
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
$sql = "SELECT
id AS col0,
title AS col1,
display_order AS col2
FROM $tbl_thematic
WHERE active = 1 $condition_session
ORDER BY col2 LIMIT $from,$number_of_items ";
$res = Database::query($sql);
$thematics = array ();
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook'];
}
while ($thematic = Database::fetch_row($res)) {
$thematic[1] = '<a href="index.php?'.api_get_cidreq().'&action=thematic_details&thematic_id='.$thematic[0].$param_gradebook.'">'.$thematic[1].'</a>';
if (api_is_allowed_to_edit(null, true)) {
$actions = '';
$actions .= '<center><a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('info.gif',get_lang('ThematicPlan')).'</a>&nbsp;';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('porcent.png',get_lang('ThematicAdvance')).'</a>&nbsp;';
if ($thematic[2] > 1) {
$actions .= '<a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('up.gif', get_lang('Up')).'</a>';
} else {
$actions .= Display::return_icon('up_na.gif','&nbsp;');
}
if ($thematic[2] < self::get_max_thematic_item()) {
$actions .= '<a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('down.gif',get_lang('Down')).'</a>';
} else {
$actions .= Display::return_icon('down_na.gif','&nbsp;');
}
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>&nbsp;';
$actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a></center>';
$thematics[] = array($thematic[0], $thematic[1], $actions);
}
}
return $thematics;
}
/**
* Get the maximum display order of the thematic item
* @return int Maximum display order
*/
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";
$rs = Database::query($sql);
$dsp=0;
$row = Database::fetch_array($rs);
return $row[0];
}
/**
* Move a thematic
*
* @param string Direction (up, down)
* @param int Thematic id
*/
function move_thematic($direction, $thematic_id)
{
// Database table definition
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
// sort direction
if ($direction == 'up') {
$sortorder = 'DESC';
} else {
$sortorder = 'ASC';
}
$sql = "SELECT * FROM $tbl_thematic ORDER BY display_order $sortorder";
$res = Database::query($sql);
$found = false;
while ($row = Database::fetch_array($res)) {
if ($found == true && empty($next_id)) {
$next_id = intval($row['id']);
$next_display_order = intval($row['display_order']);
}
if ($row['id'] == $thematic_id) {
$current_id = intval($thematic_id);
$current_display_order = intval($row['display_order']);
$found = true;
}
}
// get last done thematic advance before move thematic list
$last_done_thematic_advance = $this->get_last_done_thematic_advance();
$sql = "UPDATE $tbl_thematic SET display_order = $next_display_order WHERE id = $current_id ";
Database::query($sql);
$sql = "UPDATE $tbl_thematic SET display_order = $current_display_order WHERE id = $next_id ";
Database::query($sql);
// update done advances with de current thematic list
$update_done_advances = $this->update_done_thematic_advances($last_done_thematic_advance);
}
/**
* get thematic list
* @param int Thematic id (optional), get list by id
* @return array Thematic data
*/
public function get_thematic_list($thematic_id = null, $course_code = null, $session_id = null) {
// set current course and session
if (isset($course_code)) {
$course_info = api_get_course_info($course_code);
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC, $course_info['dbName']);
} else {
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
}
if (isset($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id();
}
$data = array();
$condition = '';
if (isset($thematic_id)) {
$thematic_id = intval($thematic_id);
$condition = " WHERE id = $thematic_id ";
} else {
$condition_session = api_get_session_condition($session_id);
$condition = " WHERE active = 1 $condition_session ";
}
$sql = "SELECT * FROM $tbl_thematic $condition ORDER BY display_order ";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
if (!empty($thematic_id)) {
$data = Database::fetch_array($res);
} else {
while ($row = Database::fetch_array($res)) {
$data[$row['id']] = $row;
}
}
}
return $data;
}
/**
* insert or update a thematic
* @return int last thematic id
*/
public function thematic_save() {
// definition database table
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
// protect data
$id = intval($this->thematic_id);
$title = Database::escape_string($this->thematic_title);
$content = Database::escape_string($this->thematic_content);
$session_id = intval($this->session_id);
// get the maximum display order of all the glossary items
$max_thematic_item = $this->get_max_thematic_item();
if (empty($id)) {
// insert
$sql = "INSERT INTO $tbl_thematic(title, content, active, display_order, session_id) VALUES ('$title', '$content', 1, ".(intval($max_thematic_item)+1).", $session_id) ";
Database::query($sql);
$last_id = Database::insert_id();
} else {
// update
$sql = "UPDATE $tbl_thematic SET title = '$title', content = '$content', session_id = $session_id WHERE id = $id ";
Database::query($sql);
$last_id = $id;
}
return $last_id;
}
/**
* Delete logically (set active field to 0) a thematic
* @param int|array One or many thematic ids
* @return int Affected rows
*/
function thematic_destroy($thematic_id) {
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
$affected_rows = 0;
if (is_array($thematic_id)) {
foreach ($thematic_id as $id) {
$id = intval($id);
$sql = "UPDATE $tbl_thematic SET active = 0 WHERE id = $id";
Database::query($sql);
$affected_rows += Database::affected_rows();
}
} else {
$thematic_id = intval($thematic_id);
$sql = "UPDATE $tbl_thematic SET active = 0 WHERE id = $thematic_id";
Database::query($sql);
$affected_rows = Database::affected_rows();
}
return $affected_rows;
}
/**
* Get the total number of thematic advance inside current course
* @see SortableTable#get_total_number_of_items()
*/
public function get_number_of_thematic_advances() {
global $thematic_id;
$tbl_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
$sql = "SELECT COUNT(id) AS total_number_of_items FROM $tbl_thematic_advance WHERE thematic_id = $thematic_id ";
$res = Database::query($sql);
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
/**
* Get the thematic advances to display on the current page (fill the sortable-table)
* @param int offset of first user to recover
* @param int Number of users to get
* @param int Column to sort on
* @param string Order (ASC,DESC)
* @see SortableTable#get_table_data($from)
*/
public function get_thematic_advance_data($from, $number_of_items, $column, $direction) {
global $thematic_id;
$tbl_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
$thematic_data = self::get_thematic_list($thematic_id);
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
$sql = "SELECT
id AS col0,
start_date AS col1,
duration AS col2,
content AS col3
FROM $tbl_thematic_advance
WHERE thematic_id = $thematic_id
ORDER BY col$column $direction LIMIT $from,$number_of_items ";
$res = Database::query($sql);
$data = array ();
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook'];
}
$i = 1;
while ($thematic_advance = Database::fetch_row($res)) {
$thematic_advance[1] = api_get_local_time($thematic_advance[1]);
if (api_is_allowed_to_edit(null, true)) {
$actions = '';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].$param_gradebook.'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>&nbsp;';
$actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].$param_gradebook.'">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a></center>';
$data[] = array($i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions);
}
$i++;
}
return $data;
}
/**
* get thematic advance data by tematic id
* @param int Thematic id
* @param string Course code (optional)
* @return array data
*/
public function get_thematic_advance_by_thematic_id($thematic_id, $course_code = null) {
// set current course
if (isset($course_code)) {
$course_info = api_get_course_info($course_code);
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE, $course_info['dbName']);
} else {
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
}
$thematic_id = intval($thematic_id);
$data = array();
$sql = "SELECT * FROM $tbl_thematic_advance WHERE thematic_id = $thematic_id ";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res)) {
$data[] = $row;
}
}
return $data;
}
/**
* get thematic advance list
* @param int Thematic advance id (optional), get data by thematic advance list
* @param string Course code (optional)
* @return array data
*/
public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null) {
// set current course
if (isset($course_code)) {
$course_info = api_get_course_info($course_code);
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE, $course_info['dbName']);
} else {
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
}
$data = array();
$condition = '';
if (isset($thematic_advance_id)) {
$thematic_advance_id = intval($thematic_advance_id);
$condition = " WHERE id = $thematic_advance_id ";
}
$sql = "SELECT * FROM $tbl_thematic_advance $condition ORDER BY start_date ";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
if (!empty($thematic_advance_id)) {
$data = Database::fetch_array($res);
} else {
// group all data group by thematic id
$tmp = array();
while ($row = Database::fetch_array($res)) {
$tmp[] = $row['thematic_id'];
if (in_array($row['thematic_id'], $tmp)) {
$data[$row['thematic_id']][$row['id']] = $row;
}
}
}
}
return $data;
}
/**
* insert or update a thematic advance
* @return int last thematic advance id
*/
public function thematic_advance_save() {
// definition database table
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
// protect data
$id = intval($this->thematic_advance_id);
$tematic_id = intval($this->thematic_id);
$attendance_id = intval($this->attendance_id);
$content = Database::escape_string($this->thematic_advance_content);
$start_date = Database::escape_string($this->start_date);
$duration = intval($this->duration);
if (empty($id)) {
// insert
$sql = "INSERT INTO $tbl_thematic_advance (thematic_id, attendance_id, content, start_date, duration) VALUES ($tematic_id, $attendance_id, '$content', '".api_get_utc_datetime($start_date)."', $duration) ";
Database::query($sql);
$last_id = Database::insert_id();
} else {
// update
$sql = "UPDATE $tbl_thematic_advance SET thematic_id = $tematic_id, attendance_id = $attendance_id, content = '$content', start_date = '".api_get_utc_datetime($start_date)."', duration = $duration WHERE id = $id ";
Database::query($sql);
$last_id = $id;
}
return $last_id;
}
/**
* delete thematic advance
* @param int Thematic advance id
* @return int Affected rows
*/
public function thematic_advance_destroy($thematic_advance_id) {
// definition database table
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
// protect data
$thematic_advance_id = intval($thematic_advance_id);
$sql = "DELETE FROM $tbl_thematic_advance WHERE id = $thematic_advance_id ";
Database::query($sql);
$affected_rows = Database::affected_rows();
return $affected_rows;
}
/**
* get thematic plan data
* @param int Thematic id (optional), get data by thematic id
* @param int Thematic plan description type (optional), get data by description type
* @return array Thematic plan data
*/
public function get_thematic_plan_data($thematic_id = null, $description_type = null) {
// definition database table
$tbl_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
$data = array();
$condition = '';
if (isset($thematic_id)) {
$thematic_id = intval($thematic_id);
$condition .= " AND thematic_id = $thematic_id ";
}
if (isset($description_type)) {
$description_type = intval($description_type);
$condition .= " AND description_type = $description_type ";
}
$sql = "SELECT * FROM $tbl_thematic_plan WHERE 1 $condition";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if (!isset($thematic_id) && !isset($description_type)) {
// group all data group by thematic id
$tmp = array();
while ($row = Database::fetch_array($rs)) {
$tmp[] = $row['thematic_id'];
if (in_array($row['thematic_id'], $tmp)) {
$data[$row['thematic_id']][$row['id']] = $row;
}
}
} else {
while ($row = Database::fetch_array($rs)) {
$data[] = $row;
}
}
}
return $data;
}
/**
* insert or update a thematic plan
* @return int affected rows
*/
public function thematic_plan_save() {
// definition database table
$tbl_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
// protect data
$thematic_id = intval($this->thematic_id);
$title = Database::escape_string($this->thematic_plan_title);
$description = Database::escape_string($this->thematic_plan_description);
$description_type = intval($this->thematic_plan_description_type);
// check thematic plan type already exists
$sql = "SELECT id FROM $tbl_thematic_plan WHERE thematic_id = $thematic_id AND description_type = $description_type ";
$rs = Database::query($sql);
$affected_rows = 0;
if (Database::num_rows($rs) > 0) {
// update
$upd = "UPDATE $tbl_thematic_plan SET title = '$title', description = '$description' WHERE thematic_id = $thematic_id AND description_type = $description_type ";
Database::query($upd);
$affected_rows = Database::affected_rows();
} else {
// insert
$ins = "INSERT INTO $tbl_thematic_plan(thematic_id, title, description, description_type) VALUES($thematic_id, '$title', '$description', $description_type) ";
Database::query($ins);
$affected_rows = Database::affected_rows();
}
return $affected_rows;
}
/**
* delete a thematic plan description
* @param int Thematic id
* @param int Description type
* @return int Affected rows
*/
public function thematic_plan_destroy($thematic_id, $description_type) {
// 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);
$sql = "DELETE FROM $tbl_thematic_plan WHERE thematic_id = $thematic_id AND description_type = $description_type ";
Database::query($sql);
$affected_rows = Database::affected_rows();
return $affected_rows;
}
/**
* update done thematic advances from thematic details interface
* @param int Thematic id
* @return int Affected rows
*/
public function update_done_thematic_advances ($thematic_advance_id) {
$thematic_data = $this->get_thematic_list();
$thematic_advance_data = $this->get_thematic_advance_list();
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$affected_rows = 0;
$a_thematic_advance_ids = array();
if (!empty($thematic_data)) {
foreach ($thematic_data as $thematic) {
$thematic_id = $thematic['id'];
if (!empty($thematic_advance_data[$thematic['id']])) {
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
$a_thematic_advance_ids[] = $thematic_advance['id'];
// update done thematic for previous advances ((done_advance = 1))
$upd = "UPDATE $tbl_thematic_advance set done_advance = 1 WHERE id = ".$thematic_advance['id']." ";
Database::query($upd);
$affected_rows += Database::affected_rows();
if ($thematic_advance['id'] == $thematic_advance_id) {
break 2;
}
}
}
}
}
// update done thematic for others advances (done_advance = 0)
if (!empty($a_thematic_advance_ids)) {
$upd = "UPDATE $tbl_thematic_advance set done_advance = 0 WHERE id NOT IN(".implode(',',$a_thematic_advance_ids).") ";
Database::query($upd);
}
return $affected_rows;
}
/**
* Get last done thematic advance from thematic details interface
* @return int Last done thematic advance id
*/
public function get_last_done_thematic_advance() {
$thematic_data = $this->get_thematic_list();
$thematic_advance_data = $this->get_thematic_advance_list();
$a_thematic_advance_ids = array();
$last_done_advance_id = 0;
if (!empty($thematic_data)) {
foreach ($thematic_data as $thematic) {
$thematic_id = $thematic['id'];
if (!empty($thematic_advance_data[$thematic['id']])) {
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
if ($thematic_advance['done_advance'] == 1) {
$a_thematic_advance_ids[] = $thematic_advance['id'];
}
}
}
}
}
if (!empty($a_thematic_advance_ids)) {
$last_done_advance_id = array_pop($a_thematic_advance_ids);
$last_done_advance_id = intval($last_done_advance_id);
}
return $last_done_advance_id;
}
/**
* Get total average of thematic advances
* @param string Course code (optional)
* @param int Session id (optional)
* @return float Average of thematic advances
*/
public function get_total_average_of_thematic_advances($course_code = null, $session_id = null) {
$thematic_data = $this->get_thematic_list(null, $course_code, $session_id);
$thematic_advance_data = $this->get_thematic_advance_list(null, $course_code);
$a_average_of_advances_by_thematic = array();
$total_average = 0;
if (!empty($thematic_data)) {
foreach ($thematic_data as $thematic) {
$thematic_id = $thematic['id'];
$a_average_of_advances_by_thematic[$thematic_id] = $this->get_average_of_advances_by_thematic($thematic_id, $course_code);
}
}
// calculate total average
if (!empty($a_average_of_advances_by_thematic)) {
$count_tematics = count($thematic_data);
$score = array_sum($a_average_of_advances_by_thematic);
$total_average = round(($score*100)/($count_tematics*100),2);
}
return $total_average;
}
/**
* Get average of advances by thematic
* @param int Thematic id
* @param string Course code (optional)
* @return float Average of thematic advances
*/
public function get_average_of_advances_by_thematic($thematic_id, $course_code = null) {
$thematic_advance_data = $this->get_thematic_advance_by_thematic_id($thematic_id, $course_code);
$average = 0;
if (!empty($thematic_advance_data)) {
// get all done advances by thematic
$advances = array();
$count_done_advances = 0;
$average = 0;
foreach ($thematic_advance_data as $thematic_advance) {
if ($thematic_advance['done_advance'] == 1) {
$count_done_advances++;
}
$advances[] = $thematic_advance['done_advance'];
}
// calculate average by thematic
$count_total_advances = count($advances);
$average = round(($count_done_advances*100)/$count_total_advances,2);
}
return $average;
}
/**
* set attributes for fields of thematic table
* @param int Thematic id
* @param string Thematic title
* @param string Thematic content
* @param int Session id
* @return void
*/
public function set_thematic_attributes($id = null, $title = '', $content = '', $session_id = 0) {
$this->thematic_id = $id;
$this->thematic_title = $title;
$this->thematic_content = $content;
$this->session_id = $session_id;
}
/**
* set attributes for fields of thematic_plan table
* @param int Thematic id
* @param string Thematic plan title
* @param string Thematic plan description
* @param int Thematic plan description type
* @return void
*/
public function set_thematic_plan_attributes($thematic_id = 0, $title = '', $description = '', $description_type = 0) {
$this->thematic_id = $thematic_id;
$this->thematic_plan_title = $title;
$this->thematic_plan_description = $description;
$this->thematic_plan_description_type = $description_type;
}
/**
* set attributes for fields of thematic_advance table
* @param int Thematic advance id
* @param int Thematic id
* @param int Attendance id
* @param string Content
* @param string Date and time
* @param int Duration in hours
* @return void
*/
public function set_thematic_advance_attributes($id = null, $thematic_id = 0, $attendance_id = 0, $content = '', $start_date = '0000-00-00 00:00:00', $duration = 0) {
$this->thematic_advance_id = $id;
$this->thematic_id = $thematic_id;
$this->attendance_id = $attendance_id;
$this->thematic_advance_content = $content;
$this->start_date = $start_date;
$this->duration = $duration;
}
/**
* set thematic id
* @param int Thematic id
* @return void
*/
public function set_thematic_id($thematic_id) {
$this->thematic_id = $thematic_id;
}
/**
* get thematic id
* @return void
*/
public function get_thematic_id() {
return $this->thematic_id;
}
/**
* Get thematic plan titles by default
* @return array
*/
public function get_default_thematic_plan_title() {
$default_thematic_plan_titles = array();
$default_thematic_plan_titles[1]= get_lang('Objectives');
$default_thematic_plan_titles[2]= get_lang('SkillToAcquire');
$default_thematic_plan_titles[3]= get_lang('Infrastructure');
$default_thematic_plan_titles[4]= get_lang('Methodology');
$default_thematic_plan_titles[5]= get_lang('AditionalNotes');
$default_thematic_plan_titles[6]= get_lang('Others');
return $default_thematic_plan_titles;
}
/**
* Get thematic plan icons by default
* @return array
*/
public function get_default_thematic_plan_icon() {
$default_thematic_plan_icon = array();
$default_thematic_plan_icon[1]= 'spire.gif';
$default_thematic_plan_icon[2]= 'korganizer.gif';
$default_thematic_plan_icon[3]= 'kcmdf_big.gif';
$default_thematic_plan_icon[4]= 'misc.gif';
$default_thematic_plan_icon[5]= 'ktip.gif';
$default_thematic_plan_icon[6]= 'new_test.gif';
return $default_thematic_plan_icon;
}
/**
* Get questions by default for help
* @return array
*/
public function get_default_question() {
$question = array();
$question[1]= get_lang('ObjectivesQuestions');
$question[2]= get_lang('DestrezaQuestions');
$question[3]= get_lang('InfraestructuraQuestions');
$question[4]= get_lang('MethodologyQuestions');
$question[5]= get_lang('AditionalsNotesQuestions');
return $question;
}
/**
* buid a string datetime from array
* @param array array containing data e.g: $array('Y'=>'2010', 'F' => '02', 'd' => '10', 'H' => '12', 'i' => '30')
* @return string date and time e.g: '2010-02-10 12:30:00'
*/
public function build_datetime_from_array($array) {
$year = '0000';
$month = $day = $hours = $minutes = $seconds = '00';
if (isset($array['Y']) && isset($array['F']) && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
$year = $array['Y'];
$month = $array['F'];
if (intval($month) < 10 ) $month = '0'.$month;
$day = $array['d'];
if (intval($day) < 10 ) $day = '0'.$day;
$hours = $array['H'];
if (intval($hours) < 10 ) $hours = '0'.$hours;
$minutes = $array['i'];
if (intval($minutes) < 10 ) $minutes = '0'.$minutes;
}
if (checkdate($month,$day,$year)) {
$datetime = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.':'.$seconds;
}
return $datetime;
}
}
?>

@ -12,7 +12,7 @@
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
require_once api_get_path(LIBRARY_PATH).'thematic.lib.php';
/**
* This class is used like controller for this course block plugin,
@ -148,7 +148,8 @@ class BlockCourse extends Block {
$a_course_students = array();
$course_data = array();
$courses = $this->courses;
$course_description = new CourseDescription();
$thematic = new Thematic();
foreach ($courses as $row_course) {
@ -156,7 +157,7 @@ class BlockCourse extends Block {
$avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
// students directly subscribed to the course
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status=".STUDENT." AND course_rel_user.course_code='$course_code'";
$rs = Database::query($sql);
$users = array();
while ($row = Database::fetch_array($rs)) {
@ -170,11 +171,10 @@ class BlockCourse extends Block {
}
$tematic_advance_progress = 0;
$course_description->set_session_id(0);
$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
$tematic_advance = $thematic->get_total_average_of_thematic_advances($course_code, 0);
if (!empty($tematic_advance)) {
$tematic_advance_progress = '<a title="'.get_lang('GoToThematicAdvance').'" href="'.api_get_path(WEB_CODE_PATH).'course_description/?cidReq='.$course_code.'#thematic_advance">'.$tematic_advance['progress'].'%</a>';
$tematic_advance_progress = '<a title="'.get_lang('GoToThematicAdvance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&action=thematic_details">'.$tematic_advance.'%</a>';
} else {
$tematic_advance_progress = '0%';
}

Loading…
Cancel
Save