Thematic tool - Adding copy funcionality for sessions + some minor UI changes

skala
Julio Montoya 14 years ago
parent 9000169e70
commit 11f02158d5
  1. 8
      main/course_progress/index.php
  2. 16
      main/course_progress/thematic.php
  3. 6
      main/course_progress/thematic_controller.php
  4. 2
      main/course_progress/thematic_plan.php
  5. 2
      main/inc/ajax/thematic.ajax.php
  6. 14
      main/inc/lib/attendance.lib.php
  7. 73
      main/inc/lib/thematic.lib.php

@ -34,7 +34,7 @@ api_protect_course_script(true);
define('ADD_THEMATIC_PLAN', 6);
// get actions
$actions = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_delete', 'moveup', 'movedown',
$actions = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_copy', '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');
@ -197,9 +197,11 @@ switch ($action) {
case 'thematic_add' :
case 'thematic_edit' :
case 'thematic_delete' :
case 'thematic_delete_select' :
case 'thematic_delete_select' :
case 'thematic_copy' :
case 'moveup' :
case 'movedown' :
if (!api_is_allowed_to_edit(null,true)) {
api_not_allowed();
}
@ -209,7 +211,7 @@ switch ($action) {
break;
case 'thematic_plan_add' :
case 'thematic_plan_edit' :
case 'thematic_plan_delete' :
case 'thematic_plan_delete' :
if (!api_is_allowed_to_edit(null,true)) {
api_not_allowed();
}

@ -64,7 +64,7 @@ if ($action == 'thematic_list') {
// display title
if (!empty($thematic_id)) {
echo '<div><strong>'.Security::remove_XSS($thematic_data[$thematic_id]['title'], STUDENT).': '.get_lang('Details').'</strong></div><br />';
//echo '<div><strong>'.Security::remove_XSS($thematic_data[$thematic_id]['title'], STUDENT).': '.get_lang('Details').'</strong></div><br />';
} else {
//echo '<div><strong>'.get_lang('ThematicDetails').'</strong></div><br />';
// display information
@ -78,20 +78,22 @@ if ($action == 'thematic_list') {
if (!empty($thematic_data)) {
// 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').': <strong><span id="div_result">'.$total_average_of_advances.'</span></strong>%</div><br />';
}
echo '<div style="text-align:right;"><h2>'.get_lang('Progress').': <span id="div_result">'.$total_average_of_advances.'</span> %</h2></div>';
echo '<table width="100%" class="data_table">';
echo '<tr><th width="33%">'.get_lang('Thematic').'</th><th>'.get_lang('ThematicPlan').'</th><th width="33%">'.get_lang('ThematicAdvance').'</th></tr>';
foreach ($thematic_data as $thematic) {
$session_star = '';
if (api_get_session_id() == $thematic['session_id']) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
} else {
continue;
}
echo '<tr>';
// display thematic title
echo '<td><h2>'.Security::remove_XSS($thematic['title'], STUDENT).'</h2><div>'.Security::remove_XSS($thematic['content'], STUDENT).'</div></td>';
echo '<td><h2>'.Security::remove_XSS($thematic['title'], STUDENT).$session_star.'</h2><div>'.Security::remove_XSS($thematic['content'], STUDENT).'</div></td>';
// display thematic plan data
echo '<td>';

@ -73,6 +73,12 @@ class ThematicController
$this->view->render();
}
}
}
//Copy a thematic to a session
if ($action == 'thematic_copy') {
$thematic->copy($_REQUEST['thematic_id']);
$action = 'thematic_list';
}
// delete many thematics

@ -41,7 +41,7 @@ echo $thematic_data['content'];
if ($message == 'ok') {
Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
}
if ($action == 'thematic_plan_list') {

@ -75,7 +75,7 @@ switch ($action) {
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();
$total_avererage = $thematic->get_total_average_of_thematic_advances(api_get_course_id(), api_get_session_id());
}
echo $total_avererage;
break;

@ -97,7 +97,8 @@ class Attendance
att.name AS col1,
att.description AS col2,
att.attendance_qualify_max AS col3,
att.locked AS col4
att.locked AS col4,
att.session_id
FROM $tbl_attendance att
WHERE att.active = 1 $condition_session
ORDER BY col$column $direction LIMIT $from,$number_of_items ";
@ -110,13 +111,18 @@ class Attendance
}
while ($attendance = Database::fetch_row($res)) {
$student_param = '';
if (api_is_drh() && ($_GET['student_id'])) {
$student_param = '&student_id='.Security::remove_XSS($_GET['student_id']);
}
$attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$param_gradebook.$student_param.'">'.$attendance[1].'</a>';
$session_star = '';
if (api_get_session_id() == $attendance[5]) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
}
$attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$param_gradebook.$student_param.'">'.$attendance[1].'</a>'.$session_star;
$attendance[3] = '<center>'.$attendance[3].'</center>';
if (api_is_allowed_to_edit(null, true)) {
$actions = '';

@ -4,7 +4,9 @@
/**
* 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>
* @author Julio Montoya <gugli100@gmail.com> SQL fixes + improvements
* @author Julio Montoya <gugli100@gmail.com> SQL fixes,
* By the way there are 3 tables that are mixed,
* there should be 3 different classes Thematic, ThematicAdvanced and Thematic plan and a controller
* @package chamilo.course_progress
*/
@ -87,20 +89,30 @@ class Thematic
while ($thematic = Database::fetch_row($res)) {
$session_star = '';
if (api_get_session_id() == $thematic[3]) {
$session_star = api_get_session_image(api_get_session_id(),$user_info['status']);
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
}
$thematic[1] = '<a href="index.php?'.api_get_cidreq().'&action=thematic_details&thematic_id='.$thematic[0].$param_gradebook.'">'.Security::remove_XSS($thematic[1], STUDENT).$session_star.'</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('lesson_plan.png',get_lang('ThematicPlan'),'','22').'</a>&nbsp;';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'','22').'</a>&nbsp;';
if (api_get_session_id()) {
if (api_get_session_id() == $thematic[3]) {
if (api_get_session_id() == $thematic[3]) {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'','22').'</a>&nbsp;';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'','22').'</a>&nbsp;';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>';
$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.png',get_lang('Delete'),'',22).'</a></center>';
$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.png',get_lang('Delete'),'',22).'</a>';
} else {
$actions .= Display::return_icon('lesson_plan_na.png',get_lang('ThematicPlan'),'',22).'&nbsp;';
$actions .= Display::return_icon('lesson_plan_calendar_na.png',get_lang('ThematicAdvance'),'',22).'&nbsp;';
$actions .= Display::return_icon('edit_na.png',get_lang('Edit'),'',22);
$actions .= Display::return_icon('delete_na.png',get_lang('Delete'),'',22).'&nbsp;';
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('Copy')), 'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$thematic[0].$param_gradebook);
}
} else {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'','22').'</a>&nbsp;';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'','22').'</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.png', get_lang('Up'),'',22).'</a>';
} else {
@ -112,7 +124,9 @@ class Thematic
$actions .= Display::return_icon('down_na.png','&nbsp;','',22);
}
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].$param_gradebook.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>';
$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.png',get_lang('Delete'),'',22).'</a></center>';
$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.png',get_lang('Delete'),'',22).'</a>';
}
$thematics[] = array($thematic[0], $thematic[1], $actions);
}
@ -319,6 +333,32 @@ class Thematic
}
return $affected_rows;
}
public function copy($thematic_id) {
$thematic = self::get_thematic_list($thematic_id, api_get_course_id(), 0);
$thematic_copy = new Thematic();
$thematic_copy->set_thematic_attributes('', $thematic['title'].' - '.get_lang('Copy'), $thematic['content'], api_get_session_id());
$new_thematic_id = $thematic_copy->thematic_save();
if (!empty($new_thematic_id)) {
$thematic_advanced = self::get_thematic_advance_by_thematic_id($thematic_id);
if(!empty($thematic_advanced)) {
foreach($thematic_advanced as $item) {
$thematic = new Thematic();
$thematic->set_thematic_advance_attributes(0, $new_thematic_id, 0, $item['content'], $item['start_date'], $item['duration']);
$thematic->thematic_advance_save();
}
}
$thematic_plan = self::get_thematic_plan_data($thematic_id);
if (!empty($thematic_plan)) {
foreach ($thematic_plan as $item) {
$thematic = new Thematic();
$thematic->set_thematic_plan_attributes($new_thematic_id, $item['title'], $item['description'], $item['description_type']);
$thematic->thematic_plan_save();
}
}
}
}
/**
* Get the total number of thematic advance inside current course
@ -687,7 +727,6 @@ class Thematic
$affected_rows = 0;
$user_id = api_get_user_id();
$all = array();
if (!empty($thematic_data)) {
@ -739,10 +778,10 @@ class Thematic
$ref = $row_thematic_done['ref'];
if (in_array($ref, $a_thematic_advance_ids)) { continue; }
// update items
Database::query("UPDATE $tbl_item_property SET lastedit_date='".date('Y-m-d H:i:s', time())."', lastedit_type='ThematicAdvanceUpdated', lastedit_user_id = $user_id WHERE tool='thematic_advance' AND ref=$ref");
Database::query("UPDATE $tbl_item_property SET lastedit_date='".api_get_utc_datetime()."', lastedit_type='ThematicAdvanceUpdated', lastedit_user_id = $user_id WHERE tool='thematic_advance' AND ref=$ref");
}
}
}
}
return $affected_rows;
}
@ -818,6 +857,16 @@ class Thematic
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);
$new_thematic_data = array();
if (!empty($thematic_data)) {
foreach ($thematic_data as $item) {
if ($item['session_id'] == api_get_session_id()) {
$new_thematic_data[] = $item;
}
}
$thematic_data = $new_thematic_data;
}
$thematic_advance_data = $this->get_thematic_advance_list(null, $course_code);
$a_average_of_advances_by_thematic = array();
$total_average = 0;
@ -834,9 +883,7 @@ class Thematic
$score = array_sum($a_average_of_advances_by_thematic);
$total_average = round(($score*100)/($count_tematics*100));
}
return $total_average;
}

Loading…
Cancel
Save