Browse Source

Merge with 1.9.x

Julio Montoya 12 years ago
parent
commit
0ee12643f7

+ 3 - 2
main/admin/user_information.php

@@ -161,6 +161,7 @@ if (Database::num_rows($res) > 0) {
 /**
  * Show the classes in which this user is subscribed
  */
+/*
 $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
 $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
 $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c '.
@@ -182,8 +183,8 @@ if (Database::num_rows($res) > 0) {
     Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
     echo '</blockquote>';
 } else {    
-    Display::display_warning_message(get_lang('NoClassesForThisUser'));
-}
+    echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
+}*/
 
 /**
  * Show the URL in which this user is subscribed

+ 10 - 3
main/document/document.php

@@ -878,9 +878,16 @@ if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
 } else {
     $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, false);
 }
-if (GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()) || UserManager::is_admin(api_get_user_id())) {
-    $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights);
+if (api_get_group_id() != 0) {
+    if (GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()) || UserManager::is_admin(api_get_user_id())) {
+        $folders = DocumentManager::get_all_document_folders($_course, api_get_group_id(), $is_allowed_to_edit || $group_member_with_upload_rights);
+    }
+} else {
+    $folders = DocumentManager::get_all_document_folders($_course, api_get_group_id(), $is_allowed_to_edit || $group_member_with_upload_rights);
 }
+
+
+//$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights);
 if ($folders === false) {
     $folders = array();
 }
@@ -1010,7 +1017,7 @@ $table_footer = '';
 $total_size = 0;
 
 if (isset($docs_and_folders) && is_array($docs_and_folders)) {
-    if (GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()) || UserManager::is_admin(api_get_user_id())) {
+    if (api_get_group_id() == 0 || (GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()) || UserManager::is_admin(api_get_user_id()))) {
         // Create a sortable table with our data
         $sortable_data = array();
 

+ 22 - 26
main/exercice/exercise.class.php

@@ -3357,7 +3357,27 @@ class Exercise {
 		$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&id='.$exe_id.'&action=qualify';
 		$user_info = UserManager::get_user_info_by_id(api_get_user_id());
 
-		$msg = '<p>'.get_lang('OralQuestionsAttempted').' :</p>
+
+            $oral_question_list = null;
+			foreach ($question_list_answers as $item) {
+                $question    = $item['question'];
+                $answer      = $item['answer'];
+                $answer_type = $item['answer_type'];
+
+                if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
+                    $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3"><tr>
+                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>
+                            <td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>
+                        </tr>
+                        <tr>
+                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Answer').'</td>
+                            <td valign="top" bgcolor="#F3F3F3">'.$answer.'</td>
+                        </tr></table>';
+                }
+			}
+
+            if (!empty($oral_question_list)) {
+                 $msg = '<p>'.get_lang('OralQuestionsAttempted').' :</p>
                     <p>'.get_lang('AttemptDetails').' : </p>
                     <table class="data_table">
                         <tr>
@@ -3377,31 +3397,7 @@ class Exercise {
                             <td>#mail#</td>
                         </tr>
                     </table>';
-            $oral_question_list = null;
-			foreach ($question_list_answers as $item) {
-                $question    = $item['question'];
-                $answer      = $item['answer'];
-                $answer_type = $item['answer_type'];
-
-                if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
-                    $oral_question_list.='<tr>
-                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>
-                            <td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>
-                        </tr>
-                        <tr>
-                            <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Answer').'</td>
-                            <td valign="top" bgcolor="#F3F3F3">'.$answer.'</td>
-                        </tr>';
-                }
-			}
-
-            if (!empty($oral_question_list)) {
-                $msg .=  '<p><br />'.get_lang('OralQuestionsAttemptedAre').' :</p>
-                    <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">';
-                $msg .= $oral_question_list;
-                $msg.='</table><br />';
-
-
+                $msg .=  '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />';
                 $msg1   = str_replace("#exercise#",    $this->exercise, $msg);
                 $msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
                 $msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);

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

@@ -425,7 +425,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
 				            }                                
                             $correct_item = preg_quote($correct_item);
                             $correct_item = api_preg_replace('|/|', '\/', $correct_item);   // to prevent error if there is a / in the text to find
-				            $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer);                            
+    			            $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer, 1);
 				        }		        				        
 				        $i++;				        
 				    }

+ 7 - 21
main/exercice/exercise_submit.php

@@ -72,18 +72,12 @@ $reminder 				= isset($_REQUEST['reminder']) ? intval($_REQUEST['reminder']) : 0
 $remind_question_id 	= isset($_REQUEST['remind_question_id']) ? intval($_REQUEST['remind_question_id']) : 0;
 $exerciseId				= isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : 0;
 
-if (empty($formSent)) {
-    $formSent = $_REQUEST['formSent'];
-}
-if (empty($exerciseResult)) {
-    $exerciseResult = $_REQUEST['exerciseResult'];
-}
-if (empty($exerciseResultCoordinates)) {
-	$exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
-}
+$formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null;
+$exerciseResult = isset($_REQUEST['exerciseResult']) ? $_REQUEST['exerciseResult'] : null;
+$exerciseResultCoordinates = isset($_REQUEST['exerciseResultCoordinates']) ? $_REQUEST['exerciseResultCoordinates'] : null;
 
 $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
-$choice = empty($choice) ? $_REQUEST['choice2'] : null;
+$choice = empty($choice) ? isset($_REQUEST['choice2']) ? $_REQUEST['choice2'] : null : null;
 
 //From submit modal
 $current_question = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : null;
@@ -95,7 +89,7 @@ $error = '';
 $exercice_attemp_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
 /*  Teacher takes an exam and want to see a preview, we delete the objExercise from the session in order to get the latest changes in the exercise */
-if (api_is_allowed_to_edit(null,true) && $_GET['preview'] == 1 ) {
+if (api_is_allowed_to_edit(null,true) && isset($_GET['preview']) && $_GET['preview'] == 1 ) {
     Session::erase('objExercise');
 }
 
@@ -474,13 +468,6 @@ if ($formSent && isset($_POST)) {
                     	$sql_exe_result = ", exe_result = 0";
                         if ($debug) { error_log('exercise_time_control_is_valid is NOT valid then exe_result = 0 '); }
                     }
-                    /*
-                    //Clean incomplete - @todo why setting to blank the status?
-                    $stat_table   = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-                    $update_query = "UPDATE $stat_table SET  status = '', exe_date = '".api_get_utc_datetime() ."' , orig_lp_item_view_id = '$learnpath_item_view_id' $sql_exe_result  WHERE exe_id = ".$exe_id;
-
-                    if ($debug) { error_log('Updating track_e_exercises '.$update_query); }
-                    Database::query($update_query);*/
                 }
                 if ($debug) { error_log('10. Redirecting to exercise_show.php'); }
                 header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
@@ -529,8 +516,6 @@ if ($question_count != 0) {
 	                    exit;
 	                }
 	            }	           
-	            //header("Location: exercise_result.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
-	            //exit;
 	        } else {
 	            //Time control is only enabled for ONE PER PAGE
 	            if (!empty($exe_id) && is_numeric($exe_id)) {
@@ -550,6 +535,7 @@ if ($question_count != 0) {
 	            	exit;
 	            } else {
 	            	header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
+                    exit;
 	            }
 	        }
 	    } else {
@@ -685,7 +671,7 @@ if ($origin != 'learnpath') {
 }
 
 if ($reminder == 2)  {
-    if ($debug) { error_log('. $reminder == 2'); }
+    if ($debug) { error_log(' $reminder == 2'); }
 
     $data_tracking  = $exercise_stat_info['data_tracking'];
     $data_tracking  = explode(',', $data_tracking);

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

@@ -10,7 +10,7 @@
  * Code
  */
 if(class_exists('MultipleAnswerCombinationTrueFalse')) { return true; }
-require 'multiple_answer_combination.class.php';
+require_once 'multiple_answer_combination.class.php';
 /**
 	CLASS MultipleAnswer
  *

+ 5 - 4
main/exercice/question.class.php

@@ -1199,9 +1199,9 @@ abstract class Question
 		// default content
 		$isContent = isset($_REQUEST['isContent']) ? intval($_REQUEST['isContent']) : null;
 
-		// question type
-		$answerType= intval($_REQUEST['answerType']);
-		$form->addElement('hidden','answerType',$_REQUEST['answerType']);
+		// Question type
+        $answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null;
+		$form->addElement('hidden','answerType', $_REQUEST['answerType']);
 
 		// html editor
 		$editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
@@ -1222,7 +1222,8 @@ abstract class Question
 		$form -> addElement ('html','</div>');
 
         // hidden values
-		$form->addElement('hidden', 'myid', intval($_REQUEST['myid']));
+        $my_id = isset($_REQUEST['myid']) ? intval($_REQUEST['myid']) : null;
+		$form->addElement('hidden', 'myid', $my_id);
 
         if ($this->type != MEDIA_QUESTION) {
 

+ 13 - 7
main/exercice/savescores.php

@@ -64,16 +64,14 @@ function save_scores($file, $score) {
         // anonymous
         $user_id = "NULL";
     }
-    $sql = "INSERT INTO $TABLETRACK_HOTPOTATOES ".
-        "(exe_name, exe_user_id, exe_date,exe_cours_id,exe_result,exe_weighting)".
-        "VALUES".
-        "(
+    $sql = "INSERT INTO $TABLETRACK_HOTPOTATOES (exe_name, exe_user_id, exe_date, exe_cours_id, exe_result, exe_weighting) VALUES (
 			'".Database::escape_string($file)."',
 			'".Database::escape_string($user_id)."',
 			'".Database::escape_string($date)."',
 			'".Database::escape_string($_cid)."',
 			'".Database::escape_string($score)."',
 			'".Database::escape_string($weighting)."')";
+
     Database::query($sql);
 
     if ($origin == 'learnpath') {
@@ -81,7 +79,15 @@ function save_scores($file, $score) {
         //table to get tracking in there as well
         global $jscript2run;
         //record the results in the learning path, using the SCORM interface (API)
-        $jscript2run .= "<script>window.parent.API.void_save_asset('$score', '$weighting', 0, 'completed');</script>";
+        $jscript2run .= "<script>
+            $(document).ready(function() {
+                //API_obj = window.frames.window.content.API;
+                //API_obj = $('content_id').context.defaultView.content.API; //works only in FF
+                //console.log(window.parent.frames.window.top.API);
+                API_obj = window.parent.frames.window.top.API;
+                API_obj.void_save_asset('$score', '$weighting', 0, 'completed');
+            });
+        </script>";
     }
 }
 
@@ -95,7 +101,7 @@ if ($origin != 'learnpath') {
     echo $jscript2run;
 } else {
     $htmlHeadXtra[] = $jscript2run;
-    Display::display_header();
-    echo get_lang('HotPotatoesFinished');
+    Display::display_reduced_header();
+    Display::display_confirmation_message(get_lang('HotPotatoesFinished'));
     Display::display_footer();
 }

+ 13 - 39
main/exercice/showinframes.php

@@ -13,7 +13,6 @@ require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php';
 
 $time = time();
-
 $doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file']));
 $cid                = api_get_course_id();
 $document_path      = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
@@ -33,8 +32,8 @@ if ($content == '') {
 	$mit = "function Finish(){";
 	$js_content = "
         //Code added - start
-        var SaveScoreVariable = 0;   
-        function mySaveScore() {            
+        var SaveScoreVariable = 0;
+        function mySaveScore() {
             if (SaveScoreVariable==0) {
                 SaveScoreVariable = 1;
                     if (C.ie) {
@@ -44,7 +43,7 @@ if ($content == '') {
                         window.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
                     }
 						}
-				}				
+				}
 				function Finish(){
                     mySaveScore();
         //Code added - end
@@ -58,10 +57,11 @@ if ($content == '') {
 	if (CheckSubFolder($full_file_path.$user_id.'.t.html') == 0) {
 		$newcontent = ReplaceImgTag($newcontent);
 	}
-} else {	
+} else {
 	$newcontent = $content;
 }
 
+
 WriteFileCont($full_file_path.$user_id.'.t.html', $newcontent);
 $doc_url = GetFolderPath($doc_url).urlencode(basename($doc_url));
 
@@ -81,15 +81,15 @@ if (isset($_SESSION['gradebook'])){
 
 if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
-			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
-			'name' => get_lang('ToolGradebook')
-		);
+        'url'  => '../gradebook/'.$_SESSION['gradebook_dest'],
+        'name' => get_lang('ToolGradebook')
+    );
 }
-$htmlHeadXtra[]  = '
+$htmlHeadXtra[] = '
 <script>
-    var height = window.innerHeight;
     $(document).ready( function(){
-        $("iframe").css("height", height)
+        var height = $(this).innerHeight() - 20;
+        $("#hotpotatoe").css("height", height)
     });
 </script>';
 
@@ -100,32 +100,6 @@ if ($origin == 'learnpath') {
     Display::display_header($nameTools,"Exercise");
 }
 $url = $document_web_path.$doc_url.$user_id.'.t.html?time='.Security::remove_XSS($time);
-echo '<iframe id="hotpotatoe" width="100%" frameborder="0" src="'.$url.'"><iframe>';
+echo '<iframe style="overflow:hidden" id="hotpotatoe" width="100%" frameborder="0" src="'.$url.'"></iframe>';
+echo '</body></html>';
 exit;
-
-
-if ($origin!='learnpath') {
-	?>
-	<frameset rows="<?php echo $header_height; ?>,*" border="0" frameborder="no">
-		<frame name="top" scrolling="no" noresize target="contents" src="testheaderpage.php?file=<?php echo Security::remove_XSS(str_replace(array('../','\\','\\0','..'),array('','','',''),urldecode($_GET['file']))); ?>">
-		<frame name="main" src="<?php echo $document_web_path.$doc_url.$user_id.'.t.html?time='.Security::remove_XSS($time); ?>">
-	<noframes>
-	<body>
-		<p>This page uses frames, but your browser doesn't support them.
-			We suggest you try Mozilla, Firebird, Safari, Opera, or other browsers updated this millenium.
- 		</p>
-	</body>
-	</noframes>
-	</frameset>
-	<?php
-} else {
-	?>
-	<script>
-		s='<?php echo $document_web_path.$doc_url.$user_id; ?>.t.html?time=<?php echo Security::remove_XSS($time); ?>';		
-		window.location=s;
-	</script>
-	<?php
-}
-?>
-
-</html>

+ 12 - 12
main/inc/ajax/exercise.ajax.php

@@ -17,6 +17,9 @@ $course_id = api_get_course_int_id();
 
 if ($debug) error_log("$action ajax call");
 
+$session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : api_get_session_id();
+$course_code = isset($_REQUEST['cidReq']) ? $_REQUEST['cidReq'] : api_get_course_id();
+
 switch ($action) {
     case 'get_live_stats':
         if (!api_is_allowed_to_edit(null, true)) {
@@ -140,17 +143,14 @@ 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
+            //Insert all
             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++;
             }
@@ -158,8 +158,6 @@ switch ($action) {
         }
         break;
     case 'update_question_order':
-        $session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : api_get_session_id();
-        $course_code = isset($_REQUEST['cidReq']) ? $_REQUEST['cidReq'] : api_get_course_id();
 
         $course_info = api_get_course_info($course_code);
         $course_id = $course_info['real_id'];
@@ -174,7 +172,7 @@ switch ($action) {
             $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);        
             $counter = 1;
             foreach ($new_question_list as $new_order_id) {            
-                Database::update($TBL_QUESTIONS, array('question_order' => $counter), array('question_id = ? AND c_id = ? AND exercice_id = ? '=>array(intval($new_order_id), $course_id, $exercise_id)), true);
+                Database::update($TBL_QUESTIONS, array('question_order' => $counter), array('question_id = ? AND c_id = ? AND exercice_id = ? '=>array(intval($new_order_id), $course_id, $exercise_id)));
                 $counter++;
             }
             Display::display_confirmation_message(get_lang('Saved'));
@@ -190,6 +188,8 @@ switch ($action) {
     	}
     	break;
     case 'save_exercise_by_now':
+        $course_info = api_get_course_info($course_code);
+        $course_id = $course_info['real_id'];
         //Use have permissions?
         if (api_is_allowed_to_session_edit()) {
         	            
@@ -288,7 +288,7 @@ switch ($action) {
             
             if ($type == 'simple') {           
                 foreach ($question_list as $my_question_id) {
-                    $objQuestionTmp  = Question :: read($my_question_id);
+                    $objQuestionTmp  = Question::read($my_question_id, $course_id);
                     $total_weight   += $objQuestionTmp->selectWeighting();
                 }
             }          
@@ -309,7 +309,7 @@ switch ($action) {
                 if ($debug) error_log("my_choice = ".print_r($my_choice, 1)."");
                                 
                // creates a temporary Question object
-            	$objQuestionTmp        = Question::read($my_question_id);
+            	$objQuestionTmp = Question::read($my_question_id, $course_id);
             	
             	//Getting free choice data
             	if ($objQuestionTmp->type  == FREE_ANSWER && $type == 'all') {
@@ -337,9 +337,9 @@ switch ($action) {
                 // Deleting old attempt
                 if (isset($attempt_list) && !empty($attempt_list[$my_question_id])) {          
                     if ($debug) error_log("delete_attempt  exe_id : $exe_id, my_question_id: $my_question_id");
-                    delete_attempt($exe_id, api_get_user_id() , api_get_course_id(), api_get_session_id(), $my_question_id);
+                    delete_attempt($exe_id, api_get_user_id() , $course_code, $session_id, $my_question_id);
                     if ($objQuestionTmp->type  == HOT_SPOT) {            	        
-            	        delete_attempt_hotspot($exe_id, api_get_user_id() , api_get_course_id(), $my_question_id);
+            	        delete_attempt_hotspot($exe_id, api_get_user_id() , $course_code, $my_question_id);
                     }
                     if (isset($attempt_list[$my_question_id]) && isset($attempt_list[$my_question_id]['marks'])) {
             	    $total_score  -= $attempt_list[$my_question_id]['marks'];            	    
@@ -384,7 +384,7 @@ switch ($action) {
                                         $objExercise->selectId(), 
                                         $total_score, 
                                         $total_weight, 
-                                        api_get_session_id(),
+                                        $session_id,
                                         $exercise_stat_info['orig_lp_id'], 
                                         $exercise_stat_info['orig_lp_item_id'], 
                                         $exercise_stat_info['orig_lp_item_view_id'], 

+ 4 - 4
main/newscorm/lp_upload.php

@@ -33,7 +33,7 @@ $is_error = isset($user_file['error']) ? $user_file['error'] : false;
 if( Request::is_post() && $is_error){
     return api_failure::set_failure('upload_file_too_big');
     unset($_FILEs['user_file']);
-}else if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_FILES) > 0 && !empty($_FILES['user_file']['name'])) {
+} else if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_FILES) > 0 && !empty($_FILES['user_file']['name'])) {
 
     // A file upload has been detected, now deal with the file...
 
@@ -129,14 +129,14 @@ if( Request::is_post() && $is_error){
     $new_dir = replace_dangerous_char(trim($file_base_name), 'strict');
 
     require_once 'learnpath.class.php';
-    
+
     $result = learnpath::verify_document_size($s);
     if ($result == true) {
         return api_failure::set_failure('upload_file_too_big');
-         
+
     }
     $type = learnpath::get_package_type($s, basename($s));
-    
+
     switch ($type) {
         case 'scorm':
             require_once 'scorm.class.php';

+ 7 - 2
main/newscorm/scorm.class.php

@@ -350,6 +350,7 @@ class scorm extends learnpath {
                 }
                 $title = Database::escape_string($item['title']);
                 $title = api_utf8_decode($title);
+
                 $max_score = Database::escape_string($item['max_score']);
 
                 if ($max_score == 0 || is_null($max_score) || $max_score == '') {
@@ -365,11 +366,15 @@ class scorm extends learnpath {
                 }
 
                 $identifier = Database::escape_string($item['identifier']);
+
+                if (empty($title)) {
+                    $title = get_lang('Untitled');
+                }
+
                 $prereq = Database::escape_string($item['prerequisites']);
 
                 $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,launch_data, parameters) VALUES " .
-                        "($course_id, $lp_id, '$type','".$identifier."','".$title."'," .
-                        "'$path',0,$max_score, $value_add" .
+                        "($course_id, $lp_id, '$type','$identifier', '$title', '$path' , 0, $max_score, $value_add" .
                         "$parent, $previous, 0, " .
                         "'$prereq', ".$item['rel_order'] .", '".$item['datafromlms']."'," .
                         "'".$item['parameters']."'" .

+ 3 - 3
main/survey/generate_link.php

@@ -29,14 +29,14 @@ if (!survey_manager::survey_generation_hash_available()) {
 $link = survey_manager::generate_survey_link($survey_id, api_get_course_int_id(), api_get_session_id(), api_get_group_id());
 echo '<div class="row">';
     echo '<div class="span12" style="text-align:center">';
-    echo Display::url(get_lang('GenerateSurveyLink'), $link, array('class' => 'btn btn-primary btn-large'));
+    echo Display::url(get_lang('GenerateSurveyAccessLink'), $link, array('class' => 'btn btn-primary btn-large'));
     echo '</div>';
     echo '<div class="span12">';
-    echo get_lang('GenerateSurveyLinkExplanation');
+    echo get_lang('GenerateSurveyAccessLinkExplanation');
 
     echo '<pre>';
     echo  $link;
     echo '</pre>';
 
     echo '</div>';
-echo '</div>';
+echo '</div>';

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

@@ -4207,7 +4207,7 @@ class SurveyUtil {
 		if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id)) {
 			$return .= '<a href="create_new_survey.php?'.api_get_cidreq().'&amp;action=edit&amp;survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
             if (survey_manager::survey_generation_hash_available()) {
-                $return .=  Display::url(Display::return_icon('new_link.png', get_lang('Newlink'),'',ICON_SIZE_SMALL), 'generate_link.php?survey_id='.$survey_id.'&'.api_get_cidreq());
+                $return .=  Display::url(Display::return_icon('new_link.png', get_lang('GenerateSurveyAccessLink'),'',ICON_SIZE_SMALL), 'generate_link.php?survey_id='.$survey_id.'&'.api_get_cidreq());
             }
 			$return .= ' <a href="survey_list.php?'.api_get_cidreq().'&amp;action=empty&amp;survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?')).'\')) return false;">'.Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
 

+ 46 - 72
main/upload/form.scorm.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  * Display part of the SCORM sub-process for upload. This script MUST BE included by upload/index.php
@@ -6,115 +7,88 @@
  * @package chamilo.upload
  * @author Yannick Warnier <ywarnier@beeznest.org>
  */
+
 /**
  * Small function to list files in archive/
  */
-function get_zip_files_in_garbage(){
-	$list = array();
-	$dh = opendir(api_get_path(SYS_ARCHIVE_PATH));
-	if($dh === false){
-		//ignore
-	}else{
-		while($entry = readdir($dh)){
-			if(substr($entry,0,1) == '.'){/*ignore files starting with . */}
-			else
-			{
-				if(preg_match('/^.*\.zip$/i',$entry)){
-					$list[] = $entry;
-				}
-			}
-		}
-		natcasesort($list);
-		closedir($dh);
-	}
-	return $list;
+function get_zip_files_in_garbage() {
+    $list = array();
+    $dh = opendir(api_get_path(SYS_ARCHIVE_PATH));
+    if ($dh === false) {
+        //ignore
+    } else {
+        while ($entry = readdir($dh)) {
+            if (substr($entry, 0, 1) == '.') {/* ignore files starting with . */
+            } else {
+                if (preg_match('/^.*\.zip$/i', $entry)) {
+                    $list[] = $entry;
+                }
+            }
+        }
+        natcasesort($list);
+        closedir($dh);
+    }
+    return $list;
 }
+
 /**
  * Just display the form needed to upload a SCORM and give its settings
  */
 $nameTools = get_lang("FileUpload");
-$interbreadcrumb[]= array ("url"=>"../newscorm/lp_controller.php?action=list", "name"=> get_lang("ToolLearnpath"));
-Display::display_header($nameTools,"Path");
-//show the title
-//api_display_tool_title(get_lang("Learnpath")." - ".$nameTools.$add_group_to_title);
-//TODO: Include right language file
+$interbreadcrumb[] = array("url" => "../newscorm/lp_controller.php?action=list", "name" => get_lang("ToolLearnpath"));
+Display::display_header($nameTools, "Path");
 
 require_once '../newscorm/content_makers.inc.php';
-require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
 
 echo '<div class="actions">';
-echo '<a href="../newscorm/lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('back.png',get_lang('ReturnToLearningPaths'),'',ICON_SIZE_MEDIUM).'</a>';
+echo '<a href="../newscorm/lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('back.png', get_lang('ReturnToLearningPaths'), '', ICON_SIZE_MEDIUM).'</a>';
 echo '</div>';
 
-$form = new FormValidator('','POST','upload.php','','id="upload_form" enctype="multipart/form-data" style="background-image: url(\'../img/scorm.jpg\'); background-repeat: no-repeat; background-position: 620px;"');
+$form = new FormValidator('', 'POST', 'upload.php', '', 'id="upload_form" enctype="multipart/form-data" style="background-image: url(\'../img/scorm.jpg\'); background-repeat: no-repeat; background-position: 620px;"');
 $form->addElement('header', '', $nameTools);
 $form->addElement('hidden', 'curdirpath', $path);
 $form->addElement('hidden', 'tool', $my_tool);
 
-$form->addElement('file','user_file',get_lang('FileToUpload'));
-$form->add_real_progress_bar('uploadScorm','user_file');
+$form->addElement('file', 'user_file', get_lang('FileToUpload'));
+$form->add_real_progress_bar('uploadScorm', 'user_file');
 $form->addRule('user_file', get_lang('ThisFieldIsRequired'), 'required');
 
-/*$select_content_marker = &$form->addElement('select','content_maker',get_lang('ContentMaker'));
-foreach($content_origins as $index => $origin){
-	$select_content_marker->addOption($origin,$origin);
-}*/
 unset($content_origins[0]);
 unset($content_origins[1]);
 
-/*
-$select_content_proximity = &$form->addElement('select','content_proximity',get_lang('ContentProximity'));
-$select_content_proximity->addOption(get_lang('Local'),"local");
-$select_content_proximity->addOption(get_lang('Remote'),"remote");
-$select_content_proximity -> setSelected("local");
-*/
-if (api_get_setting('search_enabled')=='true') {
-	$form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
-	$specific_fields = get_specific_field_list();
-	foreach ($specific_fields as $specific_field) {
-		$form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
-	}
+if (api_get_setting('search_enabled') == 'true') {
+    $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
+    $specific_fields = get_specific_field_list();
+    foreach ($specific_fields as $specific_field) {
+        $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
+    }
 }
 
 if (api_is_platform_admin()) {
-    $form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));    
+    $form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
 }
 
-$form->addElement('style_submit_button','submit', get_lang('Send'),'class="upload"');
+$form->addElement('style_submit_button', 'submit', get_lang('Send'), 'class="upload"');
 
 $form->addElement('html', '<br /><br /><br />');
-/*$list = get_zip_files_in_garbage();
-if(count($list)>0){
-	$select_file_name = &$form->addElement('select','file_name',get_lang('Or').' '.api_strtolower(get_lang('UploadLocalFileFromGarbageDir')));
-	foreach($list as $file){
-		$select_file_name->addOption($file,$file);
-	}
-	$form->addElement('submit', 'submit', get_lang('Download'));
-}
-else{
-	$text_empty = &$form->addElement('text', 'empty', get_lang('Or').' '.api_strtolower(get_lang('UploadLocalFileFromGarbageDir')));
-	$defaults["empty"] = get_lang('Empty');
-	$text_empty->freeze();
-}*/
 
-if(is_dir(api_get_path(PLUGIN_PATH)."/pens")) {
-	require_once(api_get_path(PLUGIN_PATH)."/pens/chamilo_pens.php");
-	$list = ChamiloPens::findAll();
-	if(count($list) > 0) {
-		$select_pens = $form->addElement('select', 'pens_package', get_lang('Or').' '.get_lang('select a PENS package'));
-		foreach($list as $package) {
-			$select_pens->addOption($package->getPackageName(), $package->getPackageName());
-		}
-	}
+if (is_dir(api_get_path(PLUGIN_PATH)."/pens")) {
+    require_once(api_get_path(PLUGIN_PATH)."/pens/chamilo_pens.php");
+    $list = ChamiloPens::findAll();
+    if (count($list) > 0) {
+        $select_pens = $form->addElement('select', 'pens_package', get_lang('Or').' '.get_lang('select a PENS package'));
+        foreach ($list as $package) {
+            $select_pens->addOption($package->getPackageName(), $package->getPackageName());
+        }
+    }
 }
 
-
 // the default values for the form
-$defaults = array('index_document'=>'checked="checked"','use_max_score'=>1);
+$defaults = array('index_document' => 'checked="checked"', 'use_max_score' => 1);
 $form->setDefaults($defaults);
 Display::display_normal_message(Display::tag('strong', get_lang('SupportedScormContentMakers')).': '.implode(', ', $content_origins), false);
 $form->display();
 
-
 // footer
 Display::display_footer();

+ 1 - 0
main/upload/upload.scorm.php

@@ -13,6 +13,7 @@
 $language_file = 'scorm';
 $cwdir = getcwd();
 require_once '../newscorm/lp_upload.php';
+
 //reinit current working directory as many functions in upload change it
 chdir($cwdir);