|
|
|
@ -481,22 +481,16 @@ class FillBlanks extends Question |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $separatorStartRegexp |
|
|
|
|
* @param string $separatorEndRegexp |
|
|
|
|
* @param string $correctItemRegexp |
|
|
|
|
* @param integer $questionId |
|
|
|
|
* @param $correctItem |
|
|
|
|
* @param $attributes |
|
|
|
|
* @param int $questionId |
|
|
|
|
* @param string $correctItem |
|
|
|
|
* @param array $attributes |
|
|
|
|
* @param string $answer |
|
|
|
|
* @param $listAnswersInfo |
|
|
|
|
* @param array $listAnswersInfo |
|
|
|
|
* @param boolean $displayForStudent |
|
|
|
|
* @param integer $inBlankNumber |
|
|
|
|
* @param int $inBlankNumber |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function getFillTheBlankHtml( |
|
|
|
|
$separatorStartRegexp, |
|
|
|
|
$separatorEndRegexp, |
|
|
|
|
$correctItemRegexp, |
|
|
|
|
$questionId, |
|
|
|
|
$correctItem, |
|
|
|
|
$attributes, |
|
|
|
@ -518,7 +512,7 @@ class FillBlanks extends Question |
|
|
|
|
$listMenu = self::getFillTheBlankMenuAnswers($inTeacherSolution, $displayForStudent); |
|
|
|
|
$result .= '<select name="choice['.$questionId.'][]">'; |
|
|
|
|
for ($k=0; $k < count($listMenu); $k++) { |
|
|
|
|
$selected = ""; |
|
|
|
|
$selected = ''; |
|
|
|
|
if ($correctItem == $listMenu[$k]) { |
|
|
|
|
$selected = " selected=selected "; |
|
|
|
|
} |
|
|
|
@ -528,7 +522,7 @@ class FillBlanks extends Question |
|
|
|
|
} |
|
|
|
|
$optionMenu .= '<option '.$selected.' value="'.$listMenu[$k].'">'.$listMenu[$k].'</option>'; |
|
|
|
|
} |
|
|
|
|
if ($selected == "") { |
|
|
|
|
if ($selected == '') { |
|
|
|
|
// no good answer have been found... |
|
|
|
|
$selected = " selected=selected "; |
|
|
|
|
} |
|
|
|
@ -540,7 +534,12 @@ class FillBlanks extends Question |
|
|
|
|
//no break |
|
|
|
|
case self::FILL_THE_BLANK_STANDARD: |
|
|
|
|
default: |
|
|
|
|
$result = Display::input('text', "choice[$questionId][]", $correctItem, $attributes); |
|
|
|
|
$result = Display::input( |
|
|
|
|
'text', |
|
|
|
|
"choice[$questionId][]", |
|
|
|
|
$correctItem, |
|
|
|
|
$attributes |
|
|
|
|
); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -557,19 +556,12 @@ class FillBlanks extends Question |
|
|
|
|
*/ |
|
|
|
|
public static function getFillTheBlankMenuAnswers($correctAnswer, $displayForStudent) |
|
|
|
|
{ |
|
|
|
|
// if $inDisplayForStudent, then shuffle the result array |
|
|
|
|
/*$items = explode('|', $correctAnswer); |
|
|
|
|
if ($displayForStudent) { |
|
|
|
|
shuffle($items); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $items;*/ |
|
|
|
|
$listChoises = api_preg_split("/\|/", $correctAnswer); |
|
|
|
|
$list = api_preg_split("/\|/", $correctAnswer); |
|
|
|
|
if ($displayForStudent) { |
|
|
|
|
shuffle($listChoises); |
|
|
|
|
shuffle($list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $listChoises; |
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -800,7 +792,7 @@ class FillBlanks extends Question |
|
|
|
|
* @param $studentsIdList |
|
|
|
|
* @param string $startDate |
|
|
|
|
* @param string $endDate |
|
|
|
|
* @param bool $useLastAnswerredAttempt |
|
|
|
|
* @param bool $useLastAnsweredAttempt |
|
|
|
|
* @return array |
|
|
|
|
* ( |
|
|
|
|
* [student_id] => Array |
|
|
|
@ -817,7 +809,7 @@ class FillBlanks extends Question |
|
|
|
|
$studentsIdList, |
|
|
|
|
$startDate, |
|
|
|
|
$endDate, |
|
|
|
|
$useLastAnswerredAttempt = true |
|
|
|
|
$useLastAnsweredAttempt = true |
|
|
|
|
) { |
|
|
|
|
$tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
|
|
|
$tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
|
|
@ -878,7 +870,7 @@ class FillBlanks extends Question |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// student didn't answer this bracket |
|
|
|
|
if ($useLastAnswerredAttempt) { |
|
|
|
|
if ($useLastAnsweredAttempt) { |
|
|
|
|
// if we take into account the last answered attempt |
|
|
|
|
if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
|
|
@ -928,7 +920,7 @@ class FillBlanks extends Question |
|
|
|
|
$separatorStart = $listWithStudentAnswer['blankseparatorstart']; |
|
|
|
|
$separatorEnd = $listWithStudentAnswer['blankseparatorend']; |
|
|
|
|
// lets rebuild the sentence with [correct answer][student answer][answer is correct] |
|
|
|
|
$result = ""; |
|
|
|
|
$result = ''; |
|
|
|
|
for ($i=0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) { |
|
|
|
|
$result .= $listWithStudentAnswer['commonwords'][$i]; |
|
|
|
|
$result .= $listWithStudentAnswer['tabwordsbracket'][$i]; |
|
|
|
@ -1247,12 +1239,10 @@ class FillBlanks extends Question |
|
|
|
|
$answerInfo = FillBlanks::getAnswerInfo($answerText, true); |
|
|
|
|
$correctAnswerList = $answerInfo['tabwords']; |
|
|
|
|
$studentAnswer = $answerInfo['studentanswer']; |
|
|
|
|
|
|
|
|
|
$isCorrect = true; |
|
|
|
|
|
|
|
|
|
foreach ($correctAnswerList as $i => $correctAnswer) { |
|
|
|
|
$isGoodStudentAnswer = FillBlanks::isGoodStudentAnswer($studentAnswer[$i], $correctAnswer); |
|
|
|
|
|
|
|
|
|
$isCorrect = $isCorrect && $isGoodStudentAnswer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|