Fill in blanks input width are calculated in the fly see BT#6509

1.9.x
Julio Montoya 11 years ago
parent 1d8035fe1a
commit a941044f69
  1. 1
      main/css/base.css
  2. 20
      main/exercice/exercise.lib.php

@ -2601,7 +2601,6 @@ div.admin_section h4 {
}
.question_options input[type="text"] {
width: 80px;
padding:0px;
margin:2px 2px 2px 0px;
}

@ -419,6 +419,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
$student_answer_list = $correct_answer_list[0];
}
if (!empty($correct_answer_list) && !empty($student_answer_list)) {
$correct_answer_list = $correct_answer_list[0];
$i = 0;
@ -436,13 +437,26 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
$value = str_replace(' ', '', trim($value[0]));
}
$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, 1);
// to prevent error if there is a / in the text to find
$correct_item = api_preg_replace('|/|', '\/', $correct_item);
$size = strlen($correct_item) * 10 + 10;
$attributes['style'] = 'width: '.$size.'px';
$answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value, $attributes), $answer, 1);
}
$i++;
}
} else {
$answer = api_preg_replace('/\[[^]]+\]/', Display::input('text', "choice[$questionId][]", '', $attributes), $answer);
foreach ($correct_answer_list[0] as $item) {
$size = strlen($item) * 10 + 10;
$attributes['style'] = 'width: '.$size.'px';
$pattern = '/\['.$item.'+\]/';
$answer = api_preg_replace($pattern, Display::input('text', "choice[$questionId][]", '', $attributes), $answer);
}
//$answer = api_preg_replace('/\[[^]]+\]/', Display::input('text', "choice[$questionId][]", '', $attributes), $answer);
}
$s .= $answer;
} elseif ($answerType == MATCHING) {

Loading…
Cancel
Save