Browse Source

[svn r15792] Switchable fill in blank fields syntax fixed quiz tool (see FS#2697)

Julio Montoya 16 years ago
parent
commit
a6ab382ddf

+ 2 - 2
main/exercice/exercice_submit.php

@@ -36,8 +36,8 @@
 * 	the administrator
 *	@package dokeos.exercise
 * 	@author Olivier Brouckaert
-* 	@author Julio Montoya multiple fill in blank option added
-* 	@version $Id: exercice_submit.php 15719 2008-07-04 00:50:44Z juliomontoya $
+* 	@author Julio Montoya Armas switchable fill in blank option added
+* 	@version $Id: exercice_submit.php 15792 2008-07-15 17:06:47Z juliomontoya $
 */
 
 

+ 19 - 17
main/exercice/exercise_result.php

@@ -28,8 +28,8 @@
 *	@package dokeos.exercise
 *	@author Olivier Brouckaert, main author
 *	@author Roan Embrechts, some refactoring
-* 	@author Julio Montoya multiple fill in blank option added
-* 	@version $Id: exercise_result.php 15719 2008-07-04 00:50:44Z juliomontoya $
+* 	@author Julio Montoya Armas switchable fill in blank option added
+* 	@version $Id: exercise_result.php 15792 2008-07-15 17:06:47Z juliomontoya $
 *
 *	@todo	split more code up in functions, move functions to library?
 */
@@ -494,26 +494,28 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 									
 							    		// the question is encoded like this
 									    // [A] B [C] D [E] F::10,10,10@1
-									    // number 1 before the "@" means that is a multiple fill in blank question
+									    // number 1 before the "@" means that is a switchable fill in blank question
 									    // [A] B [C] D [E] F::10,10,10@ or  [A] B [C] D [E] F::10,10,10
 									    // means that is a normal fill blank question				
-								
-										$multiple_answer_array =explode('@',$answer);	
-										// is multiple fill blank or not
-										$multiple_answer_set=false;
-										if ($multiple_answer_array[1]==1)
+
+										// first we explode the "::"
+										$pre_array = explode('::', $answer);	
+				
+										// is switchable fill blank or not			
+										$is_set_switchable = explode('@', $pre_array[1]);
+										
+										$switchable_answer_set=false;
+										if ($is_set_switchable[1]==1)
 										{
-											$multiple_answer_set=true;											
-										}
-									
-										// splits text and weightings that are joined with the character '::'
-										list($answer,$answerWeighting)=explode('::',$multiple_answer_array[0]);
+											$switchable_answer_set=true;
+										}								
+														
+										$answer = $pre_array[0];
 										
 										// splits weightings that are joined with a comma
-										$answerWeighting=explode(',',$answerWeighting);
+										$answerWeighting = explode(',',$is_set_switchable[0]);				
 
 										// we save the answer because it will be modified
-
 										$temp=$answer;
 
 										// TeX parsing
@@ -590,7 +592,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 												$answer.=$real_text[0];
 											}
 											
-											if (!$multiple_answer_set)
+											if (!$switchable_answer_set)
 											{						
 												if ($correct_tags[$i]==$user_tags[$i])
 												{
@@ -673,7 +675,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 
 											$choice[$j]=trim($choice[$j]);
 											
-											if (!$multiple_answer_set)
+											if (!$switchable_answer_set)
 											{
 												// if the word entered by the student IS the same as the one defined by the professor
 												if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j])))

+ 18 - 13
main/exercice/exercise_show.php

@@ -24,7 +24,7 @@
 /**
 *
 *	@package dokeos.exercise
-* 	@author Julio Montoya multiple fill in blank option added
+* 	@author Julio Montoya Armas switchable fill in blank option added
 * 	@version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
 *
 * 	@todo remove the debug code and use the general debug library
@@ -567,22 +567,27 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				
 			    // the question is encoded like this
 			    // [A] B [C] D [E] F::10,10,10@1
-			    // number 1 before the "@" means that is a multiple fill in blank question
+			    // number 1 before the "@" means that is a switchable fill in blank question
 			    // [A] B [C] D [E] F::10,10,10@ or  [A] B [C] D [E] F::10,10,10
-			    // means that is a normal fill blank question			    
-				$multiple=explode('@',$answer);
+			    // means that is a normal fill blank question
+
+				$pre_array = explode('::', $answer);	
 				
-				// is multiple fill blank or not								
-				$multiple_answer_set=false;				
-				if ($multiple[1]==1)
+				// is switchable fill blank or not			
+				$is_set_switchable = explode('@', $pre_array[1]);
+				$switchable_answer_set=false;
+				if ($is_set_switchable[1]==1)
 				{
-					$multiple_answer_set=true;
-				}										
-				
-				list($answer,$answerWeighting)=explode('::',$multiple[0]);				
+					$switchable_answer_set=true;
+				}								
+								
+				$answer = $pre_array[0];
 				
 				// splits weightings that are joined with a comma
-				$answerWeighting=explode(',',$answerWeighting);
+				$answerWeighting = explode(',',$is_set_switchable[0]);			
+				//list($answer,$answerWeighting)=explode('::',$multiple[0]);				
+				
+				//$answerWeighting=explode(',',$answerWeighting);
 				// we save the answer because it will be modified
 			    $temp=$answer;
 		
@@ -600,7 +605,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				// the loop will stop at the end of the text
 				$i=0;
 				//normal fill in blank
-				if (!$multiple_answer_set)
+				if (!$switchable_answer_set)
 				{
 					while(1)
 					{

+ 11 - 8
main/exercice/fill_blanks.class.php

@@ -25,6 +25,7 @@
 *	File containing the FillBlanks class.
 *	@package dokeos.exercise
 * 	@author Eric Marguin
+* 	@author Julio Montoya Armas switchable fill in blank option added
 * 	@version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
 */
 
@@ -70,22 +71,24 @@ class FillBlanks extends Question
 			
 			// the question is encoded like this
 		    // [A] B [C] D [E] F::10,10,10@1
-		    // number 1 before the "@" means that is a multiple fill in blank question
+		    // number 1 before the "@" means that is a switchable fill in blank question
 		    // [A] B [C] D [E] F::10,10,10@ or  [A] B [C] D [E] F::10,10,10
 		    // means that is a normal fill blank question		
-			    
-			$is_set_multiple = explode('@', $objAnswer->selectAnswer(1));			
-			if ($is_set_multiple[1]) 
+
+			$pre_array = explode('::', $objAnswer->selectAnswer(1));
+	
+			$is_set_switchable = explode('@', $pre_array[1]);			
+			if ($is_set_switchable[1]) 
 			{
 				$defaults['multiple_answer']=1;	
 			}
 			else
 			{
 				$defaults['multiple_answer']=0;	
-			}			
-			$a_answer = explode('::', $is_set_multiple[0]);
-			$defaults['answer'] = $a_answer[0];
-			$a_weightings = explode(',',$a_answer[1]);
+			}
+			
+			$defaults['answer'] = $pre_array[0];
+			$a_weightings = explode(',',$is_set_switchable[0]);
 		}
 		else
 		{