Browse Source

Merge with 1.9.x

Julio Montoya 12 years ago
parent
commit
3d3523332c

+ 1 - 1
main/exercice/exercice.php

@@ -552,7 +552,7 @@ if (!empty($exercise_list)) {
 
                 if ($session_id == $row['session_id']) {
                     //Settings
-                    $actions =  Display::url(Display::return_icon('edit.png',get_lang('EditQuestions'),'',ICON_SIZE_SMALL), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']);
+                    $actions = Display::url(Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']);
 
                     //Exercise results
                     $actions .='<a href="exercise_report.php?' . api_get_cidreq() . '&exerciseId='.$row['id'].'">'.Display :: return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_SMALL).'</a>';

+ 27 - 12
main/exercice/exercise.class.php

@@ -23,10 +23,6 @@ $debug = false; //All exercise scripts should depend in this debug variable
 
 require_once dirname(__FILE__).'/../inc/lib/exercise_show_functions.lib.php';
 
-/**
- * Exercise class
-* @package chamilo.exercise
-*/
 class Exercise {
 
 	public $id;
@@ -177,7 +173,6 @@ class Exercise {
 			global $_configuration, $questionList;
 			if ($this->type == ONE_PER_PAGE && $_SERVER['REQUEST_METHOD'] != 'POST' && defined('QUESTION_LIST_ALREADY_LOGGED') &&
 			isset($_configuration['live_exercise_tracking']) && $_configuration['live_exercise_tracking']) {
-				//if(empty($_SESSION['questionList']))
 				$this->questionList = $questionList;
 			}*/
 			return true;
@@ -1640,14 +1635,14 @@ class Exercise {
 						$prev_question = $questionNum - 2;
 						$all_button .= '<a href="javascript://" class="btn" onclick="previous_question_and_save('.$prev_question.', '.$question_id.' ); ">'.get_lang('PreviousQuestion').'</a>';
 					}
-					if (!empty($questions_in_media)) {
+
+                    //Next question
+                    if (!empty($questions_in_media)) {
                         $questions_in_media = "['".implode("','",$questions_in_media)."']";
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>';
                     } else {
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.'); ">'.$label.'</a>';
                     }
-					//Next question
-
 					$all_button .= '<span id="save_for_now_'.$question_id.'" class="exercise_save_mini_message"></span>&nbsp;';
 					$html .= $all_button;
 				} else {
@@ -1902,6 +1897,7 @@ class Exercise {
 		if ($debug) error_log('manage_answer $from_database: '.$from_database);
 		if ($debug) error_log('manage_answer $show_result: '.$show_result);
 		if ($debug) error_log('manage_answer $propagate_neg: '.$propagate_neg);
+        if ($debug) error_log('manage_answer $exerciseResultCoordinates: '.print_r($exerciseResultCoordinates, 1));
 		if ($debug) error_log('manage_answer $hotspot_delineation_result: '.print_r($hotspot_delineation_result, 1));
         if ($debug) error_log('manage_answer $learnpath_id: '.$learnpath_id);
         if ($debug) error_log('manage_answer $learnpath_item_id: '.$learnpath_item_id);
@@ -3338,7 +3334,7 @@ class Exercise {
             }
 	}
 
-	function show_exercise_result_header($user_data, $date = null) {
+	function show_exercise_result_header($user_data, $start_date = null, $duration = null) {
 		$array = array();
 
         if (!empty($user_data)) {
@@ -3349,8 +3345,12 @@ class Exercise {
             $array[] = array('title' => get_lang("Description"), 'content' => $this->description);
 		}
 
-		if (!empty($date)) {
-             $array[] = array('title' => get_lang("Date"), 'content' => $date);
+		if (!empty($start_date)) {
+            $array[] = array('title' => get_lang("StartDate"), 'content' => $start_date);
+		}
+
+        if (!empty($duration)) {
+            $array[] = array('title' => get_lang("Duration"), 'content' => $duration);
 		}
 
 		$html = Display::page_header(Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result'));
@@ -3800,4 +3800,19 @@ class Exercise {
         }
         return $question_count;
     }
-}
+
+    function get_exercise_list_ordered() {
+        $table_exercise_order = Database::get_course_table(TABLE_QUIZ_ORDER);
+        $course_id = api_get_course_int_id();
+        $session_id = api_get_session_id();
+        $sql = "SELECT exercise_id, exercise_order FROM $table_exercise_order WHERE c_id = $course_id AND session_id = $session_id ORDER BY exercise_order";
+        $result = Database::query($sql);
+        $list = array();
+        if (Database::num_rows($result)) {
+            while($row = Database::fetch_array($result, 'ASSOC')) {
+                $list[$row['exercise_order']] = $row['exercise_id'];
+            }
+        }
+        return $list;
+    }
+}

+ 1 - 1
main/exercice/question.class.php

@@ -1381,7 +1381,7 @@ abstract class Question
 
 		echo '<li>';
 		echo '<div class="icon_image_content">';
-		if ($objExercise->edit_exercise_in_lp == false) {
+		if ($objExercise->exercise_was_added_in_lp == true) {
             echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'));
 		} else {
 			if ($feedback_type==1) {

+ 18 - 0
main/inc/ajax/exercise.ajax.php

@@ -139,6 +139,24 @@ switch ($action) {
         } 
         echo json_encode($response);
         break;            
+    case 'update_exercise_list_order':
+        $session_id = api_get_session_id();
+        if (api_is_allowed_to_edit(null, true)) {
+            $new_list = $_REQUEST['exercise_list'];
+            $table = Database::get_course_table(TABLE_QUIZ_ORDER);
+            $counter = 1;
+            //Drop all
+            Database::query("DELETE FROM $table WHERE session_id = $session_id AND c_id = $course_id");
+            //Insert alll
+            foreach ($new_list as $new_order_id) {
+                /*Database::update($table, array('exercise_order' => $counter),
+                    array('session_id = ? AND exercise_id = ? AND c_id = ? '=> array($session_id, intval($new_order_id), $course_id)));*/
+                Database::insert($table, array('exercise_order' => $counter, 'session_id' => $session_id, 'exercise_id' => intval($new_order_id), 'c_id' => $course_id));
+                $counter++;
+            }
+            Display::display_confirmation_message(get_lang('Saved'));
+        }
+        break;
     case 'update_question_order':
         if (api_is_allowed_to_edit(null, true)) {    
             $new_question_list     = $_POST['question_id_list'];

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

@@ -2898,7 +2898,7 @@ class CourseManager {
                     $html .= '</div>';
                     $notifications = isset($params['notifications']) ? $params['notifications'] : null;
 
-                    $html .= '<div class="span6">';
+                    $html .= '<div class="span6 '.$params['class'].'">';
                         $html .='<h3>'.$params['title'].$notifications.'</h3> ';
 
                         if (!empty($params['subtitle'])) {
@@ -3052,6 +3052,7 @@ class CourseManager {
             // We simply display the title of the category.
             $params['icon'] = Display::return_icon('folder_yellow.png', $row['title'], array(), ICON_SIZE_LARGE);
             $params['title'] = $row['title'];
+            $params['class'] = 'table_user_course_category';
             $html .= self::course_item_parent(self::course_item_html($params, true), self :: display_courses_in_category($row['id'], $load_dirs));
         }
 

+ 6 - 5
main/inc/lib/database.constants.inc.php

@@ -2,16 +2,16 @@
 /* For licensing terms, see /license.txt */
 /**
  *	This is the database constants definition for Chamilo
- *  This file is called by database.lib.php and database.mysqli.lib.php  
- *  
+ *  This file is called by database.lib.php and database.mysqli.lib.php
+ *
  *  @todo the table constants have all to start with TABLE_
  *        This is because of the analogy with the tool constants TOOL_
  *
- *	@package chamilo.library 
+ *	@package chamilo.library
  */
 
 /**
- * CONSTANTS 
+ * CONSTANTS
  */
 
 //See #3910 defines the default prefix for the single course database
@@ -121,7 +121,7 @@ define('TABLE_MAIN_LEGAL', 'legal');
 // Dashboard blocks plugin
 define('TABLE_MAIN_BLOCK', 'block');
 
-// Statistic database tables 
+// Statistic database tables
 define('TABLE_STATISTIC_TRACK_E_LASTACCESS',        'track_e_lastaccess');
 define('TABLE_STATISTIC_TRACK_E_ACCESS',            'track_e_access');
 define('TABLE_STATISTIC_TRACK_E_LOGIN',             'track_e_login');
@@ -201,6 +201,7 @@ define('TABLE_DROPBOX_PERSON',  'dropbox_person');
 // Course quiz (or test, or exercice) tables
 define('TABLE_QUIZ_QUESTION',               'quiz_question');
 define('TABLE_QUIZ_TEST',                   'quiz');
+define('TABLE_QUIZ_ORDER',                  'quiz_order');
 define('TABLE_QUIZ_ANSWER',                 'quiz_answer');
 define('TABLE_QUIZ_TEST_QUESTION',          'quiz_rel_question');
 define('TABLE_QUIZ_QUESTION_OPTION',        'quiz_question_option');

+ 27 - 10
main/newscorm/learnpath.class.php

@@ -230,6 +230,7 @@ class learnpath {
         }
 
         $lp_item_id_list = array();
+
         while ($row = Database::fetch_array($res)) {
             $oItem = '';
             $lp_item_id_list[] = $row['id'];
@@ -1307,17 +1308,21 @@ class learnpath {
 
         $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
-        if (!is_numeric($mastery_score) || $mastery_score < 0)
+        if (!is_numeric($mastery_score) || $mastery_score < 0) {
             $mastery_score = 0;
+        }
 
-        if (!is_numeric($max_score) || $max_score < 0)
+        if (!is_numeric($max_score) || $max_score < 0) {
             $max_score = 100;
+        }
 
-        if ($mastery_score > $max_score)
+        if ($mastery_score > $max_score) {
             $max_score = $mastery_score;
+        }
 
-        if (!is_numeric($prerequisite_id))
+        if (!is_numeric($prerequisite_id)) {
             $prerequisite_id = 'NULL';
+        }
 
         $sql_upd = " UPDATE " . $tbl_lp_item . "
                      SET prerequisite = " . $prerequisite_id . " WHERE c_id = ".$course_id." AND id = " . $id;
@@ -2307,17 +2312,22 @@ class learnpath {
         }
         $oItem = $this->items[$item_id];
         $prereq = $oItem->get_prereq_string();
-        if (empty ($prereq)) {
+        if (empty($prereq)) {
             return '';
         }
-        if (preg_match('/^\d+$/', $prereq) && is_object($this->items[$prereq])) {	// If the prerequisite is a simple integer ID and this ID exists as an item ID,
-                                                                                    // then simply return it (with the ITEM_ prefix).
-            return 'ITEM_' . $prereq;
+        //var_dump($this->refs_list, $prereq);
+        if (preg_match('/^\d+$/', $prereq) && is_object($this->items[$prereq])) {
+            // If the prerequisite is a simple integer ID and this ID exists as an item ID,
+            // then simply return it (with the ITEM_ prefix).
+            //return 'ITEM_' . $prereq;
+            return $this->items[$prereq]->ref;
         } else {
-            if (isset ($this->refs_list[$prereq])) {
+            if (isset($this->refs_list[$prereq])) {
                 // It's a simple string item from which the ID can be found in the refs list,
                 // so we can transform it directly to an ID for export.
                 return 'ITEM_' . $this->refs_list[$prereq];
+            } else if (isset($this->refs_list['ITEM_'.$prereq])) {
+                return 'ITEM_'.$prereq;
             } else {
                 // The last case, if it's a complex form, then find all the IDs (SCORM strings)
                 // and replace them, one by one, by the internal IDs (chamilo db)
@@ -3568,7 +3578,14 @@ class learnpath {
             $item = $this->current;
         }
         if (is_object($this->items[$item])) {
-            $prereq_string = $this->items[$item]->get_prereq_string();
+            if ($this->type == 2) {
+                //Getting prereq from scorm
+                $prereq_string = $this->get_scorm_prereq_string($item);
+            } else {
+                $prereq_string = $this->items[$item]->get_prereq_string();
+            }
+
+
             if (empty($prereq_string)) {
                 return true;
             }

+ 5 - 10
main/newscorm/learnpathItem.class.php

@@ -1267,6 +1267,7 @@ class learnpathItem {
 		// Deal with &, |, ~, =, <>, {}, ,, X*, () in reverse order.
 		$this->prereq_alert = '';
 		// First parse all parenthesis by using a sequential loop (looking for less-inclusives first).
+
 		if ($prereqs_string == '_true_') { return true; }
 		if ($prereqs_string == '_false_') {
 			if (empty($this->prereq_alert)) {
@@ -1342,7 +1343,6 @@ class learnpathItem {
 						return false;
 					}
 				} else {
-
 					// No ANDs found, look for <>
 
 					if (self::debug > 1) { error_log('New LP - Didnt find any =, looking for <>', 0); }
@@ -1364,9 +1364,7 @@ class learnpathItem {
 							return false;
 						}
 					} else {
-
-						// No <> found, look for ~ (unary).
-
+						// No <> found, look for ~ (unary)
 						if (self::debug > 1) { error_log('New LP - Didnt find any =, looking for ~', 0); }
 						// Only remains: ~ and X*{}
 						if (strpos($prereqs_string, '~') !== false) {
@@ -1385,13 +1383,13 @@ class learnpathItem {
 								if (self::debug > 1) { error_log('New LP - Found ~ but strange string: '.$prereqs_string, 0); }
 							}
 						} else {
-
-							// Finally, look for sets/groups.
+							// Finally, look for sets/groups
 
 							if (self::debug > 1) { error_log('New LP - Didnt find any ~, looking for groups', 0); }
 							// Only groups here.
 							$groups = array();
 							$groups_there = preg_match_all('/((\d+\*)?\{([^\}]+)\}+)/', $prereqs_string, $groups);
+
 							if ($groups_there) {
 								foreach ($groups[1] as $gr) { // Only take the results that correspond to the big brackets-enclosed condition.
 									if (self::debug > 1) { error_log('New LP - Dealing with group '.$gr, 0); }
@@ -1419,8 +1417,7 @@ class learnpathItem {
 										} else {
 											if (self::debug > 1) { error_log('New LP - Not enough true results', 0); }
 										}
-									}
-									else {
+									} else {
 										if (self::debug > 1) { error_log('New LP - No multiplier', 0); }
 										$list = split(',', $gr);
 										$mycond = true;
@@ -1522,11 +1519,9 @@ class learnpathItem {
 												$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
 												$returnstatus = false;
 											}
-
 										}
 										return $returnstatus;
 									} else {
-
 										$status = $items[$refs_list[$prereqs_string]]->get_status(false);
 										$returnstatus = (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3]));
 

+ 26 - 15
main/newscorm/lp_content.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 
 /**
@@ -13,9 +14,13 @@
 require_once '../inc/global.inc.php';
 
 $debug = 0;
-if ($debug > 0) { error_log('New lp - In lp_content.php', 0); }
+if ($debug > 0) {
+    error_log('New lp - In lp_content.php', 0);
+}
 if (empty($lp_controller_touched)) {
-    if ($debug > 0) { error_log('New lp - In lp_content.php - Redirecting to lp_controller', 0); }
+    if ($debug > 0) {
+        error_log('New lp - In lp_content.php - Redirecting to lp_controller', 0);
+    }
     header('location: lp_controller.php?action=content&lp_id='.Security::remove_XSS($_REQUEST['lp_id']).'&item_id='.Security::remove_XSS($_REQUEST['item_id']));
 }
 $_SESSION['oLP']->error = '';
@@ -26,27 +31,29 @@ $lp_item_id = $_SESSION['oLP']->get_current_item_id();
  * Get a link to the corresponding document
  */
 $src = '';
-if ($debug > 0) { error_log('New lp - In lp_content.php - Looking for file url', 0); }
+if ($debug > 0) {
+    error_log('New lp - In lp_content.php - Looking for file url', 0);
+}
 
 $list = $_SESSION['oLP']->get_toc();
 
 $dokeos_chapter = false;
 
 foreach ($list as $toc) {
-    if ($toc['id']==$lp_item_id && ($toc['type']=='dokeos_chapter' || $toc['type']=='dokeos_module' || $toc['type']=='dir')) {
+    if ($toc['id'] == $lp_item_id && ($toc['type'] == 'dokeos_chapter' || $toc['type'] == 'dokeos_module' || $toc['type'] == 'dir')) {
         $dokeos_chapter = true;
     }
 }
 
 if ($dokeos_chapter) {
     $src = 'blank.php';
-} else {    
+} else {
     switch ($lp_type) {
         case 1:
             $_SESSION['oLP']->stop_previous_item();
             $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
             if ($prereq_check === true) {
-                $src = $_SESSION['oLP']->get_link('http', $lp_item_id);                
+                $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
                 $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
             } else {
                 $src = 'blank.php?error=prerequisites';
@@ -56,7 +63,7 @@ if ($dokeos_chapter) {
             $_SESSION['oLP']->stop_previous_item();
             $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
             if ($prereq_check === true) {
-                $src = $_SESSION['oLP']->get_link('http',$lp_item_id);
+                $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
                 $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
             } else {
                 $src = 'blank.php?error=prerequisites';
@@ -67,7 +74,7 @@ if ($dokeos_chapter) {
             $_SESSION['oLP']->stop_previous_item(); // save status manually if asset
             $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
             if ($prereq_check === true) {
-                $src = $_SESSION['oLP']->get_link('http',$lp_item_id);
+                $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
                 $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
             } else {
                 $src = 'blank.php';
@@ -78,7 +85,9 @@ if ($dokeos_chapter) {
     }
 }
 
-if ($debug > 0) { error_log('New lp - In lp_content.php - File url is '.$src, 0); }
+if ($debug > 0) {
+    error_log('New lp - In lp_content.php - File url is '.$src, 0);
+}
 $_SESSION['oLP']->set_previous_item($lp_item_id);
 
 if (isset($_SESSION['gradebook'])) {
@@ -86,18 +95,20 @@ if (isset($_SESSION['gradebook'])) {
 }
 
 if (!empty($gradebook) && $gradebook == 'view') {
-    $interbreadcrumb[] = array (
-            'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
-            'name' => get_lang('ToolGradebook')
-        );
+    $interbreadcrumb[] = array(
+        'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
+        'name' => get_lang('ToolGradebook')
+    );
 }
 // Define the 'doc.inc.php' as language file.
 $nameTools = $_SESSION['oLP']->get_name();
-$interbreadcrumb[]= array('url' => './lp_list.php', 'name' => get_lang('Doc'));
+$interbreadcrumb[] = array('url' => './lp_list.php', 'name' => get_lang('Doc'));
 // Update global setting to avoid displaying right menu.
 $save_setting = api_get_setting('show_navigation_menu');
 global $_setting;
 $_setting['show_navigation_menu'] = false;
-if ($debug > 0) { error_log('New LP - In lp_content.php - Loading '.$src, 0); }
+if ($debug > 0) {
+    error_log('New LP - In lp_content.php - Loading '.$src, 0);
+}
 
 header("Location: ".urldecode($src));

+ 2 - 2
main/template/default/auth/courses_categories.php

@@ -149,10 +149,10 @@ $stok = Security::get_token();
                         echo '<div class="thumbnail">';
                         if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
                             echo '<a class="ajax" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&amp;code='.$course['code'].'" title="'.$icon_title.'" rel="gb_page_center[778]">';
-                            echo '<img src="'.$course_medium_image.'" />';
+                            echo '<img src="'.$course_medium_image.'" alt="" />';
                             echo '</a>';
                         } else {
-                            echo '<img src="'.$course_medium_image.'" />';
+                            echo '<img src="'.$course_medium_image.'" alt="'.$title.'"/>';
                         }
                         echo '</div>';//thumb
                     echo '</div>';

+ 1 - 1
main/template/default/layout/hot_course_item.tpl

@@ -5,7 +5,7 @@
                 <div class="row">
                     <div class="span2">
                         <div class="thumbnail">
-                            <img src="{{ hot_course.extra_info.course_image }}" />                                    
+                            <img src="{{ hot_course.extra_info.course_image }}" alt="" /> 
                         </div>
                     </div>
                     <div class="span6">