Minor cleaning file exercise.class.php

skala
Julio Montoya 14 years ago
parent 62c11dd5b5
commit c9ad4c79d9
  1. 19
      main/exercice/exercise.class.php

@ -1821,7 +1821,7 @@ class Exercise {
$user_answer = '';
// Get answer list for matching
$sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" ';
$sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id = "'.$questionId.'" ';
$res_answer = Database::query($sql_answer);
$answer_matching =array();
while ($real_answer = Database::fetch_array($res_answer)) {
@ -2057,9 +2057,7 @@ class Exercise {
$answer = '';
$j = 0;
//initialise answer tags
$user_tags = array ();
$correct_tags = array ();
$real_text = array ();
$user_tags = $correct_tags = $real_text = array ();
// the loop will stop at the end of the text
while (1) {
// quits the loop if there are no more blanks (detect '[')
@ -2087,7 +2085,7 @@ class Exercise {
break;
}
if ($from_database) {
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($exeId)."' AND question_id= '".Database::escape_string($questionId)."'";
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".$exeId."' AND question_id= '".Database::escape_string($questionId)."'";
$resfill = Database::query($queryfill);
$str = Database::result($resfill,0,'answer');
@ -2095,9 +2093,9 @@ class Exercise {
$str = str_replace('\r\n', '', $str);
$choice = $arr[1];
$tmp=strrpos($choice[$j],' / ');
$choice[$j]=api_substr($choice[$j],0,$tmp);
$choice[$j]=trim($choice[$j]);
$tmp = strrpos($choice[$j],' / ');
$choice[$j] = api_substr($choice[$j],0,$tmp);
$choice[$j] = trim($choice[$j]);
//Needed to let characters ' and " to work as part of an answer
$choice[$j] = stripslashes($choice[$j]);
@ -2105,12 +2103,11 @@ class Exercise {
$choice[$j] = trim($choice[$j]);
}
$user_tags[] = api_strtolower($choice[$j]);
$user_tags[] = api_strtolower($choice[$j]);
//put the contents of the [] answer tag into correct_tags[]
$correct_tags[] = api_strtolower(api_substr($temp, 0, $pos));
$correct_tags[] = api_strtolower(api_substr($temp, 0, $pos));
$j++;
$temp = api_substr($temp, $pos +1);
//$answer .= ']';
}
$answer = '';
$real_correct_tags = $correct_tags;

Loading…
Cancel
Save