Now we can add/edit more fast the Thematic plan thanks to some jquery tricks, the Thematic advance will modify later

skala
Julio Montoya 14 years ago
parent 1bcd53f582
commit e7505492ba
  1. 46
      main/course_progress/index.php
  2. 2
      main/course_progress/layout.php
  3. 14
      main/course_progress/layout_headerless.php
  4. 54
      main/course_progress/thematic.php
  5. 2
      main/course_progress/thematic_advance.php
  6. 26
      main/course_progress/thematic_controller.php
  7. 13
      main/course_progress/thematic_plan.php
  8. 16
      main/inc/ajax/thematic.ajax.php
  9. 5
      main/inc/lib/events.lib.inc.php
  10. 52
      main/inc/lib/thematic.lib.php

@ -79,7 +79,8 @@ if (!empty($thematic_id)) {
// get default thematic plan title
$default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
//jquery thickbox already called from main/inc/header.inc.php
$htmlHeadXtra[] = api_get_jquery_ui_js();
$htmlHeadXtra[] = '<script language="javascript">
@ -96,6 +97,49 @@ function datetime_by_attendance(selected_value) {
});
}
$(document).ready(function() {
$(".thematic_plan_opener").live("click", function() {
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $(\'<div id="dialog" style="display:hidden"></div> \').appendTo(\'body\');
}
// load remote content
dialog.load(
url,
{},
function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog({
width: 720,
height: 550,
modal: true,
buttons: {
'.addslashes(get_lang('Save')).' : function() {
var serialize_form_content = $("#thematic_plan_add").serialize();
$.ajax({
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_plan",
data: serialize_form_content,
success: function(data) {
var thematic_id = $("input[name=\"thematic_id\"]").val();
$("#thematic_plan_"+thematic_id ).html(data);
}
});
dialog.dialog("close");
}
}
});
}
);
//prevent the browser to follow the link
return false;
});
});
function update_done_thematic_advance(selected_value) {
$.ajax({
contentType: "application/x-www-form-urlencoded",

@ -25,5 +25,3 @@ echo $content;
// Footer
Display :: display_footer();
?>

@ -0,0 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
// protect a course script
api_protect_course_script(true);
Display :: display_reduced_header();
// Tracking
event_access_tool($tool);
// Display
echo $content;

@ -20,23 +20,15 @@ if (api_is_allowed_to_edit(null, true)) {
switch ($action) {
case 'thematic_add' :
echo '<a href="index.php?'.api_get_cidreq().'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ThematicDetails'),'','32').'</a>';
//echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_details">'.Display::return_icon('view_table.gif',get_lang('ThematicDetails')).' '.get_lang('ThematicDetails').'</a>';//TODO:delete, no need
//echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_list">'.Display::return_icon('view_list.gif',get_lang('ThematicList')).' '.get_lang('ThematicList').'</a>';//TODO:delete, no need
break;
case 'thematic_list' :
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'','32').'</a>';
//echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_details">'.Display::return_icon('view_detailed.png',get_lang('ThematicDetails'),'','32').'</a>';
//echo '<strong>'.Display::return_icon('view_list.gif',get_lang('ThematicList')).' '.get_lang('ThematicList').'</strong>&nbsp;&nbsp;';//TODO:delete, no need
break;
case 'thematic_details' :
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'','32').'</a>';
//echo '<strong>'.Display::return_icon('view_table.gif',get_lang('ThematicDetails')).' '.get_lang('ThematicDetails').'</strong>&nbsp;&nbsp;';////TODO:delete, no need
//echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_list">'.Display::return_icon('view_text.png',get_lang('ThematicList'),'','32').'</a>';
break;
default :
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'','32').'</a>';
//echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_details">'.Display::return_icon('back.png',get_lang('ThematicDetails'),'','32').'</a>';
//echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_list">'.Display::return_icon('view_text.png',get_lang('ThematicList'),'','32').'</a>';
}
echo '</div>';
}
@ -53,8 +45,6 @@ if ($action == 'thematic_list') {
$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')));
}
//echo '<div><strong>'.get_lang('ThematicList').'</strong></div><br />';
$table->display();
} elseif ($action == 'thematic_details') {
@ -133,48 +123,12 @@ if ($action == 'thematic_list') {
echo '<td>';
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) {
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'">'.Display::return_icon('edit.png',get_lang('EditThematicPlan'),array('style'=>'vertical-align:middle'),22).'</a></div><br />';
echo '<div style="text-align:right"><a class="thematic_plan_opener" href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'">'.
Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style'=>'vertical-align:middle'),22).'</a></div><br />';
}
$new_thematic_plan_data = array();
if (!empty($thematic_plan_data[$thematic['id']]))
foreach($thematic_plan_data[$thematic['id']] as $thematic_item) {
$thematic_simple_list[] = $thematic_item['description_type'];
$new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
}
$new_id = ADD_THEMATIC_PLAN;
if (!empty($thematic_simple_list))
foreach($thematic_simple_list as $item) {
if ($item >= ADD_THEMATIC_PLAN) {
$new_id = $item + 1;
$default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
}
}
$no_data = true;
$session_star = '';
if (!empty($default_thematic_plan_title)) {
foreach ($default_thematic_plan_title as $id=>$title) {
//avoid others
if ($title == 'Others' && empty($thematic_plan_data[$thematic['id']][$id]['description'])) { continue; }
if (!empty($thematic_plan_data[$thematic['id']][$id]['title']) && !empty($thematic_plan_data[$thematic['id']][$id]['description'])) {
if (api_is_allowed_to_edit(null, true)) {
if ($thematic_plan_data[$thematic['id']][$id]['session_id'] !=0) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
}
}
echo Display::tag('h3', Security::remove_XSS($thematic_plan_data[$thematic['id']][$id]['title'], STUDENT).$session_star);
echo Security::remove_XSS($thematic_plan_data[$thematic['id']][$id]['description'], STUDENT).'</div>';
$no_data = false;
} else {
//echo '<h3>'.$title.'</strong></h3><br />';
}
}
}
echo $thematic_plan_div[$thematic['id']];
if ($no_data) {
echo '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>';
}
echo '</td>';
// display thematic advance data
@ -240,6 +194,8 @@ if ($action == 'thematic_list') {
echo '</td>';
echo '</tr>';
} //End for
echo '</table>';
} else {
echo '<div><em>'.get_lang('ThereIsNoAThematicSection').'</em></div>';

@ -73,6 +73,8 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$form->add_textfield('duration_in_hours', get_lang('DurationInHours'), false, array('size'=>'3'));
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '150'));
//$form->addElement('textarea', 'content', get_lang('Content'));
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');

@ -131,7 +131,6 @@ class ThematicController
if ($action == 'thematic_details') {
if (isset($thematic_id)) {
$thematic_data_result = $thematic->get_thematic_list($thematic_id);
if (!empty($thematic_data_result)) {
$thematic_data[$thematic_id] = $thematic_data_result;
}
@ -139,7 +138,6 @@ class ThematicController
} else {
$thematic_data = $thematic->get_thematic_list(null, api_get_course_id(), api_get_session_id());
$data['max_thematic_item'] = $thematic->get_max_thematic_item();
$data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance();
$data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances();
}
@ -150,6 +148,9 @@ class ThematicController
//Third column
$thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true);
$data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data);
$data['thematic_plan_data'] = $thematic_plan_data;
$data['thematic_advance_data'] = $thematic_advance_data;
$data['thematic_data'] = $thematic_data;
@ -173,7 +174,7 @@ class ThematicController
public function thematic_plan($action) {
$thematic= new Thematic();
$data = array();
$data = array();
$error = false;
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
@ -215,18 +216,7 @@ class ThematicController
} else if($_POST['action'] == 'thematic_plan_list') {
$title_list = $_POST['title'];
$description_list = $_POST['description'];
$description_type = $_POST['description_type'];
if (api_is_allowed_to_edit(null, true)) {
for($i=1;$i<count($title_list)+1; $i++) {
//if (!empty($description_list[$i])) {
$thematic->set_thematic_plan_attributes($_POST['thematic_id'], $title_list[$i], $description_list[$i], $description_type[$i]);
$affected_rows = $thematic->thematic_plan_save();
//}
}
$data['message'] = 'ok';
}
}
}
@ -255,7 +245,6 @@ class ThematicController
$data['thematic_id'] = $thematic_id;
}
$data['thematic_id'] = $thematic_id;
$data['action'] = $action;
$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
@ -264,10 +253,9 @@ class ThematicController
$data['default_thematic_plan_question'] = $thematic->get_default_question();
$data['thematic_data'] = $thematic->get_thematic_list($thematic_id);
// render to the view
//render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_layout('layout_headerless');
$this->view->set_template('thematic_plan');
$this->view->render();
exit;

@ -25,9 +25,8 @@ foreach($thematic_simple_list as $item) {
}
$i=1;
/*
echo '<div class="actions" style="margin-bottom:30px">';
if ($action == 'thematic_plan_edit') {
echo '<a href="index.php?action=thematic_plan_list&'.api_get_cidreq().'&thematic_id='.$thematic_id.'">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>&nbsp;&nbsp;';
} else {
@ -35,7 +34,7 @@ if ($action == 'thematic_plan_edit') {
echo '<a href="index.php?action=thematic_plan_edit&'.api_get_cidreq().'&description_type='.$new_id.'&thematic_id='.$thematic_id.'">'.Display::return_icon('wizard.png', get_lang('NewBloc'), array(), 32).'</a>';
}
echo '</div>';
*/
echo Display::tag('h2', $thematic_data['title']);
echo $thematic_data['content'];
@ -58,7 +57,10 @@ if ($action == 'thematic_plan_list') {
//$title = $default_thematic_plan_title[$id];
$form->addElement('hidden', 'description_type['.$id.']', $id);
$form->add_textfield('title['.$id.']', get_lang('Title'), true, array('size'=>'50'));
$form->add_html_editor('description['.$id.']', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
//$form->add_html_editor('description['.$id.']', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
$form->addElement('textarea', 'description['.$id.']', get_lang('Description'));
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
@ -77,8 +79,7 @@ if ($action == 'thematic_plan_list') {
$form->setDefaults($default);
}
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
//$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
$form->display();
} else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {

@ -13,6 +13,22 @@ api_protect_course_script(true);
$action = $_GET['a'];
switch ($action) {
case 'save_thematic_plan':
$thematic = new Thematic();
$title_list = $_REQUEST['title'];
$description_list = $_REQUEST['description'];
$description_type = $_REQUEST['description_type'];
if (api_is_allowed_to_edit(null, true)) {
for($i=1;$i<count($title_list)+1; $i++) {
$thematic->set_thematic_plan_attributes($_REQUEST['thematic_id'], $title_list[$i], $description_list[$i], $description_type[$i]);
$affected_rows = $thematic->thematic_plan_save();
}
}
$thematic_plan_data = $thematic->get_thematic_plan_data();
$return = $thematic->get_thematic_plan_div($thematic_plan_data);
echo $return[$_REQUEST['thematic_id']];
break;
case 'get_datetime_by_attendance':
$attendance_id = intval($_POST['attendance_id']);

@ -148,9 +148,10 @@ function event_access_tool($tool, $id_session=0) {
// only if user comes from the course $_cid
//if( eregi($_configuration['root_web'].$_cid,$_SERVER['HTTP_REFERER'] ) )
//$pos = strpos($_SERVER['HTTP_REFERER'],$_configuration['root_web'].$_cid);
$pos = strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower(api_get_path(WEB_COURSE_PATH).$_course['path']));
$pos = isset($_SERVER['HTTP_REFERER']) ? strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower(api_get_path(WEB_COURSE_PATH).$_course['path'])) : false;
// added for "what's new" notification
$pos2 = strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower($_configuration['root_web']."index"));
$pos2 = isset($_SERVER['HTTP_REFERER']) ? strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower($_configuration['root_web']."index")) : false;
// end "what's new" notification
if ($pos !== false || $pos2 !== false) {
$sql = "INSERT INTO ".$TABLETRACK_ACCESS."

@ -467,6 +467,58 @@ class Thematic
return $data;
}
public function get_thematic_plan_div($data, $id = false) {
$final_return = array();
foreach ($data as $thematic_id => $thematic_plan_data) {
$new_thematic_plan_data = array();
foreach($thematic_plan_data as $thematic_item) {
$thematic_simple_list[] = $thematic_item['description_type'];
$new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
}
$new_id = ADD_THEMATIC_PLAN;
if (!empty($thematic_simple_list)) {
foreach($thematic_simple_list as $item) {
//if ($item >= ADD_THEMATIC_PLAN) {
//$new_id = $item + 1;
$default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
//}
}
}
$no_data = true;
$session_star = '';
$return = '<div id="thematic_plan_'.$thematic_id.'">';
if (!empty($default_thematic_plan_title)) {
foreach ($default_thematic_plan_title as $id=>$title) {
$thematic_plan_data_item = '';
//avoid others
if ($title == 'Others' && empty($data[$thematic_id][$id]['description'])) {
continue;
}
if (!empty($data[$thematic_id][$id]['title']) && !empty($data[$thematic_id][$id]['description'])) {
if (api_is_allowed_to_edit(null, true)) {
if ($data[$thematic_id][$id]['session_id'] !=0) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
}
}
$return .= Display::tag('h3', Security::remove_XSS($data[$thematic_id][$id]['title'], STUDENT).$session_star);
$return .= Security::remove_XSS($data[$thematic_id][$id]['description'], STUDENT);
$no_data = false;
}
}
}
if ($no_data) {
$return .= '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>';
}
$return .= '</div>';
$final_return[$thematic_id] = $return;
}
return $final_return;
}
/**
* get thematic advance list
* @param int Thematic advance id (optional), get data by thematic advance list

Loading…
Cancel
Save