Browse Source

Fixing fill in blanks one more time now it should work adding preg_quote see #5569

Julio Montoya 12 years ago
parent
commit
f9435d253a
1 changed files with 8 additions and 17 deletions
  1. 8 17
      main/exercice/exercise.lib.php

+ 8 - 17
main/exercice/exercise.lib.php

@@ -387,7 +387,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
                 }			
             	$s.='</tr>';
 				
-			} elseif ($answerType == FILL_IN_BLANKS) {
+			} elseif ($answerType == FILL_IN_BLANKS) {                
 				list($answer) = explode('::', $answer);
                 
                 //Correct answer
@@ -417,26 +417,17 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
 				            $value = explode('/', $value);
                             
 				            if (!empty($value[0])) {				            	
-				            	$value = str_replace('&nbsp;', '',  trim($value[0]));
-				            }
-                            
-                            if (api_strpos($correct_item, '-') !== false) {
-                                $correct_item = api_preg_replace('/-/',  '\-', $correct_item);
-                            }
-                            
-                            if (api_strpos($value, '-') !== false) {
-                                $value = api_preg_replace('/-/',  '\-', $value);
-                            }
-                            
-				            $answer = api_preg_replace('/\['.$correct_item.'+\]/', Display::input('text', "choice[$questionId][]", $value), $answer);	
-                            $answer = str_replace('\-', '-', $answer);
-				        }				        				        
+				            	$value = str_replace('&nbsp;', '',  trim($value[0]));                                
+				            }                                
+                            $correct_item = preg_quote($correct_item);                            
+				            $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);	
+				        }		        				        
 				        $i++;				        
 				    }
-				} else {
+				} else {                    
 					$answer = api_preg_replace('/\[[^]]+\]/', Display::input('text', "choice[$questionId][]", '', $attributes), $answer);
 				}
-                
 				$s .= '<tr><td>'.$answer.'</td></tr>';
             } elseif ($answerType == MATCHING) {
 				// matching type, showing suggestions and answers