Yannick Warnier пре 13 година
родитељ
комит
167e89af51
39 измењених фајлова са 1092 додато и 961 уклоњено
  1. 52 33
      main/calendar/agenda.inc.php
  2. 110 131
      main/calendar/agenda.php
  3. 1 1
      main/calendar/myagenda.inc.php
  4. 2 3
      main/calendar/myagenda.php
  5. 58 0
      main/coursecopy/classes/CourseRecycler.class.php
  6. 3 3
      main/coursecopy/classes/CourseRestorer.class.php
  7. 1 1
      main/coursecopy/copy_course.php
  8. 81 5
      main/css/base.css
  9. 3 10
      main/css/base_chamilo.css
  10. 23 59
      main/document/create_document.php
  11. 7 12
      main/document/create_draw.php
  12. 7 16
      main/document/create_paint.php
  13. 67 56
      main/document/document.php
  14. 3 1
      main/document/download.php
  15. 4 2
      main/document/showinframes.php
  16. 2 1
      main/document/showinframesmin.php
  17. 20 18
      main/document/upload.php
  18. 2 2
      main/exercice/admin.php
  19. 352 353
      main/exercice/exercise.class.php
  20. 8 31
      main/exercice/exercise.lib.php
  21. 13 16
      main/exercice/exercise_result.php
  22. 17 50
      main/exercice/exercise_show.php
  23. 45 48
      main/exercice/exercise_submit.php
  24. 3 1
      main/exercice/hotspot_admin.inc.php
  25. 10 3
      main/exercice/question_admin.inc.php
  26. 3 2
      main/inc/ajax/document.ajax.php
  27. 9 5
      main/inc/lib/database.lib.php
  28. 6 5
      main/inc/lib/display.lib.php
  29. 111 31
      main/inc/lib/document.lib.php
  30. 7 7
      main/inc/lib/events.lib.inc.php
  31. 1 1
      main/inc/lib/exercise_show_functions.lib.php
  32. 1 1
      main/inc/lib/fileUpload.lib.php
  33. 3 4
      main/newscorm/learnpath.class.php
  34. 37 20
      main/newscorm/lp_view.php
  35. 8 16
      main/user/user.php
  36. 5 7
      main/work/work.lib.php
  37. 2 2
      main/work/work.php
  38. 2 1
      tests/main/inc/lib/display.lib.test.php
  39. 3 3
      tests/main/inc/lib/events.lib.inc.test.php

+ 52 - 33
main/calendar/agenda.inc.php

@@ -527,7 +527,7 @@ function display_monthcalendar($month, $year, $agenda_items) {
     							$dayheader .= $time.' '.$icon.' '.Display::div($url);
     							
     							//Hidden content
-    							$content = Display::div($icon.Display::tag('h1', $value['title']).$complete_time.$value['content']);
+    							$content = Display::div($icon.Display::tag('h1', $value['title']).$complete_time.'<hr />'.$value['content']);
     							
     							//Main div
     							$dayheader .= Display::div($content, array('id'=>'main_'.$value['calendar_type'].'_'.$value['id'], 'class' => 'dialog', 'style' => 'display:none'));
@@ -1427,8 +1427,8 @@ function show_user_filter_form()
 function show_user_group_filter_form() {    
 	echo "<select name=\"select\" onchange=\"javascript: MM_jumpMenu('parent',this,0)\">";	
     echo "<option value=\"agenda.php?user=none&action=view\">".get_lang("ShowAll")."</option>";
-	// Groups
-	
+    
+	// Groups	
 	$group_list = get_course_groups();
 
 	$group_available_to_access =array();
@@ -1537,11 +1537,10 @@ function change_visibility($tool,$id,$visibility)
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 */
 function display_courseadmin_links() {
-	//echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('calendar_add.gif', get_lang('AgendaAdd'))." ".get_lang('AgendaAdd')."</a>";
 	echo "<a href='".api_get_self()."?".api_get_cidreq()."&amp;sort=asc&amp;toolgroup=".api_get_group_id()."&action=add&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('new_event.png', get_lang('AgendaAdd'),'','32')."</a>";
 	echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=importical&amp;view=".(($_SESSION['view']=='month')?"list":Security::remove_XSS($_SESSION['view'])."&amp;origin=".Security::remove_XSS($_GET['origin']))."'>".Display::return_icon('import_calendar.png', get_lang('ICalFileImport'),'','32')."</a>";
+	
 	if (empty ($_SESSION['toolgroup'])) {
-		//echo get_lang('UserGroupFilter');
 		echo get_lang('SentTo');
 		echo "&nbsp;&nbsp;<form name=\"filter\" style=\"display:inline;\">";
 		show_user_group_filter_form();
@@ -1569,7 +1568,12 @@ function display_student_links() {
 	}	
 	$day_url = '&month='.date('m').'&year='.date('Y').'&view='.Security::remove_XSS($_GET['view']);
 	$today_url = api_get_self()."?action=view".$day_url."&toolgroup=".api_get_group_id();
-	echo Display::url(get_lang('Today'), $today_url );
+	echo Display::url(get_lang('Today'), $today_url, array('class'=>'a_button white medium'));
+	
+	//@todo Add next events and all events?  ...
+	 
+	//echo Display::url(get_lang('AllEvents'), $all_url, array('class'=>'a_button white medium'));
+	//echo Display::url(get_lang('Next events'), $all_url, array('class'=>'a_button white medium'));
 }
 
 
@@ -2304,7 +2308,7 @@ function show_add_form($id = '') {
 
 	<!-- START OF THE FORM  -->
 
-	<form enctype="multipart/form-data"  action="<?php echo api_get_self().'?origin='.$origin.'&'.api_get_cidreq()."&sort=asc&toolgroup=".Security::remove_XSS($_GET['toolgroup']).'&action='.$_GET['action']; ?>" method="post" name="new_calendar_item">
+	<form enctype="multipart/form-data"  action="<?php echo api_get_self().'?origin='.$origin.'&'.api_get_cidreq()."&sort=asc&toolgroup=".Security::remove_XSS($_GET['toolgroup']).'&action='.Security::remove_XSS($_GET['action']); ?>" method="post" name="new_calendar_item">
 	<input type="hidden" name="id" value="<?php if (isset($id)) echo $id; ?>" />
 	<input type="hidden" name="action" value="<?php if (isset($_GET['action'])) echo $_GET['action']; ?>" />
 	<input type="hidden" name="id_attach" value="<?php echo isset($_REQUEST['id_attach']) ? intval($_REQUEST['id_attach']) : null; ?>" />
@@ -2928,8 +2932,7 @@ function display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $
 	// number of days that have already passed this week * 24 hours * 60 minutes * 60 seconds
 	$current_day = date("j", $today); // Day of the month without leading zeros (1 to 31) of today
 	$day_of_the_week = date("w", $today); // Numeric representation of the day of the week	0 (for Sunday) through 6 (for Saturday) of today
-	//$timestamp_first_date_of_week=$today-(($day_of_the_week-1)*24*60*60); // timestamp of the monday of this week
-	//$timestamp_last_date_of_week=$today+((7-$day_of_the_week)*24*60*60); // timestamp of the sunday of this week
+
 	// we are loading all the calendar items of all the courses for today
 	echo "<table class=\"data_table\">";
 	// the forward and backwards url
@@ -2942,6 +2945,25 @@ function display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $
 	echo "</th>";
 	echo "<th width=\"10%\"><a href=\"", $forewardsURL, "\">".Display::return_icon('action_next.png',get_lang('Next'))."</a></th>";
 	echo "</tr>";
+	
+	// From  0 to 5h
+	$class = "class=\"row_even\"";
+	echo "<tr $class>";
+	echo ("<td valign=\"top\" width=\"75\">0:00 ".get_lang("HourShort")." - 4:30 ".get_lang("HourShort")."</td>");
+	echo "<td $class valign=\"top\" colspan=\"2\">";
+	for ($i = 0; $i < 10; $i ++) {
+		if (isset($agendaitems[$i])) {
+			if (is_array($agendaitems[$i])) {
+				foreach ($agendaitems[$i] as $key => $value) {
+					echo $value;
+				}
+			} else {
+				echo $agendaitems[$i];
+			}
+		}
+	}
+	echo "</td>";
+	echo "</tr>";
 
 	// the rows for each half an hour
 	for ($i = 10; $i < 48; $i ++) {
@@ -2990,15 +3012,11 @@ function display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $month
 	// if we moved to the next / previous week we have to recalculate the $today variable
 
 	if (!isset($_GET['week'])) {
-		/*
-		$today = mktime(0, 0, 0, 1, 1, $year);
-		$today = $today + (((int)$_GET['week']-1) * (7 * 24 * 60 * 60));
-		$week_number = date("W", $today);*/
-		$week_number = date("W", time());
-
+		$week_number = date("W", $today);
 	} else {
 		$week_number = intval($_GET['week']);
 	}
+	
 	// calculating the start date of the week
 	// the date of the monday of this week is the timestamp of today minus
 	// number of days that have already passed this week * 24 hours * 60 minutes * 60 seconds
@@ -3011,10 +3029,6 @@ function display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $month
 
 	$timestamp_first_date_of_week = mktime(0, 0, 0, $start_end['start']['month'], $start_end['start']['day'], $start_end['start']['year']);
 	$timestamp_last_date_of_week  = mktime(0, 0, 0, $start_end['end']['month'], $start_end['end']['day'], $start_end['end']['year']);
-	//var_dump($start_end);
-	/*$timestamp_first_date_of_week = $today - (($day_of_the_week -1) * 24 * 60 * 60); // timestamp of the monday of this week
-	$timestamp_last_date_of_week = $today + ((7 - $day_of_the_week) * 24 * 60 * 60); // timestamp of the sunday of this week
-	*/
 
 	$backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".api_get_course_id()."&action=view&view=week&week=". ($week_number -1);
 	$forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".api_get_course_id()."&action=view&view=week&week=". ($week_number +1);
@@ -3092,6 +3106,14 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day) {
 		// getting all the groups of the user for the current course
 		$group_memberships = GroupManager :: get_group_ids($array_course_info['db_name'], api_get_user_id());
 		$course_user_status = CourseManager::get_user_in_course_status(api_get_user_id(), $array_course_info['code']);
+		
+		
+		$start_filter  = $year."-".$month."-".$day." 00:00:00";
+		$start_filter  = api_get_utc_datetime($start_filter);
+		$end_filter    = $year."-".$month."-".$day." 23:59:59";
+		$end_filter    = api_get_utc_datetime($end_filter);
+		
+		
 		// if the user is administrator of that course we show all the agenda items
 		if ($course_user_status == '1') {
 			//echo "course admin";
@@ -3100,7 +3122,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day) {
 							FROM ".$TABLEAGENDA." agenda,
 								".$TABLE_ITEMPROPERTY." item_property
 							WHERE agenda.id = item_property.ref
-							AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
+							AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'							
 							AND item_property.tool='".TOOL_CALENDAR_EVENT."'
 							AND item_property.visibility='1'
 							GROUP BY agenda.id
@@ -3108,14 +3130,14 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day) {
 		}
 		// if the user is not an administrator of that course
 		else {
-			//echo "GEEN course admin";
+			//echo "course admin";
 			if (is_array($group_memberships) && count($group_memberships)>0) {
 				$sqlquery = "SELECT
 								agenda.*, item_property.*
 								FROM ".$TABLEAGENDA." agenda,
 									".$TABLE_ITEMPROPERTY." item_property
 								WHERE agenda.id = item_property.ref
-								AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
+								AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'
 								AND item_property.tool='".TOOL_CALENDAR_EVENT."'
 								AND	( item_property.to_user_id='".api_get_user_id()."' OR item_property.to_group_id IN (0, ".implode(", ", $group_memberships).") )
 								AND item_property.visibility='1'
@@ -3126,18 +3148,15 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day) {
 								FROM ".$TABLEAGENDA." agenda,
 									".$TABLE_ITEMPROPERTY." item_property
 								WHERE agenda.id = item_property.ref
-								AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
+								AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'
 								AND item_property.tool='".TOOL_CALENDAR_EVENT."'
 								AND ( item_property.to_user_id='".api_get_user_id()."' OR item_property.to_group_id='0')
 								AND item_property.visibility='1'
 								ORDER BY start_date ";
 			}
 		}
-		//$sqlquery = "SELECT * FROM $agendadb WHERE DAYOFMONTH(day)='$day' AND month(day)='$month' AND year(day)='$year'";
-		//echo "abc";
-		//echo $sqlquery;
+
 		$result = Database::query($sqlquery);
-		//echo Database::num_rows($result);
 		while ($item = Database::fetch_array($result)) {
 			// in the display_daycalendar function we use $i (ranging from 0 to 47) for each halfhour
 			// we want to know for each agenda item for this day to wich halfhour it must be assigned
@@ -3199,7 +3218,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '') {
 	$start_filter  = api_get_utc_datetime($start_filter);
 	$end_filter 	= $start_end['end']['year']."-".$start_end['end']['month']."-".$start_end['end']['day']." 23:59:59";
 	$end_filter  = api_get_utc_datetime($end_filter);
-	//var_dump($start_filter, $end_filter);
+
 	// get agenda-items for every course
 	foreach ($courses_dbs as $key => $array_course_info) {
 		//databases of the courses
@@ -3275,7 +3294,6 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '') {
 			//Display the events in agenda
 			$content  = "<i>$start_time - $end_time</i> <a href=\"$URL\" title=\"".$array_course_info["title"]."\"> <br />".$agenda_link."</a>";
 			$content .= "<div>".$item['title']."</div><br>";
-			//$items[$agendaday][$item['start_date']] .= Display::div($content, array('class'=>'rounded_div_agenda'));
 			$items[$agendaday][$item['start_date']] .= $content;
 		}
 	}
@@ -4038,6 +4056,7 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
     			AND item_property.tool       = '".TOOL_CALENDAR_EVENT."'
     			AND item_property.ref = agenda.id
     			AND item_property.visibility <> 2";
+    
     $result = Database::query($sql);
     $count = Database::num_rows($result);
     if ($count > 0) {
@@ -4074,8 +4093,8 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
         }
     }
 
-    if(!$done) // the message is sent to everyone, so we set the group to 0
-    {
+    if(!$done) {
+    	// the message is sent to everyone, so we set the group to 0
         api_item_property_update($course_info, TOOL_CALENDAR_EVENT, $last_id, "AgendaAdded", $user_id,0,0, $start_date,$end_date);
     }
     // storing the resources
@@ -4304,7 +4323,7 @@ function agenda_import_ical($course_info,$file) {
 	require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
    	$charset = api_get_system_encoding();
     $filepath = api_get_path(SYS_ARCHIVE_PATH).$file['name'];
-    if(!@move_uploaded_file($file['tmp_name'],$filepath)) {
+    if (!@move_uploaded_file($file['tmp_name'],$filepath)) {
     	error_log('Problem moving uploaded file: '.$file['error'].' in '.__FILE__.' line '.__LINE__);
     	return false;
     }
@@ -4371,7 +4390,7 @@ function agenda_import_ical($course_info,$file) {
     while (true) {
     	//we need to recover: summary, description, dtstart, dtend, organizer, attendee, location (=course name),
     
-    	$ve = $ical->getComponent(VEVENT, $eventcount);
+    	$ve = $ical->getComponent(VEVENT, $eventcount);    	
     	if (!$ve)
     	break;
     

+ 110 - 131
main/calendar/agenda.php

@@ -168,26 +168,24 @@ Display::display_introduction_section(TOOL_CALENDAR_EVENT);
 //setting the default year and month
 $select_year = '';
 $select_month = '';
+$select_day = '';
+
 if(!empty($_GET['year'])) {
 	$select_year = (int)$_GET['year'];
 }
 if(!empty($_GET['month'])) {
 	$select_month = (int)$_GET['month'];
 }
-
-$select_day = '';
-
 if(!empty($_GET['day'])) {
     $select_day = (int)$_GET['day'];
 }
-$select_year = '';
-if (empty($select_year)) {
-	$today = getdate();
+
+$today = getdate();
+
+if (empty($select_year)) {	
 	$select_year = $today['year'];	
 }
-
-if (empty($select_month)) {
-    $today = getdate();
+if (empty($select_month)) { 
     $select_month = $today['mon'];
 }
 
@@ -198,45 +196,101 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 display_student_links();
 echo '</div>';
 
+
+// Getting agenda items
+
+$agenda_items = get_calendar_items($select_month, $select_year);
+
+if ($_SESSION['view'] != 'month') {
+	echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
+
+	// THE LEFT PART
+	if (empty($origin) or $origin !='learnpath') {
+		echo '<td width="220" height="19" valign="top">';
+		// the small calendar
+		if (api_get_setting('display_mini_month_calendar') == 'true') {
+			display_minimonthcalendar($agenda_items, $select_month, $select_year);
+		}
+		echo '<br />';
+		if (api_get_setting('display_upcoming_events') == 'true') {
+			display_upcoming_events();
+		}
+		echo '</td>';
+		echo '<td width="20" background="../img/verticalruler.gif">&nbsp;</td>';
+	}
+
+	// THE RIGHT PART
+	echo '<td valign="top">';
+	echo '<div class="sort" style="float:left">';
+	echo '</div>';
+}
+
+$event_id = isset($_GET['id']) ? $_GET['id'] : null;
+$course_info = api_get_course_info(); 
+
 if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false,true))) {
 	switch($action) {
+		case 'add':
+			if (isset($_POST['submit_event']) && $_POST['submit_event']) {				
+				$event_start 		= (int) $_POST['fyear'].'-'.(int) $_POST['fmonth'].'-'.(int) $_POST['fday'].' '.(int) $_POST['fhour'].':'.(int) $_POST['fminute'].':00';
+				$event_stop   		= (int) $_POST['end_fyear'].'-'.(int) $_POST['end_fmonth'].'-'.(int) $_POST['end_fday'].' '.(int) $_POST['end_fhour'].':'.(int) $_POST['end_fminute'].':00';
+				$safe_title 		= Security::remove_XSS($_POST['title']);
+				$safe_file_comment 	= Security::remove_XSS($_POST['file_comment']);
+		
+				if ($_POST['empty_end_date'] == 'on' ) {
+					$event_stop = '0000-00-00 00:00:00';
+				}
+				$id = agenda_add_item($course_info,$safe_title,$_POST['content'],$event_start,$event_stop,$_POST['selectedform'],false,$safe_file_comment);
+				if (!empty($_POST['repeat'])) {
+					$end_y = intval($_POST['repeat_end_year']);
+					$end_m = intval($_POST['repeat_end_month']);
+					$end_d = intval($_POST['repeat_end_day']);
+					$end   = mktime(23, 59, 59, $end_m, $end_d, $end_y);
+					$res   = agenda_add_repeat_item($course_info,$id, $_POST['repeat_type'], $end,$_POST['selectedform'], $safe_file_comment);
+				}
+				$action = 'view';
+			} else {
+				show_add_form();
+			}
+			break;			
+		case "announce":
+			//copying the agenda item into an announcement
+			if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id))) {
+				// a coach can only delete an element belonging to his session
+				$ann_id = store_agenda_item_as_announcement($event_id);
+				$tool_group_link = (isset($_SESSION['toolgroup'])?'&toolgroup='.$_SESSION['toolgroup']:'');
+				Display::display_normal_message(get_lang('CopiedAsAnnouncement').'&nbsp;<a href="../announcements/announcements.php?id='.$ann_id.$tool_group_link.'">'.get_lang('NewAnnouncement').'</a>', false);
+			}
+			display_agenda_items($agenda_items, $select_day);
+			break;
+			
 		case 'importical':
-			if(isset($_POST['ical_submit'])) {
-                $course_info = api_get_course_info();
+			if (isset($_POST['ical_submit'])) {                
                 $ical_name = $_FILES['ical_import']['name'];
                 $ical_type = $_FILES['ical_import']['type'];
                 
                 $ext = substr($ical_name,(strrpos($ical_name,".")+1));
+
                 //$ical_type === 'text/calendar' 
                 if ($ext === 'ics' || $ext === 'ical' || $ext === 'icalendar'  || $ext === 'ifb') {
-                	agenda_import_ical($course_info,$_FILES['ical_import']);
+                	agenda_import_ical($course_info, $_FILES['ical_import']);
                 	$is_ical = true;
                 } else {
                 	$is_ical = false;
                 }
-            }
-            break;
-		case 'add':
-			if (isset($_POST['submit_event']) && $_POST['submit_event']) {
-		     	$course_info 		= api_get_course_info();
-			    $event_start 		= (int) $_POST['fyear'].'-'.(int) $_POST['fmonth'].'-'.(int) $_POST['fday'].' '.(int) $_POST['fhour'].':'.(int) $_POST['fminute'].':00';
-                $event_stop   		= (int) $_POST['end_fyear'].'-'.(int) $_POST['end_fmonth'].'-'.(int) $_POST['end_fday'].' '.(int) $_POST['end_fhour'].':'.(int) $_POST['end_fminute'].':00';
-                $safe_title 		= Security::remove_XSS($_POST['title']);
-                $safe_file_comment 	= Security::remove_XSS($_POST['file_comment']);
                 
-                if ($_POST['empty_end_date'] == 'on' ) {
-                	$event_stop = '0000-00-00 00:00:00';
-                }
-				$id = agenda_add_item($course_info,$safe_title,$_POST['content'],$event_start,$event_stop,$_POST['selectedform'],false,$safe_file_comment);
-                if (!empty($_POST['repeat'])) {
-                	$end_y = intval($_POST['repeat_end_year']);
-                    $end_m = intval($_POST['repeat_end_month']);
-                    $end_d = intval($_POST['repeat_end_day']);
-                    $end   = mktime(23, 59, 59, $end_m, $end_d, $end_y);
-                    $res = agenda_add_repeat_item($course_info,$id, $_POST['repeat_type'], $end,$_POST['selectedform'], $safe_file_comment);
+                if (!$is_ical) {
+                	Display::display_error_message(get_lang('IsNotiCalFormatFile'));
+                	display_ical_import_form();
+                	break;
+                } else {
+                	Display::display_confirmation_message(get_lang('AddSuccess'));
                 }
-			}
-			break;
+                display_agenda_items($agenda_items, $select_day);
+            } else {
+            	display_ical_import_form();
+            }
+            break;		
 		case 'edit':
 			if( !(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id'])))) {
 				// a coach can only delete an element belonging to his session
@@ -244,113 +298,38 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 					$my_id_attach = (int)$_REQUEST['id_attach'];
 					$safe_file_comment = Security::remove_XSS($_REQUEST['file_comment']);
 					store_edited_agenda_item($my_id_attach, $safe_file_comment);
+					display_agenda_items($agenda_items, $select_day);					
+				} else {					
+					show_add_form($event_id);
 				}
+			} else {
+				display_agenda_items($agenda_items, $select_day);
 			}
 			break;
-		case "delete":
-			$id=(int)$_GET['id'];
-			if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id ) ) )
-			{ // a coach can only delete an element belonging to his session
-				delete_agenda_item($id);
+		case "delete":			
+			if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id ) ) ) {
+				// a coach can only delete an element belonging to his session
+				delete_agenda_item($event_id);
 			}
+			display_agenda_items($agenda_items, $select_day);
 			break;
-		case "showhide":
-			$id=(int)$_GET['id'];
-			if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id ) ) ) {
+		case "showhide":			
+			if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id))) {
 			     // a coach can only delete an element belonging to his session			   
-				showhide_agenda_item($id);
+				showhide_agenda_item($event_id);
 			}
-			break;
-		case "announce": 		
-			//copying the agenda item into an announcement
-			$id=(int)$_GET['id'];
-			if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id))) { 
-			    // a coach can only delete an element belonging to his session
-				$ann_id = store_agenda_item_as_announcement($id);
-				$tool_group_link = (isset($_SESSION['toolgroup'])?'&toolgroup='.$_SESSION['toolgroup']:'');
-				Display::display_normal_message(get_lang('CopiedAsAnnouncement').'&nbsp;<a href="../announcements/announcements.php?id='.$ann_id.$tool_group_link.'">'.get_lang('NewAnnouncement').'</a>', false);
-			}
-			break;
+			
+			if (!empty($event_id)) {
+				display_one_agenda_item($event_id);
+			} else {
+				display_agenda_items($agenda_items, $select_day);
+			}			
+			break;		
 		case "delete_attach": 	//delete attachment file
 			$id_attach = (int)$_GET['id_attach'];
 			if (!empty($id_attach)) {
 				delete_attachment_file($id_attach);
 			}
-			break;
-	}
-}
-
-// Getting agenda items
-
-$agenda_items = get_calendar_items($select_month, $select_year);
-
-if ($_SESSION['view'] != 'month') {
-    echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
-    
-    // THE LEFT PART
-    if (empty($origin) or $origin !='learnpath') {
-    	echo '<td width="220" height="19" valign="top">';
-    	// the small calendar    	
-    	if (api_get_setting('display_mini_month_calendar') == 'true') {	   
-            display_minimonthcalendar($agenda_items, $select_month, $select_year);	   
-    	}	
-    	echo '<br />';
-    	if (api_get_setting('display_upcoming_events') == 'true') {
-    		display_upcoming_events();
-    	}
-    	echo '</td>';
-    	echo '<td width="20" background="../img/verticalruler.gif">&nbsp;</td>';
-    }
-    
-    // THE RIGHT PART
-    echo '<td valign="top">';
-    echo '<div class="sort" style="float:left">';
-    echo '</div>';
-}
-
-if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false,true) )) {		
-	switch ($action) {
-		case 'importical' :
-			if (isset($_POST['ical_submit'])) {
-		        if (!$is_ical) {
-					Display::display_error_message(get_lang('IsNotiCalFormatFile'));
-					display_ical_import_form();
-					break;
-				}
-		        display_agenda_items($agenda_items, $select_day);
-		    } else {
-		    	display_ical_import_form();
-		    }
-		    break;
-		case 'add' :
-			if (isset($_POST['submit_event']) && $_POST['submit_event']) {
-				display_agenda_items($agenda_items, $select_day);
-			} else {
-				show_add_form();
-			}
-			break;
-		case 'edit' :
-			if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id'])))) {
-				if ($_POST['submit_event']) {
-					display_agenda_items($agenda_items, $select_day);
-				} else {
-					$id=(int)$_GET['id'];
-					show_add_form($id);
-				}
-			} else {
-				display_agenda_items($agenda_items, $select_day);
-			}
-			break;
-		case 'showhide':
-			if(!empty($_GET['agenda_id'])) {
-				 display_one_agenda_item((int)$_GET['agenda_id']);
-			} else {
-				display_agenda_items($agenda_items, $select_day);
-			}
-			break;
-        case 'delete':
-        case 'delete_attach':    
-		case 'announce': 		
 			display_agenda_items($agenda_items, $select_day);
 			break;
 	}
@@ -360,14 +339,14 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 
 if ($action == "view" || empty($action)) {    
 	if ($origin != 'learnpath') {	    
-		if ($_SESSION['view'] == 'month') {			
+		if ($_SESSION['view'] == 'month') {
 		    display_monthcalendar($select_month, $select_year, $agenda_items);            
 		} else {
 		  if (!empty($_GET['agenda_id'])) {
                 display_one_agenda_item($_GET['agenda_id']);
             } else {
-                $month_name = $MonthsLong[$select_month -1];               
-                echo Display::tag('h2', $select_day.' '.$month_name.' '.$select_year);
+                $month_name = $MonthsLong[$select_month -1];                
+                echo Display::tag('h2', $select_day.' '.$month_name.' '.$select_year);                
                 display_agenda_items($agenda_items, $select_day);
             }
 		}

+ 1 - 1
main/calendar/myagenda.inc.php

@@ -228,7 +228,7 @@ function display_mymonthcalendar($user_id, $agendaitems, $month, $year, $weekday
                             $result .= $time.' '.$icon.' '.Display::div($url);
                             
                             //Hidden content
-                            $content = Display::div($icon.Display::tag('h1', $value['title']).$complete_time.Security::remove_XSS($value['content']));
+                            $content = Display::div($icon.Display::tag('h1', $value['title']).$complete_time.'<hr />'.Security::remove_XSS($value['content']));
                             
                             //Main div
                             $result .= Display::div($content, array('id'=>'main_'.$value['calendar_type'].'_'.$value['id'], 'class' => 'dialog', 'style' => 'display:none'));

+ 2 - 3
main/calendar/myagenda.php

@@ -204,12 +204,11 @@ if (isset($_user['user_id'])) {
 	}
 	
 	switch ($process) {
-		case 'month_view' :
-			
+		case 'month_view' :			
 			display_mymonthcalendar(api_get_user_id(), $agendaitems, $month, $year, array(), $monthName);
 			break;
 		case 'week_view' :
-			$agendaitems = get_week_agendaitems($my_course_list, $month, $year, $week);			
+			$agendaitems = get_week_agendaitems($my_course_list, $month, $year, $week);						
 			$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "week_view");			
 			if (api_get_setting("allow_personal_agenda") == "true") {
 				$agendaitems = get_personal_agenda_items(api_get_user_id(), $agendaitems, $day, $month, $year, $week, "week_view");

+ 58 - 0
main/coursecopy/classes/CourseRecycler.class.php

@@ -47,6 +47,8 @@ class CourseRecycler
         $this->recycle_cours_description();
         $this->recycle_wiki();
         $this->recycle_glossary();
+        $this->recycle_thematic();
+        $this->recycle_attendance();
 
 
         foreach ($this->course->resources as $type => $resources) {
@@ -408,4 +410,60 @@ class CourseRecycler
             Database::query($sql);
         }
     }
+    /**
+    * Recycle Thematics
+    */
+    function recycle_thematic($session_id = 0) {
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
+            $table_thematic         = Database :: get_course_table(TABLE_THEMATIC, $this->course->destination_db);
+            $table_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE, $this->course->destination_db);
+            $table_thematic_plan    = Database :: get_course_table(TABLE_THEMATIC_PLAN, $this->course->destination_db);
+        
+            $resources = $this->course->resources;
+            foreach ($resources[RESOURCE_THEMATIC] as $last_id => $thematic) {
+                if (is_numeric($last_id)) {
+                    
+                    foreach($thematic->thematic_advance_list as $thematic_advance) {
+                        $cond = array('id = ?'=>$thematic_advance['id']);
+                        api_item_property_update($this->destination_course_info, 'thematic_advance', $thematic_advance['id'],'ThematicAdvanceDeleted', api_get_user_id());
+                        Database::delete($table_thematic_advance, $cond);
+                    }
+                    
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
+                        $cond = array('id = ?'=>$thematic_plan['id']);
+                        api_item_property_update($this->destination_course_info, 'thematic_plan', $thematic_advance['id'], 'ThematicPlanDeleted', api_get_user_id());
+                        Database::delete($table_thematic_plan, $cond);
+                    }
+                    $cond = array('id = ?'=>$last_id);
+                    api_item_property_update($this->destination_course_info, 'thematic', $last_id,'ThematicDeleted', api_get_user_id());
+                    Database::delete($table_thematic,$cond);
+                }
+            }
+        }
+    }
+    
+    /**
+    * Recycle Attendances
+    */
+    function recycle_attendance($session_id = 0) {
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
+            $table_attendance          = Database :: get_course_table(TABLE_ATTENDANCE, $this->course->destination_db);
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR, $this->course->destination_db);
+           
+            $resources = $this->course->resources;
+            foreach ($resources[RESOURCE_ATTENDANCE] as $last_id => $obj) {
+                print_r($obj);
+                if (is_numeric($last_id)) {
+                    
+                    foreach($obj->attendance_calendar as $attendance_calendar) {
+                        $cond = array('id = ?'=>$attendance_calendar['id']);
+                        $my_id = Database::delete($table_attendance_calendar, $cond);
+                    }
+                    $cond = array('id = ?'=>$last_id);
+                    Database::delete($table_attendance, $cond);
+                    api_item_property_update($this->destination_course_info, TOOL_ATTENDANCE, $last_id,'AttendanceDeleted', api_get_user_id());
+                }
+            }
+        }
+    }
 }

+ 3 - 3
main/coursecopy/classes/CourseRestorer.class.php

@@ -1754,7 +1754,7 @@ class CourseRestorer
 	
 				$doc = '';
 				$thematic->params['id'] = null;
-				$last_id = Database::insert($table_thematic, $thematic->params, true);
+				$last_id = Database::insert($table_thematic, $thematic->params, false);
 				
 				if (is_numeric($last_id)) {
 					api_item_property_update($this->destination_course_info, 'thematic', $last_id,"ThematicAdded", api_get_user_id());
@@ -1763,7 +1763,7 @@ class CourseRestorer
 						unset($thematic_advance['id']);						
 						$thematic_advance['attendance_id'] = 0;
 						$thematic_advance['thematic_id'] = $last_id;
-						$my_id = Database::insert($table_thematic_advance, $thematic_advance, true);
+						$my_id = Database::insert($table_thematic_advance, $thematic_advance, false);
 						
 						if (is_numeric($my_id)) {
 							api_item_property_update($this->destination_course_info, 'thematic_advance', $my_id,"ThematicAdvanceAdded", api_get_user_id());
@@ -1773,7 +1773,7 @@ class CourseRestorer
 					foreach($thematic->thematic_plan_list as $thematic_plan) {
 						unset($thematic_advance['id']);						
 						$thematic_plan['thematic_id'] = $last_id;
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, true);
+						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
 						if (is_numeric($my_id)) {
 							api_item_property_update($this->destination_course_info, 'thematic_plan', $my_id, "ThematicPlanAdded", api_get_user_id());
 						}

+ 1 - 1
main/coursecopy/copy_course.php

@@ -52,7 +52,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
 	$cr = new CourseRestorer($course);
 	$cr->set_file_option($_POST['same_file_name_option']);
 	$cr->restore($_POST['destination_course']);
-	Display::display_normal_message(get_lang('CopyFinished'));
+	Display::display_normal_message(get_lang('CopyFinished').': <a href="'.api_get_course_url($_POST['destination_course']).'">'.$_POST['destination_course'].'</a>',false);
 } elseif (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'select_items') {
 	$cb = new CourseBuilder();
 	$course = $cb->build();	

+ 81 - 5
main/css/base.css

@@ -672,6 +672,31 @@ button:hover {
 }
 
 
+/* gray */
+.gray {
+    color: #e9e9e9;
+    border: solid 1px #555;
+    background: #6e6e6e;
+    background: -webkit-gradient(linear, left top, left bottom, from(#888), to(#575757));
+    background: -moz-linear-gradient(top,  #888,  #575757);
+    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#888888', endColorstr='#575757');
+}
+.gray:hover {
+    background: #616161;
+    background: -webkit-gradient(linear, left top, left bottom, from(#757575), to(#4b4b4b));
+    background: -moz-linear-gradient(top,  #757575,  #4b4b4b);
+    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#757575', endColorstr='#4b4b4b');
+}
+.gray:active {
+    color: #afafaf;
+    background: -webkit-gradient(linear, left top, left bottom, from(#575757), to(#888));
+    background: -moz-linear-gradient(top,  #575757,  #888);
+    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#575757', endColorstr='#888888');
+}
+
+
+
+
 /* orange */
 .orange {
     color: #fef4e9 !important;
@@ -695,6 +720,27 @@ button:hover {
     filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
 }
 
+/* green */
+.green {
+    color: #e8f0de;
+    border: solid 1px #538312;
+    background: #64991e;
+    background: -webkit-gradient(linear, left top, left bottom, from(#7db72f), to(#4e7d0e));
+    background: -moz-linear-gradient(top,  #7db72f,  #4e7d0e);
+    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#7db72f', endColorstr='#4e7d0e');
+}
+.green:hover {
+    background: #538018;
+    background: -webkit-gradient(linear, left top, left bottom, from(#6b9d28), to(#436b0c));
+    background: -moz-linear-gradient(top,  #6b9d28,  #436b0c);
+    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#6b9d28', endColorstr='#436b0c');
+}
+.green:active {
+    color: #a9c08c;
+    background: -webkit-gradient(linear, left top, left bottom, from(#4e7d0e), to(#7db72f));
+    background: -moz-linear-gradient(top,  #4e7d0e,  #7db72f);
+    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#4e7d0e', endColorstr='#7db72f');
+}
 
 
 
@@ -1244,10 +1290,10 @@ a.unread {
 }
 .clip_vertical {
 	position:absolute;
-	clip:rect(0px 218px 155px 0px);
-	top:-42px;
+	clip:rect(0px 218px 185px 0px);
+	top:-50px;
 	left:-32px;
-	
+		
 	 -webkit-transform: scale(0.6);
     -moz-transform: scale(0.6);
     -o-transform: scale(0.6);   
@@ -1646,8 +1692,8 @@ div.image-social-content center.friend {
 .social-background-content {
     z-index:5;
     position:relative;
-    /* border:1px dotted #DDDDDD; */
-    width:170px;
+    width:185px;
+    left:-10px;
     overflow:hidden;
 }
 
@@ -2277,4 +2323,34 @@ div.admin_section h4 {
 .document_preview_container {
     font-size: 12px !important;
     color: #111 ! important;	
+}
+
+/* Exercise comment*/
+#comments {
+    position:absolute;
+    left:795px;
+    top:0px;
+    width:200px;
+    height:75px;
+    z-index:1;
+}
+
+#questions {
+   width:40%; 
+   height:50px;
+   float:left;  
+   padding:5px;  
+}
+  
+
+.question_item {   
+    height:50px;
+    padding:5px;
+    margin:10px 0px 10px 0px; 
+}
+  
+.option_item {
+   width:150px;
+   padding:3px;
+   margin:10px;      
 }

+ 3 - 10
main/css/base_chamilo.css

@@ -1709,12 +1709,10 @@ padding-top: 0px;   padding-right: 0px; padding-bottom: 0px;    padding-left: 0p
     display: none;
 }
 /*
-------------------------------------------------------------------------------
-    OTHERS
-------------------------------------------------------------------------------
+Document title
 */
 .input_titles {
-    width: 300px;
+    width: 400px;
     -moz-border-radius-bottomleft:5px;
     -moz-border-radius-bottomright:5px;
     -moz-border-radius-topleft:5px;
@@ -1722,9 +1720,7 @@ padding-top: 0px;   padding-right: 0px; padding-bottom: 0px;    padding-left: 0p
     border:1px solid #E1E1E0;
 }
 /*
-------------------------------------------------------------------------------
     Survey
-------------------------------------------------------------------------------
 */
 #survey_title {
     background-color:#dcdcdc;
@@ -1760,10 +1756,7 @@ padding-top: 0px;   padding-right: 0px; padding-bottom: 0px;    padding-left: 0p
     padding:5px;/*border: 1px solid #264269;*/
 }
 /*
-|----------------------------------------------------------------------------
-| Added: to fit img and blocks in home page
-|----------------------------------------------------------------------------
-|
+ Added: to fit img and blocks in home page
 */
 #hellomindfactory {
     border: 1px solid #ccc;

+ 23 - 59
main/document/create_document.php

@@ -168,7 +168,7 @@ $nameTools = get_lang('CreateDocument');
 
 /*	Constants and variables */
 
-$document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id());    
+$document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id(), true);    
 if (empty($document_data)) {
     if (api_is_in_group()) {
         $group_properties   = GroupManager::get_group_properties(api_get_group_id());        
@@ -339,44 +339,20 @@ $group = array();
 
 // If allowed, add element for document title
 if (api_get_setting('use_document_title') == 'true') {
-	//$group[]= $form->add_textfield('title', get_lang('Title'),true,'class="input_titles" id="title"');
-	// replace the 	add_textfield with this
 	$group[]=$form->createElement('text','title',get_lang('Title'),'class="input_titles" id="document_title"');
-	
-	
-	//$form->applyFilter('title','trim');
-	//$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
 
 	// Added by Ivan Tcholakov, 10-OCT-2009.
 	$form->addElement('hidden', 'filename', '', array('id' => 'filename'));
 	//
 } else {
-	//$form->add_textfield('filename', get_lang('FileName'),true,'class="input_titles" id="filename" onblur="javascript: check_if_still_empty();"');
 	// replace the 	add_textfield with this
-	$group[]=$form->createElement('text', 'filename', get_lang('FileName'), 'class="input_titles" id="document_title" onblur="javascript: check_if_still_empty();"');
-	
-	//$form->applyFilter('filename','trim');
-	//$form->addRule('filename', get_lang('ThisFieldIsRequired'), 'required');
-	//$form->addRule('filename', get_lang('FileExists'), 'callback', 'document_exists');
-
+	$group[]=$form->createElement('text', 'filename', get_lang('FileName'), 'class="input_titles" id="document_title" onblur="javascript: check_if_still_empty();"');	
 	// Added by Ivan Tcholakov, 10-OCT-2009.
 	$form->addElement('hidden', 'title', '', array('id' => 'title'));
-	//
 }
 
-/*
-// Selected the file where are save the news documents
-
-build_directory_selector($folders, $path, $group_properties['directory']);
-
-$subjects = $folders;
-
-$form->addElement('select', get_lang('CurrentDirectory'), '', $folders);
-*/
-
 // Show read-only box only in groups
 if (!empty($_SESSION['_gid'])) {
-	//$renderer->setElementTemplate('<div class="row"><div class="label"></div><div class="formw">{element}{label}</div></div>', 'readonly');
 	$group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
 }
 
@@ -406,14 +382,12 @@ if (api_get_setting('use_document_title') == 'true') {
 
 $current_session_id = api_get_session_id();
 
-//$form->addElement('style_submit_button', 'submit', get_lang('SaveDocument'), 'class="save"');
-
 // HTML-editor
 $renderer->setElementTemplate('<div class="row"><div class="label" id="frmModel" style="overflow: visible;"></div><div class="formw">{element}</div></div>', 'content');
 
 $form->add_html_editor('content','', false, false, $html_editor_config);
-// Comment-field
 
+// Comment-field
 $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
 
 // If we are not in the certificates creation, display a folder chooser for the
@@ -515,8 +489,8 @@ if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'], $dir, $curr
 		}
 	}
 }
-
 //$form->addElement('textarea', 'comment', get_lang('Comment'), array ('rows' => 5, 'cols' => 50));
+
 if ($is_certificate_mode)
 	$form->addElement('style_submit_button', 'submit', get_lang('CreateCertificate'), 'class="save"');
 else
@@ -524,26 +498,14 @@ else
 
 $form->setDefaults($default);
 
-// HTML
-/*
-$form->addElement('html','<div id="frmModel" style="display:block; height:525px; width:240px; position:absolute; top:115px; left:1px;"></div>');
-*/
 
 // If form validates -> save the new document
 if ($form->validate()) {
 	$values = $form->exportValues();
 	$readonly = isset($values['readonly']) ? 1 : 0;
 
-	$values['title'] = addslashes(trim($values['title']));
-	$values['title'] = Security::remove_XSS($values['title']);
-	$values['title'] = replace_dangerous_char($values['title']);
-	$values['title'] = disable_dangerous_file($values['title']);
-
-	$values['filename'] = addslashes(trim($values['filename']));
-	$values['filename'] = Security::remove_XSS($values['filename']);
-	$values['filename'] = replace_dangerous_char($values['filename']);
-	$values['filename'] = disable_dangerous_file($values['filename']);
-	//die($values['curdirpath']);
+	$values['title'] = trim($values['title']);	
+	
 	if (!empty($values['curdirpath'])) {
 		$dir = $values['curdirpath'];
 	}
@@ -556,9 +518,15 @@ if ($form->validate()) {
 	} else	{
 		$values['filename'] = $values['title'];
 	}
+	
+	$values['filename'] = addslashes(trim($values['filename']));
+	$values['filename'] = Security::remove_XSS($values['filename']);
+	$values['filename'] = replace_dangerous_char($values['filename']);
+	$values['filename'] = disable_dangerous_file($values['filename']);
+	
 
-	$filename = $values['filename'];
-	$title = $values['title'];
+	$filename 	= $values['filename'];
+	$title 		= $values['title'];
 	$extension = 'html';
 
 	$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
@@ -567,7 +535,6 @@ if ($form->validate()) {
 		$content = str_replace('</head>', '<style> body{margin:10px;}</style> <link rel="stylesheet" href="./css/frames.css" type="text/css" /></head>', $content);
 	}
 	if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
-		$content = text_filter($content);
 		$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content);
 		
 		// change the path of mp3 to absolute
@@ -598,7 +565,7 @@ if ($form->validate()) {
 		$file_size = filesize($filepath.$filename.'.'.$extension);
 		$save_file_path = $dir.$filename.'.'.$extension;
 
-		$document_id = add_document($_course, $save_file_path, 'file', $file_size, $filename, null, $readonly);
+		$document_id = add_document($_course, $save_file_path, 'file', $file_size, $title, null, $readonly);
 		if ($document_id) {
 			api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $_user['user_id'], $to_group_id, null, null, null, $current_session_id);
 			// Update parent folders
@@ -649,19 +616,16 @@ if ($form->validate()) {
 	}
 	*/
 	
-	$dir_acum = '';
-	for ($i = 0; $i < $array_len; $i++) {
-		$url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
-		//Max char 80
-		$url_to_who = cut($dir_array[$i],80);
-		if ($is_certificate_mode) {
-			$interbreadcrumb[] = array('url' => $url_dir.'&selectcat='.Security::remove_XSS($_GET['selectcat']), 'name' => $url_to_who);
-		} else {
-			$interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
+	// Interbreadcrumb for the current directory root path
+	if (empty($document_data['parents'])) {
+		$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
+	} else {
+		foreach($document_data['parents'] as $document_sub_data) {
+			$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
 		}
-		$dir_acum .= $dir_array[$i].'/';
 	}
-	
+
+
 	Display :: display_header($nameTools, "Doc");
 	//api_display_tool_title($nameTools);
 	// actions

+ 7 - 12
main/document/create_draw.php

@@ -31,7 +31,7 @@ $nameTools = get_lang('Draw');
 api_protect_course_script();
 api_block_anonymous_users();
 
-$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id());
+$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
 if (empty($document_data)) {
     if (api_is_in_group()) {
         $group_properties   = GroupManager::get_group_properties(api_get_group_id());        
@@ -129,18 +129,13 @@ if (isset ($group)) {
 		}
 	}
 	*/
-	
-	$dir_acum = '';
-	for ($i = 0; $i < $array_len; $i++) {
-		$url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
-		//Max char 80
-		$url_to_who = cut($dir_array[$i],80);
-		if ($is_certificate_mode) {
-			$interbreadcrumb[] = array('url' => $url_dir.'&selectcat='.Security::remove_XSS($_GET['selectcat']), 'name' => $url_to_who);
-		} else {
-			$interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
+	// Interbreadcrumb for the current directory root path
+	if (empty($document_data['parents'])) {
+		$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
+	} else {
+		foreach($document_data['parents'] as $document_sub_data) {
+			$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
 		}
-		$dir_acum .= $dir_array[$i].'/';
 	}
 Display :: display_header($nameTools, 'Doc');
 

+ 7 - 16
main/document/create_paint.php

@@ -31,7 +31,7 @@ if (api_get_setting('enabled_support_paint') == 'false') {
 	api_not_allowed(true);
 }
 
-$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id());
+$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
 if (empty($document_data)) {
     if (api_is_in_group()) {
         $group_properties   = GroupManager::get_group_properties(api_get_group_id());        
@@ -113,22 +113,13 @@ if (isset ($group)) {
 }
 
 // Interbreadcrumb for the current directory root path
-	// Copied from document.php
-	$dir_array = explode('/', $dir);
-	$array_len = count($dir_array);
-	$dir_acum = '';
-	for ($i = 0; $i < $array_len; $i++) {
-		$url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
-		//Max char 80
-		$url_to_who = cut($dir_array[$i],80);
-		if ($is_certificate_mode) {
-			$interbreadcrumb[] = array('url' => $url_dir.'&selectcat='.Security::remove_XSS($_GET['selectcat']), 'name' => $url_to_who);
-		} else {
-			$interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
-		}
-		$dir_acum .= $dir_array[$i].'/';
+if (empty($document_data['parents'])) {
+	$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
+} else {
+	foreach($document_data['parents'] as $document_sub_data) {
+		$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
 	}
-//
+}
 Display :: display_header($nameTools, 'Doc');
 
 echo '<div class="actions">';

+ 67 - 56
main/document/document.php

@@ -31,7 +31,6 @@
 /**
  * Code
  */
-/*	INIT SECTION */
 
 // Language files that need to be included
 $language_file = array('document', 'slideshow', 'gradebook', 'create_course');
@@ -180,44 +179,66 @@ $is_certificate_mode = DocumentManager::is_certificate_mode($_GET['curdirpath'])
 
 //If no actions we proceed to show the document (Hack in order to use document.php?id=X) 
 if (isset($document_id)) {
-    $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());    
+    $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); 
     
     //If the document is not a folder we show the document
     if ($document_data) {
-	    if (!empty($document_data['filetype']) && $document_data['filetype'] == 'file') {
-	    	$visibility = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
+    	$parent_id     = $document_data['parent_id'];
+    	
+    	//$visibility = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
+    	$visibility = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id());
+    	
+	    if (!empty($document_data['filetype']) && $document_data['filetype'] == 'file') {	    	
 	    	if ($visibility && api_is_allowed_to_session_edit()) {    		
 	    		$url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$document_data['path'].'?'.api_get_cidreq();    	    	
 	    		header("Location: $url");
 	    	}    	
 	    	exit;
+	    } else {
+	    	if (!$visibility) {
+	    		api_not_allowed();
+	    	}
 	    }
     	$_GET['curdirpath'] = $document_data['path'];
     }
-}
-
-// What's the current path?
-// We will verify this a bit further down
-if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '') {
-    $curdirpath = Security::remove_XSS($_GET['curdirpath']);
-} elseif (isset($_POST['curdirpath']) && $_POST['curdirpath'] != '') {
-    $curdirpath = Security::remove_XSS($_POST['curdirpath']);
+    
+    // What's the current path?
+    // We will verify this a bit further down
+    if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '') {
+    	$curdirpath = Security::remove_XSS($_GET['curdirpath']);
+    } elseif (isset($_POST['curdirpath']) && $_POST['curdirpath'] != '') {
+    	$curdirpath = Security::remove_XSS($_POST['curdirpath']);
+    } else {
+    	$curdirpath = '/';
+    }
+    
+    $curdirpathurl = urlencode($curdirpath);
+    
 } else {
-    $curdirpath = '/';
-}
-
-$curdirpathurl = urlencode($curdirpath);
-
-// Check the path
-// If the path is not found (no document id), set the path to /
-$document_id = DocumentManager::get_document_id($course_info, $curdirpath);
-
-if (!$document_id) {    
-    $document_id = DocumentManager::get_document_id($course_info, $curdirpath);
+	// What's the current path?
+	// We will verify this a bit further down
+	if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '') {
+		$curdirpath = Security::remove_XSS($_GET['curdirpath']);
+	} elseif (isset($_POST['curdirpath']) && $_POST['curdirpath'] != '') {
+		$curdirpath = Security::remove_XSS($_POST['curdirpath']);
+	} else {
+		$curdirpath = '/';
+	}
+	
+	$curdirpathurl = urlencode($curdirpath);
+	
+	// Check the path
+	// If the path is not found (no document id), set the path to /
+	$document_id = DocumentManager::get_document_id($course_info, $curdirpath);
+	
+	if (!$document_id) {
+		$document_id = DocumentManager::get_document_id($course_info, $curdirpath);
+	}
+	
+	$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);	
+	$parent_id     = $document_data['parent_id'];	
 }
 
-$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
-$parent_id     = DocumentManager::get_document_id($course_info, dirname($document_data['path']));
 
 if (!$parent_id) {
     $parent_id = 0; 
@@ -225,7 +246,6 @@ if (!$parent_id) {
 
 $current_folder_id = $document_id;
 
-
 // Show preview
 if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isset($_GET['set_preview']) && $_GET['set_preview'] == strval(intval($_GET['set_preview']))) {
     if (isset($_GET['set_preview'])) {
@@ -356,31 +376,19 @@ if ($is_certificate_mode) {
 
 // Interbreadcrumb for the current directory root path
 
-$dir_array = explode('/', $curdirpath);
-$array_len = count($dir_array);
-
-$dir_acum = '';
-
-for ($i = 0; $i < $array_len; $i++) {
-    $url_dir = 'document.php?&amp;curdirpath='.$dir_acum.$dir_array[$i];
-    //Max char 80
-    $url_to_who = cut($dir_array[$i],80);
-    if ($is_certificate_mode) {
-        $interbreadcrumb[] = array('url' => $url_dir.'&amp;selectcat='.Security::remove_XSS($_GET['selectcat']), 'name' => $url_to_who);
-    } else {
-        if( $i == $array_len - 1 && !isset($_GET['createdir']) ) {
-            $url_dir = '#';
-        }
-        if ($url_to_who == 'learning_path') {
-            $url_to_who = get_lang('LearningPaths');
-        }
-        $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
-    }
-    //does not repeat the name group in the url
-    if (!empty($_SESSION['_gid'])) {
-        unset($dir_array[1]);
-    }
-    $dir_acum .= $dir_array[$i].'/';
+if (empty($document_data['parents'])) {
+	if (isset($_GET['createdir'])) {		
+		$interbreadcrumb[] = array('url' => $document_data['document_url'], 'name' => $document_data['title']);
+	} else {
+		$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
+	}	
+} else {	
+	foreach($document_data['parents'] as $document_sub_data) {
+		if (!isset($_GET['createdir']) && $document_sub_data['id'] ==  $document_data['id']) {
+			$document_sub_data['document_url'] = '#';
+		}
+		$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
+	}
 }
 
 if (isset($_GET['createdir'])) {
@@ -688,7 +696,7 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
     if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
         // Needed for directory creation
         require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
-        $post_dir_name = Security::remove_XSS($_POST['dirname']);
+        $post_dir_name = $_POST['dirname'];
 
         if ($post_dir_name == '../' || $post_dir_name == '.' || $post_dir_name == '..') {
             Display::display_error_message(get_lang('CannotCreateDir'));
@@ -701,6 +709,8 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
             $dir_name = $curdirpath.$added_slash.replace_dangerous_char($post_dir_name);
             $dir_name = disable_dangerous_file($dir_name);
             $dir_name = str_replace('.', '_', $dir_name);
+            
+            //@todo why the folder name can't have a dot. It's just the folder name
             $post_dir_name = str_replace('.', '_', $post_dir_name);
             
             $dir_check = $base_work_dir.$dir_name;
@@ -851,7 +861,7 @@ if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isse
 }
 
 /*	GET ALL DOCUMENT DATA FOR CURDIRPATH */
-if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
+if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {	
     $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, true);    
 } else {
     $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, false);
@@ -863,7 +873,7 @@ if ($folders === false) {
 }
 
 echo '<div class="actions">';
-if ($is_allowed_to_edit || $group_member_with_upload_rights){
+//if ($is_allowed_to_edit || $group_member_with_upload_rights){
 /* BUILD SEARCH FORM */
     echo '<span style="display:inline-block;">';
     $form = new FormValidator('search_document', 'get', '', '', null, false);
@@ -873,7 +883,7 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights){
     $form->addElement('style_submit_button', 'submit', get_lang('Search'), 'class="search"');
     $form->display();
     echo '</span>';
-}
+//}
 
 /* GO TO PARENT DIRECTORY */
 if ($curdirpath!= '/' && $curdirpath != $group_properties['directory'] && !$is_certificate_mode) {
@@ -899,7 +909,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
     // Create a sortable table with our data
     $sortable_data = array();
 
-    $count = 1;
+    $count = 1;    
     foreach ($docs_and_folders as $key => $document_data) {
         $row = array();        
         $row['id']   = $document_data['id'];
@@ -1199,5 +1209,6 @@ if (!empty($table_footer)) {
     Display::display_warning_message($table_footer);
 }
 
+
 // Footer
 Display::display_footer();

+ 3 - 1
main/document/download.php

@@ -72,7 +72,9 @@ if (substr($refer_script, 0, 15) == '/fillsurvey.php') {
 if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) {
     $full_file_name = $sys_course_path.$doc_url;    
     // Check visibility of document and paths    
-    if (!api_is_allowed_to_edit() && !DocumentManager::is_visible($doc_url, $_course, api_get_session_id())) {
+    $is_visible = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id());
+    //$is_visible = DocumentManager::is_visible($doc_url, $_course, api_get_session_id());
+    if (!api_is_allowed_to_edit() && !$is_visible) {
     	Display::display_error_message(get_lang('ProtectedDocument'));//api_not_allowed backbutton won't work.
     	exit; // You shouldn't be here anyway.
     }    

+ 4 - 2
main/document/showinframes.php

@@ -55,7 +55,7 @@ if (empty($document_data)) {
 }
 
 $header_file  = $document_data['path'];
-$name_to_show = cut($header_file, 80);
+$name_to_show = $document_data['title'];
 
 $path_array = explode('/', str_replace('\\', '/', $header_file));
 $path_array = array_map('urldecode', $path_array);
@@ -83,7 +83,9 @@ if ($is_allowed_in_course == false) {
 }
 
 //Check user visibility
-$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
+//$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
+$is_visible = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id());
+
 if (!api_is_allowed_to_edit() && !$is_visible) {
     api_not_allowed(true);
 }

+ 2 - 1
main/document/showinframesmin.php

@@ -69,7 +69,8 @@ if ($is_allowed_in_course == false) {
 }
 
 //Check user visibility
-$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
+//$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
+$is_visible = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id());
 if (!api_is_allowed_to_edit() && !$is_visible) {
     api_not_allowed(true);
 }

+ 20 - 18
main/document/upload.php

@@ -108,19 +108,8 @@ $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 $courseDir = $_course['path'].'/document';
 $sys_course_path = api_get_path(SYS_COURSE_PATH);
 $base_work_dir = $sys_course_path.$courseDir;
-$noPHP_SELF = true;
 
-/*
-// What's the current path?
-if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '') {
-	$path = $_GET['curdirpath'];
-} elseif (isset($_POST['curdirpath'])) {
-	$path = $_POST['curdirpath'];
-} else {
-	$path = '/';
-}*/
-
-$document_data  = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id());
+$document_data  = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id(), true);
 if (empty($document_data)) {
     $document_id  = $parent_id =  0;
     $path = '/';    
@@ -137,8 +126,7 @@ if (api_get_group_id()) {
 	require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 	// Get group info
 	$group_properties = GroupManager::get_group_properties(api_get_group_id());
-	$noPHP_SELF = true;
-
+	
 	if ($is_allowed_to_edit || GroupManager::is_user_in_group($_user['user_id'], api_get_group_id())) { // Only courseadmin or group members allowed
 		$to_group_id = api_get_group_id();
 		$req_gid = '&amp;gidReq='.api_get_group_id();
@@ -188,6 +176,16 @@ if ($is_certificate_mode) {
 	$interbreadcrumb[] = array('url' => './document.php?id='.$document_id.$req_gid, 'name'=> get_lang('Documents'));
 }
 
+// Interbreadcrumb for the current directory root path
+if (empty($document_data['parents'])) {
+	$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
+} else {
+	foreach($document_data['parents'] as $document_sub_data) {
+		$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
+	}
+}
+
+
 
 $this_section = SECTION_COURSES;
 
@@ -291,8 +289,12 @@ $multiple_form .=  '
 	</center>
 	<table class="files"></table>';
 
-$headers = array(get_lang('Send') , get_lang('Send').' ('.get_lang('Simple').')');
-echo Display::tabs($headers, array($multiple_form, $simple_form ),'tabs');
+$nav_info = api_get_navigator();
+if ($nav_info ['name'] == 'Internet Explorer') {
+	echo $simple_form;
+} else {
+	$headers = array(get_lang('Send') , get_lang('Send').' ('.get_lang('Simple').')');
+	echo Display::tabs($headers, array($multiple_form, $simple_form),'tabs');	
+}
 
-// Footer
-Display::display_footer();
+Display::display_footer();

+ 2 - 2
main/exercice/admin.php

@@ -469,7 +469,7 @@ if ($show_quiz_edition) {
 echo '</div>';
 
 if (isset($_GET['message'])) {
-	if (in_array($_GET['message'], array('ExerciseStored', 'ItemUpdated'))) {
+	if (in_array($_GET['message'], array('ExerciseStored', 'ItemUpdated', 'ItemAdded'))) {
 		Display::display_confirmation_message(get_lang($_GET['message']));
 	}
 }
@@ -481,7 +481,7 @@ if ($newQuestion || $editQuestion) {
 	<?php	
    require 'question_admin.inc.php';
 }
-
+ 
 if (isset($_GET['hotspotadmin'])) {
     
     if (!is_object($objQuestion)) {

Разлика између датотеке није приказан због своје велике величине
+ 352 - 353
main/exercice/exercise.class.php


+ 8 - 31
main/exercice/exercise.lib.php

@@ -25,7 +25,8 @@ require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
  * @param int   number of total questions
  * */
 function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false) {
-
+	
+	$s = '';
 	// Text direction for the current language
 	$is_ltr_text_direction = api_get_text_direction() != 'rtl';
 
@@ -146,31 +147,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
       ?>          
     <style>    
    
-   #questions {
-    width:40%; 
-    height:50px;
-    float:left;  
-    padding:5px;  
-   }
-   
-   #options {
-    width:40%;
-    float:left;
-    padding:5px;  
-          
-   }
-   
-   .question_item {   
-      height:50px;
-      padding:5px;
-      margin:10px 0px 10px 0px;	
-   }
-   
-   .option_item {
-    width:150px;
-    padding:3px;
-    margin:10px;      
-   } 
+  
     </style>
     <script>
     $(function() {
@@ -239,8 +216,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
 				// splits text and weightings that are joined with the character '::'
 				list($answer) = explode('::',$answer);
 
-				// because [] is parsed here we follow this procedure:
-				$answer = text_filter($answer);
 				//getting the matches
 				$answer = api_ereg_replace('\[[^]]+\]','<input type="text" name="choice['.$questionId.'][]" size="10" />',($answer));
 			}
@@ -300,6 +275,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
 
                 } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {                    
                     $options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
+                    $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
                     $s .='<tr>';     
                     $s .= Display::tag('td', $answer);
                     if (!empty($quiz_question_options)) {       
@@ -334,6 +310,8 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
                 // multiple answers
                 // set $debug_mark_answer to true at function start to
                 // show the correct answer with a suffix '-x'
+                
+            	$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
                 $help = $selected = '';
                 if ($debug_mark_answer) {
                     if ($answerCorrect) {
@@ -960,9 +938,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
     $teacher_list = CourseManager::get_teacher_list_from_course_code(api_get_course_id());
     $teacher_id_list = array();
     foreach ($teacher_list as $teacher) {
-    	$teacher_id_list[] =$teacher['user_id'];
-    }  
-    
+    	$teacher_id_list[] = $teacher['user_id'];
+    }    
     
     if (empty($hotpotatoe_where)) {
         $column             = intval($column);

+ 13 - 16
main/exercice/exercise_result.php

@@ -10,14 +10,12 @@
 *	@author Olivier Brouckaert, main author
 *	@author Roan Embrechts, some refactoring
 * 	@author Julio Montoya Armas switchable fill in blank option added
-* 	@version $Id: exercise_result.php 22201 2009-07-17 19:57:03Z cfasanando $
 *
 *	@todo	split more code up in functions, move functions to library?
 */
 /**
  * Code
  */
-/*	INIT SECTION	*/
 require_once 'exercise.class.php';
 require_once 'exercise.lib.php';
 require_once 'question.class.php';
@@ -110,7 +108,7 @@ if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
 }
 
-$nameTools=get_lang('Exercice');
+$nameTools = get_lang('Exercice');
 
 $interbreadcrumb[]=array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
 //$htmlHeadXtra[] = $objExercise->show_lp_javascript();
@@ -157,7 +155,7 @@ if (api_is_course_admin() && $origin != 'learnpath') {
 	echo '</div>';
 }
 
-$exerciseTitle=text_filter($objExercise->selectTitle());
+$exerciseTitle = $objExercise->selectTitle();
 $feedback_type = $objExercise->feedbacktype;
 
 //show exercise title
@@ -258,19 +256,18 @@ foreach ($questionList as $questionId) {
 } // end foreach() block that loops over all questions
 
 
-if ($origin != 'learnpath') {
-    if ($show_results || $show_only_score) {
-        echo '<div id="question_score">';
-        echo get_lang('YourTotalScore')." ";	
-        if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
-    	    $totalScore = 0;
-        }     
-        echo show_score($totalScore, $totalWeighting, false);	
-        echo '</div>';
-    }
-    /* <button type="submit" class="save"><?php echo get_lang('Finish');?></button> */
+
+if ($show_results || $show_only_score) {
+	echo '<div id="question_score">';
+    echo get_lang('YourTotalScore')." ";	
+    if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
+    	$totalScore = 0;
+    }     
+    echo show_score($totalScore, $totalWeighting, false);	
+    echo '</div>';
 }
 
+
 // Tracking of results
 
 //	Updates the empty exercise
@@ -278,7 +275,7 @@ if ($origin != 'learnpath') {
 $quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0);
 
 if (api_is_allowed_to_session_edit() ) {
-	update_event_exercice($exeId, $objExercise->selectId(), $totalScore, $totalWeighting, api_get_session_id(), $safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration);
+	update_event_exercice($exeId, $objExercise->selectId(), $totalScore, $totalWeighting, api_get_session_id(), $safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration, $questionList);
 }
 
 if ($origin != 'learnpath') {

+ 17 - 50
main/exercice/exercise_show.php

@@ -74,6 +74,7 @@ $is_allowedToEdit   = api_is_allowed_to_edit(null,true) || $is_courseTutor;
 //Getting results from the exe_id. This variable also contain all the information about the exercise
 $track_exercise_info = get_exercise_track_exercise_info($id);
 
+
 //No track info
 if (empty($track_exercise_info)) {
     api_not_allowed();
@@ -125,8 +126,6 @@ if($origin=='user_course') {
 	$interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users"));
 	$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".$student_id."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
 } else if($origin=='tracking_course') {
-	//$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
- 	//$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($student_id).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
  	$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$_course['directory'], 'name' => $_course['title']);
 	$interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$cidReq.'&studentlist=true&id_session='.$_SESSION['id_session'], "name" => get_lang("Tracking"));
 	$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".$student_id.'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
@@ -153,20 +152,7 @@ if ($origin != 'learnpath') {
 } else {
 	Display::display_reduced_header();
 }
-
 ?>
-<style type="text/css">
-<!--
-#comments {
-	position:absolute;
-	left:795px;
-	top:0px;
-	width:200px;
-	height:75px;
-	z-index:1;
-}
--->
-</style>
 <script language="javascript">
 function showfck(sid,marksid) {
 	document.getElementById(sid).style.display='block';
@@ -206,7 +192,7 @@ $show_only_total_score  = false;
 
 // Avoiding the "Score 0/0" message  when the exe_id is not set
 if (!empty($track_exercise_info)) {
-	$exerciseTitle			= text_filter($track_exercise_info['title']);
+	$exerciseTitle			= $track_exercise_info['title'];
 	$exerciseDescription	= $track_exercise_info['description'];
 	// if the results_disabled of the Quiz is 1 when block the script
 	$result_disabled		= $track_exercise_info['results_disabled'];
@@ -254,7 +240,7 @@ if ($show_results || $show_only_total_score) {
     echo $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName']), api_convert_and_format_date($exercise_date));
 }
 
-$i=$totalScore=$totalWeighting=0;
+$i = $totalScore = $totalWeighting = 0;
 
 if($debug>0){error_log("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));}
 
@@ -270,7 +256,7 @@ $query = "SELECT attempts.question_id, answer  from ".$TBL_TRACK_ATTEMPT." as at
 		  GROUP BY quizz_rel_questions.question_order, attempts.question_id";
 			//GROUP BY questions.position, attempts.question_id";
 
-$result =Database::query($query);	
+$result = Database::query($query);	
 $questionList = array();
 $exerciseResult = array();
 
@@ -282,7 +268,7 @@ while ($row = Database::fetch_array($result)) {
 //Fixing #2073 Fixing order of questions
 if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) {
 	$tempquestionList = explode(',',$track_exercise_info['data_tracking']);
-	if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
+	if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {	
 		$questionList = $tempquestionList;			
 	}		
 }
@@ -314,12 +300,12 @@ foreach ($questionList as $questionId) {
 	    echo $objQuestionTmp->return_header($feedback_type);
 	}		
 	if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
-        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());            
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());                    
         $questionScore   = $question_result['score'];
-        $totalScore      += $question_result['score'];
+        $totalScore      += $question_result['score'];        
 	} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType ==  MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
 		$choice = array();
-        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());                       
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());                               
         $questionScore   = $question_result['score'];
         $totalScore     += $question_result['score'];	
 	} elseif ($answerType == UNIQUE_ANSWER || $answerType ==  UNIQUE_ANSWER_NO_OPTION) {	
@@ -465,7 +451,6 @@ foreach ($questionList as $questionId) {
         		} 
         	
         		echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
-        		//<p style="text-align:center">
         		if ($answerType == HOT_SPOT_DELINEATION) {			
         			if ($organs_at_risk_hit>0) {
         				$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';				
@@ -476,24 +461,15 @@ foreach ($questionList as $questionId) {
         				$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
         			}
         			$message.='<p>'.$comment.'</p>';	
-        			echo $message;
-        			
-        			// by default we assume that the answer is ok but if the final answer after calculating the area in hotspot delineation =0 then update  
-        			if ($final_answer==0) {
-        				//update_exercise_attempt(0, 0,$questionId,$exeId, 0 ); //we do not update the user_id 
-        				//update_event_exercice($exeId, )
-        			}
-        			
+        			echo $message;              			
         		} else {
         			echo '<p>'.$comment.'</p>';
         		}
-        		//echo '<a onclick="self.parent.tb_remove();" href="#" style="float:right;">'.get_lang('Close').'</a>';
-        
         		
         		//showing the score	
          		$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
-        		$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
-        		$questionScore= mysql_result($resfree,0,"marks");
+        		$resfree = Database::query($queryfree);
+        		$questionScore= Database::result($resfree,0,"marks");
         		$totalScore+=$questionScore;        		
         		 			?>
         		 			</table>
@@ -605,12 +581,6 @@ foreach ($questionList as $questionId) {
 		</table>';		
 	}
 	
-    
-	/*
-	Do not convert question results
-	$my_total_score  = convert_score($questionScore, $total_weighting);
-	$my_total_weight = convert_score($questionWeighting, $total_weighting);*/
-	
 	$my_total_score  = $questionScore;
 	$my_total_weight = $questionWeighting;   
 	
@@ -619,16 +589,13 @@ foreach ($questionList as $questionId) {
     }  
     if ($show_results) {
 	    echo '<div id="question_score">';
-		//echo get_lang('Score')." : $my_total_score / $my_total_weight";
-		echo get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);    
-		
-        //echo get_lang('Score')." : ".show_score($my_total_score, $total_weighting, false);
+		echo get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);
 		echo '</div>';
     }
 	unset($objAnswerTmp);
 	$i++;
 
-	$totalWeighting+=$questionWeighting;
+	$totalWeighting += $questionWeighting;
     
 } // end of large foreach on questions
 
@@ -679,7 +646,7 @@ if ($origin =='student_progress') {?>
 	<button type="button" class="save" onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id()?>'" value="<?php echo get_lang('Finish'); ?>" ><?php echo get_lang('Finish');?></button>
 <?php
 }
-   
+
 if ($origin != 'learnpath') {
 	//we are not in learnpath tool
 	Display::display_footer();
@@ -688,9 +655,9 @@ if ($origin != 'learnpath') {
 		$lp_mode =  $_SESSION['lp_mode'];
 		$url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
 		$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
-		echo '<script language="javascript" type="text/javascript">'.$href.'</script>'."\n";
-
-		//record the results in the learning path, using the SCORM interface (API)
+		echo '<script language="javascript" type="text/javascript">'.$href.'</script>';		
+		
+		//Record the results in the learning path, using the SCORM interface (API)		
 		echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
 		echo '</body></html>';
 	} else {

+ 45 - 48
main/exercice/exercise_submit.php

@@ -91,11 +91,11 @@ if (empty ($exerciseType)) {
 if (empty ($exerciseId)) {
     $exerciseId = intval($_REQUEST['exerciseId']);
 }
-if (empty ($choice)) {
-    $choice = $_REQUEST['choice'];
+if (empty($choice)) {	
+    $choice = $_REQUEST['choice'];    
 }
-if (empty ($_REQUEST['choice'])) {
-    $choice = $_REQUEST['choice2'];
+if (empty($_REQUEST['choice'])) {	
+    $choice = $_REQUEST['choice2'];    
 }
 if (empty ($questionNum)) {
     $questionNum = intval($_REQUEST['questionNum']);
@@ -119,7 +119,6 @@ $safe_lp_id             = ($learnpath_id == '')             ? 0 : $learnpath_id;
 $safe_lp_item_id        = ($learnpath_item_id == '')        ? 0 : $learnpath_item_id;
 $safe_lp_item_view_id   = ($learnpath_item_view_id == '')   ? 0 : $learnpath_item_view_id;
 
-
 /*
  * Teacher takes an exam and want to see a preview, we delete the objExercise from the session in order to get the latest changes
     in the exercise 
@@ -302,8 +301,9 @@ if ($formSent && isset($_POST)) {
         $hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
         $choice     = array($hotspot_id => '');
     }
-    // if the user has answered at least one question
+    // if the user has answered at least one question    
     if (is_array($choice)) {
+    	
         if ($debug) { error_log('$choice is an array '.print_r($choice, 1)); } 	
         // Also store hotspot spots in the session ($exerciseResultCoordinates
         // will be stored in the session at the end of this script)
@@ -333,8 +333,8 @@ if ($formSent && isset($_POST)) {
                     $choice = $exerciseResult[$questionId];                    
                     if (isset($exe_id)) {
                     	//Manage the question and answer attempts
-                       if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
-                    	$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false);
+                        if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
+                    	$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false, $objExercise->propagate_neg);
                     }
                     //END of saving and qualifying
                 }
@@ -475,14 +475,13 @@ if (api_is_course_admin() && $origin != 'learnpath') {
     echo '<a href="exercice.php?show=test&id_session='.api_get_session_id().'">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'','32').'</a>';
     if ($show_quiz_edition) {
     	echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'','32').'</a>';
-        //echo Display :: return_icon('wizard.gif', get_lang('QuestionList')) . '<a href="exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '">' . get_lang('QuestionList') . '</a>';
     } else {
     	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'','32').'</a>';
     }
     echo '</div>';
 }
 
-$exerciseTitle = text_filter($objExercise->selectTitle());
+$exerciseTitle = $objExercise->selectTitle();
 echo Display::tag('h2', $exerciseTitle);
 $show_clock = true;
 $user_id = api_get_user_id();
@@ -518,8 +517,6 @@ if ($objExercise->selectAttempts() > 0) {
                     $score =  show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
                     echo Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
                     
-                    
-                    
                 } else {
                     Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);	
                 }
@@ -591,9 +588,7 @@ if (!empty ($error)) {
     $number_of_hotspot_questions = 0;
     $onsubmit = '';
     $i = 0;
-    //i have a doubt in this line cvargas
-    //var_dump($questionList);
-    if (!strcmp($questionList[0], '') === 0) {
+    if (!empty($questionList) && is_array($questionList)) {
         foreach ($questionList as $questionId) {
             $i++;
             $objQuestionTmp = Question::read($questionId);
@@ -639,39 +634,41 @@ if (!empty ($error)) {
                         
 		//Show list of questions
 	    $i = 1;    
-	    foreach ($questionList as $questionId) {
-	       
-	        // for sequential exercises
-	        if ($exerciseType == ONE_PER_PAGE) {
-	            // if it is not the right question, goes to the next loop iteration
-	            if ($questionNum != $i) {
-	                $i++;
-	                continue;
-	            } else {
-	                if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
-	                    // if the user has already answered this question
-	                    if (isset ($exerciseResult[$questionId])) {
-	                        // construction of the Question object
-	                        $objQuestionTmp = Question::read($questionId);
-	                        $questionName = $objQuestionTmp->selectTitle();
-	                        // destruction of the Question object
-	                        unset ($objQuestionTmp);
-	                        Display :: display_normal_message(get_lang('AlreadyAnswered'));
-	                        $i++;
-	                        break;
-	                    }
-	                }
-	            }
-	        }        
-	        // shows the question and its answers
-	        showQuestion($questionId, false, $origin, $i);
-	        $i++;
-	        // for sequential exercises
-	        if ($exerciseType == ONE_PER_PAGE) {
-	            // quits the loop
-	            break;
-	        }
-	    }    
+	    if (is_array($questionList)) {
+		    foreach ($questionList as $questionId) {
+		       
+		        // for sequential exercises
+		        if ($exerciseType == ONE_PER_PAGE) {
+		            // if it is not the right question, goes to the next loop iteration
+		            if ($questionNum != $i) {
+		                $i++;
+		                continue;
+		            } else {
+		                if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
+		                    // if the user has already answered this question
+		                    if (isset ($exerciseResult[$questionId])) {
+		                        // construction of the Question object
+		                        $objQuestionTmp = Question::read($questionId);
+		                        $questionName = $objQuestionTmp->selectTitle();
+		                        // destruction of the Question object
+		                        unset ($objQuestionTmp);
+		                        Display :: display_normal_message(get_lang('AlreadyAnswered'));
+		                        $i++;
+		                        break;
+		                    }
+		                }
+		            }
+		        }        
+		        // shows the question and its answers
+		        showQuestion($questionId, false, $origin, $i);
+		        $i++;
+		        // for sequential exercises
+		        if ($exerciseType == ONE_PER_PAGE) {
+		            // quits the loop
+		            break;
+		        }
+		    }    
+	    }
 	    // end foreach()
 	    echo $objExercise->show_button($nbrQuestions, $questionNum, $exerciseId);     
 	    echo '</table>

+ 3 - 1
main/exercice/hotspot_admin.inc.php

@@ -66,7 +66,7 @@ if ($modifyIn) {
     unset($buttonBack);
 }
 
-$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin='.$modifyAnswers. '&exerciseId='.$exerciseId;	
+$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?'.api_get_cidreq().'&exerciseId='.$exerciseId;	
 
 // the answer form has been submitted
 if ($submitAnswers || $buttonBack) {
@@ -484,6 +484,8 @@ if ($modifyAnswers) {
     if(!empty($msgErr)) {
         Display::display_normal_message($msgErr); //main API
     }
+
+$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin='.$modifyAnswers. '&exerciseId='.$exerciseId;
 ?>
 
 <form method="post" action="<?php echo $hotspot_admin_url; ?>" id="frm_exercise" name="frm_exercise">

+ 10 - 3
main/exercice/question_admin.inc.php

@@ -88,10 +88,17 @@ if(is_object($objQuestion)) {
         // TODO: maybe here is the better place to index this tool, including answers text
 
 	    // redirect
-	    if($objQuestion -> type != HOT_SPOT && $objQuestion -> type !=  HOT_SPOT_DELINEATION)
-	    	echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'"</script>';
-	    else
+	    if ($objQuestion -> type != HOT_SPOT && $objQuestion -> type !=  HOT_SPOT_DELINEATION) {
+	    	
+	    	if(isset($_GET['editQuestion'])) {
+	    		echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'&message=ItemUpdated"</script>';
+	    	} else {
+	    		//New question
+	    		echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'&message=ItemAdded"</script>';
+	    	}
+	    } else {
 	    	echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'&hotspotadmin='.$objQuestion->id.'"</script>';
+	    }
 	} else {	 
 		echo '<h3>'.$questionName.'</h3>';
 		if(!empty($pictureName)){

+ 3 - 2
main/inc/ajax/document.ajax.php

@@ -28,8 +28,9 @@ switch($action) {
 		
 		if (!empty($_FILES)) {		    
 		    require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
-		    $result = DocumentManager::upload_document($_FILES, $_POST['curdirpath'], '', '', 0, 'overwrite', false, false);
-		    $file = $_FILES['file'];    
+		    $file = $_FILES['file'];
+		    
+		    $result = DocumentManager::upload_document($_FILES, $_POST['curdirpath'], $file['name'], '', 0, 'overwrite', false, false);		    
 		    $json = array();
 		    $json['name'] = Display::url(api_htmlentities($file['name']), api_htmlentities($result['url']), array('target'=>'_blank'));
 		    $json['type'] = api_htmlentities($file['type']);

+ 9 - 5
main/inc/lib/database.lib.php

@@ -1057,7 +1057,7 @@ class Database {
      * Experimental useful database insert
      * @todo lot of stuff to do here
      */
-    public static function insert($table_name, $attributes , $show_query = false) {
+    public static function insert($table_name, $attributes, $show_query = false) {
         if (empty($attributes) || empty($table_name)) {
             return false;
         }
@@ -1192,7 +1192,7 @@ class Database {
         return $return_value;
     }
 
-    private function parse_where_conditions($coditions){
+    private function parse_where_conditions($coditions) {
         return self::parse_conditions(array('where'=>$coditions));
     }
 
@@ -1200,10 +1200,11 @@ class Database {
      * Experimental useful database update
      * @todo lot of stuff to do here
      */
-    public static function delete($table_name, $where_conditions) {
+    public static function delete($table_name, $where_conditions, $show_query = false) {
         $result = false;
         $where_return = self::parse_where_conditions($where_conditions);
         $sql    = "DELETE FROM $table_name $where_return ";
+        if ($show_query) { echo $sql; echo '<br />'; }
         $result = self::query($sql);
         $affected_rows = self::affected_rows();
         //@todo should return affected_rows for
@@ -1213,9 +1214,12 @@ class Database {
 
     /**
      * Experimental useful database update
+     * @param	string	table name use Database::get_main_table
+     * @param	array	array with values to updates, keys are the fields in the database: Example: $params['name'] = 'Julio'; $params['lastname'] = 'Montoya'; 
+     * @param	array	where conditions i.e array('id = ?' =>'4')
      * @todo lot of stuff to do here
      */
-    public static function update($table_name, $attributes, $where_conditions = array()) {
+    public static function update($table_name, $attributes, $where_conditions = array(), $show_query = false) {
 
         if (!empty($table_name) && !empty($attributes)) {
             $update_sql = '';
@@ -1233,7 +1237,7 @@ class Database {
                 //Parsing and cleaning the where conditions
                 $where_return = self::parse_where_conditions($where_conditions);
                 $sql    = "UPDATE $table_name SET $update_sql $where_return ";
-                //echo $sql; exit;
+                if ($show_query) { echo $sql; echo '<br />'; }
                 $result = self::query($sql);
                 $affected_rows = self::affected_rows();
                 return $affected_rows;

+ 6 - 5
main/inc/lib/display.lib.php

@@ -69,7 +69,7 @@ class Display {
 
     /**
      *	Display simple html header of table.
-     *  @deprecated
+     *  @deprecated use the HTML_table class
      */
     /*public static function display_table_header() {
         $bgcolor = 'bgcolor="white"';
@@ -89,8 +89,9 @@ class Display {
      *	@author Roan Embrechts
      *	@version 1.01
      *  @todo remove this function, is only use in user.php
+     *  @deprecated use the HTML_table class
      *	@return return type string, bgcolor
-     */
+     *//*
     public static function display_complex_table_header($properties, $column_header) {
         $width = $properties['width'];
         if (!isset($width)) {
@@ -120,7 +121,7 @@ class Display {
         echo "<tbody>\n";
         $bgcolor = 'bgcolor="'.HTML_WHITE.'"';
         return $bgcolor;
-    }
+    }*/
 
     /**
      *	Displays a table row.
@@ -130,7 +131,7 @@ class Display {
      *	@param $is_alternating true: the row colours alternate, false otherwise
      *  @todo remove this function, is only use in user.php
      */
-    public static function display_table_row($bgcolor, $table_row, $is_alternating = true) {
+    /*public static function display_table_row($bgcolor, $table_row, $is_alternating = true) {
         echo '<tr '.$bgcolor.'>';
         foreach ($table_row as & $table_element) {
             echo '<td>'.$table_element.'</td>';
@@ -144,7 +145,7 @@ class Display {
             }
         }
         return $bgcolor;
-    }
+    }*/
 
     /**
      * Displays a table

+ 111 - 31
main/inc/lib/document.lib.php

@@ -476,7 +476,7 @@ return 'application/octet-stream';
      * @param boolean $can_see_invisible
      * @return array with all document data
      */
-    public static function get_all_document_data($_course, $path = '/', $to_group_id = 0, $to_user_id = NULL, $can_see_invisible = false, $search =false) {
+    public static function get_all_document_data($_course, $path = '/', $to_group_id = 0, $to_user_id = NULL, $can_see_invisible = false, $search = false) {
         $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY, $_course['dbName']);
         $TABLE_DOCUMENT     = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
         $TABLE_COURSE       = Database::get_main_table(TABLE_MAIN_COURSE);
@@ -497,7 +497,7 @@ return 'application/octet-stream';
         $to_value	= Database::escape_string($to_value);
 
         //if they can't see invisible files, they can only see files with visibility 1
-        $visibility_bit = ' = 1';
+        //$visibility_bit = ' = 1';
         //if they can see invisible files, only deleted files (visibility 2) are filtered out
         //if ($can_see_invisible) {
         $visibility_bit = ' <> 2';
@@ -533,7 +533,7 @@ return 'application/octet-stream';
                         AND ".$to_field." = ".$to_value."
                         AND last.visibility".$visibility_bit.$condition_session;
         }
-
+		
         $result = Database::query($sql);
 
         $doc_list = array();
@@ -587,7 +587,8 @@ return 'application/octet-stream';
                     }
                     $temp[$row['id']] = $row;
                 }
-
+				//@todo use the DocumentManager::is_visible function
+				
                 //Checking disponibility in a session
                 foreach($my_repeat_ids as $id) {
                     foreach($doc_list as $row ) {
@@ -623,8 +624,19 @@ return 'application/octet-stream';
                         unset($document_data[$row['id']]);
                     }
                 }
+                
+                //Checking parents visibility
+                $final_document_data = array();
+                foreach($document_data as $row) {                	
+                	$is_visible = DocumentManager::check_visibility_tree($row['id'], $_course['code'], $current_session_id, api_get_user_id());
+                	if ($is_visible) { 
+                		$final_document_data[$row['id']]=$row;
+                	}                	 
+                }
+            } else {
+            	$final_document_data = $document_data;
             }
-            return $document_data;
+            return $final_document_data;
         } else {
             //display_error("Error getting document info from database (".Database::error().")!");
             return false;
@@ -1001,7 +1013,7 @@ return 'application/octet-stream';
      * @todo load parent_id
      * @return int id of document / false if no doc found
      */
-    public static function get_document_data_by_id($id, $course_code) {
+    public static function get_document_data_by_id($id, $course_code, $load_parents = false) {
         $course_info = api_get_course_info($course_code);
         if (empty($course_info)) {
             return false;
@@ -1014,12 +1026,52 @@ return 'application/octet-stream';
         $result = Database::query($sql);
         if ($result && Database::num_rows($result) == 1) {
             $row = Database::fetch_array($result,'ASSOC');
-            //Public document URL
-            $row['url'] = api_get_path(WEB_CODE_PATH).'document/showinframes.php?cidReq='.$course_code.'&id='.$id;            
+            
+            //@todo need to clarify the name of the URLs not nice right now
             $url_path = urlencode($row['path']);
-            $path = str_replace('%2F', '/',$url_path);            
-            $row['direct_url'] = $www.$path;            
-            $row['parent_id']  = self::get_document_id($course_info, dirname($row['path']));
+            $path 	  = str_replace('%2F', '/',$url_path);
+            
+            $row['url'] 			= api_get_path(WEB_CODE_PATH).'document/showinframes.php?cidReq='.$course_code.'&id='.$id;
+            $row['document_url'] 	= api_get_path(WEB_CODE_PATH).'document/document.php?cidReq='.$course_code.'&id='.$id;
+            $row['direct_url'] 		= $www.$path;
+            
+            if (dirname($row['path']) == '.') { 
+            	$row['parent_id'] = '0';
+            } else {
+            	$row['parent_id'] = self::get_document_id($course_info, dirname($row['path']));
+            }            
+            $parents = array();
+            
+            //Use to generate parents (needed for the breadcrumb)
+            //@todo sorry but this for is here because there's not a parent_id in the document table so we parsed the path!!
+            
+            $visibility = true;
+                        
+            if ($load_parents) { 	
+            	$dir_array = explode('/', $row['path']);
+            	$dir_array = array_filter($dir_array);            	
+            	$array_len = count($dir_array) +1 ;
+            	$real_dir  = '';
+            	
+            	for ($i = 1; $i < $array_len; $i++) {
+            		$sub_visibility = true;
+            		$real_dir .= '/'.$dir_array[$i];            	
+            		$parent_id = self::get_document_id($course_info, $real_dir);
+            		if (!empty($parent_id)) {            		
+            			 $sub_document_data = self::get_document_data_by_id($parent_id, $course_code, false);
+            			 //@todo add visibility here             			 
+            			 
+            			 /*$sub_visibility    = self::is_visible_by_id($parent_id, $course_info, api_get_session_id(), api_get_user_id());
+            			 if ($visibility && $sub_visibility == false) {
+            			 	$visibility = false;
+            			 }
+            			 */
+            			 $parents[] = $sub_document_data;
+            		}
+            	}  	
+            }
+            //$row['visibility_for_user'] = $visibility;
+            $row['parents'] = $parents;
             return $row;
         }
         return false;
@@ -2109,26 +2161,25 @@ return 'application/octet-stream';
         $base_work_dir    = $sys_course_path.$course_dir;
          
         if (isset($files['file'])) {
-            $upload_ok = process_uploaded_file($files['file'], $show_output);
+            $upload_ok = process_uploaded_file($files['file'], $show_output);            
              
             if ($upload_ok) {
                 // File got on the server without problems, now process it
                 $new_path = handle_uploaded_document($course_info, $files['file'], $base_work_dir, $path, api_get_user_id(), api_get_group_id(), null, $max_filled_space, $unzip, $if_exists, $show_output);
                 if ($new_path) {
-
-                    $new_comment = isset($title) ? trim($comment) : '';
-                    $new_title   = isset($title) ? trim($title) : '';
-
                     $docid = DocumentManager::get_document_id($course_info, $new_path);
-
-                    if ($new_path && ($new_comment || $new_title)) {
-                        if (!empty($docid)) {
-                            $table_document = Database::get_course_table(TABLE_DOCUMENT);
-                            $ct = '';
-                            if ($new_comment) $ct .= ", comment='$new_comment'";
-                            if ($new_title)   $ct .= ", title='$new_title'";
-                            Database::query("UPDATE $table_document SET ".substr($ct, 1)." WHERE id = $docid");
+                    if (!empty($docid)) {
+                    	$table_document = Database::get_course_table(TABLE_DOCUMENT);
+						$params = array();
+                        if (!empty($title)) {                        	
+                        	$params['title'] = trim($title);
+                        } else {
+                        	$params['title']  = $files['file']['name'];
                         }
+                        if (!empty($comment)) {
+                        	$params['comment'] = trim($comment);
+                        }         
+                        Database::update($table_document, $params, array('id = ?' =>$docid));                                           
                     }
 
                     // Showing message when sending zip files
@@ -2651,17 +2702,23 @@ return 'application/octet-stream';
 		    				$path_to_eval .= "['$resource_path']['files']";
 		    			}
 		    		}
-		    	}	
-		    	
+		    	}
 		    	$last_path = $resource_path;
 		    	
+		    	//$data = json_encode(array('title'=>$resource['title'], 'path'=>$last_path));
+		    	//@todo not sure if it's a good thing using base64_encode. I tried with json_encode but i received the same error
+		    	//Some testing is needed in order to prove the performance 
+		    	//Also change the explode to value from "/" to "|@j@|" it fixes  #3780
 		    	
+		    	$data = base64_encode($resource['title'].'|@j@|'.$last_path);		    	
+		    		    	
 		    	if ($is_file) {
 		    		//for backward compatibility
 		    		if (empty($resource['title'])) {
 		    			$resource['title'] = basename($resource['path']);
 		    		}
-		    		eval ('$resources_sorted'.$path_to_eval.'['.$resource['id'].'] = "'.$resource['title']."/". $last_path.'";');
+		    		//eval ('$resources_sorted'.$path_to_eval.'['.$resource['id'].'] = "'.$resource['title']."/". $last_path.'";');
+		    		eval ('$resources_sorted'.$path_to_eval.'['.$resource['id'].'] = "'.$data.'" ; ');
 		    	} else {
 		    		eval ('$resources_sorted'.$path_to_eval.'["'.$last_path.'"]["id"]='.$resource['id'].';');
 		    	}
@@ -2669,6 +2726,7 @@ return 'application/octet-stream';
     	}
     	
     	$label = get_lang('Documents');
+    	//var_dump($resources_sorted);
     	$new_array[$label] = array('id' => 0, 'files' => $resources_sorted);
     	
     	$write_result = self::write_resources_tree($course_info, $session_id, $new_array, 0, $lp_id, $target);
@@ -2679,8 +2737,7 @@ return 'application/octet-stream';
     	$img_path = api_get_path(WEB_IMG_PATH);
     	
     	if ($lp_id == false) {
-    		$return .= "<script>
-    		
+    		$return .= "<script>    		
     		    	$('.doc_folder').mouseover(function() {	
     					var my_id = this.id.split('_')[2];    						
     					$('#'+my_id).show();
@@ -2781,12 +2838,14 @@ return 'application/octet-stream';
     				$return .= '</div></div>';
     			} else {
     				if (!is_array($resource)) {
-    					
+    				//if (isset($resource)) {
+    					//var_dump($resource);
+    					$resource = base64_decode($resource);
     					// It's a file.
     					$icon		= choose_image($resource);
     					$position 	= strrpos($icon, '.');
     					$icon 		= substr($icon, 0, $position) . '_small.gif';
-    					$file_info	= explode('/', $resource);
+    					$file_info	= explode('|@j@|', $resource);
     					$my_file_title = $file_info[0];
     					$my_file_name  = $file_info[1];
 
@@ -2816,5 +2875,26 @@ return 'application/octet-stream';
     	return $return;
     }
     
+    public function check_visibility_tree($doc_id, $course_code, $session_id, $user_id) {
+    	$document_data = self::get_document_data_by_id($doc_id, $course_code);    
+  	
+    	if (!empty($document_data)) {
+    		if ($document_data['parent_id'] == false) {
+    			$visible = self::is_visible_by_id($doc_id, $course_info, $session_id, $user_id);
+    			return $visible;
+    		} else {
+    			$course_info = api_get_course_info($course_code);
+    			$visible = self::is_visible_by_id($doc_id, $course_info, $session_id, $user_id);
+    			
+    			if (!$visible) {
+    				return false;
+    			} else {
+    				return self::check_visibility_tree($document_data['parent_id'], $course_code, $session_id, $user_id);
+    			}
+    		}	
+    	} else {
+    		return false;
+    	}    	
+    }    
 }
 //end class DocumentManager

+ 7 - 7
main/inc/lib/events.lib.inc.php

@@ -305,7 +305,7 @@ function event_link($link_id) {
  * @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
  * @desc Record result of user when an exercice was done 
 */
-function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration) {
+function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration , $question_list) {
 	require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
     if ($exeid!='') {
 		// Validation in case of fraud with actived control time
@@ -323,6 +323,7 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
 	    }
 
 		$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+		array_map('intval', $question_list);
 
 		$sql = "UPDATE $TABLETRACK_EXERCICES SET
 				   exe_exo_id 		= '".Database::escape_string($exo_id)."',
@@ -335,18 +336,17 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
 				   exe_duration 	= '".Database::escape_string($duration)."',
 				   exe_date			= '".api_get_utc_datetime()."',
 				   status 			= '',
-				   start_date       = '".api_get_utc_datetime($start_date)."'
+				   start_date       = '".api_get_utc_datetime($start_date)."',
+				   data_tracking    = '".implode(',', $question_list)."'
 				 WHERE exe_id = '".Database::escape_string($exeid)."'";
 		$res = @Database::query($sql);
         
         //Deleting control time session track		
 		exercise_time_control_delete($exo_id);
-        //error_log('update_event_exercice');
-        //error_log($sql);
-		return $res;
-        
-	} else
+		return $res;        
+	} else {
 		return false;
+	}
 }
 
 /**

+ 1 - 1
main/inc/lib/exercise_show_functions.lib.php

@@ -228,7 +228,7 @@ class ExerciseShowFunctions {
         <td width="5%" align="center">
         <?php   
         
-        $question = new MultipleAnswerTrueFalse();        
+        $question 	 = new MultipleAnswerTrueFalse();        
         $new_options = Question::readQuestionOption($questionId);
         //Your choice
         if (isset($new_options[$studentChoice])) {

+ 1 - 1
main/inc/lib/fileUpload.lib.php

@@ -825,7 +825,7 @@ function add_document($_course, $path, $filetype, $filesize, $title, $comment =
 	$table_document = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
 	$sql = "INSERT INTO $table_document (path, filetype, size, title, comment, readonly, session_id)
 	        VALUES ('$path','$filetype','$filesize','".
-	Database::escape_string(htmlspecialchars($title, ENT_QUOTES, api_get_system_encoding()))."', '$comment', $readonly, $session_id)";
+	Database::escape_string($title)."', '$comment', $readonly, $session_id)";
 	if (Database::query($sql)) {
 		//display_message("Added to database (id ".Database::insert_id().")!");
 		return Database::insert_id();

+ 3 - 4
main/newscorm/learnpath.class.php

@@ -4940,8 +4940,7 @@ class learnpath {
         
         $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
         
-        if (empty($_POST['dir']) && empty($_GET['dir'])) {
-            var_dump($dir);
+        if (empty($_POST['dir']) && empty($_GET['dir'])) {            
         	$result = $this->generate_lp_folder($_course, $dir);
         	$dir 		= $result['dir'];
         	$filepath 	= $result['filepath'];
@@ -7160,7 +7159,7 @@ class learnpath {
             $return .= Display::url(Display::return_icon('accept.png', get_lang('Prerequisites'), array(), 22), $url.'&action=edit_item_prereq');
         }
         $return .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), 22), $url.'&action=delete_item');
-
+/*
         // Get the audiorecorder. Use of ob_* functions since there are echos in the file.
         ob_start();
         $audio_recorder_studentview = 'false';
@@ -7171,7 +7170,7 @@ class learnpath {
         $return .= ob_get_contents();
         ob_end_clean();
         // End of audiorecorder include
-        $return .= '</div>';
+        $return .= '</div>';*/
         return $return;
     }
 

+ 37 - 20
main/newscorm/lp_view.php

@@ -171,11 +171,15 @@ foreach($list as $toc) {
     }
 }
 
+$debug = 0;
+
 $autostart = 'true';
 // Update status, total_time from lp_item_view table when you finish the exercises in learning path.
 if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp_item_id'])) {
     global $src;
+    
     $_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
+    
     $TBL_TRACK_EXERCICES    = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
     $TBL_LP_ITEM_VIEW       = Database::get_course_table(TABLE_LP_ITEM_VIEW);
     $TBL_LP_VIEW            = Database::get_course_table(TABLE_LP_VIEW);
@@ -185,19 +189,29 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
     $safe_exe_id            = intval($_REQUEST['exeId']);
 
     if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) {
-
-        $sql = 'SELECT start_date,exe_date,exe_result,exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id;
+		
+        $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id;
         $res = Database::query($sql);
         $row_dates = Database::fetch_array($res);
 
         $time_start_date = api_strtotime($row_dates['start_date'],'UTC');
         $time_exe_date   = api_strtotime($row_dates['exe_date'],'UTC');
 
-        $mytime = ((int)$time_exe_date-(int)$time_start_date);
-        $score = (float)$row_dates['exe_result'];
-        $max_score = (float)$row_dates['exe_weighting'];
+        $mytime 	= ((int)$time_exe_date-(int)$time_start_date);        
+        $score 		= (float)$row_dates['exe_result'];
+        $max_score 	= (float)$row_dates['exe_weighting'];
+        
+        /*require_once '../exercice/exercise.class.php';
+        require_once '../exercice/question.class.php';
+        require_once '../exercice/answer.class.php';
+        require_once '../exercice/exercise.lib.php';
+        
+        $exercise_obj = new Exercise();
+        $score_result = $exercise_obj->get_exercise_result($safe_exe_id);
+        $score = (float)$score_result['score'];*/        
 
         $sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE id = '".(int)$safe_item_id."'";
+        if ($debug) error_log($sql_upd_max_score);
         Database::query($sql_upd_max_score);
 
         $sql_last_attempt = "SELECT id FROM $TBL_LP_ITEM_VIEW  WHERE lp_item_id = '$safe_item_id' AND lp_view_id = '".$_SESSION['oLP']->lp_view_id."' order by id desc limit 1";
@@ -206,10 +220,11 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
         $lp_item_view_id = $row_last_attempt[0];
 
         if (Database::num_rows($res_last_attempt) > 0) {
-            $sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score,total_time = $mytime WHERE id='".$lp_item_view_id."'";
+            $sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score, total_time = $mytime WHERE id='".$lp_item_view_id."'";
+            if ($debug) error_log($sql_upd_score);
             Database::query($sql_upd_score);
 
-            $update_query = "UPDATE $TBL_TRACK_EXERCICES SET  orig_lp_item_view_id = $lp_item_view_id  WHERE exe_id = ".$safe_exe_id;
+            $update_query = "UPDATE $TBL_TRACK_EXERCICES SET orig_lp_item_view_id = $lp_item_view_id  WHERE exe_id = ".$safe_exe_id;
             Database::query($update_query);
         }
     }
@@ -217,7 +232,8 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
     if (intval($_GET['fb_type']) > 0) {
         $src = 'blank.php?msg=exerciseFinished';
     } else {
-        $src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.Security::remove_XSS($_REQUEST['exeId']).'&origin=learnpath&learnpath_id='.$lp_id.'&learnpath_item_id='.$lp_id.'&fb_type='.Security::remove_XSS($_GET['fb_type']);
+        $src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.$safe_exe_id.'&origin=learnpath&learnpath_id='.$lp_id.'&learnpath_item_id='.$lp_id.'&fb_type='.Security::remove_XSS($_GET['fb_type']);
+        if ($debug) error_log('Calling URL'.$src);
     }
     $autostart = 'false';
 }
@@ -235,18 +251,19 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
     $htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>";
 }
 
-    // Not in fullscreen mode.
-    require_once '../inc/reduced_header.inc.php';
-    //$displayAudioRecorder = (api_get_setting('service_visio', 'active') == 'true') ? true : false;
-    // Check if audio recorder needs to be in studentview.
-    $course_id = $_SESSION['_course']['id'];
-    if ($_SESSION['status'][$course_id] == 5) {
-        $audio_recorder_studentview = true;
-    } else {
-        $audio_recorder_studentview = false;
-    }
-    // Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
-    $_SESSION['loaded_lp_view'] = true;
+// Not in fullscreen mode.
+require_once '../inc/reduced_header.inc.php';
+//$displayAudioRecorder = (api_get_setting('service_visio', 'active') == 'true') ? true : false;
+// Check if audio recorder needs to be in studentview.
+$course_id = $_SESSION['_course']['id'];
+if ($_SESSION['status'][$course_id] == 5) {
+	$audio_recorder_studentview = true;
+} else {
+	$audio_recorder_studentview = false;
+}
+
+// Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
+$_SESSION['loaded_lp_view'] = true;
 
 $display_none = '';
 $margin_left = '290px';

+ 8 - 16
main/user/user.php

@@ -22,8 +22,6 @@
 /**
  * Code
  */
-
-/*	   INIT SECTION	*/
 // name of the language file that needs to be included
 $language_file = array('registration', 'admin', 'userInfo');
 $use_anonymous = true;
@@ -216,11 +214,7 @@ if (api_is_allowed_to_edit(null, true)) {
 } // end if allowed to edit
 
 
-/*
-==============================================================================
-		FUNCTIONS
-==============================================================================
-*/
+/*		FUNCTIONS	*/
 
 function display_user_search_form() {
 	echo '<form method="get" action="user.php">';
@@ -239,11 +233,13 @@ function display_user_search_form() {
 *	@author Roan Embrechts
 *	@todo users from virtual courses always show "-" for the group related output. Edit and statistics columns are disabled *	for these users, for now.
 */
+/*
 function show_users_in_virtual_courses() {
 	global $_course, $_user, $origin;
 	$real_course_code = $_course['sysCode'];
 	$real_course_info = Database::get_course_info($real_course_code);
 	$user_subscribed_virtual_course_list = CourseManager::get_list_of_virtual_courses_for_specific_user_and_real_course($_user['user_id'], $real_course_code);
+	
 	$number_of_virtual_courses = count($user_subscribed_virtual_course_list);
 	$row = 0;
 	$column_header[$row++] = "ID";
@@ -302,17 +298,13 @@ function show_users_in_virtual_courses() {
 		}
 		echo '</tbody></table>';
 	}
-}
+}*/
 
 if (!$is_allowed_in_course) {
 	api_not_allowed(true);
 }
 
-/*
------------------------------------------------------------
-	Header
------------------------------------------------------------
-*/
+/*	Header */
 if ($origin != 'learnpath') {
 	if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
 		$interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users"));
@@ -668,10 +660,10 @@ if (api_get_setting('allow_user_headings') == 'true' && $is_courseAdmin && api_i
 }
 
 //User list of the virtual courses linked to this course.
-
-show_users_in_virtual_courses($is_allowed_to_track);
+//@todo 
+//show_users_in_virtual_courses($is_allowed_to_track);
 
 /*		FOOTER  */
 if ($origin != 'learnpath') {
 	Display::display_footer();
-}
+}

+ 5 - 7
main/work/work.lib.php

@@ -975,8 +975,8 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 	if (isset($_GET['curdirpath'])) {
 		$my_params = array ('curdirpath' => Security::remove_XSS($_GET['curdirpath']));
 	}
-
-	$my_params = array ('id' => Security::remove_XSS($_GET['id']));
+	
+	$my_params = array ('id' => isset($_GET['id']) ? $_GET['id'] : null);
 
 	if (isset($_GET['edit_dir'])) {
 		$my_params = array ('edit_dir' => Security::remove_XSS($_GET['edit_dir']));
@@ -1781,14 +1781,12 @@ function make_checkbox($name, $checked = '') {
 }
 
 function draw_date_picker($prefix, $default = '') {
-	//$default = 2008-10-01 10:00:00
 	if (empty($default)) {
-		//$default = date('Y-m-d H:i:s');
 		$default = api_get_local_time();
 	}
-	$parts = split(' ', $default);
-	list($d_year, $d_month, $d_day) = split('-', $parts[0]);
-	list($d_hour, $d_minute) = split(':', $parts[1]);
+	$parts = explode(' ', $default);
+	list($d_year, $d_month, $d_day) = explode('-', $parts[0]);
+	list($d_hour, $d_minute) = explode(':', $parts[1]);
 
 	$minute = range(10, 59);
 	array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');

+ 2 - 2
main/work/work.php

@@ -1283,14 +1283,14 @@ if ($is_course_member) {
 		$oFCKeditor->ToolbarSet = 'work';
 		$oFCKeditor->Width		= '100%';
 		$oFCKeditor->Height		= '200';
-		$oFCKeditor->Value		= $message;
+		$oFCKeditor->Value		= isset($message) ? $message : null;
 		$return =	$oFCKeditor->CreateHtml();
 		$new_folder_text .= $return;
 		$new_folder_text .= '</div>
 							</div>';
 
 		// Advanced parameters
-		$addtext .='<div id="options" style="display: none;">';
+		$addtext  = '<div id="options" style="display: none;">';
 		$addtext .= '<div style="padding:10px">';
 		$addtext .= '<b>'.get_lang('QualificationOfAssignment').'</b>';
 		$addtext .= '<table cellspacing="0" cellpading="0" border="0"><tr>';

+ 2 - 1
tests/main/inc/lib/display.lib.test.php

@@ -51,6 +51,7 @@ class TestDisplay extends UnitTestCase {
 	*	@param $is_alternating true: the row colours alternate, false otherwise
 	*	@return string color
 	*/
+	/*
 	public function testdisplay_table_row() {
 		$bgcolor = 'red';
 		$table_row = array();
@@ -60,7 +61,7 @@ class TestDisplay extends UnitTestCase {
 		ob_end_clean();
 		$this->assertTrue(is_string($res));
 		//var_dump($res);
-	}
+	}*/
 
 	public function testdisplay_sortable_table() {
 		$header='';

+ 3 - 3
tests/main/inc/lib/events.lib.inc.test.php

@@ -142,9 +142,9 @@ class TestEvents extends UnitTestCase {
 		$weighting='';
 		$session_id='';
 		$duration='';
-		$res=update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration);
+		$question_list = array();
+		$res=update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration, $question_list);
 		$this->assertTrue(is_bool($res));
 		//var_dump($res);
 	}
-}
-?>
+}

Неке датотеке нису приказане због велике количине промена