|
|
@ -759,74 +759,76 @@ class FillBlanks extends Question |
|
|
|
$endDate, |
|
|
|
$endDate, |
|
|
|
$useLastAnswerredAttempt = true |
|
|
|
$useLastAnswerredAttempt = true |
|
|
|
) { |
|
|
|
) { |
|
|
|
$tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
|
|
$tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
|
|
$tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
|
|
$tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
// request to have all the answers of student for this question |
|
|
|
// request to have all the answers of student for this question |
|
|
|
// student may have doing it several time |
|
|
|
// student may have doing it several time |
|
|
|
// student may have not answered the bracket id, in this case, is result of the answer is empty |
|
|
|
// student may have not answered the bracket id, in this case, is result of the answer is empty |
|
|
|
|
|
|
|
// we got the less recent attempt first |
|
|
|
// we got the less recent attempt first |
|
|
|
$sql = 'SELECT * FROM '.$tblTrackEAttempt.' tea |
|
|
|
$sql = ' |
|
|
|
LEFT JOIN '.$tblTrackEExercise.' tee |
|
|
|
SELECT * FROM '.$tblTrackEAttempt.' tea |
|
|
|
ON tee.exe_id = tea.exe_id |
|
|
|
LEFT JOIN '.$tblTrackEExercise.' tee |
|
|
|
AND tea.c_id = '.$courseId.' |
|
|
|
ON tee.exe_id = tea.exe_id |
|
|
|
AND exe_exo_id = '.$testId.' |
|
|
|
AND tea.c_id = '.$courseId.' |
|
|
|
|
|
|
|
AND exe_exo_id = '.$testId.' |
|
|
|
WHERE |
|
|
|
|
|
|
|
tee.c_id = '.$courseId.' AND |
|
|
|
WHERE tee.c_id = '.$courseId.' |
|
|
|
question_id = '.$questionId.' AND |
|
|
|
AND question_id = '.$questionId.' |
|
|
|
tea.user_id IN ('.implode(',', $studentsIdList).') AND |
|
|
|
AND tea.user_id IN ('.implode(',', $studentsIdList).') |
|
|
|
tea.tms >= "'.$startDate.'" AND |
|
|
|
AND tea.tms >= "'.$startDate.'" |
|
|
|
tea.tms <= "'.$endDate.'" |
|
|
|
AND tea.tms <= "'.$endDate.'" |
|
|
|
ORDER BY user_id, tea.exe_id; |
|
|
|
ORDER BY user_id, tea.exe_id; |
|
|
|
'; |
|
|
|
'; |
|
|
|
|
|
|
|
|
|
|
|
$res = Database::query($sql); |
|
|
|
$res = Database::query($sql); |
|
|
|
$tabUserResult = array(); |
|
|
|
$tabUserResult = array(); |
|
|
|
$bracketNumber = 0; |
|
|
|
$bracketNumber = 0; |
|
|
|
// foreach attempts for all students starting with his older attempt |
|
|
|
// foreach attempts for all students starting with his older attempt |
|
|
|
while ($data = Database::fetch_array($res)) { |
|
|
|
while ($data = Database::fetch_array($res)) { |
|
|
|
$tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
|
|
$tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
|
|
|
|
|
|
|
|
|
|
// for each bracket to find in this question |
|
|
|
// for each bracket to find in this question |
|
|
|
foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
|
|
foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
|
|
if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
|
|
|
|
|
|
// student has answered this bracket, cool |
|
|
|
if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
|
|
switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
|
|
// student has answered this bracket, cool |
|
|
|
case self::FILL_THE_BLANK_MENU: |
|
|
|
switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
|
|
// get the indice of the choosen answer in the menu |
|
|
|
case self::FILL_THE_BLANK_MENU : |
|
|
|
// we know that the right answer is the first entry of the menu, ie 0 |
|
|
|
// get the indice of the choosen answer in the menu |
|
|
|
// (remember, menu entries are shuffled when taking the test) |
|
|
|
// we know that the right answer is the first entry of the menu, ie 0 |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum( |
|
|
|
// (remember, menu entries are shuffled when taking the test) |
|
|
|
$tabAnswer['tabwords'][$bracketNumber], |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum( |
|
|
|
$tabAnswer['studentanswer'][$bracketNumber] |
|
|
|
$tabAnswer['tabwords'][$bracketNumber], |
|
|
|
); |
|
|
|
$tabAnswer['studentanswer'][$bracketNumber] |
|
|
|
break; |
|
|
|
); |
|
|
|
default: |
|
|
|
break; |
|
|
|
if (FillBlanks::isGoodStudentAnswer( |
|
|
|
default : |
|
|
|
$tabAnswer['studentanswer'][$bracketNumber], |
|
|
|
if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) { |
|
|
|
$tabAnswer['tabwords'][$bracketNumber] |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
|
|
) |
|
|
|
} else { |
|
|
|
) { |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
|
|
} else { |
|
|
|
} |
|
|
|
// student didn't answer this bracket |
|
|
|
} |
|
|
|
if ($useLastAnswerredAttempt) { |
|
|
|
} else { |
|
|
|
// if we take into account the last answered attempt |
|
|
|
// student didn't answer this bracket |
|
|
|
if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
|
|
if ($useLastAnswerredAttempt) { |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
|
|
// if we take into account the last answered attempt |
|
|
|
} |
|
|
|
if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
|
|
} else { |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
|
|
// we take the last attempt, even if the student answer the question before |
|
|
|
} |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
|
|
} else { |
|
|
|
} |
|
|
|
// we take the last attempt, even if the student answer the question before |
|
|
|
} |
|
|
|
$tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return $tabUserResult; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $tabUserResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -838,16 +840,17 @@ class FillBlanks extends Question |
|
|
|
{ |
|
|
|
{ |
|
|
|
$outRes = 0; |
|
|
|
$outRes = 0; |
|
|
|
// for each student in group |
|
|
|
// for each student in group |
|
|
|
foreach($resultList as $userId => $tabValue) { |
|
|
|
foreach ($resultList as $userId => $tabValue) { |
|
|
|
$trouve = false; |
|
|
|
$found = false; |
|
|
|
// for each bracket, if student has at leat one answer ( choice > -2) then he pass the question |
|
|
|
// for each bracket, if student has at least one answer ( choice > -2) then he pass the question |
|
|
|
foreach($tabValue as $i => $choice) { |
|
|
|
foreach ($tabValue as $i => $choice) { |
|
|
|
if ($choice > -2 && !$trouve) { |
|
|
|
if ($choice > -2 && !$found) { |
|
|
|
$outRes++; |
|
|
|
$outRes++; |
|
|
|
$trouve = true; |
|
|
|
$found = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $outRes; |
|
|
|
return $outRes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1044,8 +1047,11 @@ class FillBlanks extends Question |
|
|
|
* |
|
|
|
* |
|
|
|
* @return string |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function getHtmlDisplayForAnswer($answer, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) |
|
|
|
public static function getHtmlDisplayForAnswer( |
|
|
|
{ |
|
|
|
$answer, |
|
|
|
|
|
|
|
$resultsDisabled = false, |
|
|
|
|
|
|
|
$showTotalScoreAndUserChoices = false |
|
|
|
|
|
|
|
) { |
|
|
|
$result = ''; |
|
|
|
$result = ''; |
|
|
|
$listStudentAnswerInfo = self::getAnswerInfo($answer, true); |
|
|
|
$listStudentAnswerInfo = self::getAnswerInfo($answer, true); |
|
|
|
|
|
|
|
|
|
|
@ -1075,7 +1081,6 @@ class FillBlanks extends Question |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// rebuild the sentence with student answer inserted |
|
|
|
// rebuild the sentence with student answer inserted |
|
|
|
for ($i=0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
|
|
for ($i=0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
|
|
$result .= isset($listStudentAnswerInfo['commonwords'][$i]) ? $listStudentAnswerInfo['commonwords'][$i] : ''; |
|
|
|
$result .= isset($listStudentAnswerInfo['commonwords'][$i]) ? $listStudentAnswerInfo['commonwords'][$i] : ''; |
|
|
|