Juan Carlos Raña 14 years ago
parent
commit
697a3e065d
62 changed files with 732 additions and 590 deletions
  1. 0 1
      main/admin/group_add.php
  2. 0 1
      main/admin/group_edit.php
  3. 0 1
      main/admin/languages.php
  4. 5 7
      main/admin/promotions.php
  5. 2 17
      main/admin/session_add.php
  6. 7 26
      main/admin/session_list.php
  7. 0 1
      main/admin/sub_language.php
  8. 0 1
      main/admin/user_fields_add.php
  9. 0 1
      main/admin/user_list.php
  10. 0 8
      main/admin/user_move_stats.php
  11. 0 1
      main/announcements/announcements.php
  12. 0 3
      main/auth/courses.php
  13. 0 1
      main/calendar/agenda.inc.php
  14. 0 1
      main/course_home/course_home.php
  15. 120 79
      main/coursecopy/classes/CourseBuilder.class.php
  16. 12 4
      main/coursecopy/classes/CourseCopyLearnpath.class.php
  17. 62 42
      main/coursecopy/classes/CourseRestorer.class.php
  18. 3 1
      main/coursecopy/classes/Quiz.class.php
  19. 0 1
      main/create_course/add_course.php
  20. 18 45
      main/css/chamilo/default.css
  21. 1 3
      main/document/create_document.php
  22. 0 1
      main/document/showinframes.php
  23. 2 3
      main/dropbox/dropbox_functions.inc.php
  24. 72 23
      main/exercice/exercice.php
  25. 10 3
      main/exercice/exercice_submit.php
  26. 138 128
      main/exercice/exercise.class.php
  27. 14 7
      main/exercice/exercise_admin.php
  28. 1 2
      main/exercice/question_create.php
  29. 0 1
      main/forum/forumfunction.inc.php
  30. 0 1
      main/forum/forumqualify.php
  31. 0 1
      main/forum/index.php
  32. 0 1
      main/forum/viewforumcategory.php
  33. 0 1
      main/forum/viewpost.php
  34. 2 3
      main/glossary/index.php
  35. 0 1
      main/gradebook/gradebook.php
  36. 0 2
      main/gradebook/gradebook_flatview.php
  37. 0 1
      main/gradebook/index.php
  38. 0 1
      main/group/group.php
  39. 5 0
      main/inc/lib/career.lib.php
  40. 4 4
      main/inc/lib/course.lib.php
  41. 17 4
      main/inc/lib/javascript/jquery-ui/default.css
  42. 3 3
      main/inc/lib/main_api.lib.php
  43. 92 3
      main/inc/lib/message.lib.php
  44. 1 1
      main/inc/lib/promotion.lib.php
  45. 1 2
      main/inc/lib/search/search_widget.php
  46. 54 22
      main/inc/lib/sessionmanager.lib.php
  47. 0 1
      main/link/link.php
  48. 0 1
      main/mySpace/access_details.php
  49. 3 2
      main/newscorm/learnpathList.class.php
  50. 0 1
      main/newscorm/lp_add.php
  51. 0 1
      main/newscorm/lp_view.php
  52. 0 1
      main/notebook/index.php
  53. 7 24
      main/social/group_invitation.php
  54. 3 11
      main/social/invitations.php
  55. 3 4
      main/social/myfiles.php
  56. 68 72
      main/social/profile.php
  57. 1 2
      main/survey/create_new_survey.php
  58. 0 1
      main/survey/question.php
  59. 1 2
      main/survey/survey.lib.php
  60. 0 1
      main/tracking/question_course_report.php
  61. 0 1
      main/work/work.php
  62. 0 1
      user_portal.php

+ 0 - 1
main/admin/group_add.php

@@ -26,7 +26,6 @@ $this_section = SECTION_PLATFORM_ADMIN;
 // User permissions
 api_protect_admin_script();
 
-$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
 $htmlHeadXtra[] = '<script type="text/javascript">
 textarea = "";
 num_characters_permited = 255;

+ 0 - 1
main/admin/group_edit.php

@@ -28,7 +28,6 @@ $interbreadcrumb[] = array('url' => 'group_list.php','name' => get_lang('GroupLi
 
 $table_group = Database::get_main_table(TABLE_MAIN_GROUP);
 
-$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
 $htmlHeadXtra[] = '<script type="text/javascript">
 textarea = "";
 num_characters_permited = 255;

+ 0 - 1
main/admin/languages.php

@@ -49,7 +49,6 @@ if (isset($_POST['sent_http_request'])) {
 	}
 	exit;
 }
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] ='<script type="text/javascript">
  $(document).ready(function() {
 

+ 5 - 7
main/admin/promotions.php

@@ -35,7 +35,6 @@ if ($action == 'add') {
     $interbreadcrumb[]=array('url' => '#','name' => get_lang('Promotions'));
 }
 
-
 // The header.
 Display::display_header($tool_name);
 
@@ -75,8 +74,7 @@ $action_links = 'function action_formatter (cellvalue, options, rowObject) {
 $(function() { 
     <?php 
          echo Display::grid_js('promotions',  $url,$columns,$column_model,$extra_params,array(), $action_links, true);       
-    ?> 
-
+    ?>
 });
 </script>   
 <?php
@@ -117,8 +115,8 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') {
         Security::clear_token();
         $promotion->display();
     } else {
-        echo '<div class="actions">';
-        echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
+        echo '<div class="actions">';        
+        echo Display::url(Display::return_icon('back.png',get_lang('Back'),'','32'), api_get_self());
         echo '</div>';
         $token = Security::get_token();
         $form->addElement('hidden', 'sec_token');
@@ -146,8 +144,8 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') {
         Security::clear_token();
         $promotion->display();
     } else {
-        echo '<div class="actions">';
-        echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png',get_lang('Back'),'','32').' '.'</a>';
+        echo '<div class="actions">';        
+        echo Display::url(Display::return_icon('back.png',get_lang('Back'),'','32'), api_get_self());
         echo '</div>';
         $token = Security::get_token();
         $form->addElement('hidden', 'sec_token');

+ 2 - 17
main/admin/session_add.php

@@ -3,7 +3,7 @@
 
 /**
 *	@package chamilo.admin
-* 	@todo use formvalidator for the form
+* 	@todo use formvalidator for the form, remove all the select harcoded values
 */
 
 // name of the language file that needs to be included
@@ -123,20 +123,9 @@ if ($_POST['formSent']) {
         $nolimit = 1;
     } else {
     	$nolimit = null;
-    }
-    
+    }    
 	$return = SessionManager::create_session($name,$year_start,$month_start,$day_start,$year_end,$month_end,$day_end,$nb_days_acess_before,$nb_days_acess_after,$nolimit,$coach_username, $id_session_category,$id_visibility, $start_limit, $end_limit);
 
-	global $_configuration;
-	require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
-	if ($_configuration['multiple_access_urls']) {
-		$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
-		$access_url_id = api_get_current_access_url_id();
-		UrlManager::add_session_to_url($return,$access_url_id);
-	} else {
-		// we are filling by default the access_url_rel_session table
-		UrlManager::add_session_to_url($return,1);
-	}
 	if ($return == strval(intval($return))) {
 		// integer => no error on session creation
 		header('Location: add_courses_to_session.php?id_session='.$return.'&add=true&msg=');
@@ -157,10 +146,6 @@ $tool_name = get_lang('AddSession');
 //display the header
 Display::display_header($tool_name);
 
-// display the tool title
-// api_display_tool_title($tool_name);
-
-
 if (!empty($return)) {
 	Display::display_error_message($return,false);
 }

+ 7 - 26
main/admin/session_list.php

@@ -25,8 +25,7 @@ $htmlHeadXtra[] = '<script language="javascript">
 						}
 					}
 				}
-				</script>
-		';
+				</script>';
 
 $tbl_session			= Database::get_main_table(TABLE_MAIN_SESSION);
 $tbl_session_category	= Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@@ -161,7 +160,8 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id
 			 $where ";
 
-//filtering the session list by access_url
+    //filtering the session list by access_url
+    
 	if ($_configuration['multiple_access_urls']) {
 		$table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 		$access_url_id = api_get_current_access_url_id();
@@ -293,7 +293,6 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	      <td><?php echo ($enreg['date_end'] != '0000-00-00')?api_htmlentities($enreg['date_end'],ENT_QUOTES,$charset): '-'; ?></td>
 	      <td><?php echo $user_link; ?></td>
 		  <td><?php
-
 		  switch (intval($enreg['visibility'])) {
 				case SESSION_VISIBLE_READ_ONLY: //1
 					echo get_lang('ReadOnly');
@@ -305,8 +304,6 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 					echo api_ucfirst(get_lang('Invisible'));
 				break;
 		  }
-
-
 		  ?></td>
 		  <td>
 			<a href="add_users_to_session.php?page=session_list.php&id_session=<?php echo $enreg['id']; ?>"><?php Display::display_icon('user_subscribe_session.png', get_lang('SubscribeUsersToSession'),'','22'); ?></a>
@@ -316,44 +313,30 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
             <a href="<?php echo api_get_self(); ?>?sort=<?php echo $sort; ?>&action=delete&idChecked=<?php echo $enreg['id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;"><?php Display::display_icon('delete.png', get_lang('Delete'), array(), 22); ?></a>
 		  </td>
 		</tr>
-
 		<?php
 			$i=$i ? 0 : 1;
 			$x++;
 		}
-
 		unset($sessions);
-
 		?>
-
 		</table>
-
 		<br />
-
 		<div align="left">
-
 		<?php
 
 		if($num>$limit) {
-		if($page)
-			{
+		if($page) {
 			?>
-
 			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo Security::remove_XSS($_REQUEST['keyword']); ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
-
 			<?php
-			}
-			else
-			{
+			} else {
 				echo get_lang('Previous');
 			}
 			?>
-
 			|
 
 			<?php
-			if($nbr_results > $limit)
-			{
+			if($nbr_results > $limit) {
 			?>
 
 			<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&keyword=<?php echo Security::remove_XSS($_REQUEST['keyword']); ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
@@ -366,7 +349,6 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			}
 		}
 		?>
-
 		</div>
 
 		<br />
@@ -380,5 +362,4 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 	</table>
 <?php
 }
-Display::display_footer();
-?>
+Display::display_footer();

+ 0 - 1
main/admin/sub_language.php

@@ -11,7 +11,6 @@ require_once api_get_path(LIBRARY_PATH).'array.lib.php';
 $this_section=SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] ='<script type="text/javascript">
  $(document).ready(function() {
 

+ 0 - 1
main/admin/user_fields_add.php

@@ -18,7 +18,6 @@ $this_section=SECTION_PLATFORM_ADMIN;
 
 // user permissions
 api_protect_admin_script();
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function change_image_user_field (image_value) {
 	

+ 0 - 1
main/admin/user_list.php

@@ -22,7 +22,6 @@ if (isset($_configuration['deny_delete_users']) &&  $_configuration['deny_delete
 	$delete_user_available = false;
 }
 
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
 $htmlHeadXtra[] = '<script type="text/javascript">
 function load_course_list (div_course,my_user_id) {
 	 $.ajax({

+ 0 - 8
main/admin/user_move_stats.php

@@ -537,21 +537,13 @@ if (isset($_REQUEST['load_ajax'])) {
     exit;
 }
 
-
-
-
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
-
 $htmlHeadXtra[]='<style type="text/css" media="all">@import "'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css";</style>';
 
-
 $htmlHeadXtra[] = '<script type="text/javascript">
 
    function moveto (unique_id, user_id) {
         var session_id = document.getElementById(unique_id).options[document.getElementById(unique_id).selectedIndex].value;
-
-
          $.ajax({
             contentType: "application/x-www-form-urlencoded",
             beforeSend: function(objeto) {

+ 0 - 1
main/announcements/announcements.php

@@ -166,7 +166,6 @@ if ((empty($originalresource) || ($originalresource!=='no')) and (!empty($action
 */
 
 $htmlHeadXtra[] = AnnouncementManager::to_javascript();
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
     $("#emailTitle").focus();

+ 0 - 3
main/auth/courses.php

@@ -28,9 +28,6 @@ if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
 	$htmlHeadXtra[] = '<script type="text/javascript">' .
 				  	  'var GB_ROOT_DIR = "'.api_get_path(WEB_LIBRARY_PATH).'javascript/greybox/"' .
 				  	  '</script>';
-
-	$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>';
-
 	$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/greybox/AJS.js" type="text/javascript" language="javascript"></script>';
 	$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/greybox/AJS_fx.js" type="text/javascript" language="javascript"></script>';
 	$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/greybox/gb_scripts.js" type="text/javascript" language="javascript"></script>';

+ 0 - 1
main/calendar/agenda.inc.php

@@ -35,7 +35,6 @@ $MonthsLong = api_get_months_long();
 */
 
 $htmlHeadXtra[] = to_javascript();
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
 $("#agenda_title").focus();

+ 0 - 1
main/course_home/course_home.php

@@ -41,7 +41,6 @@ require dirname(__FILE__).'/../inc/global.inc.php';
 unset($_SESSION['oLP']);
 unset($_SESSION['lpobject']);
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] ='<script type="text/javascript">
 $(document).ready(function() {
 	$(".make_visible_and_invisible").attr("href", "javascript:void(0);");

+ 120 - 79
main/coursecopy/classes/CourseBuilder.class.php

@@ -58,23 +58,29 @@ class CourseBuilder {
 	function get_course() {
 		return $this->course;
 	}
+	
 	/**
 	 * Build the course-object
+	 * 
+	 * @param int      session_id
+	 * @param string   course_code
+	 * @param bool     true if you want to get the elements that exists in the course and 
+	 *                 in the session, (session_id = 0 or session_id = X) 
 	 */
-	function build($session_id = 0, $course_code = '') {
+	function build($session_id = 0, $course_code = '', $with_base_content = false) {
 		
 		if (!empty($session_id) && !empty($course_code)) {
-			$course_info = api_get_course_info($course_code);
-			$table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES,$course_info['dbName']);
+			$course_info      = api_get_course_info($course_code);
+			$table_link       = Database :: get_course_table(TABLE_LINKED_RESOURCES,$course_info['dbName']);
 			$table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
 
-			$this->build_documents($session_id,$course_code);
-			$this->build_quizzes($session_id,$course_code);
-			$this->build_glossary($session_id,$course_code);
-			$this->build_learnpaths($session_id,$course_code);
-			$this->build_links($session_id,$course_code);
-			$this->build_course_descriptions($session_id,$course_code);
-			$this->build_wiki($session_id,$course_code);
+			$this->build_documents($session_id, $course_code, $with_base_content);
+			$this->build_quizzes($session_id, $course_code,   $with_base_content);
+			$this->build_glossary($session_id, $course_code,  $with_base_content);
+			$this->build_learnpaths($session_id, $course_code,$with_base_content);
+			$this->build_links($session_id, $course_code, $with_base_content);
+			$this->build_course_descriptions($session_id, $course_code, $with_base_content);
+			$this->build_wiki($session_id, $course_code, $with_base_content);
 		} else {
 			$table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES);
 			$table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY);
@@ -127,28 +133,32 @@ class CourseBuilder {
 	/**
 	 * Build the documents
 	 */
-	function build_documents($session_id = 0,$course_code = '') {
+	function build_documents($session_id = 0, $course_code = '', $with_base_content = false) {
 
 		if (!empty($course_code) && !empty($session_id)) {
 			$course_info = api_get_course_info($course_code);
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT,$course_info['dbName']);
-			$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
-
-			$session_id = intval($session_id);
-
+			$table_doc   = Database::get_course_table(TABLE_DOCUMENT, $course_info['dbName']);
+			$table_prop  = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_info['dbName']);
+
+			$session_id  = intval($session_id);
+            if ($with_base_content) {
+                $session_condition = api_get_session_condition($session_id, true, true);                
+            } else {
+                $session_condition = api_get_session_condition($session_id, true);
+            }
 			if (!empty($this->course->type) && $this->course->type=='partial') {
-        		$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND path NOT LIKE \'/images/gallery%\' AND session_id = '.$session_id.' ORDER BY path';
+			    $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM '.$table_doc.' d, '.$table_prop.' p 
+			            WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND path NOT LIKE \'/images/gallery%\' '.$session_condition.' ORDER BY path';
 			} else {
-	        	$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND session_id = '.$session_id.' ORDER BY path';
+	        	$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM '.$table_doc.' d, '.$table_prop.' p 
+	        	        WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 '.$session_condition.' ORDER BY path';
 			}
 
 			$db_result = Database::query($sql);
-			while ($obj = Database::fetch_object($db_result))
-			{
+			while ($obj = Database::fetch_object($db_result)) {
 				$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
 				$this->course->add_resource($doc);
 			}
-
 		} else {
 			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
 			$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY);
@@ -159,14 +169,11 @@ class CourseBuilder {
 	        	$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size  FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND d.session_id = 0 ORDER BY path';
 
 			$db_result = Database::query($sql);
-			while ($obj = Database::fetch_object($db_result))
-			{
+			while ($obj = Database::fetch_object($db_result)) {
 				$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
 				$this->course->add_resource($doc);
 			}
 		}
-
-
 	}
 	/**
 	 * Build the forums
@@ -175,8 +182,7 @@ class CourseBuilder {
 		$table = Database :: get_course_table(TABLE_FORUM);
 		$sql = 'SELECT * FROM '.$table;
 		$db_result = Database::query($sql);
-		while ($obj = Database::fetch_object($db_result))
-		{
+		while ($obj = Database::fetch_object($db_result)) {
 			$forum = new Forum($obj->forum_id, $obj->forum_title, $obj->forum_comment, $obj->forum_category, $obj->forum_last_post, $obj->forum_threads, $obj->forum_posts, $obj->allow_anonymous, $obj->allow_edit, $obj->approval_direct_post, $obj->allow_attachements, $obj->allow_new_threads, $obj->default_view, $obj->forum_of_group, $obj->forum_group_public_private, $obj->forum_order, $obj->locked, $obj->session_id, $obj->forum_image);
 			$this->course->add_resource($forum);
 			$this->build_forum_category($obj->forum_category);
@@ -229,15 +235,19 @@ class CourseBuilder {
 	/**
 	 * Build the links
 	 */
-	function build_links($session_id = 0,$course_code = '')
+	function build_links($session_id = 0, $course_code = '', $with_base_content = false)
 	{
-
 		if (!empty($session_id) && !empty($course_code)) {
 			$course_info = api_get_course_info($course_code);
 			$table = Database :: get_course_table(TABLE_LINK,$course_info['dbName']);
 			$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
 			$session_id = intval($session_id);
-			$sql = "SELECT  l.id, l.title, l.url, l.description, l.category_id, l.on_homepage  FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2  AND session_id = '$session_id' ORDER BY l.display_order";
+            if ($with_base_content) {
+                $session_condition = api_get_session_condition($session_id, true, true);                
+            } else {
+                $session_condition = api_get_session_condition($session_id, true);
+            }  
+			$sql = "SELECT  l.id, l.title, l.url, l.description, l.category_id, l.on_homepage  FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 $session_condition  ORDER BY l.display_order";
 		} else {
 			$table = Database :: get_course_table(TABLE_LINK);
 			$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY);
@@ -301,15 +311,21 @@ class CourseBuilder {
 	/**
 	 * Build the Quizzes
 	 */
-	function build_quizzes($session_id = 0,$course_code = '')
-	{
-		if (!empty($course_code) && !empty($session_id)) {
+	function build_quizzes($session_id = 0, $course_code = '', $with_base_content = false)
+	{	    
+		if (!empty($course_code) && !empty($session_id)) {		    
+		    $session_id  = intval($session_id);
+            if ($with_base_content) {
+                $session_condition = api_get_session_condition($session_id, true, true);                
+            } else {
+                $session_condition = api_get_session_condition($session_id, true);
+            }            
 			$course_info = api_get_course_info($course_code);
 			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST, $course_info['dbName']);
 			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION, $course_info['dbName']);
 			$table_doc = Database :: get_course_table(TABLE_DOCUMENT, $course_info['dbName']);
 			$session_id = intval($session_id);
-			$sql = 'SELECT * FROM '.$table_qui.' WHERE active >=0 AND session_id = '.$session_id; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
+			$sql = 'SELECT * FROM '.$table_qui.' WHERE active >=0 '.$session_condition; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
 		} else {
 			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
 			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
@@ -323,7 +339,8 @@ class CourseBuilder {
 				$doc = Database::fetch_object(Database::query("SELECT id FROM ".$table_doc." WHERE path = '/audio/".$obj->sound."'"));
 				$obj->sound = $doc->id;
 			}
-			$quiz = new Quiz($obj->id, $obj->title, $obj->description, $obj->random, $obj->type, $obj->active, $obj->sound, $obj->max_attempt, $obj->results_disabled, $obj->access_condition, $obj->start_time, $obj->end_time, $obj->feedback_type, $obj->random_answers, $obj->expired_time);
+			$quiz = new Quiz($obj->id, $obj->title, $obj->description, $obj->random, $obj->type, $obj->active, $obj->sound, $obj->max_attempt, 
+			                 $obj->results_disabled, $obj->access_condition, $obj->start_time, $obj->end_time, $obj->feedback_type, $obj->random_answers, $obj->expired_time, $obj->session_id);
 			$sql = 'SELECT * FROM '.$table_rel.' WHERE exercice_id = '.$obj->id;
 			$db_result2 = Database::query($sql);
 			while ($obj2 = Database::fetch_object($db_result2)) {
@@ -337,9 +354,8 @@ class CourseBuilder {
 		} else {
 			$this->build_quiz_questions();
 		}
-
-
 	}
+	
 	/**
 	 * Build the Quiz-Questions
 	 */
@@ -514,13 +530,19 @@ class CourseBuilder {
 	/**
 	 * Build the course-descriptions
 	 */
-	function build_course_descriptions($session_id = 0,$course_code = '')
+	function build_course_descriptions($session_id = 0,$course_code = '', $with_base_content = false)
 	{
 		if (!empty($session_id) && !empty($course_code)) {
 			$course_info = api_get_course_info($course_code);
 			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION,$course_info['dbName']);
 			$session_id = intval($session_id);
-			$sql = 'SELECT * FROM '.$table. ' WHERE session_id ='.$session_id;
+            if ($with_base_content) {
+                $session_condition = api_get_session_condition($session_id, false, true);                
+            } else {
+                $session_condition = api_get_session_condition($session_id, false);
+            }  
+           
+			$sql = 'SELECT * FROM '.$table. ' '.$session_condition;
 		} else {
 			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
 			$sql = 'SELECT * FROM '.$table. ' WHERE session_id = 0';
@@ -536,23 +558,29 @@ class CourseBuilder {
 	/**
 	 * Build the learnpaths
 	 */
-	function build_learnpaths($session_id = 0,$course_code = '') {
+	function build_learnpaths($session_id = 0,$course_code = '', $with_base_content = false) {
 
 		if (!empty($session_id) && !empty($course_code)) {
 			$course_info 	= api_get_course_info($course_code);
 			$table_main 	= Database :: get_course_table(TABLE_LP_MAIN,$course_info['dbName']);
 			$table_item 	= Database :: get_course_table(TABLE_LP_ITEM,$course_info['dbName']);
 			$table_tool 	= Database::get_course_table(TABLE_TOOL_LIST,$course_info['dbName']);
-
-			$sql = 'SELECT * FROM '.$table_main.' WHERE session_id = '.$session_id;
+			
+			$session_id = intval($session_id);
+            if ($with_base_content) {
+                $session_condition = api_get_session_condition($session_id, false, true);                
+            } else {
+                $session_condition = api_get_session_condition($session_id, false);
+            }            
+			$sql = 'SELECT * FROM '.$table_main.' '.$session_condition;
 		} else {
-			$table_main 	= Database :: get_course_table(TABLE_LP_MAIN);
-			$table_item 	= Database :: get_course_table(TABLE_LP_ITEM);
+			$table_main 	= Database::get_course_table(TABLE_LP_MAIN);
+			$table_item 	= Database::get_course_table(TABLE_LP_ITEM);
 			$table_tool 	= Database::get_course_table(TABLE_TOOL_LIST);
 
 			$sql = 'SELECT * FROM '.$table_main.' WHERE session_id = 0';
 		}
-
+        error_log($sql);
 		$db_result = Database::query($sql);
 
 		while ($obj = Database::fetch_object($db_result)) {
@@ -560,23 +588,23 @@ class CourseBuilder {
 			$sql_items = "SELECT * FROM ".$table_item." WHERE lp_id = ".$obj->id."";
 			$db_items = Database::query($sql_items);
 			while ($obj_item = Database::fetch_object($db_items)) {
-				$item['id']				= $obj_item->id;
-				$item['item_type'] 		= $obj_item->item_type;
-				$item['ref'] 			= $obj_item->ref;
-				$item['title'] 			= $obj_item->title;
-				$item['description'] 	= $obj_item->description;
-				$item['path'] 			= $obj_item->path;
-				$item['min_score'] 		= $obj_item->min_score;
-				$item['max_score'] 		= $obj_item->max_score;
-				$item['mastery_score'] 	= $obj_item->mastery_score;
-				$item['parent_item_id'] = $obj_item->parent_item_id;
-				$item['previous_item_id'] = $obj_item->previous_item_id;
-				$item['next_item_id'] 	= $obj_item->next_item_id;
-				$item['display_order'] 	= $obj_item->display_order;
-				$item['prerequisite']	= $obj_item->prerequisite;
-				$item['parameters'] 	= $obj_item->parameters;
-				$item['launch_data'] 	= $obj_item->launch_data;
-				$item['audio'] 			= $obj_item->audio;				
+				$item['id']				   = $obj_item->id;
+				$item['item_type'] 		   = $obj_item->item_type;
+				$item['ref'] 			   = $obj_item->ref;
+				$item['title'] 			   = $obj_item->title;
+				$item['description'] 	   = $obj_item->description;
+				$item['path'] 			   = $obj_item->path;
+				$item['min_score'] 		   = $obj_item->min_score;
+				$item['max_score'] 		   = $obj_item->max_score;
+				$item['mastery_score'] 	   = $obj_item->mastery_score;
+				$item['parent_item_id']    = $obj_item->parent_item_id;
+				$item['previous_item_id']  = $obj_item->previous_item_id;
+				$item['next_item_id'] 	   = $obj_item->next_item_id;
+				$item['display_order']     = $obj_item->display_order;
+				$item['prerequisite']	   = $obj_item->prerequisite;
+				$item['parameters'] 	   = $obj_item->parameters;
+				$item['launch_data'] 	   = $obj_item->launch_data;
+				$item['audio'] 			   = $obj_item->audio;				
 				$items[] = $item;
 			}
 
@@ -608,24 +636,26 @@ class CourseBuilder {
 								$visibility,
 								$obj->author,
 								$obj->preview_image,
+								$obj->use_max_score,
+								$obj->autolunch,
+								$obj->created_on,
+								$obj->modified_on,
+								$obj->publicated_on,
+								$obj->expired_on,														
+								$obj->session_id,
 								$items);
-
 			$this->course->add_resource($lp);
 		}
 
 		//save scorm directory (previously build_scorm_documents())
 		$i = 1;
-		if($dir=@opendir($this->course->backup_path.'/scorm'))
-		{
-			while($file=readdir($dir))
-			{
-				if(is_dir($this->course->backup_path.'/scorm/'.$file) && !in_array($file,array('.','..')))
-				{
+		if($dir=@opendir($this->course->backup_path.'/scorm')) {
+			while($file=readdir($dir)) {
+				if(is_dir($this->course->backup_path.'/scorm/'.$file) && !in_array($file,array('.','..'))) {
 					$doc = new ScormDocument($i++, '/'.$file, $file);
 					$this->course->add_resource($doc);
 				}
 			}
-
 			closedir($dir);
 		}
 	}
@@ -633,29 +663,34 @@ class CourseBuilder {
 	/**
 	 * Build the glossarys
 	 */
-	function build_glossary($session_id = 0, $course_code = '') {
+	function build_glossary($session_id = 0, $course_code = '', $with_base_content = false) {
 
 		if (!empty($session_id) && !empty($course_code)) {
 			$course_info = api_get_course_info($course_code);
 			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY,$course_info['dbName']);
 			$session_id = intval($session_id);
+		    if ($with_base_content) {
+                $session_condition = api_get_session_condition($session_id, false, true);                
+            } else {
+                $session_condition = api_get_session_condition($session_id, false);
+            }
+            //@todo check this queries are the same ... 
 	        if (!empty($this->course->type) && $this->course->type=='partial') {
-	        	$sql = 'SELECT * FROM '.$table_glossary.' g WHERE session_id = '.$session_id;
+	        	$sql = 'SELECT * FROM '.$table_glossary.' g '.$session_condition;
 	        } else {
-	        	$sql = 'SELECT * FROM '.$table_glossary.' g WHERE session_id = '.$session_id;
+	        	$sql = 'SELECT * FROM '.$table_glossary.' g '.$session_condition;
 	        }
 		} else {
 			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
+			//@todo check this queries are the same ... ayayay 
 	        if (!empty($this->course->type) && $this->course->type=='partial') {
 	        	$sql = 'SELECT * FROM '.$table_glossary.' g WHERE session_id = 0';
 	        } else {
 	        	$sql = 'SELECT * FROM '.$table_glossary.' g WHERE session_id = 0';
 	        }
 		}
-
 		$db_result = Database::query($sql);
-		while ($obj = Database::fetch_object($db_result))
-		{
+		while ($obj = Database::fetch_object($db_result)) {
 			$doc = new Glossary($obj->glossary_id, $obj->name, $obj->description, $obj->display_order);
 			$this->course->add_resource($doc);
 		}
@@ -690,13 +725,19 @@ class CourseBuilder {
 		return $list;
 	}
 
-	function build_wiki($session_id = 0, $course_code = 0)
+	function build_wiki($session_id = 0, $course_code = 0, $with_base_content = false)
 	{
 		if (!empty($session_id) && !empty($course_code)) {
 			$course_info = api_get_course_info($course_code);
 			$tbl_wiki = Database::get_course_table(TABLE_WIKI,$course_info['dbName']);
-			$session_id = intval($session_id);
-	        $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE session_id='.$session_id.'';
+			 $session_id = intval($session_id);
+            if ($with_base_content) {
+                $session_condition = api_get_session_condition($session_id, false, true);                
+            } else {
+                $session_condition = api_get_session_condition($session_id, false);
+            }  
+            
+	        $sql = 'SELECT * FROM ' . $tbl_wiki . ' '.$session_condition;
 		} else {
 			$tbl_wiki = Database::get_course_table(TABLE_WIKI);
 	        $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE session_id = 0';

+ 12 - 4
main/coursecopy/classes/CourseCopyLearnpath.class.php

@@ -107,8 +107,9 @@ class CourseCopyLearnpath extends Resource {
 	 * @param string $visibility
 	 * @param array  $items
 	 */
-	function CourseCopyLearnpath($id,$type,$name,$path,$ref,$description,$content_local,$default_encoding,$default_view_mode,$prevent_reinit,$force_commit,$content_maker,$display_order,$js_lib,$content_license,$debug,$visibility, $author, $preview_image, $items)
-	{
+	function CourseCopyLearnpath($id,$type,$name, $path,$ref,$description,$content_local,$default_encoding,$default_view_mode,$prevent_reinit,$force_commit,
+	                             $content_maker, $display_order,$js_lib,$content_license,$debug, $visibility, $author, $preview_image,
+	                             $use_max_score, $autolunch, $created_on, $modified_on, $publicated_on, $expired_on, $session_id, $items) {
 		parent::Resource($id,RESOURCE_LEARNPATH);
 		$this->lp_type = $type;
 		$this->name = $name;
@@ -127,6 +128,14 @@ class CourseCopyLearnpath extends Resource {
 		$this->debug = $debug;
 		$this->visibility=$visibility;
 		
+		$this->use_max_score=$use_max_score;
+		$this->autolunch=$autolunch;
+		$this->created_on=$created_on;
+		$this->modified_on=$modified_on;
+		$this->publicated_on=$publicated_on;
+		$this->expired_on=$expired_on;
+		$this->session_id=$session_id;	
+		
 		$this->author= $author;
 		$this->preview_image= $preview_image;
 		
@@ -158,5 +167,4 @@ class CourseCopyLearnpath extends Resource {
 		parent::show();
 		echo $this->name;
 	}
-}
-?>
+}

+ 62 - 42
main/coursecopy/classes/CourseRestorer.class.php

@@ -20,6 +20,7 @@ require_once api_get_path(SYS_CODE_PATH).'exercice/question.class.php';
 require_once 'Glossary.class.php';
 require_once 'wiki.class.php';
 require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
+require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 
 define('FILE_SKIP', 1);
@@ -65,7 +66,7 @@ class CourseRestorer
 	 * @param	bool	Course settings are going to be restore?
 	 
 	 */
-	function restore($destination_course_code = '', $session_id = 0, $update_course_settings = false) {
+	function restore($destination_course_code = '', $session_id = 0, $update_course_settings = false, $respect_base_content = false) {
 		if ($destination_course_code == '') {
 			$course_info = api_get_course_info();
 			$this->course->destination_db = $course_info['dbName'];
@@ -99,9 +100,9 @@ class CourseRestorer
 
 		if (!empty($session_id)) {
 			$this->restore_documents($session_id, $destination_course_code);
-			$this->restore_quizzes($session_id);
+			$this->restore_quizzes($session_id, $respect_base_content);
 			$this->restore_glossary($session_id);
-			$this->restore_learnpaths($session_id);
+			$this->restore_learnpaths($session_id, $respect_base_content);
 			$this->restore_links($session_id);
 			$this->restore_course_descriptions($session_id);
 			$this->restore_wiki($session_id);
@@ -338,7 +339,7 @@ class CourseRestorer
 										$course_info = api_get_course_info($destination_course_code);
 										$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
 
-										copy_folder_course_session($basedir_dest_path, $base_path_document,$session_id,$course_info, $document);
+										copy_folder_course_session($basedir_dest_path, $base_path_document, $session_id, $course_info, $document);
 
 										copy($course_path.$document->path, $dest_document_path);                                        
                                         
@@ -898,7 +899,7 @@ class CourseRestorer
 	/**
 	 * Restore Quiz
 	 */
-	function restore_quizzes($session_id = 0) {
+	function restore_quizzes($session_id = 0, $respect_base_content = false) {
 		if ($this->course->has_resources(RESOURCE_QUIZ)) {
 			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST, $this->course->destination_db);
 			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION, $this->course->destination_db);
@@ -907,21 +908,27 @@ class CourseRestorer
 			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
 				$doc = '';
 				if (strlen($quiz->media) > 0) {
-					if ($this->course->resources[RESOURCE_DOCUMENT][$quiz->media]->is_restored())
-					{
+					if ($this->course->resources[RESOURCE_DOCUMENT][$quiz->media]->is_restored()) {
 						$sql = "SELECT path FROM ".$table_doc." WHERE id = ".$resources[RESOURCE_DOCUMENT][$quiz->media]->destination_id;
 						$doc = Database::query($sql);
 						$doc = Database::fetch_object($doc);
 						$doc = str_replace('/audio/', '', $doc->path);
 					}
 				}
-				if ($id != -1) {
-
-					$condition_session = "";
-    				if (!empty($session_id)) {
-    					$session_id = intval($session_id);
-    					$condition_session = " , session_id = '$session_id' ";
-    				}
+				if ($id != -1) {				   
+                    if ($respect_base_content) {
+                        $my_session_id = $quiz->session_id; 
+                        if (!empty($quiz->session_id)) {
+                            $my_session_id = $session_id;
+                        }
+                        $condition_session = " , session_id = '$my_session_id' ";
+                    } else {
+    					$condition_session = "";
+        				if (!empty($session_id)) {
+        					$session_id = intval($session_id);
+        					$condition_session = " , session_id = '$session_id' ";
+    				    }
+                    }
 
 					// check resources inside html from fckeditor tool and copy correct urls into recipient course
 					$quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($quiz->description, $this->course->code, $this->course->destination_path);
@@ -935,8 +942,8 @@ class CourseRestorer
 						"', active = '".$quiz->active.
 						"', sound = '".Database::escape_string($doc).
 						"', max_attempt = ".(int)$quiz->attempts.
-						", results_disabled = ".(int)$quiz->results_disabled.
-						", access_condition = '".$quiz->access_condition.
+						",  results_disabled = ".(int)$quiz->results_disabled.
+						",  access_condition = '".$quiz->access_condition.
 						"', start_time = '".$quiz->start_time.
 						"', end_time = '".$quiz->end_time.
 						"', feedback_type = ".(int)$quiz->feedback_type.
@@ -1260,25 +1267,32 @@ class CourseRestorer
 	/**
 	 * Restore learnpaths
 	 */
-	function restore_learnpaths($session_id = 0)
+	function restore_learnpaths($session_id = 0, $respect_base_content = false)
 	{
 		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
-			$table_main 	= Database::get_course_table(TABLE_LP_MAIN, $this->course->destination_db);
-			$table_item 	= Database::get_course_table(TABLE_LP_ITEM, $this->course->destination_db);
-			$table_tool 	= Database::get_course_table(TABLE_TOOL_LIST, $this->course->destination_db);
+			$table_main 	= Database::get_course_table(TABLE_LP_MAIN,  $this->course->destination_db);
+			$table_item 	= Database::get_course_table(TABLE_LP_ITEM,  $this->course->destination_db);
+			$table_tool 	= Database::get_course_table(TABLE_TOOL_LIST,$this->course->destination_db);
 
 			$resources = $this->course->resources;
 
-
 			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
 			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
 
 			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
 
-				$condition_session = "";
-				if (!empty($session_id)) {
-					$session_id = intval($session_id);
-					$condition_session = " , session_id = '$session_id' ";
+				$condition_session = "";				  
+				if (!empty($session_id)) {			    
+                    if ($respect_base_content) {
+                        $my_session_id = $lp->session_id; 
+                        if (!empty($lp->session_id)) {
+                            $my_session_id = $session_id;
+                        }
+                        $condition_session = " , session_id = '$my_session_id' ";                        
+                    } else {
+                        $session_id = intval($session_id);
+                        $condition_session = " , session_id = '$session_id' ";  
+                    }					
 				}
 
 				//Adding the author's image
@@ -1296,23 +1310,29 @@ class CourseRestorer
 				}
 
 				$sql = "INSERT INTO ".$table_main." SET " .
-						"lp_type = '".$lp->lp_type."', " .
-						"name = '".Database::escape_string($lp->name)."', " .
-						"path = '".Database::escape_string($lp->path)."', " .
-						"ref = '".$lp->ref."', " .
-						"description = '".Database::escape_string($lp->description)."', " .
-						"content_local = '".Database::escape_string($lp->content_local)."', " .
-						"default_encoding = '".Database::escape_string($lp->default_encoding)."', " .
-						"default_view_mod = '".Database::escape_string($lp->default_view_mod)."', " .
-						"prevent_reinit = '".Database::escape_string($lp->prevent_reinit)."', " .
-						"force_commit = '".Database::escape_string($lp->force_commit)."', " .
-						"content_maker = '".Database::escape_string($lp->content_maker)."', " .
-						"display_order = '".Database::escape_string($lp->display_order)."', " .
-						"js_lib= '".Database::escape_string($lp->js_lib)."', " .
-						"content_license= '".Database::escape_string($lp->content_license)."', " .
-						"author= '".Database::escape_string($lp->author)."', " .
-						"preview_image= '".Database::escape_string($lp->preview_image)."', " .
-						"debug= '".Database::escape_string($lp->debug)."' $condition_session ";
+						"lp_type            = '".$lp->lp_type."', " .
+						"name               = '".Database::escape_string($lp->name)."', " .
+						"path               = '".Database::escape_string($lp->path)."', " .
+						"ref                = '".$lp->ref."', " .
+						"description        = '".Database::escape_string($lp->description)."', " .
+						"content_local      = '".Database::escape_string($lp->content_local)."', " .
+						"default_encoding   = '".Database::escape_string($lp->default_encoding)."', " .
+						"default_view_mod   = '".Database::escape_string($lp->default_view_mod)."', " .
+						"prevent_reinit     = '".Database::escape_string($lp->prevent_reinit)."', " .
+						"force_commit       = '".Database::escape_string($lp->force_commit)."', " .
+						"content_maker      = '".Database::escape_string($lp->content_maker)."', " .
+						"display_order      = '".Database::escape_string($lp->display_order)."', " .
+						"js_lib             = '".Database::escape_string($lp->js_lib)."', " .
+						"content_license    = '".Database::escape_string($lp->content_license)."', " .
+						"author             = '".Database::escape_string($lp->author)."', " .
+						"preview_image      = '".Database::escape_string($lp->preview_image)."', " .
+        				"use_max_score      = '".Database::escape_string($lp->use_max_score)."', " .
+        				"autolunch          = '".Database::escape_string($lp->autolunch)."', " .
+        				"created_on         = '".Database::escape_string($lp->created_on)."', " .
+        				"modified_on        = '".Database::escape_string($lp->modified_on)."', " .
+        				"publicated_on      = '".Database::escape_string($lp->publicated_on)."', " .
+				        "expired_on         = '".Database::escape_string($lp->expired_on)."', " .
+						"debug              = '".Database::escape_string($lp->debug)."' $condition_session ";
 
 				Database::query($sql);
 

+ 3 - 1
main/coursecopy/classes/Quiz.class.php

@@ -85,7 +85,8 @@ class Quiz extends Resource
 	 * @param int $type
 	 * @param int $active
 	 */
-	function Quiz($id, $title, $description, $random, $type, $active, $media, $attempts = 0, $results_disabled = 0, $access_condition = null, $start_time = '0000-00-00 00:00:00', $end_time = '0000-00-00 00:00:00', $feedback_type = 0, $random_answers = 0, $expired_time = 0)
+	function Quiz($id, $title, $description, $random, $type, $active, $media, $attempts = 0, $results_disabled = 0, $access_condition = null, 
+	             $start_time = '0000-00-00 00:00:00', $end_time = '0000-00-00 00:00:00', $feedback_type = 0, $random_answers = 0, $expired_time = 0, $session_id = 0)
 	{
 		parent::Resource($id, RESOURCE_QUIZ);
 		$this->title = $title;
@@ -104,6 +105,7 @@ class Quiz extends Resource
 		$this->feedback_type = $feedback_type;
 		$this->random_answers = $random_answers; 
 		$this->expired_time = $expired_time;
+		$this->session_id = $session_id;
 	}
 	/**
 	 * Add a question to this Quiz

+ 0 - 1
main/create_course/add_course.php

@@ -43,7 +43,6 @@ if ($course_validation_feature) {
     require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
 }
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
     $("#title").focus();

+ 18 - 45
main/css/chamilo/default.css

@@ -1348,65 +1348,38 @@ a.personal_agenda:hover, a.personal_agenda:hover {
 /*****************************************************
  *  DISPLAY MESSAGES	                             *
  *****************************************************/
-/* normal and erro message-box */
-.normal-message {
-    position: relative;
-    margin-top: 10px;
-    margin-bottom: 10px;
-    min-height: 30px;
-    border-width: 1px;
-    border-style: solid;
-    -moz-border-radius: 10px;    
-    padding: 6px;
-    color: #00407F;
-	background-color: #EAF8FE;
+.normal-message {    
+    color: #00407F;	
     border: 1px solid #CDE6F5;	
     background: url("images/background_message.png") repeat-x scroll 0 0 #EAF8FE;
 }
-.warning-message {
-    position: relative;
-    margin-top: 10px;
-    margin-bottom: 10px;
-    border-width: 1px;
-    border-style: solid;
-    -moz-border-radius: 10px;
-    padding: 6px;
+.warning-message {    
     border: 1px solid #FFB30F;
     color: #000;    
-    min-height: 30px;
 	background: url("images/background_message.png") repeat-x scroll 0 0 #FFEFA7;
 }
-.confirmation-message {    
-    border-color:#1F8323;
-    -moz-border-radius: 10px;
+.confirmation-message {
+	border: 1px solid #1F8323;
     color:#1F8323;
-    position: relative;
-    margin-top: 10px;
-    margin-bottom: 10px;
-    border-width: 1px;
-    border-style: solid;
-    padding:6px;
-    min-height: 30px;
 	background: url("images/background_message.png") repeat-x scroll 0 0 #CAF0C7;
 }
-.error-message {
-    position: relative;
-    margin-top: 10px;
-    margin-bottom: 10px;
-    border-width: 1px;
-    border-style: solid;
-    -moz-border-radius: 10px;
-    padding: 6px;
+.error-message {        
     border: 1px solid #FF0000;
-    color: #440000;    
-    min-height: 30px;
+    color: #440000;
 	background: url("images/background_message.png") repeat-x scroll 0 0 #FFD1D1;
 }
-.confirmation-message .bottom-link, .error-message .bottom-link, .normal-message .bottom-link, .warning-message .bottom-link {
-    position: absolute;
-    bottom: 0.2em;
-    right: 0.5em;
+.confirmation-message, .error-message, .normal-message, .warning-message {
+	min-height: 30px;
+	position: relative;
+    margin-top: 10px;
+    margin-bottom: 10px;	
+    -moz-border-radius: 10px;
+    border-radius: 10px;    
+	border-width: 1px;
+    border-style: solid;
+	padding:6px;	
 }
+
 /* New training */
 .bottom-link {
     border: 2px outset;

+ 1 - 3
main/document/create_document.php

@@ -17,10 +17,8 @@ require_once '../inc/global.inc.php';
 $_SESSION['whereami'] = 'document/create';
 $this_section = SECTION_COURSES;
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
-function InnerDialogLoaded()
-{
+function InnerDialogLoaded() {
 	/*
 	var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
 	return B.ClickFrame();

+ 0 - 1
main/document/showinframes.php

@@ -142,7 +142,6 @@ if (api_get_setting('show_glossary_in_documents') == 'ismanual') {
                                 //   });';
 }
 
-$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"></script>';
 $htmlHeadXtra[] = '<script type="text/javascript">
 <!--
     var jQueryFrameReadyConfigPath = \''.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js\';

+ 2 - 3
main/dropbox/dropbox_functions.inc.php

@@ -11,13 +11,12 @@
 
 $this_section = SECTION_COURSES;
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
-$("#category_title").focus();
+    $("#category_title").focus();
 }
 $(document).ready(function () {
-  setFocus();
+    setFocus();
 });
 </script>';
 

+ 72 - 23
main/exercice/exercice.php

@@ -722,9 +722,9 @@ if ($show == 'test') {
             $i=1;
             echo '<table class="data_table">';
             if ($is_allowedToEdit) {
-                $headers = array(get_lang('ExerciseName'),get_lang('QuantityQuestions'), get_lang('Actions'));
+                $headers = array(get_lang('ExerciseName'), get_lang('QuantityQuestions'), get_lang('Actions'));
             } else {
-            	$headers = array(get_lang('ExerciseName'), get_lang('Attempts'), get_lang('Status'), get_lang('Actions'));
+            	$headers = array(get_lang('ExerciseName'), get_lang('Status'), get_lang('Results'));
             }
             $header_list = '';
             foreach($headers as $header) {
@@ -743,18 +743,40 @@ if ($show == 'test') {
                 $session_img = api_get_session_image($row['session_id'], $_user['status']);
                 
                 $time_limits = false;                            
-                if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
+                if ($row['start_time'] != '0000-00-00 00:00:00' || $row['end_time'] != '0000-00-00 00:00:00') {
                     $time_limits = true;    
                 }                        
                 if ($time_limits) {
                     // check if start time
-                    $start_time = api_strtotime($row['start_time'],'UTC');
-                    $end_time   = api_strtotime($row['end_time'],'UTC');                                      
-                    $now        = time();
-                    $is_actived_time = false;                    
-                    if ($now > $start_time && $end_time > $now ) {
-                        $is_actived_time = true;
+                    $start_time = false;
+                    if ($row['start_time'] != '0000-00-00 00:00:00') {
+                        $start_time = api_strtotime($row['start_time'],'UTC');
                     }
+                    $end_time = false;
+                    if ($row['end_time'] != '0000-00-00 00:00:00') {
+                        $end_time   = api_strtotime($row['end_time'],'UTC');  
+                    }                                    
+                    $now        = time();
+                    $is_actived_time = false;
+                    
+                    //If both "clocks" are enable
+                    if ($start_time && $end_time) {                  
+                        if ($now > $start_time && $end_time > $now ) {
+                            $is_actived_time = true;
+                        }
+                    } else {
+                        //we check the start and end
+                        if ($start_time) {
+                            if ($now > $start_time) {
+                               $is_actived_time = true;
+                            }
+                        }
+                        if ($end_time) {
+                            if ($end_time > $now ) {
+                               $is_actived_time = true;
+                            }
+                        }
+                    }                    
                 }                
                       
                 // Teacher only
@@ -828,10 +850,12 @@ if ($show == 'test') {
                     //$attempts = get_count_exam_results($row['id']).' '.get_lang('Attempts');
                     
                     //$item .=  Display::tag('td',$attempts);
-                    $item .=  Display::tag('td',$number_of_questions);           
+                    $item .=  Display::tag('td', $number_of_questions);
+                        
                 } else {
                      
-                    // Student only
+                    // --- Student only
+                    
                     
                     $row['title'] = text_filter($row['title']);                 
     
@@ -881,16 +905,34 @@ if ($show == 'test') {
                                     $attempt_text =  get_lang('LatestAttempt') . ' : ';                                
                                     $attempt_text .= show_score($row_track['exe_result'], $row_track['exe_weighting']);
                                 } else {
-                                    //$attempt_text =  get_lang('NotAttempted');
-                                    $attempt_text =  sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
+                                    if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
+                                        $attempt_text =  sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
+                                    } else {
+                                        if ($row['start_time'] != '0000-00-00 00:00:00') { 
+                                            $attempt_text = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($row['start_time']));
+                                        }
+                                        if ($row['end_time'] != '0000-00-00 00:00:00') {
+                                            $attempt_text = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($row['end_time']));     
+                                        } 
+                                    }
                                 }                           
                             } else {
                                 $attempt_text =  get_lang('CantShowResults');
                             }
                         } else {
-                            //Examn not ready
-                            //$attempt_text = get_lang('ExamNotAvailableAtThisTime');
-                            $attempt_text =  sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
+                            //Quiz not ready
+                            if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
+                                $attempt_text =  sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
+                            } else {
+                                //$attempt_text = get_lang('ExamNotAvailableAtThisTime');                                
+                                if ($row['start_time'] != '0000-00-00 00:00:00') { 
+                                    $attempt_text = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($row['start_time']));
+                                }
+                                if ($row['end_time'] != '0000-00-00 00:00:00') {
+                                    $attempt_text = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($row['end_time']));     
+                                } 
+                                
+                            }
                         }
                     } else {
                         //Normal behaviour
@@ -908,18 +950,25 @@ if ($show == 'test') {
                         }
                     }
                     
-                    //User Attempts    
+                    //User Attempts
+                    /*    
                     if (empty($row['max_attempt'])) {
-                        $item .=  Display::tag('td',$num);     
+                        //$item .=  Display::tag('td',$num);     
                     } else {
                         if (empty($num)) {
-                        	$num = 0;
+                        	$num = '';
                         }
-                        $item .=  Display::tag('td',$num.' / '.$row['max_attempt']);                        
+                        //$item .=  Display::tag('td',$num.' / '.$row['max_attempt']);                        
+                    }*/
+                    
+                    if (empty($num)) {
+                            $num = '';
                     }
-                    $item .=  Display::tag('td', $attempt_text);                    
+                        
+                    $item .=  Display::tag('td', $attempt_text);
+                                     
                     //See results
-                    $actions ='<a href="exercice.php?' . api_get_cidreq() . '&show=result&exerciseId='.$row['id'].'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>';
+                    $actions =' '.$num.' <a href="exercice.php?' . api_get_cidreq() . '&show=result&exerciseId='.$row['id'].'">   '.Display::return_icon('show_test_results.gif', get_lang('Results')).' </a>';
                 }                
                 $class = 'row_even';
                 if ($count % 2) {
@@ -999,7 +1048,7 @@ if ($show == 'test') {
                             $nbrActiveTests = $nbrActiveTests +1;
                             $item .= Display::tag('td', '<a href="showinframes.php?'.api_get_cidreq().'&file='.$path.'&cid='.api_get_course_id().'&uid='.api_get_user_id().'"'.(!$active?'class="invisible"':'').'">'.$title.'</a>');
                             $item .= Display::tag('td', '');                            
-                            $item .= Display::tag('td', '');
+                            //$item .= Display::tag('td', '');
                             $actions ='<a href="exercice.php?' . api_get_cidreq() . '&show=result&path='.$path.'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>';
                             $item .= Display::tag('td', $actions);                            
                             echo Display::tag('tr',$item, array('class'=>$class));

+ 10 - 3
main/exercice/exercice_submit.php

@@ -39,7 +39,6 @@ if($debug) { error_log('Entered exercise_submit.php: '.print_r($_POST,1)); }
 // Notice for unauthorized people.
 api_protect_course_script(true);
 $is_allowedToEdit = api_is_allowed_to_edit(null,true);
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 
 if (api_get_setting('show_glossary_in_extra_tools') == 'true') {
     $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/glossary.js" type="text/javascript" language="javascript"></script>'; //Glossary
@@ -513,9 +512,17 @@ if ($limit_time_exists) {
     $exercise_end_time 		= api_strtotime($objExercise->end_time,'UTC');
     $time_now 				= time();
     
-    $permission_to_start = (($time_now - $exercise_start_time) > 0) ? true : false;            
+    if ($objExercise->start_time != '0000-00-00 00:00:00') {
+        $permission_to_start = (($time_now - $exercise_start_time) > 0) ? true : false;
+    } else {
+        $permission_to_start = true;
+    }         
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-        $exercise_timeover = (($time_now - $exercise_end_time) > 0) ? true : false;        
+        if ($objExercise->end_time != '0000-00-00 00:00:00') {
+            $exercise_timeover = (($time_now - $exercise_end_time) > 0) ? true : false;
+        } else {
+            $exercise_timeover = false;
+        }        
     }
     
     if (!$permission_to_start || $exercise_timeover) {

+ 138 - 128
main/exercice/exercise.class.php

@@ -548,7 +548,8 @@ class Exercise {
 						random_answers='".Database::escape_string($random_answers)."',
 						active='".Database::escape_string($active)."',
 						feedback_type='".Database::escape_string($feedbacktype)."',
-						start_time='$start_time',end_time='$end_time',
+						start_time    = '$start_time',
+						end_time      = '$end_time',
 						max_attempt='".Database::escape_string($attempts)."',
             			expired_time='".Database::escape_string($expired_time)."',
             			propagate_neg='".Database::escape_string($propagate_neg)."',
@@ -562,7 +563,7 @@ class Exercise {
 			api_item_property_update($_course, TOOL_QUIZ, $id,'QuizUpdated',api_get_user_id());
 
             if (api_get_setting('search_enabled')=='true') {
-                $this -> search_engine_edit();
+                $this->search_engine_edit();
             }
 
 		} else {// creates a new exercise
@@ -599,7 +600,7 @@ class Exercise {
 
         	api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizAdded',api_get_user_id());
 			if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {			    
-                $this -> search_engine_save();
+                $this->search_engine_save();
 			}
 		}
 
@@ -827,7 +828,7 @@ class Exercise {
 		api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizDeleted',api_get_user_id());
 
 		if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) {
-			$this -> search_engine_delete();
+			$this->search_engine_delete();
 		}
 	}
 
@@ -848,10 +849,10 @@ class Exercise {
 		}
 		$form->addElement('header', '', $form_title);
 		// title
-		$form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles" id="exercise_title"');
+		$form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles" id="exercise_title"');
 		//$form->applyFilter('exerciseTitle','html_filter');
 
-		$form -> addElement('html','<div class="row">
+		$form->addElement('html','<div class="row">
 		<div class="label"></div>
 		<div class="formw" style="height:50px">
 			<a href="javascript://" onclick=" return show_media()"> <span id="media_icon"> <img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang('ExerciseDescription').'</span></a>
@@ -863,12 +864,12 @@ class Exercise {
 			$editor_config = array_merge($editor_config, $type);
 		}
 
-		$form -> addElement ('html','<div class="HideFCKEditor" id="HiddenFCKexerciseDescription" >');
-		$form -> add_html_editor('exerciseDescription', get_lang('langExerciseDescription'), false, false, $editor_config);
-		$form -> addElement ('html','</div>');
+		$form->addElement ('html','<div class="HideFCKEditor" id="HiddenFCKexerciseDescription" >');
+		$form->add_html_editor('exerciseDescription', get_lang('langExerciseDescription'), false, false, $editor_config);
+		$form->addElement ('html','</div>');
 
 
-		$form -> addElement('html','<div class="row">
+		$form->addElement('html','<div class="row">
 			<div class="label">&nbsp;</div>
 			<div class="formw">
 				<a href="javascript://" onclick=" return advanced_parameters()"><span id="img_plus_and_minus"><div style="vertical-align:top;" ><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'</div></span></a>
@@ -876,7 +877,7 @@ class Exercise {
 			</div>');
 
 		// Random questions
-		$form -> addElement('html','<div id="options" style="display:none">');
+		$form->addElement('html','<div id="options" style="display:none">');
 
 		if($type=='full') {
 	
@@ -896,13 +897,13 @@ class Exercise {
                 $radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2'));
                 $form->addGroup($radios_feedback, null, get_lang('FeedbackType'));
             
-			    //$form -> addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
+			    //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
 				// test type
 				$radios = array();
 				$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('QuestionsPerPageOne'),'2',array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
 				$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('QuestionsPerPageAll'),'1',array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
 				
-				$form -> addGroup($radios, null, get_lang('QuestionsPerPage'));
+				$form->addGroup($radios, null, get_lang('QuestionsPerPage'));
 			} else {
 				// if is Directfeedback but has not questions we can allow to modify the question type
 				if ($this->selectNbrQuestions() == 0) {
@@ -917,16 +918,16 @@ class Exercise {
                     $form->addGroup($radios_feedback, null, get_lang('FeedbackType'));
                     
 				    
-					//$form -> addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
+					//$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
 					// test type
 					$radios = array();
 					$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SimpleExercise'),'1');
 					$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
-					$form -> addGroup($radios, null, get_lang('ExerciseType'));
+					$form->addGroup($radios, null, get_lang('ExerciseType'));
 				} else {
 					//we force the options to the DirectFeedback exercisetype
-					$form -> addElement('hidden', 'exerciseFeedbackType',EXERCISE_FEEDBACK_TYPE_DIRECT);
-					$form -> addElement('hidden', 'exerciseType',ONE_PER_PAGE);
+					$form->addElement('hidden', 'exerciseFeedbackType',EXERCISE_FEEDBACK_TYPE_DIRECT);
+					$form->addElement('hidden', 'exerciseType',ONE_PER_PAGE);
 				}
 			}
 
@@ -934,7 +935,7 @@ class Exercise {
 			$radios_results_disabled[] = FormValidator :: createElement ('radio', 'results_disabled', null, get_lang('Yes'), '0', array('id'=>'result_disabled_0'));
 			$radios_results_disabled[] = FormValidator :: createElement ('radio', 'results_disabled', null, get_lang('No'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
 			$radios_results_disabled[] = FormValidator :: createElement ('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
-			$form -> addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'));
+			$form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'));
 
 			$random = array();
 			$option=array();
@@ -945,38 +946,44 @@ class Exercise {
 			$random[] = FormValidator :: createElement ('select', 'randomQuestions',null,$option);
 			$random[] = FormValidator :: createElement ('static', 'help','help','<span style="font-style: italic;">'.get_lang('RandomQuestionsHelp').'</span>');
 			//$random[] = FormValidator :: createElement ('text', 'randomQuestions', null,null,'0');
-			$form -> addGroup($random,null,get_lang('RandomQuestions'),'<br />');
+			$form->addGroup($random,null,get_lang('RandomQuestions'),'<br />');
 
 			//random answers
 			$radios_random_answers = array();
 			$radios_random_answers[] = FormValidator :: createElement ('radio', 'randomAnswers', null, get_lang('Yes'),'1');
 			$radios_random_answers[] = FormValidator :: createElement ('radio', 'randomAnswers', null, get_lang('No'),'0');
-			$form -> addGroup($radios_random_answers, null, get_lang('RandomAnswers'));
+			$form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'));
 
 			//Attempts
 			$attempt_option=range(0,10);
 			$attempt_option[0]=get_lang('Infinite');
 
-			$form -> addElement('select', 'exerciseAttempts',get_lang('ExerciseAttempts'),$attempt_option);
-
-			$form -> addElement('checkbox', 'enabletimelimit',get_lang('EnableTimeLimits'),null,'onclick = "  return timelimit() "');
-		  	$var= Exercise::selectTimeLimit();
+			$form->addElement('select', 'exerciseAttempts',get_lang('ExerciseAttempts'),$attempt_option);
 
-			if(($this -> start_time!='0000-00-00 00:00:00')||($this -> end_time!='0000-00-00 00:00:00'))
-				$form -> addElement('html','<div id="options2" style="display:block;">');
+			$form->addElement('checkbox', 'activate_start_date_check',get_lang('EnableStartTime'),null, array('onclick' => 'activate_start_date()'));			
+			
+		  	$var = Exercise::selectTimeLimit();
+			if (($this->start_time!='0000-00-00 00:00:00'))
+				$form->addElement('html','<div id="start_date_div" style="display:block;">');
 			else
-				$form -> addElement('html','<div id="options2" style="display:none;">');
-
-	    	//$form -> addElement('date', 'start_time', get_lang('ExeStartTime'), array('language'=>'es','format' => 'dMYHi'));
-	    	//$form -> addElement('date', 'end_time', get_lang('ExeEndTime'), array('language'=>'es','format' => 'dMYHi'));
-	   		$form->addElement('datepicker', 'start_time', get_lang('ExeStartTime'), array('form_name'=>'exercise_admin'), 5);
-			$form->addElement('datepicker', 'end_time', get_lang('ExeEndTime'), array('form_name'=>'exercise_admin'), 5);
-
-     		//$form -> addElement('select', 'enabletimercontroltotalminutes',get_lang('ExerciseTimerControlMinutes'),$time_minutes_option);
-      		$form -> addElement('html','</div>');
+				$form->addElement('html','<div id="start_date_div" style="display:none;">');
+
+	   		$form->addElement('datepicker', 'start_time', '', array('form_name'=>'exercise_admin'), 5);
+	   		
+            $form->addElement('html','</div>');
+	   		              
+	   		$form->addElement('checkbox', 'activate_end_date_check',  get_lang('EnableEndTime'),  null,array('onclick' => 'activate_end_date()'));
+	   		if (($this->end_time!='0000-00-00 00:00:00'))
+                $form->addElement('html','<div id="end_date_div" style="display:block;">');
+            else
+                $form->addElement('html','<div id="end_date_div" style="display:none;">');
+                
+			$form->addElement('datepicker', 'end_time', '', array('form_name'=>'exercise_admin'), 5);
 
+     		//$form->addElement('select', 'enabletimercontroltotalminutes',get_lang('ExerciseTimerControlMinutes'),$time_minutes_option);
+      		$form->addElement('html','</div>');
 
-      		$check_option=$this -> selectType();
+      		$check_option=$this->selectType();
 
 			if ($check_option==1 && isset($_GET['exerciseId'])) {
 				$diplay = 'none';
@@ -984,101 +991,103 @@ class Exercise {
 				$diplay = 'block';
 			}
 			
-			$form -> addElement('checkbox', 'propagate_neg',get_lang('PropagateNegativeResults'),null);
+			$form->addElement('checkbox', 'propagate_neg',get_lang('PropagateNegativeResults'),null);
 			
-
-    		$form -> addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
+    		$form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
 
 			//Timer control
 			$time_hours_option = range(0,12);
 			$time_minutes_option = range(0,59);
-			$form -> addElement('checkbox', 'enabletimercontrol',get_lang('EnableTimerControl'),null,array('onclick' =>'option_time_expired()','id'=>'enabletimercontrol','onload'=>'check_load_time()'));
+			$form->addElement('checkbox', 'enabletimercontrol',get_lang('EnableTimerControl'),null,array('onclick' =>'option_time_expired()','id'=>'enabletimercontrol','onload'=>'check_load_time()'));
 			$expired_date = (int)$this->selectExpiredTime();
 
 			if(($expired_date!='0')) {
-			    $form -> addElement('html','<div id="timercontrol" style="display:block;">');
+			    $form->addElement('html','<div id="timercontrol" style="display:block;">');
 			} else {
-			    $form -> addElement('html','<div id="timercontrol" style="display:none;">');
+			    $form->addElement('html','<div id="timercontrol" style="display:none;">');
 			}
 
-			$form -> addElement('text', 'enabletimercontroltotalminutes',get_lang('ExerciseTotalDurationInMinutes'),array('style' => 'width : 35px','id' => 'enabletimercontroltotalminutes'));
-			$form -> addElement('html','</div>');
-			//$form -> addElement('text', 'exerciseAttempts', get_lang('ExerciseAttempts').' : ',array('size'=>'2'));			
-
-			$form -> addElement('html','</div>');  //End advanced setting
-			$form -> addElement('html','</div>');
-
-	        $defaults = array();
-
-	        if (api_get_setting('search_enabled') === 'true') {
-	            require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
-
-	            $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
-	            $form -> addElement ('html','<br /><div class="row">');
-	            $form -> addElement ('html', '<div class="label">'. get_lang('SearchFeatureDocumentLanguage') .'</div>');
-	            $form -> addElement ('html', '<div class="formw">'. api_get_languages_combo() .'</div>');
-	            $form -> addElement ('html','</div><div class="sub-form">');
-
-	            $specific_fields = get_specific_field_list();
-	            foreach ($specific_fields as $specific_field) {
-	                $form -> addElement ('text', $specific_field['code'], $specific_field['name']);
-	                $filter = array('course_code'=> "'". api_get_course_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''. TOOL_QUIZ .'\'');
-	                $values = get_specific_field_values_list($filter, array('value'));
-	                if ( !empty($values) ) {
-	                    $arr_str_values = array();
-	                    foreach ($values as $value) {
-	                        $arr_str_values[] = $value['value'];
-	                    }
-	                    $defaults[$specific_field['code']] = implode(', ', $arr_str_values);
-	                }
-	            }
-	            $form -> addElement ('html','</div>');
-	        }
+			$form->addElement('text', 'enabletimercontroltotalminutes',get_lang('ExerciseTotalDurationInMinutes'),array('style' => 'width : 35px','id' => 'enabletimercontroltotalminutes'));
+			$form->addElement('html','</div>');
+			//$form->addElement('text', 'exerciseAttempts', get_lang('ExerciseAttempts').' : ',array('size'=>'2'));			
+			
+			
+		    $defaults = array();
+
+            if (api_get_setting('search_enabled') === 'true') {
+                require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
+
+                $form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
+                $form->addElement ('html','<br /><div class="row">');
+                $form->addElement ('html', '<div class="label">'. get_lang('SearchFeatureDocumentLanguage') .'</div>');
+                $form->addElement ('html', '<div class="formw">'. api_get_languages_combo() .'</div>');
+                $form->addElement ('html','</div><div class="sub-form">');
+
+                $specific_fields = get_specific_field_list();
+                foreach ($specific_fields as $specific_field) {
+                    $form->addElement ('text', $specific_field['code'], $specific_field['name']);
+                    $filter = array('course_code'=> "'". api_get_course_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''. TOOL_QUIZ .'\'');
+                    $values = get_specific_field_values_list($filter, array('value'));
+                    if ( !empty($values) ) {
+                        $arr_str_values = array();
+                        foreach ($values as $value) {
+                            $arr_str_values[] = $value['value'];
+                        }
+                        $defaults[$specific_field['code']] = implode(', ', $arr_str_values);
+                    }
+                }
+                $form->addElement ('html','</div>');
+            }
+
+			$form->addElement('html','</div>');  //End advanced setting
+			$form->addElement('html','</div>');
 		}
 
 		// submit
 		isset($_GET['exerciseId'])?$text=get_lang('ModifyExercise'):$text=get_lang('ProcedToQuestions');
-		$form -> addElement('html', '<br /><br />');
-		$form -> addElement('style_submit_button', 'submitExercise', $text, 'class="save"');
+		$form->addElement('html', '<br /><br />');
+		$form->addElement('style_submit_button', 'submitExercise', $text, 'class="save"');
 
-		$form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required');
+		$form->addRule('exerciseTitle', get_lang('GiveExerciseName'), 'required');
 		if($type=='full') {
 			// rules
-			$form -> addRule ('exerciseAttempts', get_lang('Numeric'), 'numeric');
-			$form -> addRule ('start_time', get_lang('InvalidDate'), 'date');
-	        $form -> addRule ('end_time', get_lang('InvalidDate'), 'date');
-	        $form -> addRule(array ('start_time', 'end_time'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
+			$form->addRule('exerciseAttempts', get_lang('Numeric'), 'numeric');
+			$form->addRule('start_time', get_lang('InvalidDate'), 'date');
+	        $form->addRule('end_time', get_lang('InvalidDate'), 'date');
+	        //$form->addRule(array ('start_time', 'end_time'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
 		}
 
 		// defaults
-		if($type=='full') {
-			if($this -> id > 0) {
-				if ($this -> random > $this->selectNbrQuestions()) {
+		if ($type=='full') {
+			if($this->id > 0) {
+				if ($this->random > $this->selectNbrQuestions()) {
 					$defaults['randomQuestions'] =  $this->selectNbrQuestions();
 				} else {
-					$defaults['randomQuestions'] = $this -> random;
+					$defaults['randomQuestions'] = $this->random;
 				}
 				$defaults['randomAnswers'] = $this ->selectRandomAnswers();
-				$defaults['exerciseType'] = $this -> selectType();
-				$defaults['exerciseTitle'] = $this -> selectTitle();
-				$defaults['exerciseDescription'] = $this -> selectDescription();
+				$defaults['exerciseType'] = $this->selectType();
+				$defaults['exerciseTitle'] = $this->selectTitle();
+				$defaults['exerciseDescription'] = $this->selectDescription();
 				$defaults['exerciseAttempts'] = $this->selectAttempts();
 				$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
 				$defaults['results_disabled'] = $this->selectResultsDisabled();
 				$defaults['propagate_neg'] = $this->selectPropagateNeg();
 
-	  			if(($this -> start_time!='0000-00-00 00:00:00')||($this -> end_time!='0000-00-00 00:00:00'))
-	            	$defaults['enabletimelimit'] = 1;
+	  			if (($this->start_time!='0000-00-00 00:00:00'))
+	            	$defaults['activate_start_date_check'] = 1;
+            	if ($this->end_time!='0000-00-00 00:00:00')
+                    $defaults['activate_end_date_check'] = 1;
 
-			    $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00')? $this -> start_time : date('Y-m-d 12:00:00');
-	        	$defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00')?$this -> end_time : date('Y-m-d 12:00:00',time()+84600);
+			    $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00')? $this->start_time : date('Y-m-d 12:00:00');
+	        	$defaults['end_time']   = ($this->end_time!='0000-00-00 00:00:00')?$this->end_time : date('Y-m-d 12:00:00',time()+84600);
 
 				//Get expired time
-				if($this -> expired_time != '0') {
-				$defaults['enabletimercontrol'] = 1;
-				$defaults['enabletimercontroltotalminutes'] = $this -> expired_time;
+				if($this->expired_time != '0') {
+    				$defaults['enabletimercontrol'] = 1;
+    				$defaults['enabletimercontroltotalminutes'] = $this->expired_time;
 				} else {
-				$defaults['enabletimercontroltotalminutes'] = 0;
+				    $defaults['enabletimercontroltotalminutes'] = 0;
 				}
 
 			} else {
@@ -1091,18 +1100,18 @@ class Exercise {
 				$defaults['results_disabled'] = 0;
 
 				$defaults['start_time'] = date('Y-m-d 12:00:00');
-				$defaults['end_time'] = date('Y-m-d 12:00:00',time()+84600);
+				$defaults['end_time']   = date('Y-m-d 12:00:00',time()+84600);
 			}
 		} else {
-			$defaults['exerciseTitle'] = $this -> selectTitle();
-			$defaults['exerciseDescription'] = $this -> selectDescription();
+			$defaults['exerciseTitle'] = $this->selectTitle();
+			$defaults['exerciseDescription'] = $this->selectDescription();
 		}
 
         if (api_get_setting('search_enabled') === 'true') {
             $defaults['index_document'] = 'checked="checked"';
         }
 
-		$form -> setDefaults($defaults);
+		$form->setDefaults($defaults);
 	}
 
 	/**
@@ -1111,29 +1120,33 @@ class Exercise {
 	 */
 	function processCreation($form, $type='') {
 
-		$this -> updateTitle($form -> getSubmitValue('exerciseTitle'));
-		$this -> updateDescription($form -> getSubmitValue('exerciseDescription'));
-		$this -> updateAttempts($form -> getSubmitValue('exerciseAttempts'));
-		$this -> updateFeedbackType($form -> getSubmitValue('exerciseFeedbackType'));
-		$this -> updateType($form -> getSubmitValue('exerciseType'));
-		$this -> setRandom($form -> getSubmitValue('randomQuestions'));
-		$this -> updateRandomAnswers($form -> getSubmitValue('randomAnswers'));
-		$this -> updateResultsDisabled($form -> getSubmitValue('results_disabled'));
-    	$this -> updateExpiredTime($form -> getSubmitValue('enabletimercontroltotalminutes'));    	
-    	$this -> updatePropagateNegative($form -> getSubmitValue('propagate_neg'));
-
-		if ($form -> getSubmitValue('enabletimelimit')==1) {
-           $start_time = $form -> getSubmitValue('start_time');
-           $this->start_time = $start_time['Y'].'-'.$start_time['F'].'-'.$start_time['d'].' '.$start_time['H'].':'.$start_time['i'].':00';
-           $end_time = $form -> getSubmitValue('end_time');
-           $this->end_time = $end_time['Y'].'-'.$end_time['F'].'-'.$end_time['d'].' '.$end_time['H'].':'.$end_time['i'].':00';
+		$this->updateTitle($form->getSubmitValue('exerciseTitle'));
+		$this->updateDescription($form->getSubmitValue('exerciseDescription'));
+		$this->updateAttempts($form->getSubmitValue('exerciseAttempts'));
+		$this->updateFeedbackType($form->getSubmitValue('exerciseFeedbackType'));
+		$this->updateType($form->getSubmitValue('exerciseType'));
+		$this->setRandom($form->getSubmitValue('randomQuestions'));
+		$this->updateRandomAnswers($form->getSubmitValue('randomAnswers'));
+		$this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
+    	$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));    	
+    	$this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
+
+		if ($form->getSubmitValue('activate_start_date_check') == 1) {
+           $start_time = $form->getSubmitValue('start_time');
+           $this->start_time = $start_time['Y'].'-'.$start_time['F'].'-'.$start_time['d'].' '.$start_time['H'].':'.$start_time['i'].':00';           
     	} else {
-           $this->start_time = '0000-00-00 00:00:00';
-           $this->end_time = '0000-00-00 00:00:00';
+           $this->start_time = '0000-00-00 00:00:00';           
         }
+        
+	    if ($form->getSubmitValue('activate_end_date_check') == 1) {
+           $end_time = $form->getSubmitValue('end_time');
+           $this->end_time = $end_time['Y'].'-'.$end_time['F'].'-'.$end_time['d'].' '.$end_time['H'].':'.$end_time['i'].':00';
+        } else {           
+           $this->end_time   = '0000-00-00 00:00:00';
+        }        
 
-		if ($form -> getSubmitValue('enabletimercontrol') == 1) {
-		   $expired_total_time = $form -> getSubmitValue('enabletimercontroltotalminutes');
+		if ($form->getSubmitValue('enabletimercontrol') == 1) {
+		   $expired_total_time = $form->getSubmitValue('enabletimercontroltotalminutes');
 		   if ($this->expired_time == 0) {
 			   $this->expired_time = $expired_total_time;
 		   }
@@ -1141,23 +1154,20 @@ class Exercise {
 			$this->expired_time = 0;
 		}
 
-		if ($form -> getSubmitValue('randomAnswers') == 1) {
+		if ($form->getSubmitValue('randomAnswers') == 1) {
            $this->random_answers=1;
     	} else {
            $this->random_answers=0;
         }
-
-		$this -> save($type);
+		$this->save($type);
 	}
 
-	function search_engine_save() {
-	    
+	function search_engine_save() {	    
 		if ($_POST['index_document'] != 1) {
 			return;
 		}
-
 		$course_id = api_get_course_id();
-
+		
 		require_once api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php';
 		require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
 		require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';

+ 14 - 7
main/exercice/exercise_admin.php

@@ -59,14 +59,22 @@ $htmlHeadXtra[] = '<script type="text/javascript">
 				}
 		}
 
-		function timelimit() {
-			if(document.getElementById(\'options2\').style.display == \'none\')
-			{
-				document.getElementById(\'options2\').style.display = \'block\';
+		function activate_start_date() {
+			if(document.getElementById(\'start_date_div\').style.display == \'none\') {
+				document.getElementById(\'start_date_div\').style.display = \'block\';
 			} else {
-				document.getElementById(\'options2\').style.display = \'none\';
+				document.getElementById(\'start_date_div\').style.display = \'none\';
 			}
 		}
+		
+		function activate_end_date() {
+            if(document.getElementById(\'end_date_div\').style.display == \'none\') {
+                document.getElementById(\'end_date_div\').style.display = \'block\';
+            } else {
+                document.getElementById(\'end_date_div\').style.display = \'none\';
+            }
+        }
+        
 
 		function feedbackselection() {
 			var index = document.exercise_admin.exerciseFeedbackType.selectedIndex;
@@ -123,7 +131,6 @@ $htmlHeadXtra[] = '<script type="text/javascript">
                    
 		</script>';
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
     $("#exercise_title").focus();
@@ -203,6 +210,6 @@ if ($form->validate()) {
 			$form->freeze();
 		}	
 	}
-	$form -> display ();
+	$form->display();
 }
 Display::display_footer();

+ 1 - 2
main/exercice/question_create.php

@@ -40,8 +40,7 @@ $form->addElement('select', 'question_type', get_lang('QuestionType'), $question
 
 // the question types (jquery form element)
 $form->addElement('hidden', 'question_type_hidden', get_lang('QuestionType'), array('id'=>'question_type_hidden'));
-$form->addElement('static','','<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript"></script>
-							<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.customselect.js" type="text/javascript"></script>');
+$form->addElement('static','','<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.customselect.js" type="text/javascript"></script>');
 $form->addElement('static','select_question_type', get_lang('QuestionType'),'<div id="questiontypes"></div>');
 
 //session id

+ 0 - 1
main/forum/forumfunction.inc.php

@@ -30,7 +30,6 @@ get_notifications_of_user();
 
 /* Javascript */
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
     $("#forum_title").focus();

+ 0 - 1
main/forum/forumqualify.php

@@ -35,7 +35,6 @@ $nameTools=get_lang('ToolForum');
 
 /*     Including necessary files */
 
-$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
 $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
                                         $(document).ready(function(){ $(\'.hide-me\').slideUp() });
                                     function hidecontent(content){ $(content).slideToggle(\'normal\'); }

+ 0 - 1
main/forum/index.php

@@ -27,7 +27,6 @@ $language_file = 'forum';
 
 // Including the global initialization file.
 require_once '../inc/global.inc.php';
-$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
 $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
     $(document).ready(function(){ $(\'.hide-me\').slideUp() });
     function hidecontent(content){ $(content).slideToggle(\'normal\'); }

+ 0 - 1
main/forum/viewforumcategory.php

@@ -28,7 +28,6 @@ $language_file = 'forum';
 // Including the global initialization file.
 require '../inc/global.inc.php';
 
-$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
 $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
     $(document).ready(function(){ $(\'.hide-me\').slideUp() });
     function hidecontent(content){ $(content).slideToggle(\'normal\'); }

+ 0 - 1
main/forum/viewpost.php

@@ -26,7 +26,6 @@ $nameTools = get_lang('ToolForum');
 require 'forumconfig.inc.php';
 require_once 'forumfunction.inc.php';
 
-$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
 $htmlHeadXtra[] = '<script language="javascript">
                                         $(document).ready(function(){ $(\'.hide-me\').slideUp() });
                                     function hidecontent(content){ $(content).slideToggle(\'normal\'); }

+ 2 - 3
main/glossary/index.php

@@ -25,13 +25,12 @@ require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 
 // Additional javascripts.
 $htmlHeadXtra[] = GlossaryManager::javascript_glossary();
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
-$("#glossary_title").focus();
+    $("#glossary_title").focus();
 }
 $(document).ready(function () {
-  setFocus();
+    setFocus();
 });
 </script>';
 // setting the tool constants

+ 0 - 1
main/gradebook/gradebook.php

@@ -28,7 +28,6 @@ require_once 'lib/fe/userform.class.php';
 require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php';
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready( function() {
 	for (i=0;i<$(".actions").length;i++) {

+ 0 - 2
main/gradebook/gradebook_flatview.php

@@ -27,8 +27,6 @@ if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
 	exit;
 }
 
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
-
 $interbreadcrumb[] = array ('url' => $_SESSION['gradebook_dest'].'?selectcat=1', 'name' => get_lang('ToolGradebook'));
 
 $showeval = isset($_POST['showeval']) ? '1' : '0';

+ 0 - 1
main/gradebook/index.php

@@ -32,7 +32,6 @@ require_once api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php';
 require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready( function() {
 	for (i=0;i<$(".actions").length;i++) {

+ 0 - 1
main/group/group.php

@@ -25,7 +25,6 @@ $this_section = SECTION_COURSES;
 // Notice for unauthorized people.
 api_protect_course_script(true);
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready( function() {
 	for (i=0;i<$(".actions").length;i++) {

+ 5 - 0
main/inc/lib/career.lib.php

@@ -99,7 +99,12 @@ class Career extends Model {
     
         // Setting the rules
         $form->addRule('name', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
+               
+                                
         return $form;
+        
+
+                                
     }
     /**
      * Copies the career to a new one

+ 4 - 4
main/inc/lib/course.lib.php

@@ -3097,9 +3097,9 @@ class CourseManager {
         
         if (!empty($course_info)) {
             $cb = new CourseBuilder('', $course_info);
-		    $course = $cb->build($source_session_id,$source_session_id['code']);		    		
+		    $course = $cb->build($source_session_id, $source_course_code, true);		    		
     		$course_restorer = new CourseRestorer($course);
-    		$course_restorer->restore($destination_course_code, $destination_session_id, true);
+    		$course_restorer->restore($destination_course_code, $destination_session_id, true, true);
     		return true;		
         }
         return false;
@@ -3114,14 +3114,14 @@ class CourseManager {
      * @param 	int		source session id
      * @return 	
      */
-    function copy_course_simple($new_title, $source_course_code, $source_session_id = 0) {
+    function copy_course_simple($new_title, $source_course_code, $source_session_id = 0, $destination_session_id = 0) {
         $source_course_info = api_get_course_info($source_course_code);
         if (!empty($source_course_info)) {
             $new_course_code = self::generate_nice_next_course_code($source_course_code); 
             if ($new_course_code) {
                 $new_course_info = self::create_course($new_title, $new_course_code, false);
                 if (!empty($new_course_info['code'])) {                    
-                    $result = self::copy_course($source_course_code, $source_session_id, $new_course_info['code'], 0);
+                    $result = self::copy_course($source_course_code, $source_session_id, $new_course_info['code'], $destination_session_id);
                     if ($result) {
                         return $new_course_info;
                     }                   

+ 17 - 4
main/inc/lib/javascript/jquery-ui/default.css

@@ -8,13 +8,15 @@
 .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { 
 	border: 1px solid #d3d3d3; 
 	/* background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;*/
-	background: #EFEFEF; 
+	background: #F2F2F2; 
 	font-weight: normal; 
 	color: #555555; 
+	height:30px;
+	
 }	
 .ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; }
 .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { 
-	border: 1px solid #999999; 
+	border: 1px solid #999999;
 	/*background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x;*/
 	background: #E5EDF9; 
 	font-weight: normal; 
@@ -22,8 +24,19 @@
 }
 
 /* jqgrid: Changes the row style in a table (even, odd) */
-.ui-priority-secondary, .ui-widget-content .ui-priority-secondary,  .ui-widget-header .ui-priority-secondary { opacity: 1; font-weight: normal; background-color: #F2F2F2; }
-.ui-widget-content { background: #FFF; }
+.ui-priority-secondary, .ui-widget-content .ui-priority-secondary,  .ui-widget-header .ui-priority-secondary { 
+	opacity: 1; 
+	font-weight: normal;
+	background-color: #F9F9F9; 
+}
+.ui-widget-content { 
+	background: #fff;
+	border: 1px solid #ddd;
+}
+
+.ui-jqgrid .ui-jqgrid-htable th {
+	height:30px;
+}
 
 /* jqgrid: Changing anchors colors see main/session/ */
 

+ 3 - 3
main/inc/lib/main_api.lib.php

@@ -3148,7 +3148,7 @@ function copyr($source, $dest, $exclude = array(), $copied_files = array()) {
 }
 
 // TODO: Using DIRECTORY_SEPARATOR is not recommended, this is an obsolete approach. Documentation header to be added here.
-function copy_folder_course_session($pathname, $base_path_document,$session_id,$course_info, $document) {
+function copy_folder_course_session($pathname, $base_path_document, $session_id, $course_info, $document) {
     $table = Database :: get_course_table(TABLE_DOCUMENT, $course_info['dbName']);
     $session_id = intval($session_id);
     // Check whether directory already exists.
@@ -4811,7 +4811,7 @@ function api_get_jquery_ui_js($include_jqgrid = false) {
  */
 function api_get_jquery_libraries_js($libraries, $include_jquery = true) {
     $js = '';
-    $js_path   =  api_get_path(WEB_LIBRARY_PATH).'javascript/';    
+    $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/';    
 
     if ($include_jquery) {
         //Jquery
@@ -4821,7 +4821,7 @@ function api_get_jquery_libraries_js($libraries, $include_jquery = true) {
     //jquery-ui js and css
     if (in_array('jquery-ui', $libraries)) {
         //Jquery ui
-        $theme      = 'smoothness'; // Current themes: cupertino, smoothness, ui-lightness. Find the themes folder in main/inc/lib/javascript/jquery-ui
+        $theme = 'smoothness'; // Current themes: cupertino, smoothness, ui-lightness. Find the themes folder in main/inc/lib/javascript/jquery-ui
         $js .= '<link rel="stylesheet" href="'.$js_path.'jquery-ui/'.$theme.'/jquery-ui-1.8.7.custom.css" type="text/css">';
         $js .= '<script src="'.$js_path.'jquery-ui/'.$theme.'/jquery-ui-1.8.7.custom.min.js" type="text/javascript" language="javascript"></script>';
     }

+ 92 - 3
main/inc/lib/message.lib.php

@@ -854,10 +854,9 @@ class MessageManager
 	 * @param int group id
 	 */
 	public static function display_messages_for_group($group_id) {
-
 		global $my_group_role;
-
 		$rows = self::get_messages_by_group($group_id);
+		 
 		$rows = self::calculate_children($rows);
 		$group_info = GroupPortalManager::get_group_data($group_id);
 		$current_user_id = api_get_user_id();
@@ -981,14 +980,104 @@ class MessageManager
 
 		return $html_messages;
 	}
+	
+
+    /**
+     * Displays messages of a group with nested view
+     * @param int group id
+     */
+    public static function display_title_messages_for_group($group_id) {
+        global $my_group_role;
+        $rows = self::get_messages_by_group($group_id);             
+        $rows = self::calculate_children($rows);
+        $group_info = GroupPortalManager::get_group_data($group_id);
+        $current_user_id = api_get_user_id();
+        $topics_per_page = 5;
+        $items_per_page = 3;
+        $count_items = 0;
+        $html_messages = '';
+        $query_vars = array('id'=>$group_id,'topics_page_nr'=>0);
+
+        if (is_array($rows) && count($rows)> 0) {
+
+            // prepare array for topics with its items
+            $topics = array();
+            $x = 0;
+            foreach ($rows as $index=>$value) {
+                if (empty($value['parent_id'])) {
+                    $x = $index;
+                    $topics[$x] = $value;
+                } else {
+                    $topics[$x]['items'][] = $value;
+                }
+            }
+            uasort($topics,array('MessageManager','order_desc_date'));
+
+            $param_names = array_keys($_GET);
+            $array_html = array();
+            foreach ($topics as $index => $topic) {
+                $html = '';
+                // topics
+                $indent = 0;
+                $user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']);
+                $files_attachments = self::get_links_message_attachment_files($topic['id']);
+                $name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
+
+                $html .= '<div class="rounded_div" style="width:620px">';           
+                    
+                        $html .= '<a href="#" class="head" id="head_'.$topic['id'].'">';
+                        $html .= '<span class="message-group-title-topic">'.(((isset($_GET['anchor_topic']) && $_GET['anchor_topic'] == 'topic_'.$topic['id']) || in_array('items_'.$topic['id'].'_page_nr',$param_names))?Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align: middle')):
+                                    Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align: middle'))).'
+                                    '.Security::remove_XSS($topic['title']).'</span>';
+                        $html .= '</a>';
+
+                        if ($topic['send_date']!=$topic['update_date']) {
+                            if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) {
+                                $html .= '<span class="message-group-date" > ('.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).')</span>';
+                            }
+                        } else {
+                            $html .= '<span class="message-group-date"> <i>'.get_lang('Created').' '.date_to_str_ago($topic['send_date']).'</i></span>';
+                        }
+
+                        $html .= '<div id="topic_'.$topic['id'].'" >';
+                            $html .= '<a name="topic_'.$topic['id'].'"></a>';
+                            $html.= '<div style="margin-bottom:10px">';
+                                $html.= '<div id="message-reply-link" style="margin-right:10px">
+                                         <a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=reply_message_group&anchor_topic=topic_'.$topic['id'].'&topics_page_nr='.intval($_GET['topics_page_nr']).'&items_page_nr='.intval($_GET['items_page_nr']).'" class="thickbox" title="'.get_lang('Reply').'">'.Display :: return_icon('talk.png', get_lang('Reply')).'</a>';
+
+                                if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || $topic['user_sender_id'] == $current_user_id) {
+                                    $html.= '&nbsp;&nbsp;<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=edit_message_group&anchor_topic=topic_'.$topic['id'].'&topics_page_nr='.intval($_GET['topics_page_nr']).'&items_page_nr='.intval($_GET['items_page_nr']).'" class="thickbox" title="'.get_lang('Edit').'">'.Display :: return_icon('edit.gif', get_lang('Edit')).'</a>';
+                                }
+                                $html.= '</div>';
+                                $html.= '<br />';
+                                    $image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);                           $image_repository = $image_path['dir'];
+                                    $existing_image = $image_path['file'];
+                                $html.= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'"  width="44" height="44" title="'.$name.'" />&nbsp;<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.'&nbsp;</a></div>';
+                                $html.= '<div class="message-group-content">'.$topic['content'].'</div>';
+                                $html.= '<div class="message-attach">'.(!empty($files_attachments)?implode('&nbsp;|&nbsp;',$files_attachments):'').'</div>';
+                            $html.= '</div>';
+                $html .= '</div>';                
+                $html .= '</div>'; //rounded_div
+                
+                $array_html[] = array($html);
+            }
+            // grids for items and topics  with paginations
+
+            //$html_messages .= '<div class="social-box-container2">';
+            $html_messages .= Display::return_sortable_grid('topics', array(), $array_html, array('hide_navigation'=>false, 'per_page' => $topics_per_page), $query_vars, false, array(true, true, true,false), false);
+            //$html_messages .= '</div>';
+        }
+
+        return $html_messages;
+    }
 
+	
 	/**
 	 * Add children to messages by id is used for nested view messages
 	 * @param array  rows of messages
 	 * @return array new list adding the item children
 	 */
 	public static function calculate_children($rows) {
-
 		foreach($rows as $row) {
 			$rows_with_children[$row["id"]]=$row;
 			$rows_with_children[$row["parent_id"]]["children"][]=$row["id"];

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

@@ -157,7 +157,7 @@ class Promotion extends Model {
         
             if (!empty($session_list)) {
                 foreach($session_list  as $item) {
-                    $sid = SessionManager::copy_session($item['id'], true, false, true);
+                    $sid = SessionManager::copy_session($item['id'], true, false, true, true);                    
                     if ($sid != 0) {
                         $pid = $this->save($new);
                         SessionManager::suscribe_sessions_to_promotion($pid,array($sid));

+ 1 - 2
main/inc/lib/search/search_widget.php

@@ -17,8 +17,7 @@ require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
  * @param   array $htmlHeadXtra     A reference to the doc $htmlHeadXtra
  */
 function search_widget_prepare(&$htmlHeadXtra) {
-    $htmlHeadXtra[] = '
-    <script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"></script>
+    $htmlHeadXtra[] = '    
     <script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.autocomplete.js"></script>
     <script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'search/search_widget.js"></script>
     <link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.autocomplete.css" />

+ 54 - 22
main/inc/lib/sessionmanager.lib.php

@@ -8,7 +8,7 @@
 
 /* LIBRARIES */
 require_once 'display.lib.php';
-require_once(dirname(__FILE__).'/course.lib.php');
+require_once 'course.lib.php';
 
 /**
 *	This class provides methods for sessions management.
@@ -54,20 +54,20 @@ class SessionManager {
       * @todo use an array to replace all this parameters or use the model.lib.php ...
 	  * @return mixed       Session ID on success, error message otherwise
       **/
-	public static function create_session($sname,$syear_start,$smonth_start,$sday_start,$syear_end,$smonth_end,$sday_end,$snb_days_acess_before,$snb_days_acess_after,$nolimit,$coach_username, $id_session_category,$id_visibility, $start_limit = true, $end_limit = true, $fix_name = false) {		
-		$name= Database::escape_string(trim($sname));
-		$year_start= intval($syear_start);
-		$month_start=intval($smonth_start);
-		$day_start=intval($sday_start);
-		$year_end=intval($syear_end);
-		$month_end=intval($smonth_end);
-		$day_end=intval($sday_end);
+	public static function create_session($sname,$syear_start,$smonth_start,$sday_start,$syear_end,$smonth_end,$sday_end,$snb_days_acess_before,$snb_days_acess_after, $nolimit,$coach_username, $id_session_category,$id_visibility, $start_limit = true, $end_limit = true, $fix_name = false) {		
+		$name                 = Database::escape_string(trim($sname));
+		$year_start           = intval($syear_start);
+		$month_start          = intval($smonth_start);
+		$day_start            = intval($sday_start);
+		$year_end             = intval($syear_end);
+		$month_end            = intval($smonth_end);
+		$day_end              = intval($sday_end);
 		$nb_days_acess_before = intval($snb_days_acess_before);
-		$nb_days_acess_after = intval($snb_days_acess_after);
-		$id_session_category = intval($id_session_category);
-		$id_visibility   = intval($id_visibility);
-		$tbl_user		= Database::get_main_table(TABLE_MAIN_USER);
-		$tbl_session	= Database::get_main_table(TABLE_MAIN_SESSION);        
+		$nb_days_acess_after  = intval($snb_days_acess_after);
+		$id_session_category  = intval($id_session_category);
+		$id_visibility        = intval($id_visibility);
+		$tbl_user		      = Database::get_main_table(TABLE_MAIN_USER);
+		$tbl_session	      = Database::get_main_table(TABLE_MAIN_SESSION);        
     
 		if(is_int($coach_username)) {
 			$id_coach = $coach_username;
@@ -133,14 +133,21 @@ class SessionManager {
 				$sql_insert = "INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id,visibility)
 							   VALUES('".$name."','$date_start','$date_end','$id_coach',".api_get_user_id().",".$nb_days_acess_before.", ".$nb_days_acess_after.", ".$id_session_category.", ".$id_visibility.")";
 				Database::query($sql_insert);
-				$id_session=Database::insert_id();
+				$session_id = Database::insert_id();
+				
+				//Adding to the correct URL				
+				require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';				
+                
+                $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+                $access_url_id = api_get_current_access_url_id();
+                UrlManager::add_session_to_url($session_id,$access_url_id);            
 
 				// add event to system log
 				$time = time();
 				$user_id = api_get_user_id();
-				event_system(LOG_SESSION_CREATE, LOG_SESSION_ID, $id_session, $time, $user_id);
+				event_system(LOG_SESSION_CREATE, LOG_SESSION_ID, $session_id, $time, $user_id);
 
-				return $id_session;
+				return $session_id;
 			}
 		}
 	}
@@ -1383,8 +1390,16 @@ class SessionManager {
      * @return  int     The new session ID on success, 0 otherwise
      * @todo make sure the extra session fields are copied too
      */
-    public function copy_session($id, $copy_courses=true, $copy_users=true, $create_new_courses = false) {
-        $id = (int)$id;
+    /**
+     * @param $id
+     * @param $copy_courses
+     * @param $copy_users
+     * @param $create_new_courses
+     * @param $set_exercises_lp_invisible
+     * @return unknown_type
+     */
+    public function copy_session($id, $copy_courses=true, $copy_users = true, $create_new_courses = false, $set_exercises_lp_invisible = false) {
+        $id = intval($id);
         $s = self::fetch($id);
         $s['year_start']    = substr($s['date_start'],0,4);
         $s['month_start']   = substr($s['date_start'],5,2);
@@ -1408,9 +1423,10 @@ class SessionManager {
              false,(int)$s['id_coach'], $s['session_category_id'],
              (int)$s['visibility'],$consider_start, $consider_end, true);
         
-        if (!is_numeric($sid)) {
+        if (!is_numeric($sid) || empty($sid)) {
         	return false;
         }
+        
         if ($copy_courses) {
             // Register courses from the original session to the new session
             $courses = self::get_course_list_by_session_id($id);
@@ -1432,9 +1448,25 @@ class SessionManager {
                     	ini_set('memory_limit','256M');
                     	ini_set('max_execution_time',0);
                     }                    
-                    foreach($short_courses as $course_data) {
-                        $course_info = CourseManager::copy_course_simple($course_data['title'].' '.get_lang('Copy'), $course_data['course_code'], $id);
+                    foreach ($short_courses as $course_data) {
+                        $course_info = CourseManager::copy_course_simple($course_data['title'].' '.get_lang('Copy'), $course_data['course_code'], $id, $sid);
                         if ($course_info) {
+                            //By default new elements are invisible
+                            if ($set_exercises_lp_invisible) {     
+                                                           
+                                require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
+                                $list       = new LearnpathList('', $course_info['code'], $sid);
+                                $flat_list  = $list->get_flat_list(); 
+                                if (!empty($flat_list)) {                               
+                                    foreach($flat_list as $lp_id => $data) { 
+                                        api_item_property_update($course_info, TOOL_LEARNPATH, $lp_id, 'invisible', api_get_user_id(), 0 ,0, $sid);
+                                        api_item_property_update($course_info, TOOL_LEARNPATH, $lp_id, 'invisible', api_get_user_id(), 0 ,0);
+                                    }
+                                }
+                                $quiz_table   = Database::get_course_table(TABLE_QUIZ_TEST, $course_info['db_name']);
+                                $sql = "UPDATE $quiz_table SET active = 0 ";
+                                $result=Database::query($sql);                                
+                            }
                             $new_short_courses[] = $course_info['code'];
                         }                             
                     }                    

+ 0 - 1
main/link/link.php

@@ -31,7 +31,6 @@ require_once 'linkfunctions.php';
 $this_section = SECTION_COURSES;
 api_protect_course_script();
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready( function() {
 	for (i=0;i<$(".actions").length;i++) {

+ 0 - 1
main/mySpace/access_details.php

@@ -172,7 +172,6 @@ if (isset($_GET['origin']) && strcmp($_GET['origin'], 'tracking_course') === 0)
 	$interbreadcrumb[] = array ("url" => "javascript: void(0);", "name" => get_lang("Details"));
 }
 
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function load_results(type) {
         $.ajax({

+ 3 - 2
main/newscorm/learnpathList.class.php

@@ -30,11 +30,11 @@ class learnpathList {
      * @param	int			Optional session id (otherwise we use api_get_session_id())
      * @return	void
      */
-    function __construct($user_id, $course_code='', $session_id = null, $order_by = null) {
+    function __construct($user_id, $course_code = '', $session_id = null, $order_by = null) {
 
         if (!empty($course_code)){
             $course_info = api_get_course_info($course_code);
-            $lp_table = Database::get_course_table(TABLE_LP_MAIN, $course_info['dbName']);
+            $lp_table = Database::get_course_table(TABLE_LP_MAIN, $course_info['db_name']);
         } else {
             $course_code = api_get_course_id();
             $lp_table = Database::get_course_table(TABLE_LP_MAIN);
@@ -54,6 +54,7 @@ class learnpathList {
             $order =  Database::parse_conditions(array('order'=>$order_by));            
         }
         $sql = "SELECT * FROM $lp_table $condition_session $order";
+        error_log($sql);
         $res = Database::query($sql);
         $names = array();
         while ($row = Database::fetch_array($res,'ASSOC')) {

+ 0 - 1
main/newscorm/lp_add.php

@@ -38,7 +38,6 @@ $currentstyle = api_get_setting('stylesheets');
 //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'css/'.$currentstyle.'/learnpath.css"/>';
 //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="learnpath.css" />'; //will be a merged with original learnpath.css
 $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="dtree.css" />'; //will be moved
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
 $("#learnpath_title").focus();

+ 0 - 1
main/newscorm/lp_view.php

@@ -44,7 +44,6 @@ $my_style       = $platform_theme;
 /*  Header  */
 
 // Se incluye la libreria en el lp_controller.php
-// $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
 
 $htmlHeadXtra[] = api_get_jquery_ui_js(); //jQuery-UI
 

+ 0 - 1
main/notebook/index.php

@@ -26,7 +26,6 @@ require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 
 // Additional javascript
 $htmlHeadXtra[] = NotebookManager::javascript_notebook();
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
 $("#note_title").focus();

+ 7 - 24
main/social/group_invitation.php

@@ -1,4 +1,4 @@
-<?php //$id: $
+<?php
 /* For licensing terms, see /license.txt */
 /**
  * @package chamilo.social
@@ -183,25 +183,20 @@ $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 <script type="text/javascript">
 function add_user (code, content) {
-
 	// document.getElementById("user_to_add").value = "";
 	//document.getElementById("ajax_list_users_single").innerHTML = "";
-
 	destination = document.getElementById("destination_users");
-
 	for (i=0;i<destination.length;i++) {
 		if(destination.options[i].text == content) {
 				return false;
 		}
 	}
-
 	destination.options[destination.length] = new Option(content,code);
 	destination.selectedIndex = -1;
 	sortOptions(destination.options);
 
 }
-function remove_item(origin)
-{
+function remove_item(origin) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 		if(origin.options[i].selected) {
 			origin.options[i]=null;
@@ -398,8 +393,7 @@ if ($add_type=='multiple') {
 if(!empty($errorMsg)) {
 	Display::display_error_message($errorMsg); //main API
 }
-	echo '<div class="social-box-container2">';	
-		
+	
 ?>
 
 <table border="0" cellpadding="5" cellspacing="0" width="100%">
@@ -483,7 +477,6 @@ foreach($sessionUsersList as $enreg) {
 
 <?php
 }
-
 unset($sessionUsersList);
 ?>
 
@@ -504,7 +497,6 @@ unset($sessionUsersList);
 //current group members
 $members = GroupPortalManager::get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_PENDING_INVITATION));
 if (is_array($members) && count($members)>0) {
-
 	foreach ($members as &$member) {
 		$image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true);
 		$picture = UserManager::get_picture_user($member['user_id'], $image_path['file'],80);
@@ -512,19 +504,14 @@ if (is_array($members) && count($members)>0) {
 	}
 	echo '<span class="social-groups-text1"><strong>'.get_lang('UsersAlreadyInvited').'</strong></span>';
 	Display::display_sortable_grid('invitation_profile', array(), $members, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true));
-}
-		
+}		
 	echo '</div>'; // end layout right
-
-echo '</div>'; //
-
-
+echo '</div>';
 ?>
 
 <script type="text/javascript">
 <!--
-function moveItem(origin , destination){
-
+function moveItem(origin , destination) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 		if(origin.options[i].selected) {
 			destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
@@ -534,7 +521,6 @@ function moveItem(origin , destination){
 	}
 	destination.selectedIndex = -1;
 	sortOptions(destination.options);
-
 }
 
 function sortOptions(options) {
@@ -599,19 +585,16 @@ function loadUsersInSelect(select){
 	}
 }
 
-function makepost(select){
-
+function makepost(select) {
 	var options = select.options;
 	var ret = "";
 	for (i = 0 ; i<options.length ; i++)
 		ret = ret + options[i].value +'::'+options[i].text+";;";
-
 	return ret;
 
 }
 -->
 </script>
 <?php
-
 /* 		FOOTER */
 Display::display_footer();

+ 3 - 11
main/social/invitations.php

@@ -113,7 +113,7 @@ echo '<div id="social-content">';
 
 	echo '<div id="social-content-right">';
 	
-        echo '<div class="rounded_div" style="width:90%">';
+        
     
 		if (!empty($show_message)) {
 			Display :: display_normal_message($show_message);
@@ -238,14 +238,6 @@ echo '<div id="social-content">';
 			Display::display_sortable_grid('waiting_user', array(), $new_invitation, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false,false,true,true,true,true));
 		}
 	echo '</div>';
-	
-	///////////7
-	echo '</div>';
-	echo '</div>';
-	
-	////////////7
-	
+	echo '</div>';	
 echo '</div>';
-
-Display::display_footer();
-?>
+Display::display_footer();

+ 3 - 4
main/social/myfiles.php

@@ -67,9 +67,7 @@ function show_icon_edit(element_html) {
 function hide_icon_edit(element_html)  {
 	ident="#edit_image";
 	$(ident).hide();
-}		
-		
-
+}
 </script>';
 api_block_anonymous_users();
 
@@ -110,7 +108,8 @@ echo '<div id="social-content">';
 
 	echo '<div id="social-content-right>';
 		echo '<a href=""></a>';//TODO: hack and delete this line
-		echo '</br>';								
+		echo '<br />';								
         echo '<table><tr><td><iframe name="fileManager" id="fileManager" src="'.api_get_path(WEB_PATH).'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=stand_alone" scrolling="no" noresize="noresize" frameborder="no" style="height:450px; width:655px; float:left"></iframe></td></tr></table>';
 	echo '</div>';
+echo '</div>';	
 Display::display_footer();

+ 68 - 72
main/social/profile.php

@@ -245,14 +245,15 @@ $user_online_list = who_is_online(api_get_setting('time_limit_whosonline'), true
 $user_online_count = count($user_online_list);
 
 echo '<div id="social-content">';
-echo '  <div id="social-content-left">';
-//this include the social menu div
-SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
-echo '  </div>';
 
-echo '  <div id="social-content-right">';
+echo '<div id="social-content-left">';
+    //this include the social menu div
+    SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
+echo '</div>';
+
+echo '<div id="social-content-right">';
 
-echo '      <div class="rounded_div" style="width:300px">';
+echo '<div class="rounded_div" style="width:300px">';
 
 if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
 	echo '<div><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
@@ -361,7 +362,6 @@ if ($show_full_profile) {
 	if (!empty($extra_information_value)) echo $extra_information;
 }
 
-
 echo '</div>';	// close div tag rounded 
 
 
@@ -429,10 +429,9 @@ if ($show_full_profile) {
 	}
 	$friend_html.= '</div>';
 	echo $friend_html;	
+	echo '</div>'; // close div tag rounded 
 }
 
-echo '</div>'; // close div tag rounded 
-
 if ($show_full_profile) {
 
 	// MY GROUPS
@@ -479,32 +478,32 @@ if ($show_full_profile) {
 
     if (count($grid_my_groups) > 0) {
 		echo '<div class="rounded_div" style="width:90%">';
-				echo '<div><h3>'.get_lang('MyGroups').'</h3></div>';
-				$count_groups = 0;
-				if (count($results) == 1 ) {
-					$count_groups = count($results).' '.get_lang('Group');
-				} else {
-					$count_groups = count($results).' '.get_lang('Groups');
-				}
-				echo '<div>'.$count_groups.'</div>';
-				if ($i > $max_numbers_of_group) {
-					if (api_get_user_id() == $user_id) {
-						echo '<div class="box_shared_profile_group_actions"><a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
-					} else {
-						echo '<div class="box_shared_profile_group_actions"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=mygroups&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAllMyGroups').'</a></div>';
-					}
-				}
-    			//Display::display_sortable_grid('shared_profile_mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
-    			$total = count($grid_my_groups);
-    			$i = 1;
-    			foreach($grid_my_groups as $group) {
-    			    echo $group[0];    			    
-    			    if ($i < $total) {
-    			        echo ', ';
-    			    }
-    			    $i++;
+    		echo '<div><h3>'.get_lang('MyGroups').'</h3></div>';
+    		$count_groups = 0;
+    		if (count($results) == 1 ) {
+    			$count_groups = count($results).' '.get_lang('Group');
+    		} else {
+    			$count_groups = count($results).' '.get_lang('Groups');
+    		}
+    		echo '<div>'.$count_groups.'</div>';
+    		if ($i > $max_numbers_of_group) {
+    			if (api_get_user_id() == $user_id) {
+    				echo '<div class="box_shared_profile_group_actions"><a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
+    			} else {
+    				echo '<div class="box_shared_profile_group_actions"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=mygroups&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAllMyGroups').'</a></div>';
     			}
-		echo '<br /><br /></div>';		
+    		}
+    		//Display::display_sortable_grid('shared_profile_mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
+    		$total = count($grid_my_groups);
+    		$i = 1;
+    		foreach($grid_my_groups as $group) {
+    		    echo $group[0];    			    
+    		    if ($i < $total) {
+    		        echo ', ';
+    		    }
+    		    $i++;
+    		}
+		echo '<br /><br /></div>';	//close rounded	
 	}
 
 	// COURSES LIST
@@ -531,16 +530,15 @@ if ($show_full_profile) {
 					$listInactives[] = $value;
 				}
 			}
-			echo '</div>';				
-		echo '</div>';
+			echo '</div>';		//social-content-training		
+		echo '</div>'; //close rounded
 	}
 	// user feeds
 	$user_feeds = SocialManager::get_user_feeds($user_id);
 	if (!empty($user_feeds)) {
 		echo '<div class="rounded_div" style="width:90%">';				
 			echo '<div><h3>'.get_lang('RSSFeeds').'</h3></div>';
-			echo '<div class="social-content-training">'.$user_feeds.'</div>';
-	
+			echo '<div class="social-content-training">'.$user_feeds.'</div>';	
 		echo '</div>';
 	}
 
@@ -585,11 +583,11 @@ if ($show_full_profile) {
         					echo ' '.(substr($pending_invitations[$i]['content'],0,50));
         					echo '<br />';
         					echo '<a id="btn_accepted_'.$user_invitation_id.'" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
-        					echo '<div id="id_response">&nbsp;</div>';
+        					echo '<div id="id_response"></div>';
 					    echo '</div>';
 				    echo '</div>';								
 				}
-				echo '</div>';      				
+				echo '</div>'; //close rounded     				
 			}
 		}
 				
@@ -609,53 +607,51 @@ if ($show_full_profile) {
 			echo $file_list;
 			echo '</div>';
 		}
-		echo '</div>'; // close div tag .social-box-content1		
+		echo '</div>'; // close rounded		
 	}
 	
 	 
 	if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
 		
 		echo '<div class="rounded_div" style="width:280px">';
-		echo '<div><h3>'.get_lang('MoreInformation').'</h3></div>';
-		
-    		$cut_size = 220;
-    		if (!empty($user_info['competences'])) {
-    			echo '<br />';
-    			echo '<div class="social-background-content" style="width:100%;">';
+		echo '<div><h3>'.get_lang('MoreInformation').'</h3></div>';		
+		$cut_size = 220;
+		if (!empty($user_info['competences'])) {
+			echo '<br />';
+			echo '<div class="social-background-content" style="width:100%;">';
     			echo '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
     			echo '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
-    			echo '</div>';
-    			echo '<br />';
-    		}
-    		if (!empty($user_info['diplomas'])) {
-    			echo '<div class="social-background-content" style="width:100%;" >';
+			echo '</div>';
+			echo '<br />';
+		}
+		if (!empty($user_info['diplomas'])) {
+			echo '<div class="social-background-content" style="width:100%;" >';
     			echo '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
     			echo '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
-    			echo '</div>';
-    			echo '<br />';
-    		}
-    		if (!empty($user_info['openarea'])) {
-    			echo '<div class="social-background-content" style="width:100%;" >';
+			echo '</div>';
+			echo '<br />';
+		}
+		if (!empty($user_info['openarea'])) {
+			echo '<div class="social-background-content" style="width:100%;" >';
     			echo '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
     			echo '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
-    			echo '</div>';
-    			echo '<br />';
-    		}
-    		if (!empty($user_info['teach'])) {
-    			echo '<div class="social-background-content" style="width:100%;" >';
+			echo '</div>';
+			echo '<br />';
+		}
+		if (!empty($user_info['teach'])) {
+			echo '<div class="social-background-content" style="width:100%;" >';
     			echo '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
     			echo '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
-    			echo '</div>';
-    			echo '<br />';
-    		}				
-		
-		echo '</div>';     
-	}
-	
-	
+			echo '</div>';
+			echo '<br />';
+		}		
+		echo '</div>'; //rounded     
+	}	
+	echo '</div>'; // close social-box-main1
 }
-echo '</div>'; // close div tag .socialContentRight
-echo '<form id="id_reload" name="id_reload" action="profile.php">&nbsp;</form>';
+
+//echo '<form id="id_reload" name="id_reload" action="profile.php"></form>';
+echo '</div>';
 echo '</div>';
 
 Display :: display_footer();

+ 1 - 2
main/survey/create_new_survey.php

@@ -33,7 +33,6 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
 		function advanced_parameters() {
 			if(document.getElementById(\'options\').style.display == \'none\') {
@@ -46,7 +45,7 @@ $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
 		}
 
 		function setFocus(){
-		$("#surveycode_title").focus();
+		  $("#surveycode_title").focus();
 		}
 		$(document).ready(function () {
 		  setFocus();

+ 0 - 1
main/survey/question.php

@@ -18,7 +18,6 @@ require '../inc/global.inc.php';
 //require_once api_get_path(LIBRARY_PATH).'survey.lib.php';
 require_once 'survey.lib.php';
 
-$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 						$(document).ready( function() {
 							$("button").click(function() {

+ 1 - 2
main/survey/survey.lib.php

@@ -16,10 +16,9 @@ $config['survey']['debug'] = false;
 require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
 require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
 		function setFocus(){
-		$("#search_title").focus();
+		  $("#search_title").focus();
 		}
 		$(document).ready(function () {
 		  setFocus();

+ 0 - 1
main/tracking/question_course_report.php

@@ -43,7 +43,6 @@ $global = true;
 
 $course_list = $course_select_list = array();
 $course_select_list[0] = get_lang('None');
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 
 $htmlHeadXtra[] = '
 <script type="text/javascript">

+ 0 - 1
main/work/work.php

@@ -86,7 +86,6 @@ $ctok = $_SESSION['sec_token'];
 $stok = Security::get_token();
 
 $htmlHeadXtra[] = to_javascript_work();
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
 $("#work_title").focus();

+ 0 - 1
user_portal.php

@@ -52,7 +52,6 @@ require_once $libpath.'sessionmanager.lib.php';
 
 api_block_anonymous_users(); // Only users who are logged in can proceed.
 
-//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>';
 //$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.toggle.js" type="text/javascript" language="javascript"></script>';
 
 /* Table definitions */