Julio Montoya 12 лет назад
Родитель
Сommit
cb3020e45a
41 измененных файлов с 876 добавлено и 1002 удалено
  1. 0 1
      main/admin/settings.php
  2. 19 21
      main/admin/skills_profile.php
  3. 0 1
      main/admin/user_list.php
  4. 16 20
      main/auth/cas/lib/CAS/PGTStorage/pgt-db.php
  5. 2 3
      main/calendar/agenda.inc.php
  6. 48 53
      main/calendar/allagendas.php
  7. 4 6
      main/course_description/add.php
  8. 0 3
      main/document/document_lite.php
  9. 3 5
      main/document/download_scorm.php
  10. 1 3
      main/exercice/addlimits.php
  11. 3 4
      main/exercice/exercise.class.php
  12. 1 4
      main/exercice/exercise.lib.php
  13. 1 1
      main/exercice/exercise_reminder.php
  14. 1 3
      main/exercice/exercise_submit.php
  15. 142 142
      main/exercice/exercise_submit_modal.php
  16. 223 226
      main/exercice/global_multiple_answer.class.php
  17. 0 7
      main/gradebook/lib/be/category.class.php
  18. 26 27
      main/gradebook/lib/fe/linkaddeditform.class.php
  19. 126 126
      main/gradebook/lib/flatview_data_generator.class.php
  20. 0 2
      main/gradebook/lib/gradebook_functions.inc.php
  21. 0 3
      main/inc/ajax/model.ajax.php
  22. 16 17
      main/inc/ajax/user_manager.ajax.php
  23. 0 2
      main/inc/global.inc.php
  24. 0 8
      main/inc/lib/chat.lib.php
  25. 0 1
      main/inc/lib/database.lib.php
  26. 0 11
      main/inc/lib/document.lib.php
  27. 0 1
      main/inc/lib/extra_field.lib.php
  28. 0 1
      main/inc/lib/main_api.lib.php
  29. 0 1
      main/inc/lib/nanogong.lib.php
  30. 1 6
      main/inc/lib/online.inc.php
  31. 1 3
      main/inc/lib/sessionmanager.lib.php
  32. 114 118
      main/inc/lib/skill.lib.php
  33. 0 3
      main/inc/lib/thematic.lib.php
  34. 1 2
      main/inc/lib/tracking.lib.php
  35. 6 6
      main/newscorm/lp_impress.php
  36. 1 1
      main/newscorm/lp_view.php
  37. 56 57
      main/tracking/course_session_report.php
  38. 0 24
      main/tracking/exams.php
  39. 60 73
      main/tracking/question_course_report.php
  40. 0 1
      main/work/work.php
  41. 4 5
      plugin/bbb/lib/bbb.lib.php

+ 0 - 1
main/admin/settings.php

@@ -233,7 +233,6 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
         //$r = api_set_settings_category($my_category, 'false', $_configuration['access_url'], array('checkbox', 'radio'));
 
         //This is a more accurate way of updating to false the checkboxes and radios the settings
-        //var_dump($settings);exit;
 
         /*
         foreach ($values as $key => $value) {

+ 19 - 21
main/admin/skills_profile.php

@@ -46,18 +46,18 @@ $total_skills_to_search = array();
 
 if ($form->validate()) {
     $values = $form->getSubmitValues();
-    
+
     $skills = $values['skills'];
     if (!empty($skills)) {
-                
-        $hidden_skills = isset($values['hidden_skills']) ? $values['hidden_skills'] : array();    
+
+        $hidden_skills = isset($values['hidden_skills']) ? $values['hidden_skills'] : array();
         $skills = array_merge($skills, $hidden_skills);
-        
+
         $skills = array_filter($skills);
         $skills = array_unique($skills);
-        
+
         $_SESSION['skills'] = $skills;
-        
+
     } else {
         $skills = isset($_SESSION['skills']) ? $_SESSION['skills']: array();
     }
@@ -71,21 +71,21 @@ $count_skills = count($skills);
 $users  = $skill_rel_user->get_user_by_skills($skills);
 
 if (!empty($users)) {
-    foreach ($users as $user) {            
+    foreach ($users as $user) {
         $user_info = api_get_user_info($user['user_id']);
         $user_list[$user['user_id']]['user'] = $user_info;
         $my_user_skills = $skill_rel_user->get_user_skills($user['user_id']);
         $user_skills = array();
         $found_counts = 0 ;
         foreach($my_user_skills as $my_skill) {
-            
+
             $found = false;
             if (in_array($my_skill['skill_id'], $skills)) {
                 $found = true;
                 $found_counts++;
             }
             $user_skills[] = array('skill_id' => $my_skill['skill_id'], 'found' => $found);
-            $total_skills_to_search[$my_skill['skill_id']] = $my_skill['skill_id']; 
+            $total_skills_to_search[$my_skill['skill_id']] = $my_skill['skill_id'];
         }
         $user_list[$user['user_id']]['skills'] = $user_skills;
         $user_list[$user['user_id']]['total_found_skills'] = $found_counts;
@@ -105,7 +105,7 @@ $tpl->assign('total_search_skills', $count_skills);
 
 if (!empty($skills)) {
     $counter = 0;
-    foreach($skills as $hidden_skill_id) {        
+    foreach($skills as $hidden_skill_id) {
         $form->addElement('hidden', 'hidden_skills[]', $hidden_skill_id);
         $counter++;
     }
@@ -125,36 +125,34 @@ $id     = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
 
 switch ($action) {
     case 'remove_skill':
-        $new_skill = array();      
+        $new_skill = array();
         foreach ($skills as $skill_id) {
             if ($id != $skill_id) {
                 $new_skill[] = $skill_id;
-            }            
-        }  
+            }
+        }
         $skills = $_SESSION['skills'] = $new_skill;
-        break;    
+        break;
     case 'load_profile':
         $skill_profile = new SkillRelProfile();
-        $skills = $skill_profile->get_skills_by_profile($id);        
-        $total_skills_to_search = $skill->get_skills_info($skills);        
+        $skills = $skill_profile->get_skills_by_profile($id);
+        $total_skills_to_search = $skill->get_skills_info($skills);
         break;
 }
 
 $skill_list = array();
 foreach ($total_skills_to_search as $skill_info) {
-    $skill_list[$skill_info['id']] = $skill_info;        
+    $skill_list[$skill_info['id']] = $skill_info;
 }
 
-$tpl->assign('skill_list', $skill_list);   
+$tpl->assign('skill_list', $skill_list);
 $tpl->assign('search_skill_list', $skills);
 
 $form_to_html = $form->return_form();
 
-//var_dump($total_skills_to_search);
-
 $tpl->assign('form', $form_to_html);
 $tpl->assign('url', $url);
 
 $content = $tpl->fetch('default/skill/profile.tpl');
 $tpl->assign('content', $content);
-$tpl->display_one_col_template();  
+$tpl->display_one_col_template();

+ 0 - 1
main/admin/user_list.php

@@ -763,7 +763,6 @@ $form->addElement('html', '</td><td>');
 /*
  * @todo fix this code
 $extra_data = UserManager::get_extra_fields( 0,10,5, 'ASC', true, 1);
-var_dump($extra_data);
 $extra_options = array();
 if (!empty($extra_data)) {
     $extra_options[0] = get_lang('All');

+ 16 - 20
main/auth/cas/lib/CAS/PGTStorage/pgt-db.php

@@ -2,10 +2,10 @@
 /*
  * Copyright © 2003-2010, The ESUP-Portail consortium & the JA-SIG Collaborative.
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
- * 
+ *
  *     * Redistributions of source code must retain the above copyright notice,
  *       this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above copyright notice,
@@ -35,7 +35,7 @@
 
 /**
  * @class PGTStorageDB
- * The PGTStorageDB class is a class for PGT database storage. An instance of 
+ * The PGTStorageDB class is a class for PGT database storage. An instance of
  * this class is returned by CASClient::SetPGTStorageDB().
  *
  * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
@@ -45,9 +45,9 @@
 
 class PGTStorageDB extends PGTStorage
 {
-  /** 
+  /**
    * @addtogroup internalPGTStorageDB
-   * @{ 
+   * @{
    */
 
   /**
@@ -81,7 +81,7 @@ class PGTStorageDB extends PGTStorage
   var $_link = null;
 
   /**
-   * This method returns the handle of the connection to the database where PGT's are 
+   * This method returns the handle of the connection to the database where PGT's are
    * stored.
    *
    * @return a handle of connection.
@@ -94,7 +94,7 @@ class PGTStorageDB extends PGTStorage
     }
 
   /**
-   * The name of the table where PGT's are stored. Written by 
+   * The name of the table where PGT's are stored. Written by
    * PGTStorageDB::PGTStorageDB(), read by getTable().
    *
    * @hideinitializer
@@ -117,7 +117,7 @@ class PGTStorageDB extends PGTStorage
   // ########################################################################
   //  DEBUGGING
   // ########################################################################
-  
+
   /**
    * This method returns an informational string giving the type of storage
    * used by the object (used for debugging purposes).
@@ -144,7 +144,7 @@ class PGTStorageDB extends PGTStorage
   // ########################################################################
   //  CONSTRUCTOR
   // ########################################################################
-  
+
   /**
    * The class constructor, called by CASClient::SetPGTStorageDB().
    *
@@ -178,11 +178,11 @@ class PGTStorageDB extends PGTStorage
       // XXX should use setURL and setTable
       phpCAS::traceEnd();
     }
-  
+
   // ########################################################################
   //  INITIALIZATION
   // ########################################################################
-  
+
   /**
    * This method is used to initialize the storage. Halts on error.
    *
@@ -196,8 +196,8 @@ class PGTStorageDB extends PGTStorage
 		return;
       // call the ancestor's method (mark as initialized)
       parent::init();
-      
-	  //include phpDB library (the test was introduced in release 0.4.8 for 
+
+	  //include phpDB library (the test was introduced in release 0.4.8 for
 	  //the integration into Tikiwiki).
 	  if (!class_exists('DB')) {
 		include_once('DB.php');
@@ -206,13 +206,9 @@ class PGTStorageDB extends PGTStorage
       // try to connect to the database
       $this->_link = DB::connect($this->getURL());
       if ( DB::isError($this->_link) ) {
-	phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
+	    phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
       }
-      var_dump($this->_link);
+
       phpCAS::traceBEnd();
     }
-
-  /** @} */
-}
-
-?>
+}

+ 2 - 3
main/calendar/agenda.inc.php

@@ -3672,7 +3672,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
         // $sqlquery = "SELECT * FROM $agendadb WHERE (DAYOFMONTH(day)>='$start_day' AND DAYOFMONTH(day)<='$end_day')
         //				AND (MONTH(day)>='$start_month' AND MONTH(day)<='$end_month')
         //				AND (YEAR(day)>='$start_year' AND YEAR(day)<='$end_year')";
-        //var_dump($sqlquery);
+
         $result = Database::query($sqlquery);
         while ($item = Database::fetch_array($result)) {
             $agendaday_string = api_convert_and_format_date($item['start_date'], "%d", date_default_timezone_get());
@@ -5030,7 +5030,7 @@ function agenda_import_ical($course_info, $file)
       $attendee 	 = $ve->getProperty('attendee');
       $course_name = $ve->getProperty('location');
       //insert the event in our database
-      //var_dump($title,$desc,$start_date,$end_date);
+
       $id = agenda_add_item($course_info,$title,$desc,$start_date_string,$end_date_string,$_POST['selectedform']);
 
 
@@ -5139,7 +5139,6 @@ function agenda_import_ical($course_info, $file)
             $all_day = 'true';
         }
 
-        //var_dump($start_date_string, $end_date_string, $all_day);
         $id = $agenda_obj->add_event(
             $start_date_string,
             $end_date_string,

+ 48 - 53
main/calendar/allagendas.php

@@ -2,12 +2,12 @@
 /* For licensing terms, see /license.txt */
 
 /**
- * 
+ *
  * Get the all events by session/course
- * @author Julio Montoya cleaning code, chamilo code style changes, all agenda feature work with courses and sessions, only admins and rrhh users can see this page 
- * 
- *  
- * @author Carlos Brolo First code submittion  
+ * @author Julio Montoya cleaning code, chamilo code style changes, all agenda feature work with courses and sessions, only admins and rrhh users can see this page
+ *
+ *
+ * @author Carlos Brolo First code submittion
  */
 
 // name of the language file that needs to be included
@@ -56,7 +56,7 @@ if (!empty ($course_path)) {
 // showing the header
 Display::display_header(get_lang('MyAgenda'));
 
-function display_mymonthcalendar_2($agendaitems, $month, $year, $weekdaynames=array(), $monthName, $session_id) {	
+function display_mymonthcalendar_2($agendaitems, $month, $year, $weekdaynames=array(), $monthName, $session_id) {
 	global $DaysShort, $course_path;
 	//Handle leap year
 	$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
@@ -108,22 +108,22 @@ function display_mymonthcalendar_2($agendaitems, $month, $year, $weekdaynames=ar
 	echo "</table>\n";
 }
 
-function get_agenda_items_by_course_list($course_list, $month, $year, $session_id = 0) {	
+function get_agenda_items_by_course_list($course_list, $month, $year, $session_id = 0) {
 	global $setting_agenda_link;
 	//echo $sql  = 'SELECT name FROM chamilo_main.class WHERE name = "'.$grado.'" ORDER BY name ASC';
 	//$result = Database::query($sql);
 	//while ($row = Database::fetch_array($result, 'ASSOC')) {
-	
-	$agendaitems = array ();	
+
+	$agendaitems = array ();
 	$course_name_list = array();
 	foreach ($course_list as $course) {
-		
+
 		$db_name		= $course['db_name'];
 		$code			= $course['code'];
 		$title			= $course['title'];
-		$course_name_list[] = $title;		
+		$course_name_list[] = $title;
 		//$sql2  = 'SELECT code, db_name, title FROM chamilo_main.course WHERE category_code = "'.$course_name.'" ';
-//		$courses_dbs = Database::query($sql2);		
+//		$courses_dbs = Database::query($sql2);
 
 		$items = array ();
 		// $courses_dbs = array();
@@ -132,8 +132,8 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i
 		//$db_name 	= $row2['db_name'];
 		//$code 		= $row2['code'];
 		//$title 		= $row2['title'];
-		//echo "<center><h2>".$db_name."</h2></center>";		
-		
+		//echo "<center><h2>".$db_name."</h2></center>";
+
 		//databases of the courses
 		$TABLEAGENDA 		= Database :: get_course_table(TABLE_AGENDA, $db_name);
 		$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $db_name);
@@ -143,9 +143,9 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i
 		$session_condition = '';
 		if ($session_id != 0) {
 			$session_id = intval($session_id);
-			$session_condition = "AND session_id = $session_id"; 
+			$session_condition = "AND session_id = $session_id";
 		}
-		
+
 		$sqlquery = "SELECT	DISTINCT agenda.*, item_property.*
 						FROM ".$TABLEAGENDA." agenda,
 							 ".$TABLE_ITEMPROPERTY." item_property
@@ -155,20 +155,19 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i
 						AND item_property.tool='".TOOL_CALENDAR_EVENT."'
 						AND item_property.visibility='1' $session_condition
 						GROUP BY agenda.id
-						ORDER BY start_date ";		
+						ORDER BY start_date ";
 		$result = Database::query($sqlquery);
 		while ($item = Database::fetch_array($result,'ASSOC')) {
-			//var_dump($item);
+
 			//taking the day
-			$agendaday = date("j",strtotime($item['start_date']));				
+			$agendaday = date("j",strtotime($item['start_date']));
 			if(!isset($items[$agendaday])){$items[$agendaday]=array();}
 			//taking the time
 			$time = date("H:i",strtotime($item['start_date']));
-			//var_dump($time );
+
 			$end_time= date("H:i",strtotime($item['end_date']));
 			$URL = api_get_path(WEB_PATH)."main/calendar/allagendas.php?cidReq=".urlencode($code)."&amp;sort=asc&amp;view=list&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday"; // RH  //Patrick Cool: to highlight the relevant agenda item
-			//var_dump($URL);
-			
+
 			if ($setting_agenda_link == 'coursecode') {
 				//$title=$array_course_info['title'];
 				$agenda_link = api_substr($title, 0, 14);
@@ -178,12 +177,12 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i
 			if(!isset($items[$agendaday][$item['start_date']])) {
 				$items[$agendaday][$item['start_date']] = '';
 			}
-			
+
 			$items[$agendaday][$item['start_date']] .= "".get_lang('StartTimeWindow')."&nbsp;<i>".$time."</i>"."&nbsp;-&nbsp;".get_lang("EndTimeWindow")."&nbsp;<i>".$end_time."</i>&nbsp;";
 			$items[$agendaday][$item['start_date']] .= '<br />'."<b><a href=\"$URL\" title=\"".Security::remove_XSS($title)."\">".$agenda_link."</a> </b> ".Security::remove_XSS($item['title'])."<br /> ";
 			$items[$agendaday][$item['start_date']] .= '<br/>';
 		}
-		
+
 		if (is_array($items) && count($items) > 0) {
 			while (list ($agendaday, $tmpitems) = each($items)) {
 				if(!isset($agendaitems[$agendaday])) {
@@ -257,31 +256,27 @@ $my_session_id = intval($_GET['session']);
 $my_course_list = array();
 
 if(!empty($my_session_id)) {
-	$_SESSION['my_course_list'] = array();	
+	$_SESSION['my_course_list'] = array();
 	$my_course_list = array();
 } else {
-	//echo 'here';
 	$my_course_list = $_SESSION['my_course_list'];
-	 
-	//var_dump($_SESSION['my_course_list'], $my_course_list);	
-	
+
 	$my_course_list_keys = array_keys($my_course_list);
-	
-	//var_dump($my_course_list, $my_course_list_keys);
-	if (!in_array($my_course_id, $my_course_list_keys)) {	
+
+	if (!in_array($my_course_id, $my_course_list_keys)) {
 		$course_info = api_get_course_info_by_id($my_course_id);
-		$_SESSION['my_course_list'][$my_course_id] = $course_info;	
+		$_SESSION['my_course_list'][$my_course_id] = $course_info;
 		$my_course_list = $_SESSION['my_course_list'];
 		//echo $my_course_id.'added ';
 	}
-	
+
 	if (isset($_GET['delete_course_option'])) {
-		$course_id_to_delete = intval($_GET['delete_course_option']);	
-		unset($_SESSION['my_course_list'][$course_id_to_delete]);	
+		$course_id_to_delete = intval($_GET['delete_course_option']);
+		unset($_SESSION['my_course_list'][$course_id_to_delete]);
 		$my_course_list = $_SESSION['my_course_list'];
 	}
 	//clean the array
-	$my_course_list = array_filter($my_course_list);	
+	$my_course_list = array_filter($my_course_list);
 }
 
 /* 	OUTPUT	*/
@@ -319,24 +314,24 @@ if (isset ($_user['user_id'])) {
 
 	if (api_is_platform_admin()) {
 		$courses  = array();
-		$sessions = SessionManager::get_sessions_list();		
-		
+		$sessions = SessionManager::get_sessions_list();
+
 	} elseif(api_is_drh()) {
-		$courses  = CourseManager::get_courses_followed_by_drh(api_get_user_id());		
+		$courses  = CourseManager::get_courses_followed_by_drh(api_get_user_id());
 		$sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
 	}
 
 	echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
 	echo '<tr>';
-	
+
 	// output: the small calendar item on the left and the view / add links
 	echo '<td width="220" valign="top">';
-		
+
 		echo '<br />';
 		if (count($courses) > 0) {
 			echo '<h1>'.get_lang('SelectACourse').'</h1>';
-			
-			foreach ($courses as $row_course) {	
+
+			foreach ($courses as $row_course) {
 				$course_code = $row_course['id'];
 				$title = $row_course['title'];
 				$my_course_list_keys = array_keys($my_course_list);
@@ -349,37 +344,37 @@ if (isset ($_user['user_id'])) {
 		}
 		if (count($sessions) > 0) {
 			echo '<h1>'.get_lang('SelectASession').'</h1>';
-			foreach ($sessions as $session) {			
+			foreach ($sessions as $session) {
 				$id = $session['id'];
 				$name = $session['name'];
-				echo '<a href="allagendas.php?session='.$id.'">'.$name.'</a><br />'; 
+				echo '<a href="allagendas.php?session='.$id.'">'.$name.'</a><br />';
 			}
 		}
 	echo '</td>';
-		
+
 	// the divider
 	// OlivierB : the image has a white background, which causes trouble if the portal has another background color. Image should be transparent. ----> echo "<td width=\"20\" background=\"../img/verticalruler.gif\">&nbsp;</td>";
 	echo "<td width=\"20\">&nbsp;</td>";
 	// the main area: day, week, month view
 	echo '<td valign="top">';
-	
+
 	//@todo hardcoding option
 	$process = 'month_view';
-	
+
 	switch ($process) {
 		case "month_view" :
 			$session_id = 0;
 			//By courses
 			if (is_array($my_course_list) && count($my_course_list) > 0) {
-				$course_list = $my_course_list;				
+				$course_list = $my_course_list;
 			} else {
 				//session
 				$course_list = SessionManager::get_course_list_by_session_id($my_session_id);
-				$session_id = $my_session_id;				
-				echo '<h1>'.$sessions[$session_id]['name'].'</h1>';					
+				$session_id = $my_session_id;
+				echo '<h1>'.$sessions[$session_id]['name'].'</h1>';
 			}
 			if (is_array($course_list) && count($course_list) > 0) {
-				
+
 				$agendaitems = get_agenda_items_by_course_list($course_list, $month, $year, $session_id);
 				//$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "month_view");
 				display_mymonthcalendar_2($agendaitems, $month, $year, array(), $monthName, $session_id);

+ 4 - 6
main/course_description/add.php

@@ -2,7 +2,7 @@
 /* For licensing terms, see /license.txt */
 
 /**
-* View (MVC patter) for adding a course description 
+* View (MVC patter) for adding a course description
 * @author Christian Fasanando <christian1827@gmail.com>
 * @package chamilo.course_description
 */
@@ -10,8 +10,6 @@
 // protect a course script
 api_protect_course_script(true);
 
-//var_dump($_SESSION['studentview']);
-
 // display categories
 $categories = array ();
 foreach ($default_description_titles as $id => $title) {
@@ -35,8 +33,8 @@ foreach ($categories as $id => $title) {
 echo '</div>';
 
 // error messages
-if (isset($error) && intval($error) == 1) {	
-	Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);	
+if (isset($error) && intval($error) == 1) {
+	Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
 }
 
 // default header title form
@@ -64,7 +62,7 @@ if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
 }
 $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
 
-// display default questions			
+// display default questions
 if (isset ($question[$description_type])) {
 	$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
 	$message .= $question[$description_type];

+ 0 - 3
main/document/document_lite.php

@@ -1126,6 +1126,3 @@ if (!is_null($docs_and_folders)) {
 $content .= Display::div($link, array('class' => 'right'));
 $controller->tpl->assign('content', $content);
 $controller->tpl->display($tpl);
-
-//var_dump($sortable_data);
-

+ 3 - 5
main/document/download_scorm.php

@@ -6,7 +6,7 @@
  *	@package chamilo.document
  */
 /**
- * Code 
+ * Code
  */
 
 session_cache_limiter('none');
@@ -48,17 +48,15 @@ if (strpos($doc_url,'../') OR strpos($doc_url,'/..')) {
 
 $sys_course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/scorm';
 
-//var_dump($sys_course_path);
-
 if (is_dir($sys_course_path.$doc_url)) {
     api_not_allowed();
 }
- 
+
 if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) {
     $full_file_name = $sys_course_path.$doc_url;
     // Launch event
     event_download($doc_url);
-    
+
     DocumentManager::file_send_for_download($full_file_name);
 }
 exit;

+ 1 - 3
main/exercice/addlimits.php

@@ -17,7 +17,6 @@ require_once '../inc/global.inc.php';
 require_once 'exercise.class.php';
 require_once 'question.class.php';
 require_once 'answer.class.php';
-require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 
 // name of the language file that needs to be included
 $language_file='exercice';
@@ -29,8 +28,7 @@ api_protect_course_script();
 
 $dsp_percent = false;
 $debug=0;
-if($debug>0)
-{
+if($debug>0) {
 	echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";exervar_dump($_POST);
 }
 // general parameters passed via POST/GET

+ 3 - 4
main/exercice/exercise.class.php

@@ -3647,9 +3647,9 @@ class Exercise
 
         //Fixes multiple answer question in order to be exact
         if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
-            //var_dump($answer_correct_array, $real_answers);
+
             $diff = @array_diff($answer_correct_array, $real_answers);
-            //var_dump($diff);
+
             /*
              * All good answers or nothing works like exact
               $counter = 1;
@@ -4481,10 +4481,9 @@ class Exercise
                     }
                     $questions_in_category = $one_question_per_category;
                 }
-                //var_dump($questions_in_category);
+
                 while (list($category_id, $question_id) = each($questions_in_category)) {
                     $elements = Testcategory::getNElementsFromArray($question_id, $number_of_random_question);
-                    //var_dump($elements);
                     $temp_question_list = array_merge($temp_question_list, $elements);
                 }
 

+ 1 - 4
main/exercice/exercise.lib.php

@@ -1700,7 +1700,7 @@ function get_exercise_result_ranking_by_attempt($my_score, $my_exe_id, $exercise
             }
         }
         $return_value = array('position' => $position, 'count' => count($my_ranking));
-        //var_dump($my_score, $my_ranking);
+
         if ($return_string) {
             if (!empty($position) && !empty($my_ranking)) {
                 return $position.'/'.count($my_ranking);
@@ -1793,7 +1793,6 @@ function get_average_score_by_course($course_code, $session_id)
         foreach ($user_results as $result) {
             if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) {
                 $score = $result['exe_result'] / $result['exe_weighting'];
-                //var_dump($score);
                 $avg_score +=$score;
             }
         }
@@ -1801,7 +1800,6 @@ function get_average_score_by_course($course_code, $session_id)
         //$avg_score = show_score( $avg_score / count($user_results) , $result['exe_weighting']);
         $avg_score = ($avg_score / count($user_results));
     }
-    //var_dump($avg_score);
     return $avg_score;
 }
 
@@ -1997,7 +1995,6 @@ function get_number_students_answer_count($answer_id, $question_id, $exercise_id
                     cu.status        = ".STUDENT." AND
                     relation_type <> 2 AND
                     e.status = ''";
-    //var_dump($sql);
     $result = Database::query($sql);
     $return = 0;
     if ($result) {

+ 1 - 1
main/exercice/exercise_reminder.php

@@ -168,7 +168,7 @@ foreach ($attempt_list as $question_id => $options) {
 				$item['answer'] = $objExercise->fill_in_blank_answer_to_string($item['answer']);
 				break;
 			case HOT_SPOT:
-				//var_dump($item['answer']);
+
 				break;
 		}
 

+ 1 - 3
main/exercice/exercise_submit.php

@@ -536,7 +536,6 @@ if ($objExercise->selectAttempts() > 0) {
 if ($debug) { error_log("4. Setting the exe_id: $exe_id");} ;
 
 //5. Getting user exercise info (if the user took the exam before) - generating exe_id
-//var_dump($learnpath_id.' - '.$learnpath_item_id.' - '.$learnpath_item_view_id);
 
 $exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
 
@@ -1041,7 +1040,6 @@ if ($reminder == 2)  {
 	    	exit;
     	}
     }
-    //var_dump($remind_question_id, $my_remind_list, $data_tracking, $current_question);
 }
 
 if ($objExercise->review_answers) {
@@ -1330,7 +1328,7 @@ function render_question_list($objExercise, $questionList, $current_question, $e
                 echo $objQuestionTmp->show_media_content();
 
                 $count_of_questions_inside_media = count($media_question_list);
-                //var_dump($media_question_list);
+
                 //Show questions that belongs to a media
                 if (!empty($media_question_list)) {
                     foreach ($media_question_list as $my_question_id) {

+ 142 - 142
main/exercice/exercise_submit_modal.php

@@ -57,7 +57,7 @@ $nbrQuestions	= intval($_GET['nbrQuestions']);
 Session::erase('objExerciseExtra'.$exerciseId);
 Session::erase('exerciseResultExtra'.$exerciseId);
 Session::erase('questionListExtra'.$exerciseId);
-			
+
 //round-up the coordinates
 $coords = explode('/',$_GET['hotspot']);
 $user_array = '';
@@ -70,43 +70,43 @@ if (is_array($coords) && count($coords)>0){
 
 $user_array = substr($user_array,0,-1);
 
-if (isset($_GET['choice'])){ 
-    $choice_value = intval($_GET['choice']);    
+if (isset($_GET['choice'])){
+    $choice_value = intval($_GET['choice']);
 }
 
 // Getting the options by js
 if (empty($choice_value)) {
-    
-	echo "<script>		
-		// this works for only radio buttons		
+
+	echo "<script>
+		// this works for only radio buttons
 		var f= self.parent.window.document.frm_exercise;
-		var choice_js=''; 
-		
+		var choice_js='';
+
 		var hotspot = new Array();
 		var hotspotcoord = new Array();
 		var counter=0;
-		for( var i = 0; i < f.elements.length; i++ ) { 					
-			if (f.elements[i].type=='radio' && f.elements[i].checked) {				
-				//alert( f.elements[i].name);				
+		for( var i = 0; i < f.elements.length; i++ ) {
+			if (f.elements[i].type=='radio' && f.elements[i].checked) {
+				//alert( f.elements[i].name);
 				choice_js = f.elements[i].value;
-                counter ++;				
-			}																																
-																	
-			if (f.elements[i].type=='hidden' ) {	
-				name = f.elements[i].name;					
+                counter ++;
+			}
+
+			if (f.elements[i].type=='hidden' ) {
+				name = f.elements[i].name;
 				if (name.substr(0,7)=='hotspot')
-					hotspot.push(f.elements[i].value);	
-			
+					hotspot.push(f.elements[i].value);
+
 				if (name.substr(0,20)=='hotspot_coordinates')
-					hotspotcoord.push(f.elements[i].value);			
-				//hotspot = f.elements[i].value;														
-			}															
-		}					
+					hotspotcoord.push(f.elements[i].value);
+				//hotspot = f.elements[i].value;
+			}
+		}
 		if (counter==0) {
-			choice_js=-1; // this is an error	
-		}				
+			choice_js=-1; // this is an error
+		}
 		//alert(choice_js);
-	";		
+	";
 	// IMPORTANT
 	//this is the real redirect function
 	echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";</script>';
@@ -116,7 +116,7 @@ $choice = array();
 $questionid= $questionList[$questionNum];
 // $choice_value => value of the user selection
 $choice[$questionid] = $choice_value;
-	
+
 // initializing
 if(!is_array($exerciseResult)) {
     $exerciseResult = array();
@@ -127,39 +127,39 @@ if (is_array($choice)) {
     if ($exerciseType == EXERCISE_FEEDBACK_TYPE_DIRECT) {
         // $exerciseResult receives the content of the form.
         // Each choice of the student is stored into the array $choice
-        $exerciseResult = $choice; 
+        $exerciseResult = $choice;
     } else {
         // gets the question ID from $choice. It is the key of the array
         list($key)=array_keys($choice);
         // if the user didn't already answer this question
         if(!isset($exerciseResult[$key])) {
             // stores the user answer into the array
-            $exerciseResult[$key]=$choice[$key];   
+            $exerciseResult[$key]=$choice[$key];
         }
-    }        
+    }
 }
 
 // the script "exercise_result.php" will take the variable $exerciseResult from the session
 
 Session::write('exerciseResult', $exerciseResult);
-Session::write('exerciseResultCoordinates', $exerciseResultCoordinates); 
+Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
 
-/* 
+/*
 // if it is the last question (only for a sequential exercise)
 if($questionNum >= $nbrQuestions)
-{	
+{
     if($debug>0){echo str_repeat('&nbsp;',0).'Redirecting to exercise_result.php - Remove debug option to let this happen'."<br />\n";}
 	// goes to the script that will show the result of the exercise
     // header("Location: exercise_result.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
-  	// echo 'location result'; 
+  	// echo 'location result';
 }*/
 
-// gets the student choice for this question	
+// gets the student choice for this question
 //print_r($choice); echo "<br>";
 
 
 // creates a temporary Question object
-if (in_array($questionid, $questionList)) { 
+if (in_array($questionid, $questionList)) {
 	$objQuestionTmp 	= Question :: read($questionid);
 	$questionName		=$objQuestionTmp->selectTitle();
 	$questionDescription=$objQuestionTmp->selectDescription();
@@ -188,70 +188,70 @@ $hot_spot_load = false;
 if (!empty($choice_value)) {
 	for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
 		$answer            = $objAnswerTmp->selectAnswer($answerId);
-		$answerComment     = $objAnswerTmp->selectComment($answerId);	
+		$answerComment     = $objAnswerTmp->selectComment($answerId);
 		$answerDestination = $objAnswerTmp->selectDestination($answerId);
-		
-		$answerCorrect     = $objAnswerTmp->isCorrect($answerId);  	
+
+		$answerCorrect     = $objAnswerTmp->isCorrect($answerId);
 		$answerWeighting   = $objAnswerTmp->selectWeighting($answerId);
 		$numAnswer         = $objAnswerTmp->selectAutoId($answerId);
-		
+
 		//delineation
 		$delineation_cord  = $objAnswerTmp->selectHotspotCoordinates(1);
 		$answer_delineation_destination=$objAnswerTmp->selectDestination(1);
         if ($dbg_local>0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination,0);}
-        
+
 		switch($answerType) {
 			// for unique answer
 			case UNIQUE_ANSWER :
-				$studentChoice = ($choice_value == $numAnswer)?1:0;						
-				if ($studentChoice) {					
+				$studentChoice = ($choice_value == $numAnswer)?1:0;
+				if ($studentChoice) {
 					$questionScore	+=$answerWeighting;
 					$totalScore		+=$answerWeighting;
-					$newquestionList[]=$questionid;				
+					$newquestionList[]=$questionid;
 				}
 				break;
-			case HOT_SPOT_DELINEATION :	
+			case HOT_SPOT_DELINEATION :
 			    $studentChoice=$choice[$answerId];
-				if ($studentChoice) {					
-					$newquestionList[]=$questionid;	
-				}					
-				if ($answerId===1) {	
+				if ($studentChoice) {
+					$newquestionList[]=$questionid;
+				}
+				if ($answerId===1) {
 					$questionScore	+=$answerWeighting;
-					$totalScore		+=$answerWeighting;	
+					$totalScore		+=$answerWeighting;
 					$_SESSION['hotspot_coord'][1]	=$delineation_cord;
 					$_SESSION['hotspot_dest'][1]	=$answer_delineation_destination;
-				}		
-				break;					
+				}
+				break;
 		}
-			
-	
-        if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {							
+
+
+        if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
             //display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect);
             //echo $questionScore;
             if ($studentChoice) {
                 $destination = $answerDestination;
-                $comment = $answerComment;                
+                $comment = $answerComment;
             }
         } elseif($answerType == HOT_SPOT_DELINEATION) {
-                if ($next) {										
+                if ($next) {
                     if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
                     $hot_spot_load = true; //apparently the script is called twice
-                    $user_answer = $user_array;			
+                    $user_answer = $user_array;
                     $_SESSION['exerciseResultCoordinates'][$questionid]=$user_answer; //needed for exercise_result.php
 
                     // we compare only the delineation not the other points
-                    $answer_question	= $_SESSION['hotspot_coord'][1];					
+                    $answer_question	= $_SESSION['hotspot_coord'][1];
                     $answerDestination	= $_SESSION['hotspot_dest'][1];
 
                     $poly_user 				= convert_coordinates($user_answer,'/');
-                    $poly_answer 			= convert_coordinates($answer_question,'|');                        
+                    $poly_answer 			= convert_coordinates($answer_question,'|');
                     $max_coord 				= poly_get_max($poly_user,$poly_answer);
 
                     if (empty($_GET['hotspot'])) { //no user response
                         $overlap = -2;
                     } else {
                         $poly_user_compiled 	= poly_compile($poly_user,$max_coord);
-                        $poly_answer_compiled 	= poly_compile($poly_answer,$max_coord);	                        
+                        $poly_answer_compiled 	= poly_compile($poly_answer,$max_coord);
                         $poly_results 			= poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
 
                         $overlap = $poly_results['both'];
@@ -280,46 +280,46 @@ if (!empty($choice_value)) {
                         if ($dbg_local>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
                     }
 
-                    $destination_items= explode('@@', $answerDestination);	                        
-                    $threadhold_total = $destination_items[0];			            
-                    $threadhold_items=explode(';',$threadhold_total);				        		            
+                    $destination_items= explode('@@', $answerDestination);
+                    $threadhold_total = $destination_items[0];
+                    $threadhold_items=explode(';',$threadhold_total);
                     $threadhold1 = $threadhold_items[0]; // overlap
                     $threadhold2 = $threadhold_items[1]; // excess
-                    $threadhold3 = $threadhold_items[2];	 //missing          
+                    $threadhold3 = $threadhold_items[2];	 //missing
 
                     // echo $final_overlap.'  '.$threadhold1 .' - '. $final_missing.' '. $threadhold2 .' - '. $final_excess.'  '. $threadhold3;
 
                     // if is delineation
-                    if ($answerId===1) { 
+                    if ($answerId===1) {
                         //setting colors
-                        if ($final_overlap>=$threadhold1) {	
+                        if ($final_overlap>=$threadhold1) {
                             $overlap_color=true; //echo 'a';
                         }
                         //echo $excess.'-'.$threadhold2;
-                        if ($final_excess<=$threadhold2)  {	
+                        if ($final_excess<=$threadhold2)  {
                             $excess_color=true; //echo 'b';
                         }
                         //echo '--------'.$missing.'-'.$threadhold3;
-                        if ($final_missing<=$threadhold3) {	
+                        if ($final_missing<=$threadhold3) {
                             $missing_color=true; //echo 'c';
-                        }			
+                        }
 
-                        // if pass							
+                        // if pass
                         //if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
-                        if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {												
-                            $next=1; //go to the oars	
-                            $result_comment=get_lang('Acceptable');		
+                        if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
+                            $next=1; //go to the oars
+                            $result_comment=get_lang('Acceptable');
                         } else {
                             $next=1; //Go to the oars. If $next =  0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
                             $wrong_results = true;
-                            $result_comment=get_lang('Unacceptable');								
-                            $special_comment = $comment=$answerDestination=$objAnswerTmp->selectComment(1);								
+                            $result_comment=get_lang('Unacceptable');
+                            $special_comment = $comment=$answerDestination=$objAnswerTmp->selectComment(1);
                             $answerDestination=$objAnswerTmp->selectDestination(1);
                             $destination_items= explode('@@', $answerDestination);
                             $try_hotspot=$destination_items[1];
                             $lp_hotspot=$destination_items[2];
                             $select_question_hotspot=$destination_items[3];
-                            $url_hotspot=$destination_items[4];	            											
+                            $url_hotspot=$destination_items[4];
                              //echo 'show the feedback';
                         }
                     } elseif($answerId>1) {
@@ -330,9 +330,9 @@ if (!empty($choice_value)) {
                             continue;
                         }
                         if ($dbg_local>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
-                        //check the intersection between the oar and the user												
+                        //check the intersection between the oar and the user
                         //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
-                        //echo 'official';print_r($x_list);print_r($y_list);												
+                        //echo 'official';print_r($x_list);print_r($y_list);
                         //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
 
                         //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
@@ -340,14 +340,14 @@ if (!empty($choice_value)) {
 
                         $poly_answer 			= convert_coordinates($delineation_cord,'|');
                         $max_coord 				= poly_get_max($poly_user,$poly_answer); //getting max coordinates
-                        $test = false;                            
+                        $test = false;
                         // if ($answerId == 2 ){$test = true;} for test oars
 
                         if (empty($_GET['hotspot'])) { //no user response
                             $overlap = false;
                         } else {
-                            //	poly_compile really works tested with gnuplot                            
-                            $poly_user_compiled	  	= poly_compile($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1                          						
+                            //	poly_compile really works tested with gnuplot
+                            $poly_user_compiled	  	= poly_compile($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1
                             $poly_answer_compiled 	= poly_compile($poly_answer,$max_coord,$test);
                             $overlap 			  	= poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
                         }
@@ -359,26 +359,26 @@ if (!empty($choice_value)) {
                         } else {
                             if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
 
-                            $organs_at_risk_hit++;  
+                            $organs_at_risk_hit++;
                             //show the feedback
                             $next=1;
-                            $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);                                
-                            $answerDestination=$objAnswerTmp->selectDestination($answerId);                                                                 
+                            $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
+                            $answerDestination=$objAnswerTmp->selectDestination($answerId);
                             $destination_items= explode('@@', $answerDestination);
                             $try_hotspot=$destination_items[1];
                             $lp_hotspot=$destination_items[2];
                             $select_question_hotspot=$destination_items[3];
-                            $url_hotspot=$destination_items[4];                                                                                 
+                            $url_hotspot=$destination_items[4];
                         }
                     }
-                } else {	
-                    // the first delineation feedback		
-                    if ($dbg_local>0) { error_log(__LINE__.' first',0);}							
+                } else {
+                    // the first delineation feedback
+                    if ($dbg_local>0) { error_log(__LINE__.' first',0);}
                     //we send the error
-                }	
+                }
             }
 	}
-	
+
 	if ($overlap_color) {
 		$overlap_color='green';
     } else {
@@ -394,89 +394,89 @@ if (!empty($choice_value)) {
     } else {
 		$excess_color='red';
     }
-    
+
     if (!is_numeric($final_overlap)) {
     	$final_overlap = 0;
     }
-    
+
     if (!is_numeric($final_missing)) {
     	$final_missing = 0;
     }
     if (!is_numeric($final_excess)) {
     	$final_excess = 0;
     }
-    
+
     if ($final_excess>100) {
     	$final_excess = 100;
     }
-    
-    
-	$table_resume = '<table class="data_table" >				
+
+
+	$table_resume = '<table class="data_table" >
 	<tr class="row_odd" >
 		<td></td>
 		<td ><b>'.get_lang('Requirements').'</b></td>
 		<td><b>'.get_lang('YourAnswer').'</b></td>
 	</tr>
-		
+
 	<tr class="row_even">
 		<td><b>'.get_lang('Overlap').'</b></td>
 		<td>'.get_lang('Min').' '.$threadhold1.'</td>
 		<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
 	</tr>
-			
+
 	<tr>
 		<td><b>'.get_lang('Excess').'</b></td>
 		<td>'.get_lang('Max').' '.$threadhold2.'</td>
 		<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
 	</tr>
-			 
+
 	<tr class="row_even">
 		<td><b>'.get_lang('Missing').'</b></td>
 		<td>'.get_lang('Max').' '.$threadhold3.'</td>
 		<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
-	</tr>		
+	</tr>
 	</table>';
-	//var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
-}	
+}
+
 $_SESSION['newquestionList'] = $newquestionList;
 
 $links='';
 
-if ($choice_value == -1) {		
+if ($choice_value == -1) {
     if ($answerType != HOT_SPOT_DELINEATION) {
         $links .= '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a><br />';
     }
 }
 
-if ($answerType != HOT_SPOT_DELINEATION) {  
+if ($answerType != HOT_SPOT_DELINEATION) {
     if (!empty($destination)) {
         $item_list = explode('@@',$destination);
     	//print_R($item_list);
     	$try = $item_list[0];
     	$lp = $item_list[1];
     	$destinationid= $item_list[2];
-    	$url=$item_list[3];    
-    }	
+    	$url=$item_list[3];
+    }
 	$table_resume='';
 } else {
 		$try = $try_hotspot;
 		$lp = $lp_hotspot;
 		$destinationid= $select_question_hotspot;
 		$url=$url_hotspot;
-	if ($organs_at_risk_hit==0 && $wrong_results==false ) { 
+	if ($organs_at_risk_hit==0 && $wrong_results==false ) {
 		// no error = no oar and no wrong result for delineation
 		//show if no error
 		//echo 'no error';
-		$comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);	
-		$answerDestination		 = $objAnswerTmp->selectDestination($nbrAnswers);						
+		$comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
+		$answerDestination		 = $objAnswerTmp->selectDestination($nbrAnswers);
 
 		//we send the error
 		$destination_items= explode('@@', $answerDestination);
 		$try=$destination_items[1];
 		$lp=$destination_items[2];
 		$destinationid=$destination_items[3];
-		$url=$destination_items[4];		
-		$exerciseResult[$questionid] = 1;	
+		$url=$destination_items[4];
+		$exerciseResult[$questionid] = 1;
 	} else {
 		$exerciseResult[$questionid] = 0;
 	}
@@ -484,17 +484,17 @@ if ($answerType != HOT_SPOT_DELINEATION) {
 
 
 // the link to retry the question
-if ($try==1) {	
-	$num_value_array= (array_keys($questionList, $questionid));	
+if ($try==1) {
+	$num_value_array= (array_keys($questionList, $questionid));
 	$links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
 }
 
 // the link to theory (a learning path)
-if (!empty($lp)) {	
+if (!empty($lp)) {
 	$lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
 	require_once('../newscorm/learnpathList.class.php');
-	$list = new LearnpathList(api_get_user_id());	
-	$flat_list = $list->get_flat_list();		
+	$list = new LearnpathList(api_get_user_id());
+	$flat_list = $list->get_flat_list();
 	$links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
 }
 $links.='<br />';
@@ -509,23 +509,23 @@ if ($destinationid==-1) {
 	$links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
 } else {
 	// the link to other question
-	if (in_array($destinationid,$questionList)) { 
+	if (in_array($destinationid,$questionList)) {
 		$objQuestionTmp = Question :: read($destinationid);
 		$questionName=$objQuestionTmp->selectTitle();
-		$num_value_array= (array_keys($questionList, $destinationid));																	
+		$num_value_array= (array_keys($questionList, $destinationid));
 		$links.= Display :: return_icon('quiz.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
 	}
 }
 
 echo '<script>
-		function SendEx(num) { 
-        
-		  	if (num == -1) {	  	
-		  		self.parent.window.location.href = "exercise_result.php?take_session=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'"; 
-		   		self.parent.tb_remove();  	
+		function SendEx(num) {
+
+		  	if (num == -1) {
+		  		self.parent.window.location.href = "exercise_result.php?take_session=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
+		   		self.parent.tb_remove();
 		  	} else {
                 num -= 1;
-		  		self.parent.window.location.href = "exercise_submit.php?tryagain=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'"; 
+		  		self.parent.window.location.href = "exercise_submit.php?tryagain=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
 		   		self.parent.tb_remove();
 		  	}
 		}
@@ -535,41 +535,41 @@ if ($links!='') {
 	echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
     <a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;">'.api_ucfirst(get_lang('Close')).'</a>
 	<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
-	
-	if ($answerType == HOT_SPOT_DELINEATION) {		
+
+	if ($answerType == HOT_SPOT_DELINEATION) {
 		if ($organs_at_risk_hit > 0) {
-			//$message='<p>'.get_lang('YourDelineation').'</p>';								
-			//$message.=$table_resume;					
+			//$message='<p>'.get_lang('YourDelineation').'</p>';
+			//$message.=$table_resume;
 			$message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
 			//if ($wrong_results) { }
 			$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
-			$message.='<p>'.$comment.'</p>';			
-		} else {	
-			$message='<p>'.get_lang('YourDelineation').'</p>';								
-			$message.=$table_resume;	
-			$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';				
-			$message.='<p>'.$comment.'</p>';				
+			$message.='<p>'.$comment.'</p>';
+		} else {
+			$message='<p>'.get_lang('YourDelineation').'</p>';
+			$message.=$table_resume;
+			$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
+			$message.='<p>'.$comment.'</p>';
 		}
 		echo $message;
 	} else {
 		echo '<p>'.$comment.'</p>';
-	}	
+	}
 	echo '<h3>'.$links.'</h3>';
 	echo '</div>';
-    
-	$_SESSION['hot_spot_result']=$message;								
+
+	$_SESSION['hot_spot_result']=$message;
 	$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
 	//reseting the exerciseResult variable
 	Session::write('exerciseResult',$exerciseResult);
-	
+
 	//save this variables just in case the exercise loads an LP with other exercise
 	$_SESSION['objExerciseExtra'.$exerciseId] 	 = $_SESSION['objExercise'];
 	$_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
-	$_SESSION['questionListExtra'.$exerciseId]	 = $_SESSION['questionList'];	 
+	$_SESSION['questionListExtra'.$exerciseId]	 = $_SESSION['questionList'];
 } else {
 	$questionNum++;
 	echo '<script>
-			self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";	  		 	
-   			//self.parent.tb_remove();	  	
- 	 	</script>';	
+			self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
+   			//self.parent.tb_remove();
+ 	 	</script>';
 }

+ 223 - 226
main/exercice/global_multiple_answer.class.php

@@ -1,255 +1,252 @@
 <?php
 /* For licensing terms, see /license.txt */
-if (!class_exists('GlobalMultipleAnswer')):
 
-    class GlobalMultipleAnswer extends Question {
+class GlobalMultipleAnswer extends Question {
 
-        static $typePicture = 'mcmagl.gif';
-        static $explanationLangVar = 'GlobalMultipleAnswer';
+    static $typePicture = 'mcmagl.gif';
+    static $explanationLangVar = 'GlobalMultipleAnswer';
 
-        /* Constructor */
+    /* Constructor */
 
-        function GlobalMultipleAnswer() {
-            parent::question();
-            $this->type = GLOBAL_MULTIPLE_ANSWER;
-            $this->isContent = $this->getIsContent();
+    function GlobalMultipleAnswer() {
+        parent::question();
+        $this->type = GLOBAL_MULTIPLE_ANSWER;
+        $this->isContent = $this->getIsContent();
+    }
+
+    /**
+     * function which redifines Question::createAnswersForm
+     * @param the formvalidator instance
+     * @param the answers number to display
+     */
+    function createAnswersForm($form) {
+
+        $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
+        $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
+
+        $obj_ex = $_SESSION['objExercise'];
+
+        /* Mise en variable de Affichage "Reponses" et son icone, "N�", "Vrai", "Reponse" */
+        $html = '<table class="data_table">
+                <tr>
+                    <th width="10px">
+                        ' . get_lang('Number') . '
+                    </th>
+                    <th width="10px">
+                        ' . get_lang('True') . '
+                    </th>
+                    <th width="50%">
+                        ' . get_lang('Answer') . '
+                    </th>';
+
+        // Espace entre l'entete et les r�ponses
+        if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
+            $html .='<th>' . get_lang('Comment') . '</th>';
         }
+        $html .='</tr>';
 
-        /**
-         * function which redifines Question::createAnswersForm
-         * @param the formvalidator instance
-         * @param the answers number to display
-         */
-        function createAnswersForm($form) {
-
-            $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
-            $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
-
-            $obj_ex = $_SESSION['objExercise'];
-
-            /* Mise en variable de Affichage "Reponses" et son icone, "N�", "Vrai", "Reponse" */
-            $html = '<table class="data_table">
-					<tr>
-						<th width="10px">
-							' . get_lang('Number') . '
-						</th>
-						<th width="10px">
-							' . get_lang('True') . '
-						</th>
-						<th width="50%">
-							' . get_lang('Answer') . '
-						</th>';
-
-            // Espace entre l'entete et les r�ponses					
-            if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
-                $html .='<th>' . get_lang('Comment') . '</th>';
-            }
-            $html .='</tr>';
-            
-            
-            $form->addElement('label', get_lang('Answers') . '<br /> <img src="../img/fill_field.png">', $html);
-
-            /* Initialiation variable */
-            $defaults = array();
-            $correct = 0;
-
-            /* Mise en variable du nombre de reponse */
-            if (!empty($this->id)) {
-                $answer = new Answer($this->id);
-                $answer->read();
-                if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
-                    $nb_answers = $answer->nbrAnswers;
-                }
-            }
 
-            #le nombre de r�ponses est bien enregistr� sous la forme int(nb)
+        $form->addElement('label', get_lang('Answers') . '<br /> <img src="../img/fill_field.png">', $html);
 
-            /* Ajout mise en forme nb reponse */
-            $form->addElement('hidden', 'nb_answers');
-            $boxes_names = array();
+        /* Initialiation variable */
+        $defaults = array();
+        $correct = 0;
 
-            /* V�rification : Cr�action d'au moins une r�ponse */
-            if ($nb_answers < 1) {
-                $nb_answers = 1;
-                Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
+        /* Mise en variable du nombre de reponse */
+        if (!empty($this->id)) {
+            $answer = new Answer($this->id);
+            $answer->read();
+            if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
+                $nb_answers = $answer->nbrAnswers;
             }
+        }
+
+        #le nombre de r�ponses est bien enregistr� sous la forme int(nb)
+
+        /* Ajout mise en forme nb reponse */
+        $form->addElement('hidden', 'nb_answers');
+        $boxes_names = array();
+
+        /* V�rification : Cr�action d'au moins une r�ponse */
+        if ($nb_answers < 1) {
+            $nb_answers = 1;
+            Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
+        }
+
+        //D�but affichage score global dans la modification d'une question
+        $scoreA = "0"; //par reponse
+        $scoreG = "0"; //Global
 
-            //D�but affichage score global dans la modification d'une question
-            $scoreA = "0"; //par reponse
-            $scoreG = "0"; //Global
-
-            /* boucle pour sauvegarder les donn�es dans le tableau defaults */
-            for ($i = 1; $i <= $nb_answers; ++$i) {
-                /* si la reponse est de type objet */
-                if (is_object($answer)) {
-                    $defaults['answer[' . $i . ']'] = $answer->answer[$i];
-                    $defaults['comment[' . $i . ']'] = $answer->comment[$i];
-                    $defaults['correct[' . $i . ']'] = $answer->correct[$i];
-
-                    //------------- D�but
-                    $scoreA = $answer->weighting[$i];
-                }
-                if ($scoreA > 0) {
-                    $scoreG = $scoreG + $scoreA;
-                }
-                //------------- Fin
-                //------------- Debut si un des scores par reponse est egal � 0 : la coche vaut 1 (coch�)
-                if ($scoreA == 0)
-                    $defaults['pts'] = 1;
-                else
-                    $defaults['pts'] = 0;
-
-                $renderer = & $form->defaultRenderer();			
-            
-                $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct['.$i.']');  
-                $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');  
-                $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');  
-                $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment['.$i.']');  
-                //$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting['.$i.']');        
-
-                $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
-                $answer_number->freeze();
-
-                $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"');
-                $boxes_names[] = 'correct[' . $i . ']';
-
-                $form->addElement('html_editor', 'answer[' . $i . ']', null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
-                $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
-
-                // show comment when feedback is enable
-                if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
-                    $form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
-                }
-
-                $form->addElement('html', '</tr>');
+        /* boucle pour sauvegarder les donn�es dans le tableau defaults */
+        for ($i = 1; $i <= $nb_answers; ++$i) {
+            /* si la reponse est de type objet */
+            if (is_object($answer)) {
+                $defaults['answer[' . $i . ']'] = $answer->answer[$i];
+                $defaults['comment[' . $i . ']'] = $answer->comment[$i];
+                $defaults['correct[' . $i . ']'] = $answer->correct[$i];
+
+                //------------- D�but
+                $scoreA = $answer->weighting[$i];
             }
-            //--------- Mise en variable du score global lors d'une modification de la question/r�ponse
-            $defaults['weighting[1]'] = (round($scoreG));
-
-            $form->addElement('html', '</div></div></table>');
-            
-            //$form -> addElement ('html', '<br />');
-            $form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
-
-            //only 1 answer the all deal ...
-            $form->addElement('text', 'weighting[1]', get_lang('Score'));
-
-            global $pts;
-            //--------- Creation coche pour ne pas prendre en compte les n�gatifs
-            $form->addElement('checkbox', 'pts', '', get_lang('NoNegativeScore'));
-            $form->addElement('html', '<br />');
-            
-            // Affiche un message si le score n'est pas renseign�
-            $form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
-
-            $navigator_info = api_get_navigator();
-            global $text, $class;
-
-            //ie6 fix
-            if ($obj_ex->edit_exercise_in_lp == true) {
-                if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-                    $form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="minus"');
-                    $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="plus"');
-                    $form->addElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
-                } else {
-                    $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'), 'class="minus"');
-                    $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'), 'class="plus"');
-                    $form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
-                    // setting the save button here and not in the question class.php
-                }
+            if ($scoreA > 0) {
+                $scoreG = $scoreG + $scoreA;
             }
-            $renderer->setElementTemplate('{element}&nbsp;', 'lessAnswers');
-            $renderer->setElementTemplate('{element}&nbsp;', 'submitQuestion');
-            $renderer->setElementTemplate('{element}', 'moreAnswers');
-            
-            $form->addElement('html', '</div></div>');
+            //------------- Fin
+            //------------- Debut si un des scores par reponse est egal � 0 : la coche vaut 1 (coch�)
+            if ($scoreA == 0)
+                $defaults['pts'] = 1;
+            else
+                $defaults['pts'] = 0;
 
-            $defaults['correct'] = $correct;
+            $renderer = & $form->defaultRenderer();
 
-            if (!empty($this->id)) {
-                $form->setDefaults($defaults);
-            } else {
-                if ($this->isContent == 1) {
-                    $form->setDefaults($defaults);
-                }
+            $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct['.$i.']');
+            $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');
+            $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');
+            $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment['.$i.']');
+            //$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting['.$i.']');
+
+            $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
+            $answer_number->freeze();
+
+            $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"');
+            $boxes_names[] = 'correct[' . $i . ']';
+
+            $form->addElement('html_editor', 'answer[' . $i . ']', null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
+            $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
+
+            // show comment when feedback is enable
+            if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
+                $form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
             }
-            $form->setConstants(array('nb_answers' => $nb_answers));
+
+            $form->addElement('html', '</tr>');
         }
+        //--------- Mise en variable du score global lors d'une modification de la question/r�ponse
+        $defaults['weighting[1]'] = (round($scoreG));
+
+        $form->addElement('html', '</div></div></table>');
+
+        //$form -> addElement ('html', '<br />');
+        $form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
 
-        /**
-         * abstract function which creates the form to create / edit the answers of the question
-         * @param the formvalidator instance
-         * @param the answers number to display
-         */
-        function processAnswersCreation($form) {
-            $questionWeighting = $nbrGoodAnswers = 0;
-            $objAnswer = new Answer($this->id);
-            $nb_answers = $form->getSubmitValue('nb_answers');
-
-            // Score total
-            $answer_score = trim($form->getSubmitValue('weighting[1]'));
-
-            // Reponses correctes
-            $nbr_corrects = 0;
-            for ($i = 1; $i <= $nb_answers; $i++) {
-                $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
-                if ($goodAnswer) {
-                    $nbr_corrects++;
-                }
+        //only 1 answer the all deal ...
+        $form->addElement('text', 'weighting[1]', get_lang('Score'));
+
+        global $pts;
+        //--------- Creation coche pour ne pas prendre en compte les n�gatifs
+        $form->addElement('checkbox', 'pts', '', get_lang('NoNegativeScore'));
+        $form->addElement('html', '<br />');
+
+        // Affiche un message si le score n'est pas renseign�
+        $form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
+
+        $navigator_info = api_get_navigator();
+        global $text, $class;
+
+        //ie6 fix
+        if ($obj_ex->edit_exercise_in_lp == true) {
+            if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
+                $form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="minus"');
+                $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="plus"');
+                $form->addElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
+            } else {
+                $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'), 'class="minus"');
+                $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'), 'class="plus"');
+                $form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
+                // setting the save button here and not in the question class.php
             }
-            // Set question weighting (score total)
-            $questionWeighting = $answer_score;
-
-            // Set score per answer
-            $nbr_corrects = $nbr_corrects == 0 ? 1 : $nbr_corrects;
-            $answer_score = $nbr_corrects == 0 ? 0 : $answer_score;
-            //echo('affiche1');var_dump($answer_score);echo('<br>');
-
-            $answer_score = ($answer_score / $nbr_corrects);
-            //echo('affiche2');var_dump($answer_score);echo('<br>');
-            //$answer_score �quivaut � la valeur d'une bonne r�ponse
-            // cr�ation variable pour r�cuperer la valeur de la coche pour la prise en compte des n�gatifs
-            $test = "";
-            $test = $form->getSubmitValue('pts');
-
-            for ($i = 1; $i <= $nb_answers; $i++) {
-                $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
-                $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
-                $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
-
-                if ($goodAnswer) {
-                    $weighting = abs($answer_score);
-                } else {
-                    if ($test == 1) {
-                        $weighting = 0;
-                    }else
-                        $weighting = -abs($answer_score);
-                }
-
-                $objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i);
+        }
+        $renderer->setElementTemplate('{element}&nbsp;', 'lessAnswers');
+        $renderer->setElementTemplate('{element}&nbsp;', 'submitQuestion');
+        $renderer->setElementTemplate('{element}', 'moreAnswers');
+
+        $form->addElement('html', '</div></div>');
+
+        $defaults['correct'] = $correct;
+
+        if (!empty($this->id)) {
+            $form->setDefaults($defaults);
+        } else {
+            if ($this->isContent == 1) {
+                $form->setDefaults($defaults);
             }
-            // saves the answers into the data base
-            $objAnswer->save();
+        }
+        $form->setConstants(array('nb_answers' => $nb_answers));
+    }
 
-            // sets the total weighting of the question --> sert � donner le score total pendant l'examen
-            $this->updateWeighting($questionWeighting);
-            $this->save();
+    /**
+     * abstract function which creates the form to create / edit the answers of the question
+     * @param the formvalidator instance
+     * @param the answers number to display
+     */
+    function processAnswersCreation($form) {
+        $questionWeighting = $nbrGoodAnswers = 0;
+        $objAnswer = new Answer($this->id);
+        $nb_answers = $form->getSubmitValue('nb_answers');
+
+        // Score total
+        $answer_score = trim($form->getSubmitValue('weighting[1]'));
+
+        // Reponses correctes
+        $nbr_corrects = 0;
+        for ($i = 1; $i <= $nb_answers; $i++) {
+            $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
+            if ($goodAnswer) {
+                $nbr_corrects++;
+            }
         }
+        // Set question weighting (score total)
+        $questionWeighting = $answer_score;
+
+        // Set score per answer
+        $nbr_corrects = $nbr_corrects == 0 ? 1 : $nbr_corrects;
+        $answer_score = $nbr_corrects == 0 ? 0 : $answer_score;
+
+        $answer_score = ($answer_score / $nbr_corrects);
+
+        //$answer_score �quivaut � la valeur d'une bonne r�ponse
+        // cr�ation variable pour r�cuperer la valeur de la coche pour la prise en compte des n�gatifs
+        $test = "";
+        $test = $form->getSubmitValue('pts');
+
+        for ($i = 1; $i <= $nb_answers; $i++) {
+            $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
+            $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
+            $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
 
-        function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
-            $header = parent::return_header($feedback_type, $counter, $score, $show_media);
-            $header .= '<table class="'.$this->question_table_class .'">			
-			<tr>
-				<th>' . get_lang("Choice") . '</th>
-				<th>' . get_lang("ExpectedChoice") . '</th>
-				<th>' . get_lang("Answer") . '</th>';
-            if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
-                $header .= '<th>' . get_lang("Comment") . '</th>';
+            if ($goodAnswer) {
+                $weighting = abs($answer_score);
             } else {
-                $header .= '<th>&nbsp;</th>';
+                if ($test == 1) {
+                    $weighting = 0;
+                }else
+                    $weighting = -abs($answer_score);
             }
-            $header .= '</tr>';
-            return $header;
+
+            $objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i);
+        }
+        // saves the answers into the data base
+        $objAnswer->save();
+
+        // sets the total weighting of the question --> sert � donner le score total pendant l'examen
+        $this->updateWeighting($questionWeighting);
+        $this->save();
+    }
+
+    function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
+        $header = parent::return_header($feedback_type, $counter, $score, $show_media);
+        $header .= '<table class="'.$this->question_table_class .'">
+        <tr>
+            <th>' . get_lang("Choice") . '</th>
+            <th>' . get_lang("ExpectedChoice") . '</th>
+            <th>' . get_lang("Answer") . '</th>';
+        if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
+            $header .= '<th>' . get_lang("Comment") . '</th>';
+        } else {
+            $header .= '<th>&nbsp;</th>';
         }
+        $header .= '</tr>';
+        return $header;
     }
-endif;
+}

+ 0 - 7
main/gradebook/lib/be/category.class.php

@@ -653,12 +653,6 @@ class Category implements GradebookItem
 		$rescount     = 0;
 		$ressum       = 0;
 		$weightsum    = 0;
-        /*$debug = false;
-
-        if ($stud_id == 11) {
-            $debug = true;
-        }
-        if ($debug) var_dump($links);*/
 
 		if (!empty($cats)) {
 			foreach ($cats as $cat) {
@@ -691,7 +685,6 @@ class Category implements GradebookItem
 		if (!empty($links)) {
 			foreach ($links as $link) {
 				$linkres = $link->calc_score($stud_id);
-                //if ($debug) var_dump($linkres);
 
 				if (isset($linkres) && $link->get_weight() != 0) {
 					$linkweight     = $link->get_weight();

+ 26 - 27
main/gradebook/lib/fe/linkaddeditform.class.php

@@ -52,7 +52,7 @@ class LinkAddEditForm extends FormValidator
 			if ($link->needs_name_and_description()) {
 				$this->add_textfield('name', get_lang('Name'), true, array('size'=>'40', 'maxlength'=>'40'));
 			} else {
-				$select = $this->addElement('select', 'select_link', get_lang('ChooseItem'));				
+				$select = $this->addElement('select', 'select_link', get_lang('ChooseItem'));
 				foreach ($link->get_all_links() as $newlink) {
 					$select->addoption($newlink[1],$newlink[0]);
 				}
@@ -61,20 +61,20 @@ class LinkAddEditForm extends FormValidator
 			$this->addElement('label',get_lang('Name'),  '<span class="freeze">'.$link->get_name().' ['.$link->get_type_name().']</span>');
 			$this->addElement('hidden','name_link',$link->get_name(),array('id'=>'name_link'));
 		}
-        
+
         if (count($category_object) == 1) {
             $this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id());
-        } else {         
-            $select_gradebook = $this->addElement('select', 'select_gradebook', get_lang('SelectGradebook'), array(), array('id' => 'hide_category_id'));            
+        } else {
+            $select_gradebook = $this->addElement('select', 'select_gradebook', get_lang('SelectGradebook'), array(), array('id' => 'hide_category_id'));
             $this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero');
 
             $default_weight = 0;
-            if (!empty($category_object)) {         
-                foreach ($category_object as $my_cat) {                
+            if (!empty($category_object)) {
+                foreach ($category_object as $my_cat) {
                     if ($my_cat->get_course_code() == api_get_course_id()) {
                         $grade_model_id = $my_cat->get_grade_model_id();
                         if (empty($grade_model_id)) {
-                        
+
                             if ($my_cat->get_parent_id() == 0 ) {
                                 $default_weight = $my_cat->get_weight();
                                 $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id());
@@ -85,49 +85,48 @@ class LinkAddEditForm extends FormValidator
                             $select_gradebook->addoption(get_lang('Select'), 0);
                         }
                         if ($link->get_category_id() == $my_cat->get_id()) {
-                            $default_weight = $my_cat->get_weight();                        
+                            $default_weight = $my_cat->get_weight();
                         }
                     }
                 }
             }
         }
-        
+
 		$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$category_object[0]->get_weight().'] '), true, array (
 			'size' => '4',
 			'maxlength' => '5',
             'class' => 'span1'
 		));
-        
-        $this->addElement('hidden', 'weight');        
-        
+
+        $this->addElement('hidden', 'weight');
+
         /*
-        
+
 		// ELEMENT: weight
         $this->add_textfield('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
             'size' => '4',
             'maxlength' => '5',
             'class' => 'span1'
         ));*/
-        
+
 		$this->addRule('weight_mask',get_lang('OnlyNumbers'),'numeric');
 		$this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
-		if ($form_type == self :: TYPE_EDIT) {            
+		if ($form_type == self :: TYPE_EDIT) {
             $parent_cat = Category :: load($link->get_category_id());
-            
+
             if ($parent_cat[0]->get_parent_id() == 0) {
-                $values['weight'] = $link->get_weight();                
+                $values['weight'] = $link->get_weight();
             } else {
                 $cat = Category :: load($parent_cat[0]->get_parent_id());
                 //$global_weight = $cat[0]->get_weight();
                 //$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
-                //var_dump($global_weight, $link->get_weight(), $parent_cat[0]->get_weight());
                 //$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight;
                 //$values['weight'] = $weight;
-                $values['weight'] = $link->get_weight() ;                
-            }			
-            $defaults['weight_mask'] = $values['weight'] ;   
+                $values['weight'] = $link->get_weight() ;
+            }
+            $defaults['weight_mask'] = $values['weight'] ;
             $defaults['select_gradebook'] = $link->get_category_id();
-            
+
 		}
 		// ELEMENT: max
 		if ($link->needs_max()) {
@@ -161,7 +160,7 @@ class LinkAddEditForm extends FormValidator
 		if ($form_type == self :: TYPE_EDIT) {
 			$defaults['visible'] = $link->is_visible();
 		}
-		
+
 		// ELEMENT: add results
 		if ($form_type == self :: TYPE_ADD && $link->needs_results()) {
 			$this->addElement('checkbox', 'addresult', get_lang('AddResult'));
@@ -172,13 +171,13 @@ class LinkAddEditForm extends FormValidator
 		} else {
 			$this->addElement('style_submit_button', 'submit', get_lang('LinkMod'),'class="save"');
 		}
-        
+
         if ($form_type == self :: TYPE_ADD) {
-            $setting = api_get_setting('tool_visible_by_default_at_creation');   
+            $setting = api_get_setting('tool_visible_by_default_at_creation');
             $visibility_default = 1;
-            if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {            
+            if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
                 $visibility_default = 0;
-            }            
+            }
             $defaults['visible']  = $visibility_default;
         }
 

+ 126 - 126
main/gradebook/lib/flatview_data_generator.class.php

@@ -21,7 +21,7 @@ class FlatViewDataGenerator
 	private $users;
 	private $evals;
 	private $links;
-	private $evals_links;	
+	private $evals_links;
     public $params;
 	public  $category = array();
 
@@ -54,32 +54,32 @@ class FlatViewDataGenerator
 	 * Get array containing column header names (incl user columns)
 	 */
 	public function get_header_names($items_start = 0, $items_count = null , $show_detail = false) {
-		$headers = array();        
-                
+		$headers = array();
+
         if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {
             $headers[] = get_lang('OfficialCode');
-        }        
+        }
         if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) {
             if (api_is_western_name_order()) {
-                $headers[] = get_lang('FirstnameAndLastname');	
+                $headers[] = get_lang('FirstnameAndLastname');
             } else {
-                $headers[] = get_lang('LastnameAndFirstname');	
+                $headers[] = get_lang('LastnameAndFirstname');
             }
         } else {
             if (api_is_western_name_order()) {
                 $headers[] = get_lang('FirstName');
-                $headers[] = get_lang('LastName');                
+                $headers[] = get_lang('LastName');
             } else {
                 $headers[] = get_lang('LastName');
-                $headers[] = get_lang('FirstName');                
+                $headers[] = get_lang('FirstName');
             }
         }
 		if (!isset($items_count)) {
 			$items_count = count($this->evals_links) - $items_start;
 		}
-        
+
         $parent_id = $this->category->get_parent_id();
-        
+
         if ($parent_id == 0) {
             $main_weight  = $this->category->get_weight();
             $grade_model_id = $this->category->get_grade_model_id();
@@ -87,35 +87,35 @@ class FlatViewDataGenerator
             $main_cat  = Category::load($parent_id, null, null);
             $main_weight = $main_cat[0]->get_weight();
             $grade_model_id = $main_cat[0]->get_grade_model_id();
-        }  
-        
+        }
+
         $use_grade_model = true;
         if (empty($grade_model_id) || $grade_model_id == -1) {
-            $use_grade_model = false;    
+            $use_grade_model = false;
         }
-		        
+
 		//@todo move these in a function
 		$sum_categories_weight_array = array();
 		if (isset($this->category) && !empty($this->category)) {
-			$categories = Category::load(null, null, null, $this->category->get_id());            
+			$categories = Category::load(null, null, null, $this->category->get_id());
 			if (!empty($categories)) {
-			    foreach ($categories as $category) {			         
+			    foreach ($categories as $category) {
 				    $sum_categories_weight_array[$category->get_id()] = $category->get_weight();
                 }
 			} else {
-			    $sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight();                
+			    $sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight();
 			}
 		}
-        
+
         //No category was added
-        
-        $course_code 	= api_get_course_id();            
+
+        $course_code 	= api_get_course_id();
         $session_id		= api_get_session_id();
 
         $allcat  = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id');
-                    
-        if ($parent_id == 0 && !empty($allcat)) {             
-            
+
+        if ($parent_id == 0 && !empty($allcat)) {
+
             //Means there are any subcategory
             foreach ($allcat as $sub_cat) {
                 $sub_cat_weight = 100*$sub_cat->get_weight()/$main_weight;
@@ -123,30 +123,30 @@ class FlatViewDataGenerator
                 if (isset($this->params['export_pdf']) && $this->params['export_pdf']) {
                    $add_weight = null;
                 }
-                $headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).$add_weight;                    
+                $headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).$add_weight;
             }
         } else {
             if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
                 for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
-                    $item = $this->evals_links[$count + $items_start];                    
-                    $weight = 100*$item->get_weight()/$main_weight;                    
-                    $headers[] = $item->get_name().' '.$weight.' % ';                
+                    $item = $this->evals_links[$count + $items_start];
+                    $weight = 100*$item->get_weight()/$main_weight;
+                    $headers[] = $item->get_name().' '.$weight.' % ';
                 }
-            }            
+            }
         }
         $headers[] = api_strtoupper(get_lang('GradebookQualificationTotal'));
 		return $headers;
 	}
-	
-	function get_max_result_by_link($id) {						
+
+	function get_max_result_by_link($id) {
 		$max = 0;
 		foreach ($this->users as $user) {
-			$item  = $this->evals_links [$id];					
-			$score = $item->calc_score($user[0]);			
+			$item  = $this->evals_links [$id];
+			$score = $item->calc_score($user[0]);
 			if ($score[0] > $max) {
 				$max = $score[0];
-			}			
-		}		
+			}
+		}
 		return $max ;
 	}
 
@@ -163,7 +163,7 @@ class FlatViewDataGenerator
 			$headers[] = $item->get_name();
 		}
 		return $headers;
-	}		
+	}
 
 	/**
 	 * Get actual array data
@@ -176,28 +176,28 @@ class FlatViewDataGenerator
 	public function get_data ($users_sorting = 0, $users_start = 0, $users_count = null,
 							  $items_start = 0, $items_count = null,
 							  $ignore_score_color = false, $show_all = false) {
-		
+
 		// do some checks on users/items counts, redefine if invalid values
 		if (!isset($users_count)) {
 			$users_count = count ($this->users) - $users_start;
 		}
 		if ($users_count < 0) {
 			$users_count = 0;
-		}        
+		}
 		if (!isset($items_count)) {
 			$items_count = count ($this->evals) + count ($this->links) - $items_start;
 		}
 		if ($items_count < 0) {
 			$items_count = 0;
 		}
-        
+
 		// copy users to a new array that we will sort
 		// TODO - needed ?
 		$usertable = array ();
 		foreach ($this->users as $user) {
 			$usertable[] = $user;
 		}
-        
+
 		// sort users array
 		if ($users_sorting & self :: FVDG_SORT_LASTNAME) {
 			usort($usertable, array ('FlatViewDataGenerator','sort_by_last_name'));
@@ -211,7 +211,7 @@ class FlatViewDataGenerator
 
 		// select the requested users
 		$selected_users = array_slice($usertable, $users_start, $users_count);
-        
+
 		// generate actual data array
 		$scoredisplay = ScoreDisplay :: instance();
 
@@ -221,21 +221,21 @@ class FlatViewDataGenerator
 			$displaytype |= SCORE_IGNORE_SPLIT;
 		}
 		//@todo move these in a function
-		$sum_categories_weight_array = array();     
-        
-        if (isset($this->category) && !empty($this->category)) {            
+		$sum_categories_weight_array = array();
+
+        if (isset($this->category) && !empty($this->category)) {
             $categories = Category::load(null, null, null, $this->category->get_id());
             if (!empty($categories)) {
-                foreach($categories as $category) {                  
+                foreach($categories as $category) {
                     $sum_categories_weight_array[$category->get_id()] = $category->get_weight();
                 }
             } else {
                 $sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight();
             }
         }
-        
+
         $parent_id = $this->category->get_parent_id();
-        
+
         if ($parent_id == 0) {
             $main_weight  = $this->category->get_weight();
             $grade_model_id = $this->category->get_grade_model_id();
@@ -243,170 +243,170 @@ class FlatViewDataGenerator
             $main_cat  = Category::load($parent_id, null, null);
             $main_weight = $main_cat[0]->get_weight();
             $grade_model_id = $main_cat[0]->get_grade_model_id();
-        }        
-                
+        }
+
         $use_grade_model = true;
         if (empty($grade_model_id) || $grade_model_id == -1) {
-            $use_grade_model = false;    
-        }        
-        
+            $use_grade_model = false;
+        }
+
         $export_to_pdf = false;
-        if (isset($this->params['export_pdf']) && $this->params['export_pdf']) {     
+        if (isset($this->params['export_pdf']) && $this->params['export_pdf']) {
             $export_to_pdf = true;
         }
-                
-		foreach ($selected_users as $user) {             
-			$row = array();     
+
+		foreach ($selected_users as $user) {
+			$row = array();
             if ($export_to_pdf) {
                 $row['user_id'] = $user_id = $user[0];	//user id
             } else {
                 $row[] = $user_id = $user[0];	//user id
             }
-            
-            if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {       
+
+            if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {
                 if ($export_to_pdf) {
                     $row['official_code'] = $user[4];	//official code
                 } else {
                     $row[] = $user[4];	//official code
                 }
             }
-            
-            if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) {       
+
+            if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) {
                 if ($export_to_pdf) {
-                    $row['name'] = api_get_person_name($user[3], $user[2]);	//last name			
+                    $row['name'] = api_get_person_name($user[3], $user[2]);	//last name
                 } else {
-                    $row[] = api_get_person_name($user[3], $user[2]);	//last name			
+                    $row[] = api_get_person_name($user[3], $user[2]);	//last name
                 }
             } else {
                 if ($export_to_pdf) {
                     if (api_is_western_name_order()) {
                         $row['firstname']   = $user[3];
-                        $row['lastname']    = $user[2];                        
+                        $row['lastname']    = $user[2];
                     } else {
                         $row['lastname']    = $user[2];
                         $row['firstname']   = $user[3];
                     }
                 } else {
                     if (api_is_western_name_order()) {
-                        $row[]   = $user[3];	//first name    
-                        $row[]   = $user[2];	//last name                        
+                        $row[]   = $user[3];	//first name
+                        $row[]   = $user[2];	//last name
                     } else {
                         $row[]   = $user[2];	//last name
-                        $row[]   = $user[3];	//first name                            
+                        $row[]   = $user[3];	//first name
                     }
                 }
             }
-          
+
 			$item_value = 0;
             $item_value_total = 0;
 			$item_total = 0;
-            
+
             $convert_using_the_global_weight = true;
-            
-            $course_code 	= api_get_course_id();            
+
+            $course_code 	= api_get_course_id();
             $session_id		= api_get_session_id();
             $allcat         = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id');
 
             if ($parent_id == 0 && !empty($allcat)) {
-                                                
+
                 foreach ($allcat as $sub_cat) {
                     $score 			= $sub_cat->calc_score($user_id);
                     $real_score     = $score;
-                    $divide			= ( ($score[1])==0 ) ? 1 : $score[1];      
-                    
+                    $divide			= ( ($score[1])==0 ) ? 1 : $score[1];
+
                     $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
                     $item_value     = $score[0]/$divide*$main_weight;
 
-                    //Fixing total when using one or multiple gradebooks                    
+                    //Fixing total when using one or multiple gradebooks
                     $percentage     = $sub_cat->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight();
-                    $item_value     = $percentage*$item_value;                    
+                    $item_value     = $percentage*$item_value;
                     $item_total		+= $sub_cat->get_weight();
-                    
-                    if ($convert_using_the_global_weight) {                                             
-                        $score[0] = $score[0]/$main_weight*$sub_cat->get_weight();                        
+
+                    if ($convert_using_the_global_weight) {
+                        $score[0] = $score[0]/$main_weight*$sub_cat->get_weight();
                         $score[1] = $main_weight ;
-                    }                    
-                                        
+                    }
+
                     if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
                     //if (true) {
-                        $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);    
-                        $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);                        
+                        $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);
+                        $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
                         $temp_score = Display::tip($real_score, $temp_score);
-                    } else {                        
-                        $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);                    
+                    } else {
+                        $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
                         $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
                         $temp_score = Display::tip($temp_score, $real_score);
-                    }                    
-                    
+                    }
+
                     if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
                         if (!$show_all) {
-                           $row[] = $temp_score.' ';   
-                        } else {                 
+                           $row[] = $temp_score.' ';
+                        } else {
                            $row[] = $temp_score;
-                        }                    
+                        }
                     }
-                    $item_value_total +=$item_value;    
+                    $item_value_total +=$item_value;
                 }
                 if ($convert_using_the_global_weight) {
                     //$item_total = $main_weight;
                 }
             } else  {
                 for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
-                    $item  			= $this->evals_links[$count + $items_start];                    
+                    $item  			= $this->evals_links[$count + $items_start];
                     $score 			= $item->calc_score($user_id);
                     $real_score     = $score;
                     $divide			= ( ($score[1])==0 ) ? 1 : $score[1];
-                    
+
                     //sub cat weight
                     $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
 
                     $item_value     = $score[0]/$divide;
-                    
-                    //Fixing total when using one or multiple gradebooks 
-                    if ($this->category->get_parent_id() == 0 ) {                        
+
+                    //Fixing total when using one or multiple gradebooks
+                    if ($this->category->get_parent_id() == 0 ) {
                         $item_value     = $score[0]/$divide*$item->get_weight();
                     } else {
-                        $item_value     = $item_value*$item->get_weight();                         
+                        $item_value     = $item_value*$item->get_weight();
                     }
-                    
-                    $item_total     += $item->get_weight();                    
+
+                    $item_total     += $item->get_weight();
                     /*
-                    $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);                    
-                    $temp_score  = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);                    
+                    $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
+                    $temp_score  = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);
                     $temp_score = Display::tip($temp_score, $complete_score);*/
-                    
+
                     //if (true) {
                     if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
-                        $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);    
-                        $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);                        
+                        $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);
+                        $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);
                         $temp_score = Display::tip($real_score, $temp_score);
-                    } else {                                             
-                        $temp_score     = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);                    
+                    } else {
+                        $temp_score     = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);
                         $temp_score = Display::tip($temp_score, $complete_score);
                     }
-                    
+
                     if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
-                        if (!$show_all) {                            
-                            if (in_array($item->get_type() , array(LINK_EXERCISE, LINK_DROPBOX, LINK_STUDENTPUBLICATION, 
+                        if (!$show_all) {
+                            if (in_array($item->get_type() , array(LINK_EXERCISE, LINK_DROPBOX, LINK_STUDENTPUBLICATION,
                                                                    LINK_LEARNPATH, LINK_FORUM_THREAD,  LINK_ATTENDANCE,LINK_SURVEY))) {
                                 if (!empty($score[0])) {
-                                   $row[] = $temp_score.' ';                                        
+                                   $row[] = $temp_score.' ';
                                 } else {
                                    $row[] = '';
                                 }
-                            } else {                                
+                            } else {
                                 $row[] = $temp_score.' ';
-                            }					
-                        } else {                         
-                           $row[] = $temp_score;                           
-                        }          
-                    }                    
+                            }
+                        } else {
+                           $row[] = $temp_score;
+                        }
+                    }
                     $item_value_total +=$item_value;
                 }
                 $item_total = $main_weight;
-            }            
-			$total_score = array($item_value_total, $item_total);            
-            
+            }
+			$total_score = array($item_value_total, $item_total);
+
 			if (!$show_all) {
                 if ($export_to_pdf) {
                     $row['total'] = $scoredisplay->display_score($total_score);
@@ -420,10 +420,10 @@ class FlatViewDataGenerator
                     $row[] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS);
                 }
 			}
-			unset($score); 
-            //var_dump($row);exit;
+			unset($score);
+
 			$data[] = $row;
-		}        
+		}
 		return $data;
 	}
 
@@ -443,7 +443,7 @@ class FlatViewDataGenerator
 			$row = array ();
 			for ($count=0;$count < count($this->evals_links); $count++) {
 				$item = $this->evals_links [$count];
-				$score = $item->calc_score($user[0]);				
+				$score = $item->calc_score($user[0]);
 				$porcent_score = isset($score[1]) &&  $score[1] > 0 ? ($score[0]*100)/$score[1] :0;
 				$row[$item->get_name()] = $porcent_score;
 			}
@@ -487,7 +487,7 @@ class FlatViewDataGenerator
 		usort($usertable, array ('FlatViewDataGenerator','sort_by_first_name'));
 
 		$data = array ();
-		
+
 		$selected_users = $usertable;
 		foreach ($selected_users as $user) {
 			$row = array ();
@@ -498,19 +498,19 @@ class FlatViewDataGenerator
 			for ($count=0;$count < count($this->evals_links); $count++) {
 				$item = $this->evals_links[$count];
 				$score = $item->calc_score($user[0]);
-			
+
 				$divide =( ($score[1])==0 ) ? 1 : $score[1];
                 $item_value += $score[0]/$divide*$item->get_weight();
 				$item_total += $item->get_weight();
-				
-				
+
+
 				$score_denom = ($score[1]==0) ? 1 : $score[1];
 				$score_final = ($score[0] / $score_denom) * 100;
 				$row[] = $score_final;
 			}
 			$total_score = array($item_value, $item_total);
 			$score_final = ($item_value / $item_total) * 100;
-			
+
 			$row[] = $score_final;
 			$data[] = $row;
 		}

+ 0 - 2
main/gradebook/lib/gradebook_functions.inc.php

@@ -764,7 +764,6 @@ function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array(
 
     if ($has_data) {
         $counter = 1;
-        //var_dump($printable_data);exit;
         foreach ($printable_data[1] as &$printable_data_row) {
             $column = 0;
             $table->setCellContents($row, $column, $counter);
@@ -783,7 +782,6 @@ function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array(
                 if ($key === 'total') {
                     $attributes['style'] = 'font-weight:bold';
                 }
-                //var_dump($key, $printable_data_cell, $attributes);
                 $table->setCellContents($row, $column, $printable_data_cell);
                 $table->updateCellAttributes($row, $column, $attributes);
                 $column++;

+ 0 - 3
main/inc/ajax/model.ajax.php

@@ -93,7 +93,6 @@ if ($_REQUEST['_search'] == 'true') {
         $where_condition .= ' AND '.$where_condition_in_form;
     }
     $filters = isset($_REQUEST['filters']) ? json_decode($_REQUEST['filters']) : false;
-    //var_dump($filters);
 
     //for now
     $extra_field = new ExtraField('session');
@@ -132,7 +131,6 @@ if ($_REQUEST['_search'] == 'true') {
 
                         if (isset($double_select[$rule->field])) {
                             $data = explode('#', $rule->data);
-                            //var_dump($data);
                             $rule->data = $data[1].'::'.$double_select[$rule->field];
                         } else {
                             // only was sent 1 select
@@ -160,7 +158,6 @@ if ($_REQUEST['_search'] == 'true') {
 
         if (!empty($condition_array)) {
             $where_condition .= ' AND ( ';
-            //var_dump($condition_array);
             $where_condition .= implode($filters->groupOp, $condition_array);
 
             $where_condition .= ' ) ';

+ 16 - 17
main/inc/ajax/user_manager.ajax.php

@@ -1,24 +1,23 @@
 <?php
 /* For licensing terms, see /chamilo_license.txt */
 /**
- * Responses to AJAX calls 
+ * Responses to AJAX calls
  */
 $language_file = array('admin', 'registration', 'userInfo');
 require_once '../global.inc.php';
 $action = $_GET['a'];
 
-switch ($action) {	
-    case 'get_user_popup':        
+switch ($action) {
+    case 'get_user_popup':
         $user_info = api_get_user_info($_REQUEST['user_id']);
-        //var_dump($user_info);
         echo '<div class="well">';
             echo '<div class="row">';
             echo '<div class="span2">';
-            echo '<div class="thumbnail">';            
+            echo '<div class="thumbnail">';
             echo '<img src="'.$user_info['avatar'].'" /> ';
             echo '</div>';
             echo '</div>';
-            echo '<div class="span3">';            
+            echo '<div class="span3">';
             if (api_get_setting('show_email_addresses') == 'false') {
                 $user_info['mail'] = ' ';
             } else {
@@ -32,19 +31,19 @@ switch ($action) {
         break;
     case 'user_id_exists':
         if (api_is_anonymous()) {
-            echo '';    
-        } else {   
+            echo '';
+        } else {
             if (UserManager::is_user_id_valid($_GET['user_id'])) {
                 echo 1;
             } else {
                 echo 0;
             }
         }
-        break;        
+        break;
 	case 'search_tags':
         if (api_is_anonymous()) {
-			echo '';	
-		} else {		
+			echo '';
+		} else {
 			if (isset($_GET['tag']) && isset($_GET['field_id'])) {
                 echo UserManager::get_tags($_GET['tag'], $_GET['field_id'],'json','10');
             }
@@ -53,27 +52,27 @@ switch ($action) {
 	case 'generate_api_key':
 		if (api_is_anonymous()) {
 			echo '';
-		} else {		
+		} else {
 			$array_list_key = array();
 			$user_id = api_get_user_id();
 			$api_service = 'dokeos';
 			$num = UserManager::update_api_key($user_id, $api_service);
 			$array_list_key = UserManager::get_api_keys($user_id, $api_service);
-			?>			
+			?>
 			<div class="row">
 				<div class="label"><?php echo get_lang('MyApiKey'); ?></div>
 				<div class="formw">
 				<input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php echo $array_list_key[$num]; ?>"/>
 				</div>
 			</div>
-			<?php			
+			<?php
 		}
         break;
 	case 'active_user':
-		if (api_is_platform_admin() && api_global_admin_can_edit_admin($_GET['user_id'])) {            
+		if (api_is_platform_admin() && api_global_admin_can_edit_admin($_GET['user_id'])) {
 			$user_id = intval($_GET['user_id']);
-			$status  = intval($_GET['status']);            
-			if (!empty($user_id)) {                
+			$status  = intval($_GET['status']);
+			if (!empty($user_id)) {
                 UserManager::change_active_state($user_id, $status, true);
                 echo $status;
             }

+ 0 - 2
main/inc/global.inc.php

@@ -255,7 +255,6 @@ $app['translator'] = $app->share($app->extend('translator', function($translator
     foreach ($filter as $entry) {
         //$domain = $entry->getBasename('.inc.po');
         $locale = api_get_language_isocode($language); //'es_ES';
-        //var_dump($locale);exit;
         //$translator->addResource('pofile', $entry->getPathname(), $locale, $domain);
         $translator->addResource('pofile', $entry->getPathname(), $locale, 'messages');
     }
@@ -857,7 +856,6 @@ $app->before(
             $app->abort(500, "archive folder must be writeable");
         }
 
-        //var_dump($_setting);
         //$app['request']->getSession()->start();
     }
 );

+ 0 - 8
main/inc/lib/chat.lib.php

@@ -136,14 +136,6 @@ class Chat extends Model
         }
 
         //print_r($_SESSION['chatHistory']);
-
-        /*
-          var_dump($_SESSION['openChatBoxes']);
-          var_dump($_SESSION['tsChatBoxes']);
-          var_dump($_SESSION['chatHistory']);
-          var_dump($items);
-         */
-        //print_r($_SESSION['chatHistory']);
         $sql = "UPDATE ".$this->table." SET recd = 1 WHERE to_user = '".$to_user_id."' AND recd = 0";
         Database::query($sql);
 

+ 0 - 1
main/inc/lib/database.lib.php

@@ -167,7 +167,6 @@ class Database
     {
         //forces fatal errors so we can debug more easily
         if (!empty($extra)) {
-            var_dump($extra);
             //@todo remove this
             echo "<h3>Dev Message: get_course_table() doesn't have a 2nd parameter</h3>";
             //exit;

+ 0 - 11
main/inc/lib/document.lib.php

@@ -1389,7 +1389,6 @@ class DocumentManager
                 }
 
                 if (isset($item_info_in_session['visibility'])) {
-                    //if ($doc_id == 85) { var_dump($item_info_in_session);}
                     if ($item_info_in_session['visibility'] == 1) {
                         return true;
                     }
@@ -2364,19 +2363,12 @@ class DocumentManager
         $content_html = file_get_contents($destiny_path.'/'.$file_name);
         $destination_file = $destiny_path.'/'.$file_name;
 
-
         $pre_original = strstr($original_path, 'document');
         $pre_destin = strstr($destiny_path, 'document');
 
-        //var_dump ("pre_original $pre_original");
-        //var_dump ("pre_destin $pre_destin");
-
         $pre_original = substr($pre_original, 8, strlen($pre_original));
         $pre_destin = substr($pre_destin, 8, strlen($pre_destin));
 
-        //var_dump ("pre_original $pre_original");
-        //var_dump ("pre_destin $pre_destin");
-
         $levels = count(explode('/', $pre_destin)) - 1;
         $link_to_add = '';
         for ($i = 1; $i <= $levels; $i++) {
@@ -2399,10 +2391,7 @@ class DocumentManager
             $pre_destin = '..'.$pre_destin.'/';
         }
 
-        //var_dump($pre_original);
-
         $levels = explode('/', $pre_original);
-        //var_dump($levels);
 
         $count_pre_destination_levels = 0;
         foreach ($levels as $item) {

+ 0 - 1
main/inc/lib/extra_field.lib.php

@@ -238,7 +238,6 @@ class ExtraField extends Model {
      */
     static function extra_field_double_select_convert_array_to_string($options) {
         $string = null;
-        //var_dump($options);
         $options_parsed = self::extra_field_double_select_convert_array_to_ordered_array($options);
 
         if (!empty($options_parsed)) {

+ 0 - 1
main/inc/lib/main_api.lib.php

@@ -1471,7 +1471,6 @@ function api_get_course_info_by_id($id = null, $add_extra_values = false) {
         $_course = array();
         if (Database::num_rows($result) > 0) {
             $course_data = Database::fetch_array($result);
-            var_dump($course_data);
             if ($add_extra_values) {
                 $extra_field_values = new ExtraField('course');
                 $course_data['extra_fields'] = $extra_field_values->get_handler_extra_data($course_data['code']);

+ 0 - 1
main/inc/lib/nanogong.lib.php

@@ -209,7 +209,6 @@ class Nanogong
                 $items[5] = $exe_id;
                 $filename = $filename = implode('-', $items);
                 $new_name = $this->store_path.$filename.'.'.$extension;
-                //var_dump($old_name, $new_name);
                 rename($old_name, $new_name);
                 break;
             }

+ 1 - 6
main/inc/lib/online.inc.php

@@ -248,12 +248,7 @@ class Online {
             $valid_date_time->sub(new DateInterval($diff));*/
             $users_online = array();
             while(list($login_user_id, $login_date) = Database::fetch_row($result)) {
-                    $users_online[] = $login_user_id;
-                /*$user_login_date = new DateTime($login_date);
-                var_dump($user_login_date->format('Y-m-d H:i:s'), $valid_date_time->format('Y-m-d H:i:s'));
-                if ($user_login_date->format('Y-m-d H:i:s') > $valid_date_time->format('Y-m-d H:i:s')) {
-
-                }*/
+                $users_online[] = $login_user_id;
             }
             return $users_online;
         } else {

+ 1 - 3
main/inc/lib/sessionmanager.lib.php

@@ -364,7 +364,7 @@ class SessionManager {
                 }
 
                 //Cleaning double selects
-                //var_dump($session);
+
                 foreach ($session as $key => &$value) {
                     if (isset($options_by_double[$key]) || isset($options_by_double[$key.'_second'])) {
                         $options = explode('::', $value);
@@ -520,7 +520,6 @@ class SessionManager {
             $options_by_double['extra_'.$double['field_variable']] = $my_options;
         }
 
-        //var_dump($options_by_double);
         //sc.name as category_name,
         $select = "
                 SELECT * FROM (
@@ -627,7 +626,6 @@ class SessionManager {
                 }
 
                 //Cleaning double selects
-                //var_dump($session);
                 foreach ($session as $key => &$value) {
                     if (isset($options_by_double[$key]) || isset($options_by_double[$key.'_second'])) {
                         $options = explode('::', $value);

+ 114 - 118
main/inc/lib/skill.lib.php

@@ -113,7 +113,7 @@ class SkillRelSkill extends Model {
         }
         return $parents;
     }
-    
+
 
     public function get_children($skill_id, $load_user_data = false, $user_id = false) {
         $skills = $this->find('all', array('where'=> array('parent_id = ? '=> $skill_id)));
@@ -127,7 +127,7 @@ class SkillRelSkill extends Model {
                 $done_skills[] = $done_skill['skill_id'];
             }
         }
-        
+
         if (!empty($skills)) {
             foreach ($skills as &$skill) {
                 $skill['data'] = $skill_obj->get($skill['skill_id']);
@@ -213,7 +213,7 @@ class SkillRelGradebook extends Model {
                 $gradebooks_to_add[] = $gradebook_id;
             }
         }
-        //var_dump($gradebooks_to_add, $gradebooks_to_remove);
+
         if (!empty($gradebooks_to_remove)) {
             foreach($gradebooks_to_remove as $id) {
                $this->delete($id);
@@ -278,7 +278,7 @@ class SkillRelUser extends Model {
 class Skill extends Model {
     var $columns  = array('id', 'name','description', 'access_url_id', 'short_code');
     var $required = array('name');
-    
+
     /** Array of colours by depth, for the coffee wheel. Each depth has 4 col */
     /*var $colours = array(
       0 => array('#f9f0ab', '#ecc099', '#e098b0', '#ebe378'),
@@ -326,7 +326,7 @@ class Skill extends Model {
     }
 
     function get_all($load_user_data = false, $user_id = false, $id = null, $parent_id = null) {
-        $id_condition = '';        
+        $id_condition = '';
         if (isset($id) && !empty($id)) {
             $id = intval($id);
             $id_condition = " WHERE s.id = $id";
@@ -340,11 +340,11 @@ class Skill extends Model {
                 $id_condition = " AND ss.parent_id = $parent_id";
             }
         }
-        
-        $sql = "SELECT s.id, s.name, s.description, ss.parent_id, ss.relation_type 
+
+        $sql = "SELECT s.id, s.name, s.description, ss.parent_id, ss.relation_type
                 FROM {$this->table} s INNER JOIN {$this->table_skill_rel_skill} ss ON (s.id = ss.skill_id) $id_condition
                 ORDER BY ss.id, ss.parent_id";
-                        
+
         $result = Database::query($sql);
         $skills = array();
 
@@ -357,10 +357,10 @@ class Skill extends Model {
                 $skills[$row['id']] = $row;
             }
         }
-        
+
         /*
         if ($load_user_data && $user_id) {
-            $passed_skills = $this->get_user_skills($user_id);            
+            $passed_skills = $this->get_user_skills($user_id);
             foreach ($skills as &$skill) {
                 $skill['done_by_user'] = 0;
                 if (in_array($skill['id'], $passed_skills)) {
@@ -368,17 +368,17 @@ class Skill extends Model {
                 }
             }
         }*/
-  
-            
+
+
         //Load all children of the parent_id
-        if (!empty($skills) && !empty($parent_id)) {           
+        if (!empty($skills) && !empty($parent_id)) {
             foreach ($skills as $skill) {
-                $children = self::get_all($load_user_data, $user_id, $id, $skill['id']);               
+                $children = self::get_all($load_user_data, $user_id, $id, $skill['id']);
                  if (!empty($children)) {
                     //$skills = array_merge($skills, $children);
                     $skills = $skills + $children;
-                } 
-            }                  
+                }
+            }
         }
         return $skills;
     }
@@ -392,7 +392,7 @@ class Skill extends Model {
         $result = Database::store_result($result,'ASSOC');
         return $result;
     }
-    
+
     /* Get one level childrens */
     function get_children($skill_id, $load_user_data = false) {
         $skill_rel_skill = new SkillRelSkill();
@@ -404,20 +404,20 @@ class Skill extends Model {
         }
         return $skills;
     }
-    
+
     /* Get all children of the current node (recursive)*/
     function get_all_children($skill_id) {
-        $skill_rel_skill = new SkillRelSkill();        
-        $children = $skill_rel_skill->get_children($skill_id);       
-        foreach ($children as $child) {             
-            $sub_children = $this->get_all_children($child['skill_id']);            
+        $skill_rel_skill = new SkillRelSkill();
+        $children = $skill_rel_skill->get_children($skill_id);
+        foreach ($children as $child) {
+            $sub_children = $this->get_all_children($child['skill_id']);
         }
         if (!empty($sub_children)) {
             $children = array_merge($children, $sub_children);
-        }        
+        }
         return $children;
     }
-    
+
 
     /**
      * Gets all parents from from the wanted skill
@@ -444,19 +444,19 @@ class Skill extends Model {
         }
         return $skills;
     }
-    
-    /* 
-     * Adds a new skill 
+
+    /*
+     * Adds a new skill
      */
     public function add($params) {
         if (!isset($params['parent_id'])) {
             $params['parent_id'] = 1;
         }
-        
+
         if (!is_array($params['parent_id'])) {
             $params['parent_id'] = array($params['parent_id']);
         }
-        
+
         $skill_rel_skill     = new SkillRelSkill();
         $skill_rel_gradebook = new SkillRelGradebook();
 
@@ -465,9 +465,9 @@ class Skill extends Model {
         $skill_id = $this->save($params);
         if ($skill_id) {
             //Saving skill_rel_skill (parent_id, relation_type)
-            
-            foreach ($params['parent_id'] as $parent_id) {   
-                $relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);                
+
+            foreach ($params['parent_id'] as $parent_id) {
+                $relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);
                 if (!$relation_exists) {
                     $attributes = array(
                                     'skill_id'      => $skill_id,
@@ -477,7 +477,7 @@ class Skill extends Model {
                     );
                     $skill_rel_skill->save($attributes);
                 }
-            }   
+            }
 
             if (!empty($params['gradebook_id'])) {
                 foreach ($params['gradebook_id'] as $gradebook_id) {
@@ -491,7 +491,7 @@ class Skill extends Model {
         }
         return null;
     }
-    
+
     public function add_skill_to_user($user_id, $gradebook_id) {
         $skill_gradebook = new SkillRelGradebook();
         $skill_rel_user  = new SkillRelUser();
@@ -510,46 +510,46 @@ class Skill extends Model {
             }
         }
     }
-    
+
     /* Deletes a skill */
     public function delete($skill_id) {
         /*$params = array('skill_id' => $skill_id);
-        
+
         $skill_rel_skill     = new SkillRelSkill();
         $skills = $skill_rel_skill->get_all(array('where'=>array('skill_id = ?' =>$skill_id)));
-        
+
         $skill_rel_profile     = new SkillRelProfile();
         $skill_rel_gradebook = new SkillRelGradebook();
         $skill_rel_user     = new SkillRelUser();
-        
+
         $this->delete($skill_id);
-        
+
         $skill_rel_gradebook->delete($params);*/
-        
-    
+
+
     }
 
-    public function edit($params) {        
+    public function edit($params) {
         if (!isset($params['parent_id'])) {
             $params['parent_id'] = 1;
         }
         $skill_rel_skill     = new SkillRelSkill();
         $skill_rel_gradebook = new SkillRelGradebook();
 
-        //Saving name, description        
+        //Saving name, description
         $this->update($params);
-        
+
         $skill_id = $params['id'];
 
         if ($skill_id) {
             //Saving skill_rel_skill (parent_id, relation_type)
-            
+
             if (!is_array($params['parent_id'])) {
                 $params['parent_id'] = array($params['parent_id']);
             }
-            
-            foreach ($params['parent_id'] as $parent_id) {   
-                $relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);                
+
+            foreach ($params['parent_id'] as $parent_id) {
+                $relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);
                 if (!$relation_exists) {
                     $attributes = array(
                                     'skill_id'      => $skill_id,
@@ -593,7 +593,7 @@ class Skill extends Model {
             }
         }
         return $clean_skill;
-    }    
+    }
 
     public function get_skills_tree($user_id = null, $skill_id = null, $return_flat_array = false, $add_root = false) {
         if ($skill_id == 1 ) {
@@ -604,11 +604,9 @@ class Skill extends Model {
         } else {
             $skills = $this->get_all(false, false, null, $skill_id);
         }
-   
+
         $original_skill = $skills;
 
-        //var_dump($skills);
-   
         //Show 1 item
         if (!empty($skill_id)) {
             if ($add_root) {
@@ -616,240 +614,238 @@ class Skill extends Model {
                     //Default root node
                     $skills[1] = array('id' => '1', 'name' => get_lang('Root'), 'parent_id' => '0');
                     $skill_info = $this->get_skill_info($skill_id);
-                    
+
                     //2nd node
                     $skills[$skill_id] = $skill_info;
                     //Uncomment code below to hide the searched skill
-                    $skills[$skill_id]['data']['parent_id'] =  $skill_info['parent_id'];                    
+                    $skills[$skill_id]['data']['parent_id'] =  $skill_info['parent_id'];
                     $skills[$skill_id]['parent_id'] =  1;
-                    
+
                 }
             }
         }
-                
+
         $refs = array();
         $skills_tree = null;
 
         // Create references for all nodes
-        $flat_array = array();      
+        $flat_array = array();
         $family = array();
-        
+
         if (!empty($skills)) {
             foreach ($skills as &$skill) {
                 if ($skill['parent_id'] == 0) {
                     $skill['parent_id'] = 'root';
                 }
-                                
+
                 // because except main keys (id, name, children) others keys are not saved while in the space tree
                 $skill['data'] = array('parent_id' => $skill['parent_id']);
-                  
+
                 //In order to paint all members of a family with the same color
-                if (empty($skill_id)) {                    
+                if (empty($skill_id)) {
                     if ($skill['parent_id'] == 1) {
-                        $family[$skill['id']] = $this->get_all_children($skill['id']);        
+                        $family[$skill['id']] = $this->get_all_children($skill['id']);
                     }
-                } else {                    
+                } else {
                     if ($skill['parent_id'] == $skill_id) {
-                        $family[$skill['id']] = $this->get_all_children($skill['id']);        
+                        $family[$skill['id']] = $this->get_all_children($skill['id']);
                     }
-                    
+
                     /*if ($skill_id == $skill['id']) {
-                        $skill['parent_id'] = 1;   
+                        $skill['parent_id'] = 1;
                     }*/
                 }
-                
-                
+
+
                 if (!isset($skill['data']['real_parent_id'])) {
                     $skill['data']['real_parent_id'] = $skill['parent_id'];
                 }
-                
+
                 //User achieved the skill (depends in the gradebook with certification)
-                $skill['data']['achieved'] = false;             
+                $skill['data']['achieved'] = false;
                 if ($user_id) {
-                    $skill['data']['achieved'] = $this->user_has_skill($user_id, $skill['id']);                    
+                    $skill['data']['achieved'] = $this->user_has_skill($user_id, $skill['id']);
                 }
-                
+
                 //Check if the skill has related gradebooks
-                $skill['data']['skill_has_gradebook'] = false;                
+                $skill['data']['skill_has_gradebook'] = false;
                 if (isset($skill['gradebooks']) && !empty($skill['gradebooks'])) {
                     $skill['data']['skill_has_gradebook'] = true;
                 }
                 $refs[$skill['id']] = &$skill;
                 $flat_array[$skill['id']] =  &$skill;
             }
-            //var_dump($skills);
-            //var_dump($refs);
-            
+
             //Checking family value
-            
+
             $family_id = 1;
             $new_family_array = array();
-            foreach ($family as $main_family_id => $family_items) {                
+            foreach ($family as $main_family_id => $family_items) {
                 if (!empty($family_items)) {
                     foreach ($family_items as $item) {
                         $new_family_array[$item['skill_id']] = $family_id;
                     }
                 }
-                $new_family_array[$main_family_id] = $family_id;                
+                $new_family_array[$main_family_id] = $family_id;
                 $family_id++;
-            }  
+            }
 
             if (empty($original_skill)) {
                 $refs['root']['children'][0] = $skills[1];
                 $skills[$skill_id]['data']['family_id'] = 1;
                 $refs['root']['children'][0]['children'][0] = $skills[$skill_id];
-                $flat_array[$skill_id] =  $skills[$skill_id];                
+                $flat_array[$skill_id] =  $skills[$skill_id];
             } else {
                 // Moving node to the children index of their parents
-                foreach ($skills as $my_skill_id => &$skill) {                
+                foreach ($skills as $my_skill_id => &$skill) {
                     $skill['data']['family_id'] = $new_family_array[$skill['id']];
                     $refs[$skill['parent_id']]['children'][] = &$skill;
                     $flat_array[$my_skill_id] =  $skill;
-                }                
+                }
             }
-            
+
             $skills_tree = array(
                 'name'      => get_lang('SkillRootName'),
                 'id'        => 'root',
                 'children'  => $refs['root']['children'],
                 'data'      => array()
-            );            
-        }                
+            );
+        }
         if ($return_flat_array) {
             return $flat_array;
         }
         unset($skills);
         return $skills_tree;
     }
-    
+
     /**
      * Get skills tree as a simplified JSON structure
      * @param int user id
      * @param int skill id
      * @param bool return a flat array or not
      * @param int depth of the skills
-     * 
+     *
      */
-    public function get_skills_tree_json($user_id = null, $skill_id = null, $return_flat_array = false, $main_depth = 2) {        
+    public function get_skills_tree_json($user_id = null, $skill_id = null, $return_flat_array = false, $main_depth = 2) {
         $tree = $this->get_skills_tree($user_id, $skill_id, $return_flat_array, true);
         $simple_tree = array();
         if (!empty($tree['children'])) {
             foreach ($tree['children'] as $element) {
-                $simple_tree[] = array( 'name'      => $element['name'], 
-                                        'children'  => $this->get_skill_json($element['children'], 1, $main_depth),                                        
+                $simple_tree[] = array( 'name'      => $element['name'],
+                                        'children'  => $this->get_skill_json($element['children'], 1, $main_depth),
                                         );
             }
         }
         //var_dump($simple_tree[0]['children']);
         return json_encode($simple_tree[0]['children']);
     }
-    
+
     /**
      * Get JSON element
      */
     public function get_skill_json($subtree, $depth = 1, $max_depth = 2) {
         $simple_sub_tree = array();
         if (is_array($subtree)) {
-            $counter = 1;            
+            $counter = 1;
             foreach ($subtree as $elem) {
                 $tmp = array();
                 $tmp['name'] = $elem['name'];
                 $tmp['id'] = $elem['id'];
 
                 if (is_array($elem['children'])) {
-                    $tmp['children'] = $this->get_skill_json($elem['children'], $depth+1, $max_depth);                                        
+                    $tmp['children'] = $this->get_skill_json($elem['children'], $depth+1, $max_depth);
                 } else {
                     //$tmp['colour'] = $this->colours[$depth][rand(0,3)];
                 }
                 if ($depth > $max_depth) {
                     continue;
                 }
-                                
+
                 $tmp['depth'] = $depth;
                 $tmp['counter'] = $counter;
                 $counter++;
-                
+
                 if (isset($elem['data']) && is_array($elem['data'])) {
                     foreach ($elem['data'] as $key => $item) {
                         $tmp[$key] = $item;
                     }
-                }                
+                }
                 $simple_sub_tree[] = $tmp;
             }
             return $simple_sub_tree;
         }
         return null;
     }
-    
+
     function get_user_skill_ranking($user_id) {
-        $user_id = intval($user_id);        
+        $user_id = intval($user_id);
         $sql = "SELECT count(skill_id) count FROM {$this->table} s INNER JOIN {$this->table_skill_rel_user} su ON (s.id = su.skill_id)
                 WHERE user_id = $user_id";
-        $result = Database::query($sql);        
+        $result = Database::query($sql);
         if (Database::num_rows($result)) {
             $result = Database::fetch_row($result);
             return $result[0];
         }
-        return false;        
+        return false;
     }
-    
+
     function get_user_list_skill_ranking($start, $limit, $sidx, $sord, $where_condition) {
         $start = intval($start);
         $limit = intval($limit);
         /*  ORDER BY $sidx $sord */
         $sql = "SELECT *, @rownum:=@rownum+1 rank FROM (
-                        SELECT u.user_id, firstname, lastname, count(username) skills_acquired 
+                        SELECT u.user_id, firstname, lastname, count(username) skills_acquired
                         FROM {$this->table} s INNER JOIN {$this->table_skill_rel_user} su ON (s.id = su.skill_id)
                         INNER JOIN {$this->table_user} u ON u.user_id = su.user_id, (SELECT @rownum:=0) r
                         WHERE 1=1 $where_condition
                         GROUP BY username
-                        ORDER BY skills_acquired desc                   
-                        LIMIT $start , $limit)  AS T1, (SELECT @rownum:=0) r";        
-        $result = Database::query($sql);        
+                        ORDER BY skills_acquired desc
+                        LIMIT $start , $limit)  AS T1, (SELECT @rownum:=0) r";
+        $result = Database::query($sql);
         if (Database::num_rows($result)) {
             return Database::store_result($result, 'ASSOC');
         }
-        return array();       
+        return array();
     }
-    
+
     function get_user_list_skill_ranking_count() {
         $sql = "SELECT count(*) FROM (
                         SELECT count(distinct 1)
-                        FROM {$this->table} s INNER JOIN {$this->table_skill_rel_user} su ON (s.id = su.skill_id) 
+                        FROM {$this->table} s INNER JOIN {$this->table_skill_rel_user} su ON (s.id = su.skill_id)
                         INNER JOIN {$this->table_user} u ON u.user_id = su.user_id
                         GROUP BY username
                      ) as T1";
         $result = Database::query($sql);
         if (Database::num_rows($result)) {
             $result = Database::fetch_row($result);
-        
+
             return $result[0];
         }
         return 0;
     }
-    
+
     function get_count_skills_by_course($course_code) {
         $sql = "SELECT count(skill_id) as count FROM {$this->table_gradebook} g INNER JOIN {$this->table_skill_rel_gradebook} sg ON g.id = sg.gradebook_id
                 WHERE course_code = '$course_code'";
-        
+
         $result = Database::query($sql);
         if (Database::num_rows($result)) {
-            $result = Database::fetch_row($result);            
+            $result = Database::fetch_row($result);
             return $result[0];
         }
         return 0;
     }
-    
+
     function get_courses_by_skill($skill_id) {
         $skill_id = intval($skill_id);
         $sql = "SELECT c.title, c.code FROM {$this->table_gradebook} g INNER JOIN {$this->table_skill_rel_gradebook} sg ON g.id = sg.gradebook_id
                  INNER JOIN {$this->table_course} c ON c.code = g.course_code
                  WHERE sg.skill_id = $skill_id";
-        $result = Database::query($sql);        
-        return Database::store_result($result, 'ASSOC');                 
+        $result = Database::query($sql);
+        return Database::store_result($result, 'ASSOC');
     }
-    
-    
+
+
     /**
     * Return true if the user has the skill
     *

+ 0 - 3
main/inc/lib/thematic.lib.php

@@ -559,9 +559,6 @@ class Thematic
             $session_star = '';
             $return = '<div id="thematic_plan_'.$thematic_id.'">';
 
-            //var_dump($thematic_simple_list);
-            //var_dump($new_thematic_plan_data);
-
 			if (!empty($thematic_plan_data)) {
 				foreach ($thematic_plan_data as $plan_data) {
 

+ 1 - 2
main/inc/lib/tracking.lib.php

@@ -983,8 +983,7 @@ class Tracking
                 }
 
                 $lp_with_quiz = 0;
-                if ($debug)
-                    var_dump($lp_list);
+
                 foreach ($lp_list as $lp_id) {
                     //Check if LP have a score we asume that all SCO have an score
                     $sql = "SELECT count(id) as count FROM $lp_item_table

+ 6 - 6
main/newscorm/lp_impress.php

@@ -63,7 +63,7 @@ if ($is_allowed_to_edit) {
     $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list&isStudentView=false', 'name' => get_lang('LearningPaths'));
     $interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=".$_SESSION['oLP']->lp_id."&isStudentView=false", 'name' => $_SESSION['oLP']->get_name());
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Preview'));
-    echo return_breadcrumb($interbreadcrumb, null, null);
+    echo $app['template']->returnBreadcrumb($interbreadcrumb, null, null);
     echo '</div>';
 }
 $html = '';
@@ -83,8 +83,8 @@ foreach ($list as $toc) {
 }
 
 //Setting the template
-$tpl = new Template($tool_name, false, false, true);
-$tpl->assign('html', $html);
-$content = $tpl->fetch('default/learnpath/impress.tpl');
-$tpl->assign('content', $content);
-$tpl->display_one_col_template();
+//$tpl = new Template($tool_name, false, false, true);
+$app['template']->assign('html', $html);
+$content = $app['template']->fetch('default/learnpath/impress.tpl');
+$app['template']->assign('content', $content);
+$app['template']->display_one_col_template();

+ 1 - 1
main/newscorm/lp_view.php

@@ -353,7 +353,7 @@ if ($is_allowed_to_edit) {
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Preview'));
     //$interbreadcrumb[] = array('type' => 'right', 'url' => api_get_self()."?action=add_item&type=step&lp_id=".$_SESSION['oLP']->lp_id."&isStudentView=false", 'name' => get_lang('Edit'), 'class' => 'btn btn-mini btn-warning');
 
-    echo $app['template']->return_breadcrumb($interbreadcrumb, null, null);
+    echo $app['template']->returnBreadcrumb($interbreadcrumb, null, null);
     echo '</div>';
 }
 echo '<div id="learning_path_left_zone" style="'.$display_none.'"> ';

+ 56 - 57
main/tracking/course_session_report.php

@@ -23,15 +23,15 @@ $this_section = "session_my_space";
 
 $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
 
-if(!$is_allowedToTrack) {	
-	api_not_allowed(true);	
+if(!$is_allowedToTrack) {
+	api_not_allowed(true);
 }
 
 $export_to_xls = false;
 if (isset($_GET['export'])) {
 	$export_to_xls = true;
 }
-if (api_is_platform_admin() ) {	
+if (api_is_platform_admin() ) {
 	$global = true;
 } else {
 	$global = false;
@@ -69,15 +69,15 @@ $course_list = SessionManager::get_course_list_by_session_id($session_id);
 
 if (!$export_to_xls) {
 	Display :: display_header(get_lang("MySpace"));
-	echo '<div class="actions" style ="font-size:10pt;" >';	
-    
-	if ($global) {	
-		
+	echo '<div class="actions" style ="font-size:10pt;" >';
+
+	if ($global) {
+
 		$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
 		$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher');
 		$menu_items[] = Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32);
 		$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
-		
+
 		$nb_menu_items = count($menu_items);
 		if($nb_menu_items>1) {
 			foreach($menu_items as $key=> $item) {
@@ -86,37 +86,37 @@ if (!$export_to_xls) {
 			echo '<br />';
 		}
 	} else {
-        
+
 		echo '<div style="float:left; clear:left">
-				<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|			
-				<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';		
-		echo '</div>';	
+				<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
+				<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
+		echo '</div>';
 	}
 	echo '</div>';
-	
+
 	if (api_is_platform_admin()) {
 		echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=coaches">'.get_lang('DisplayCoaches').'</a> | ';
-		echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=useroverview">'.get_lang('DisplayUserOverview').'</a>';		
+		echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=useroverview">'.get_lang('DisplayUserOverview').'</a>';
 		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=sessionoverview">'.get_lang('DisplaySessionOverview').'</a>';
-		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';	
+		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';
 		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin">'.get_lang('LPQuestionListResults').'</a>';
-			
-		echo ' | '.get_lang('LPExerciseResultsBySession').'';	
-			
-				
-	}	
-	
+
+		echo ' | '.get_lang('LPExerciseResultsBySession').'';
+
+
+	}
+
 	echo '<h2>'.get_lang('LPExerciseResultsBySession').'</h2>';
 	$form->display();
 	Display::display_normal_message(get_lang('StudentScoreAverageIsCalculatedBaseInAllLPsAndAllAttempts'));
-	
-		
+
+
 	//echo '<h3>'.sprintf(get_lang('FilteringWithScoreX'), $filter_score).'%</h3>';
-	
+
 //	echo '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exercise_id.'"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsXLS').'</a><br /><br />';
 }
 
-	
+
 $users = SessionManager::get_users_by_session($session_id);
 $course_average = $course_average_counter = array();
 
@@ -125,42 +125,41 @@ $main_result = array();
 //Getting course list
 foreach ($course_list  as $current_course ) {
 	$course_info = api_get_course_info($current_course['code']);
-	$_course = $course_info; 
+	$_course = $course_info;
 	$attempt_result = array();
-	
+
 	//Getting LP list
 	$list = new learnpathList('', $current_course['code'], $session_id);
 	$lp_list = $list->get_flat_list();
-		
+
 	// Looping LPs
-	foreach ($lp_list as $lp_id =>$lp) {		
-		$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);		
+	foreach ($lp_list as $lp_id =>$lp) {
+		$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);
 		//Looping Chamilo Exercises in LP
 		foreach ($exercise_list as $exercise) {
 			$exercise_stats = get_all_exercise_event_from_lp($exercise['path'], $course_info['id'], $session_id);
 			//Looping Exercise Attempts
 			foreach($exercise_stats as $stats) {
-				$attempt_result[$stats['exe_user_id']]['result'] += $stats['exe_result'] / $stats['exe_weighting'];		
-				$attempt_result[$stats['exe_user_id']]['attempts']++;								
-			}			
-		}		
+				$attempt_result[$stats['exe_user_id']]['result'] += $stats['exe_result'] / $stats['exe_weighting'];
+				$attempt_result[$stats['exe_user_id']]['attempts']++;
+			}
+		}
 	}
 	$main_result[$current_course['code']] = $attempt_result;
 }
 
-//var_dump($main_result);
 $total_average_score = 0;
 $total_average_score_count = 0;
 if (!empty($users) && is_array($users)) {
-	
+
 	$html_result .= '<table  class="data_table">';
 	$html_result .= '<tr><th>'.get_lang('User').'</th>';
-	foreach($course_list as $item ) {		
-		$html_result .= '<th>'.$item['title'].'<br /> '.get_lang('AverageScore').' %</th>';	
+	foreach($course_list as $item ) {
+		$html_result .= '<th>'.$item['title'].'<br /> '.get_lang('AverageScore').' %</th>';
 	}
 	$html_result .= '<th>'.get_lang('AverageScore').' %</th>';
-	$html_result .= '<th>'.get_lang('LastConnexionDate').'</th></tr>';	
-	
+	$html_result .= '<th>'.get_lang('LastConnexionDate').'</th></tr>';
+
 	foreach ($users  as $user) {
 		$total_student = 0;
 		$counter ++;
@@ -171,22 +170,22 @@ if (!empty($users) && is_array($users)) {
 		$html_result .= "<tr class='$s_css_class'>
 							<td >";
 		$html_result .= $user['firstname'].' '.$user['lastname'];
-		$html_result .= "</td>";	
-		
+		$html_result .= "</td>";
+
 		//Getting course list
-		
+
 		$counter = 0;
 		$total_result_by_user = 0;
 		foreach($course_list  as $current_course ) {
-			$total_course = 0;			
+			$total_course = 0;
 			$user_info_stat = $main_result[$current_course['code']][$user['user_id']];
 			$html_result .= "<td>";
 			if (!empty($user_info_stat['result']) && !empty($user_info_stat['attempts'])) {
 				$result =round($user_info_stat['result']/$user_info_stat['attempts'] * 100, 2);
 				$total_course +=$result;
-				$total_result_by_user +=$result;		
+				$total_result_by_user +=$result;
 				$course_average[$current_course['code']] += $total_course;
-				$course_average_counter[$current_course['code']]++;				
+				$course_average_counter[$current_course['code']]++;
 				$result = $result .' ('.$user_info_stat['attempts'].' '.get_lang('Attempts').')';
 				$counter++;
 			} else {
@@ -194,18 +193,18 @@ if (!empty($users) && is_array($users)) {
 			}
 			$html_result .= $result;
 			$html_result .= "</td>";
-		}		
+		}
 		if (empty($counter)) {
 			$total_student = '-';
-		} else {			
+		} else {
 			$total_student = $total_result_by_user/$counter;
 			$total_average_score+=$total_student;
 			$total_average_score_count++;
-		}		
+		}
 		$string_date=Tracking :: get_last_connection_date($user['user_id'],true);
-		$html_result .="<td>$total_student</td><td>$string_date</td></tr>";		
+		$html_result .="<td>$total_student</td><td>$string_date</td></tr>";
 	}
-	
+
 	$html_result .="<tr><th>".get_lang('AverageScore')."</th>";
 	$total_average = 0;
 	$counter = 0;
@@ -216,28 +215,28 @@ if (!empty($users) && is_array($users)) {
 			$average_per_course = '-';
 		}
 		if (!empty($average_per_course)) {
-			$counter++;		
+			$counter++;
 		}
 		$total_average = $total_average + $average_per_course;
 		$html_result .="<td>$average_per_course</td>";
-	}	
+	}
 	if (!empty($total_average_score_count)) {
 		$total_average = round($total_average_score/($total_average_score_count*100)*100,2);
 	} else {
 		$total_average = '-';
 	}
-			
+
 	$html_result .='<td>'.$total_average.'</td>';
 	$html_result .="<td>-</td>";
 	$html_result .="</tr>";
 	$html_result .= '</table>';
-} else {	
+} else {
 	Display::display_warning_message(get_lang('NoResults'));
 }
 
 
 if (!$export_to_xls) {
-	echo $html_result;	
+	echo $html_result;
 }
 
 $filename = 'exam-reporting-'.date('Y-m-d-h:i:s').'.xls';
@@ -256,7 +255,7 @@ function sort_user($a, $b) {
 		}
 		return 0;
 	}
-	return 1;	
+	return 1;
 }
 
 function export_complete_report_xls($filename, $array) {

+ 0 - 24
main/tracking/exams.php

@@ -248,34 +248,10 @@ if(!empty($course_list) && is_array($course_list)) {
                         }
                         $i++;
 
-                        /*echo "    <td align='right'>
-                              ";
-                        echo         $current_student_id.' ';
-                        echo "    </td>";
-                        */
-
-                        //var_dump($pourcentageScore);
-                /*        echo "    <td align='right'>
-                              ";
-                        echo         $pourcentageScore.' %';
-                        echo "    </td>";
-
-                        echo "<td align='right'>
-                             ";
-                             /*
-                        echo         $a_essais['essais'];
-                        echo "    </td>
-                                <td align='center'>
-                             ";*/
-
                         if ($a_essais['essais'] > 0 ) {
                             $taken++;
                         }
 
-                        /*if ($pourcentageScore >= $parameter_porcentage) {
-                            $total_with_parameter_porcentage++;
-                        }*/
-
                         if ($pourcentageScore >= $filter_score) {
                             $total_with_parameter_score++;
                         }

+ 60 - 73
main/tracking/question_course_report.php

@@ -34,7 +34,7 @@ if (isset($_GET['export'])) {
 	$export_to_xls = true;
 }
 
-if (api_is_platform_admin() ) {	
+if (api_is_platform_admin() ) {
 	$global = true;
 } else {
 	$global = false;
@@ -46,7 +46,7 @@ $course_select_list[0] = get_lang('None');
 
 $htmlHeadXtra[] = '
 <script type="text/javascript">
-function load_courses() {	
+function load_courses() {
 	document.search_simple.submit();
 }
 </script>	';
@@ -56,11 +56,11 @@ $session_id = intval($_REQUEST['session_id']);
 if (empty($session_id)) {
 	$temp_course_list = CourseManager :: get_courses_list();
 } else {
-	$temp_course_list = SessionManager::get_course_list_by_session_id($session_id);	
+	$temp_course_list = SessionManager::get_course_list_by_session_id($session_id);
 }
-	
+
 foreach($temp_course_list  as $temp_course_item) {
-	$course_item = CourseManager ::get_course_information($temp_course_item['code']);    		
+	$course_item = CourseManager ::get_course_information($temp_course_item['code']);
 	$course_list[]= array('db_name' =>$course_item['db_name'],'code'=>$course_item['code'], 'title'=>$course_item['title'], 'visual_code'=>$course_item['visual_code']);
 	$course_select_list[$temp_course_item['code']]	= $course_item['title'];
 }
@@ -86,108 +86,95 @@ if (empty($course_code)) {
 
 $form->setDefaults(array('course_code'=>(string)$course_code));
 $course_info = api_get_course_info($course_code);
-//var_dump($session_id);
-if (!empty($course_info)) {	
+
+if (!empty($course_info)) {
 	$list = new learnpathList('', $course_code);
-	$lp_list = $list->get_flat_list();	
-	$_course = $course_info;	
+	$lp_list = $list->get_flat_list();
+	$_course = $course_info;
 	$main_question_list = array();
 	foreach ($lp_list as $lp_id =>$lp) {
-		$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);	
-        //var_dump($exercise_list);	
-		foreach ($exercise_list as $exercise) {		
-			$my_exercise = new Exercise();			
-			//$my_exercise->read($exercise['ref']);
+		$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);
+
+		foreach ($exercise_list as $exercise) {
+			$my_exercise = new Exercise();
+
 			$my_exercise->read($exercise['path']);
-			$question_list = $my_exercise->selectQuestionList();			
-								
-			$exercise_stats = get_all_exercise_event_from_lp($exercise['path'],$course_info['id'], $session_id);			
-			//echo '<pre>'; print_r($exercise_stats);		
-				
-			foreach($question_list  as $question_id) {
+			$question_list = $my_exercise->selectQuestionList();
+
+			$exercise_stats = get_all_exercise_event_from_lp($exercise['path'],$course_info['id'], $session_id);
+
+			foreach ($question_list  as $question_id) {
 				$question_data = Question::read($question_id);
-                ///var_dump($question_data);
-				$main_question_list[$question_id] = $question_data;		
+				$main_question_list[$question_id] = $question_data;
 				$quantity_exercises = 0;
 				$question_result = 0;
-                //echo '<pre>';
-				//print_r($exercise_stats);
+
 				foreach($exercise_stats as $stats) {
 					if (!empty($stats['question_list'])) {
 						foreach($stats['question_list'] as $my_question_stat) {
-                           // var_dump($my_question_stat);							
-							if ($question_id == $my_question_stat['question_id']) {				
-								//var_dump($my_question_stat);		
-								$question_result =  $question_result + $my_question_stat['marks'];		
-					//			var_dump($my_question_stat['marks']);
-								$quantity_exercises++;					
+							if ($question_id == $my_question_stat['question_id']) {
+								$question_result =  $question_result + $my_question_stat['marks'];
+								$quantity_exercises++;
 							}
 						}
 					}
 				}
-                //echo $question_id;
-                //var_dump($question_result.' - '.$quantity_exercises.$main_question_list[$question_id]->weighting);
                 if(!empty($quantity_exercises)) {
 				    $main_question_list[$question_id]->results =(($question_result / ($quantity_exercises)) ) ; // Score % average
                 } else {
                     $main_question_list[$question_id]->results = 0;
                 }
-				$main_question_list[$question_id]->quantity = $quantity_exercises;	
-            
+				$main_question_list[$question_id]->quantity = $quantity_exercises;
+
 			}
 		}
 	}
 }
 
-//var_dump($main_question_list);
-
-//var_dump($main_question_list);
-//$course_list = SessionManager::get_course_list_by_session_id($session_id);
-
 if (!$export_to_xls) {
-	
+
 	Display :: display_header(get_lang("MySpace"));
 	echo '<div class="actions" style ="font-size:10pt;" >';
 	if ($global) {
-				
+
 		$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
 		$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher');
-		$menu_items[] = Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32);		
+		$menu_items[] = Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32);
 		$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
-		
+
 		$nb_menu_items = count($menu_items);
 		if($nb_menu_items>1) {
 			foreach($menu_items as $key=> $item) {
-				echo $item;			
-			}			
+				echo $item;
+			}
 		}
 	} else {
 		echo '<div style="float:left; clear:left">
-				<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|			
+				<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
 				<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
-			
-		echo '</div>';	
-	}	
+
+		echo '</div>';
+	}
 	echo '</div>';
-	
+
 if (api_is_platform_admin()) {
 		echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=coaches">'.get_lang('DisplayCoaches').'</a> | ';
-		echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=useroverview">'.get_lang('DisplayUserOverview').'</a>';		
+		echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=useroverview">'.get_lang('DisplayUserOverview').'</a>';
 		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=sessionoverview">'.get_lang('DisplaySessionOverview').'</a>';
-		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';	
+		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';
 		echo ' | '.get_lang('LPQuestionListResults');
-		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin">'.get_lang('LPExerciseResultsBySession').'</a>';	
-				
-	}		
+		echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin">'.get_lang('LPExerciseResultsBySession').'</a>';
+
+	}
 	echo '<br />';
 	echo '<h2>'.get_lang('LPQuestionListResults').'</h2>';
-	
+
 	$form->display();
 	//Display::display_normal_message(get_lang('QuestionsAreTakenFromLPExercises'));
-	
+
 	if (empty($course_code)) {
-		Display::display_warning_message(get_lang('PleaseSelectACourse'));	
-	}	
+		Display::display_warning_message(get_lang('PleaseSelectACourse'));
+	}
 }
 
 $course_average = array();
@@ -196,10 +183,10 @@ $counter = 0;
 
 if (!empty($main_question_list) && is_array($main_question_list)) {
 	$html_result .= '<table  class="data_table">';
-	$html_result .= '<tr><th>'.get_lang('Question').Display :: return_icon('info3.gif', get_lang('QuestionsAreTakenFromLPExercises'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>';	
+	$html_result .= '<tr><th>'.get_lang('Question').Display :: return_icon('info3.gif', get_lang('QuestionsAreTakenFromLPExercises'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>';
 	$html_result .= '<th>'.$course_info['visual_code'].' '.get_lang('AverageScore').Display :: return_icon('info3.gif', get_lang('AllStudentsAttemptsAreConsidered'), array('align' => 'absmiddle', 'hspace' => '3px')).' </th>';
-    $html_result .= '<th>'.get_lang('Quantity').'</th>';	
-	
+    $html_result .= '<th>'.get_lang('Quantity').'</th>';
+
 	foreach($main_question_list  as $question) {
 		$total_student = 0;
 		$counter ++;
@@ -210,33 +197,33 @@ if (!empty($main_question_list) && is_array($main_question_list)) {
 		$html_result .= "<tr class='$s_css_class'>
 							<td >";
 		$question_title = trim($question->question);
-		if (empty($question_title)) {			
+		if (empty($question_title)) {
 			$html_result .= get_lang('Untitled').' '.get_lang('Question').' #'.$question->id;
-		} else {				
+		} else {
 			$html_result .= $question->question;
 		}
-		
+
 		$html_result .= "</td>";
-		
-		$html_result .= "<td>";						
+
+		$html_result .= "<td>";
 		$html_result .= round($question->results, 2).' / '.$question->weighting;
 		$html_result .= "</td>";
-        
-        $html_result .= "<td>";                       
+
+        $html_result .= "<td>";
         $html_result .= $question->quantity;
         $html_result .= "</td>";
-        
+
 	}
 	$html_result .="</tr>";
 	$html_result .= '</table>';
-} else {	
+} else {
 	if (!empty($course_code)) {
 		Display::display_warning_message(get_lang('NoResults'));
 	}
 }
 
 if (!$export_to_xls) {
-	echo $html_result;	
+	echo $html_result;
 }
 
 $filename = 'exam-reporting-'.date('Y-m-d-h:i:s').'.xls';
@@ -255,7 +242,7 @@ function sort_user($a, $b) {
 		}
 		return 0;
 	}
-	return 1;	
+	return 1;
 }
 
 function export_complete_report_xls($filename, $array) {

+ 0 - 1
main/work/work.php

@@ -654,7 +654,6 @@ switch ($action) {
 									   parent_id 	=  '".$work_id."' ,
                                        session_id	= '".intval($id_session)."' ,
                                        user_id 		= '".$user_id."'";
-                    //var_dump($sql_add_publication);exit;
                     Database::query($sql_add_publication);
                     $id = Database::insert_id();
                 }

+ 4 - 5
plugin/bbb/lib/bbb.lib.php

@@ -1,6 +1,6 @@
 <?php
 /**
- * This script initiates a videoconference session, calling the BigBlueButton 
+ * This script initiates a videoconference session, calling the BigBlueButton
  * API
  * @package chamilo.plugin.bigbluebutton
  */
@@ -145,7 +145,7 @@ class bbb {
         }
     }
     /**
-     * Tells whether the given meeting exists and is running 
+     * Tells whether the given meeting exists and is running
      * (using course code as name)
      * @param string Meeting name (usually the course code)
      * @return bool True if meeting exists, false otherwise
@@ -307,7 +307,6 @@ class bbb {
                         }
                     }
                 }
-                //var_dump($record_array);
                 $item['show_links']  = implode('<br />', $record_array);
             }
 
@@ -412,8 +411,8 @@ class bbb {
         if (empty($ids) or (is_array($ids) && count($ids)==0)) { return false; }
         $recordingParams = array(
            /*
-            * NOTE: Set the recordId below to a valid id after you have 
-            * created a recorded meeting, and received a real recordID 
+            * NOTE: Set the recordId below to a valid id after you have
+            * created a recorded meeting, and received a real recordID
             * back from your BBB server using the
             * getRecordingsWithXmlResponseArray method.
             */