Modify behaviour of setting result_disabled see BT#11202

result disabled value:
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT
1.10.x
jmontoyaa 10 years ago
parent 748658d204
commit a788c0e861
  1. 180
      main/exercice/exercise.class.php
  2. 90
      main/exercice/exercise_show.php
  3. 17
      main/exercice/fill_blanks.class.php
  4. 2
      main/exercice/overview.php
  5. 29
      main/inc/lib/exercise.lib.php
  6. 178
      main/inc/lib/exercise_show_functions.lib.php

@ -3137,7 +3137,8 @@ class Exercise
$from_database = false, $from_database = false,
$show_result = true, $show_result = true,
$propagate_neg = 0, $propagate_neg = 0,
$hotspot_delineation_result = array() $hotspot_delineation_result = array(),
$showTotalScoreAndUserChoices = false
) { ) {
global $debug; global $debug;
//needed in order to use in the exercise_attempt() for the time //needed in order to use in the exercise_attempt() for the time
@ -3279,7 +3280,6 @@ class Exercise
if ($debug) error_log('Start answer loop '); if ($debug) error_log('Start answer loop ');
$answer_correct_array = array();
$orderedHotspots = []; $orderedHotspots = [];
if ($answerType == HOT_SPOT) { if ($answerType == HOT_SPOT) {
@ -3300,8 +3300,6 @@ class Exercise
$answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId); $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
$answerAutoId = $objAnswerTmp->selectAutoId($answerId); $answerAutoId = $objAnswerTmp->selectAutoId($answerId);
$answer_correct_array[$answerId] = (bool)$answerCorrect;
if ($debug) { if ($debug) {
error_log("answer auto id: $answerAutoId "); error_log("answer auto id: $answerAutoId ");
error_log("answer correct: $answerCorrect "); error_log("answer correct: $answerCorrect ");
@ -3455,7 +3453,7 @@ class Exercise
$real_answers[$answerId] = false; $real_answers[$answerId] = false;
} }
} else { } else {
$studentChoice = $choice[$answerAutoId]; $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : '';
if ($answerCorrect == $studentChoice) { if ($answerCorrect == $studentChoice) {
//$answerCorrect = 1; //$answerCorrect = 1;
$real_answers[$answerId] = true; $real_answers[$answerId] = true;
@ -3492,7 +3490,6 @@ class Exercise
} }
} else { } else {
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
if ($answerCorrect == 1) { if ($answerCorrect == 1) {
if ($studentChoice) { if ($studentChoice) {
$real_answers[$answerId] = true; $real_answers[$answerId] = true;
@ -3512,10 +3509,10 @@ class Exercise
$str = ''; $str = '';
if ($from_database) { if ($from_database) {
$sql = "SELECT answer $sql = "SELECT answer
FROM $TBL_TRACK_ATTEMPT FROM $TBL_TRACK_ATTEMPT
WHERE WHERE
exe_id = $exeId AND exe_id = $exeId AND
question_id= ".intval($questionId); question_id= ".intval($questionId);
$result = Database::query($sql); $result = Database::query($sql);
$str = Database::result($result, 0, 'answer'); $str = Database::result($result, 0, 'answer');
} }
@ -3571,9 +3568,9 @@ class Exercise
} }
if ($from_database) { if ($from_database) {
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
WHERE WHERE
exe_id = '".$exeId."' AND exe_id = '".$exeId."' AND
question_id= ".intval($questionId).""; question_id= ".intval($questionId)."";
$resfill = Database::query($queryfill); $resfill = Database::query($queryfill);
$str = Database::result($resfill, 0, 'answer'); $str = Database::result($resfill, 0, 'answer');
api_preg_match_all('#\[([^[]*)\]#', $str, $arr); api_preg_match_all('#\[([^[]*)\]#', $str, $arr);
@ -3683,12 +3680,8 @@ class Exercise
// loop other all blanks words // loop other all blanks words
if (!$switchableAnswerSet) { if (!$switchableAnswerSet) {
// not switchable answer, must be in the same place than teacher order // not switchable answer, must be in the same place than teacher order
for ($i = 0; $i < count( for ($i = 0; $i < count($listCorrectAnswers['tabwords']); $i++) {
$listCorrectAnswers['tabwords'] $studentAnswer = isset($choice[$i]) ? trim($choice[$i]) : '';
); $i++) {
$studentAnswer = isset($choice[$i]) ? trim(
$choice[$i]
) : '';
// This value is the user input, not escaped while correct answer is escaped by fckeditor // This value is the user input, not escaped while correct answer is escaped by fckeditor
// Works with cyrillic alphabet and when using ">" chars see #7718 #7610 #7618 // Works with cyrillic alphabet and when using ">" chars see #7718 #7610 #7618
@ -3719,16 +3712,12 @@ class Exercise
$listStudentAnswerTemp = $choice; $listStudentAnswerTemp = $choice;
$listTeacherAnswerTemp = $listCorrectAnswers['tabwords']; $listTeacherAnswerTemp = $listCorrectAnswers['tabwords'];
// for every teacher answer, check if there is a student answer // for every teacher answer, check if there is a student answer
for ($i = 0; $i < count( for ($i = 0; $i < count($listStudentAnswerTemp); $i++) {
$listStudentAnswerTemp
); $i++) {
$studentAnswer = trim( $studentAnswer = trim(
$listStudentAnswerTemp[$i] $listStudentAnswerTemp[$i]
); );
$found = false; $found = false;
for ($j = 0; $j < count( for ($j = 0; $j < count($listTeacherAnswerTemp); $j++) {
$listTeacherAnswerTemp
); $j++) {
$correctAnswer = $listTeacherAnswerTemp[$j]; $correctAnswer = $listTeacherAnswerTemp[$j];
if (!$found) { if (!$found) {
if (FillBlanks::isGoodStudentAnswer( if (FillBlanks::isGoodStudentAnswer(
@ -3835,9 +3824,9 @@ class Exercise
if ($from_database && empty($calculatedAnswerId)) { if ($from_database && empty($calculatedAnswerId)) {
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
WHERE WHERE
exe_id = '".$exeId."' AND exe_id = '".$exeId."' AND
question_id= ".intval($questionId).""; question_id= ".intval($questionId)."";
$resfill = Database::query($queryfill); $resfill = Database::query($queryfill);
$answer = Database::result($resfill, 0, 'answer'); $answer = Database::result($resfill, 0, 'answer');
} }
@ -3870,7 +3859,6 @@ class Exercise
} }
} }
break; break;
// for free answer
case FREE_ANSWER: case FREE_ANSWER:
if ($from_database) { if ($from_database) {
$query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
@ -3892,7 +3880,7 @@ class Exercise
$questionScore = 0; $questionScore = 0;
} }
$arrques = $questionName; $arrques = $questionName;
$arrans = $choice; $arrans = $choice;
} else { } else {
$studentChoice = $choice; $studentChoice = $choice;
if ($studentChoice) { if ($studentChoice) {
@ -3911,7 +3899,7 @@ class Exercise
$choice = str_replace('\r\n', '', $choice); $choice = str_replace('\r\n', '', $choice);
$choice = stripslashes($choice); $choice = stripslashes($choice);
$questionScore = Database::result($resq,0,"marks"); $questionScore = Database::result($resq,0,"marks");
if ($questionScore==-1) { if ($questionScore == -1) {
$totalScore+=0; $totalScore+=0;
} else { } else {
$totalScore+=$questionScore; $totalScore+=$questionScore;
@ -4010,12 +3998,15 @@ class Exercise
} }
if ($show_result) { if ($show_result) {
if ($showTotalScoreAndUserChoices == true) {
$user_answer = '';
}
echo '<tr>'; echo '<tr>';
echo '<td>' . $s_answer_label . '</td>'; echo '<td>' . $s_answer_label . '</td>';
echo '<td>' . $user_answer; echo '<td>' . $user_answer;
if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
if (isset($real_list[$i_answer_correct_answer])) { if (isset($real_list[$i_answer_correct_answer]) && $showTotalScoreAndUserChoices == false) {
echo Display::span( echo Display::span(
$real_list[$i_answer_correct_answer], $real_list[$i_answer_correct_answer],
['style' => 'color: #008000; font-weight: bold;'] ['style' => 'color: #008000; font-weight: bold;']
@ -4060,8 +4051,8 @@ class Exercise
$studentChoice = Database::result($result, 0, "hotspot_correct"); $studentChoice = Database::result($result, 0, "hotspot_correct");
if ($studentChoice) { if ($studentChoice) {
$questionScore += $answerWeighting; $questionScore += $answerWeighting;
$totalScore += $answerWeighting; $totalScore += $answerWeighting;
} }
} else { } else {
if (!isset($choice[$answerAutoId])) { if (!isset($choice[$answerAutoId])) {
@ -4095,10 +4086,9 @@ class Exercise
} }
$choice[$answerAutoId] = 0; $choice[$answerAutoId] = 0;
if ($choiceIsValid) { if ($choiceIsValid) {
$questionScore += $answerWeighting; $questionScore += $answerWeighting;
$totalScore += $answerWeighting; $totalScore += $answerWeighting;
$choice[$answerAutoId] = 1; $choice[$answerAutoId] = 1;
} }
} }
@ -4157,21 +4147,17 @@ class Exercise
} }
} }
} }
$_SESSION['hotspot_coord'][1] = $delineation_cord; $_SESSION['hotspot_coord'][1] = $delineation_cord;
$_SESSION['hotspot_dest'][1] = $answer_delineation_destination; $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
break; break;
} // end switch Answertype } // end switch Answertype
if ($show_result) { if ($show_result) {
if ($debug) error_log('show result '.$show_result); if ($debug) error_log('Showing questions $from '.$from);
if ($from == 'exercise_result') { if ($from == 'exercise_result') {
if ($debug) error_log('Showing questions $from '.$from); // display answers (if not matching type, or if the answer is correct)
//display answers (if not matching type, or if the answer is correct)
if ( if (
!in_array( !in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE]) ||
$answerType,
[MATCHING, DRAGGABLE, MATCHING_DRAGGABLE]
) ||
$answerCorrect $answerCorrect
) { ) {
if ( if (
@ -4187,7 +4173,6 @@ class Exercise
) )
) )
) { ) {
//if ($origin != 'learnpath') {
ExerciseShowFunctions::display_unique_or_multiple_answer( ExerciseShowFunctions::display_unique_or_multiple_answer(
$feedback_type, $feedback_type,
$answerType, $answerType,
@ -4198,11 +4183,10 @@ class Exercise
0, 0,
0, 0,
0, 0,
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
//}
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) { } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
//if ($origin!='learnpath') {
ExerciseShowFunctions::display_multiple_answer_true_false( ExerciseShowFunctions::display_multiple_answer_true_false(
$feedback_type, $feedback_type,
$answerType, $answerType,
@ -4213,11 +4197,10 @@ class Exercise
0, 0,
$questionId, $questionId,
0, 0,
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
//} } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
// if ($origin!='learnpath') {
ExerciseShowFunctions::display_multiple_answer_combination_true_false( ExerciseShowFunctions::display_multiple_answer_combination_true_false(
$feedback_type, $feedback_type,
$answerType, $answerType,
@ -4228,39 +4211,48 @@ class Exercise
0, 0,
0, 0,
0, 0,
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
//}
} elseif ($answerType == FILL_IN_BLANKS) { } elseif ($answerType == FILL_IN_BLANKS) {
//if ($origin!='learnpath') { ExerciseShowFunctions::display_fill_in_blanks_answer(
ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer,0,0, $results_disabled); $feedback_type,
// } $answer,
0,
0,
$results_disabled,
'',
$showTotalScoreAndUserChoices
);
} elseif ($answerType == CALCULATED_ANSWER) { } elseif ($answerType == CALCULATED_ANSWER) {
//if ($origin!='learnpath') { ExerciseShowFunctions::display_calculated_answer(
ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer,0,0); $feedback_type,
// } $answer,
0,
0,
$results_disabled,
$showTotalScoreAndUserChoices
);
} elseif ($answerType == FREE_ANSWER) { } elseif ($answerType == FREE_ANSWER) {
//if($origin != 'learnpath') {
ExerciseShowFunctions::display_free_answer( ExerciseShowFunctions::display_free_answer(
$feedback_type, $feedback_type,
$choice, $choice,
$exeId, $exeId,
$questionId, $questionId,
$questionScore $questionScore,
$results_disabled
); );
//}
} elseif ($answerType == ORAL_EXPRESSION) { } elseif ($answerType == ORAL_EXPRESSION) {
// to store the details of open questions in an array to be used in mail // to store the details of open questions in an array to be used in mail
//if ($origin != 'learnpath') {
ExerciseShowFunctions::display_oral_expression_answer( ExerciseShowFunctions::display_oral_expression_answer(
$feedback_type, $feedback_type,
$choice, $choice,
0, 0,
0, 0,
$nano); $nano,
//} $results_disabled
);
} elseif ($answerType == HOT_SPOT) { } elseif ($answerType == HOT_SPOT) {
//if ($origin != 'learnpath') {
foreach ($orderedHotspots as $correctAnswerId => $hotspot) { foreach ($orderedHotspots as $correctAnswerId => $hotspot) {
if ($hotspot->getHotspotAnswerId() == $answerAutoId) { if ($hotspot->getHotspotAnswerId() == $answerAutoId) {
break; break;
@ -4274,11 +4266,10 @@ class Exercise
$studentChoice, $studentChoice,
$answerComment, $answerComment,
$results_disabled, $results_disabled,
$answerId $answerId,
$showTotalScoreAndUserChoices
); );
// }
} elseif ($answerType == HOT_SPOT_ORDER) { } elseif ($answerType == HOT_SPOT_ORDER) {
//if ($origin != 'learnpath') {
ExerciseShowFunctions::display_hotspot_order_answer( ExerciseShowFunctions::display_hotspot_order_answer(
$feedback_type, $feedback_type,
$answerId, $answerId,
@ -4286,7 +4277,6 @@ class Exercise
$studentChoice, $studentChoice,
$answerComment $answerComment
); );
//}
} elseif ($answerType == HOT_SPOT_DELINEATION) { } elseif ($answerType == HOT_SPOT_DELINEATION) {
$user_answer = $_SESSION['exerciseResultCoordinates'][$questionId]; $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
@ -4480,7 +4470,8 @@ class Exercise
$exeId, $exeId,
$questionId, $questionId,
$answerId, $answerId,
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
} else { } else {
ExerciseShowFunctions::display_unique_or_multiple_answer( ExerciseShowFunctions::display_unique_or_multiple_answer(
@ -4492,8 +4483,9 @@ class Exercise
$answerCorrect, $answerCorrect,
$exeId, $exeId,
$questionId, $questionId,
"", '',
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
} }
break; break;
@ -4509,7 +4501,8 @@ class Exercise
$exeId, $exeId,
$questionId, $questionId,
$answerId, $answerId,
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
} else { } else {
ExerciseShowFunctions::display_multiple_answer_combination_true_false( ExerciseShowFunctions::display_multiple_answer_combination_true_false(
@ -4521,8 +4514,9 @@ class Exercise
$answerCorrect, $answerCorrect,
$exeId, $exeId,
$questionId, $questionId,
"", '',
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
} }
break; break;
@ -4538,7 +4532,8 @@ class Exercise
$exeId, $exeId,
$questionId, $questionId,
$answerId, $answerId,
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
} else { } else {
ExerciseShowFunctions::display_multiple_answer_true_false( ExerciseShowFunctions::display_multiple_answer_true_false(
@ -4550,8 +4545,9 @@ class Exercise
$answerCorrect, $answerCorrect,
$exeId, $exeId,
$questionId, $questionId,
"", '',
$results_disabled $results_disabled,
$showTotalScoreAndUserChoices
); );
} }
break; break;
@ -4562,7 +4558,8 @@ class Exercise
$exeId, $exeId,
$questionId, $questionId,
$results_disabled, $results_disabled,
$str $str,
$showTotalScoreAndUserChoices
); );
break; break;
case CALCULATED_ANSWER: case CALCULATED_ANSWER:
@ -4570,7 +4567,10 @@ class Exercise
$feedback_type, $feedback_type,
$answer, $answer,
$exeId, $exeId,
$questionId $questionId,
$results_disabled,
'',
$showTotalScoreAndUserChoices
); );
break; break;
case FREE_ANSWER: case FREE_ANSWER:
@ -4579,7 +4579,8 @@ class Exercise
$choice, $choice,
$exeId, $exeId,
$questionId, $questionId,
$questionScore $questionScore,
$results_disabled
); );
break; break;
case ORAL_EXPRESSION: case ORAL_EXPRESSION:
@ -4589,7 +4590,8 @@ class Exercise
$choice, $choice,
$exeId, $exeId,
$questionId, $questionId,
$nano $nano,
$results_disabled
) . '</td> ) . '</td>
</tr> </tr>
</table>'; </table>';
@ -4601,7 +4603,8 @@ class Exercise
$answer, $answer,
$studentChoice, $studentChoice,
$answerComment, $answerComment,
$results_disabled); $results_disabled
);
break; break;
case HOT_SPOT_DELINEATION: case HOT_SPOT_DELINEATION:
$user_answer = $user_array; $user_answer = $user_array;
@ -6606,7 +6609,6 @@ class Exercise
foreach ($questionList as $questionId) { foreach ($questionList as $questionId) {
$i++; $i++;
// For sequential exercises // For sequential exercises
if ($this->type == ONE_PER_PAGE) { if ($this->type == ONE_PER_PAGE) {
// If it is not the right question, goes to the next loop iteration // If it is not the right question, goes to the next loop iteration
if ($currentQuestion != $i) { if ($currentQuestion != $i) {
@ -7428,7 +7430,6 @@ class Exercise
$selected = 'selected="selected"'; $selected = 'selected="selected"';
$selectedValue = $val['id']; $selectedValue = $val['id'];
} }
//$s .= '<option value="'.$val['id'].'" '.$selected.'>'.$val['letter'].'</option>';
$s .= '<option value="'.$item.'" '.$selected.'>'.$val['letter'].'</option>'; $s .= '<option value="'.$item.'" '.$selected.'>'.$val['letter'].'</option>';
$item++; $item++;
} }
@ -7442,7 +7443,6 @@ class Exercise
</script>'; </script>';
} }
if (isset($select_items[$lines_count])) { if (isset($select_items[$lines_count])) {
$s.= '<div id="window_'.$windowId.'_answer" class=""> $s.= '<div id="window_'.$windowId.'_answer" class="">
<b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].' <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'

@ -174,14 +174,16 @@ function getFCK(vals,marksid) {
<?php <?php
$show_results = true; $show_results = true;
$show_only_total_score = false; $show_only_total_score = false;
$showTotalScoreAndUserChoices = true;
// Avoiding the "Score 0/0" message when the exe_id is not set // Avoiding the "Score 0/0" message when the exe_id is not set
if (!empty($track_exercise_info)) { if (!empty($track_exercise_info)) {
// if the results_disabled of the Quiz is 1 when block the script // if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled']; $result_disabled = $track_exercise_info['results_disabled'];
if (!(api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) ) { if (true) {
if ($result_disabled == 1) { //if (!(api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) ) {
if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
$show_results = false; $show_results = false;
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"> echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
@ -195,7 +197,7 @@ if (!empty($track_exercise_info)) {
</tr> </tr>
</table>'; </table>';
} }
} elseif ($result_disabled == 2) { } elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
$show_results = false; $show_results = false;
$show_only_total_score = true; $show_only_total_score = true;
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
@ -207,6 +209,26 @@ if (!empty($track_exercise_info)) {
</tr> </tr>
</table>'; </table>';
} }
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
$attempts = Event::getExerciseResultsByUser(
api_get_user_id(),
$objExercise->id,
api_get_course_int_id(),
api_get_session_id(),
$track_exercise_info['orig_lp_id'],
$track_exercise_info['orig_lp_item_id'],
'desc'
);
$numberAttempts = count($attempts);
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
$show_results = true;
$show_only_total_score = true;
$showTotalScoreAndUserChoices = false;
} else {
$show_results = true;
$show_only_total_score = true;
$showTotalScoreAndUserChoices = true;
}
} }
} }
} else { } else {
@ -218,7 +240,7 @@ if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
$show_results = false; $show_results = false;
} }
if ($show_results || $show_only_total_score) { if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) {
$user_info = api_get_user_info($student_id); $user_info = api_get_user_info($student_id);
//Shows exercise header //Shows exercise header
echo $objExercise->show_exercise_result_header( echo $objExercise->show_exercise_result_header(
@ -237,7 +259,7 @@ if ($debug > 0) {
} }
$arrques = array(); $arrques = array();
$arrans = array(); $arrans = array();
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." "; $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." ";
$sql = "SELECT attempts.question_id, answer $sql = "SELECT attempts.question_id, answer
@ -320,9 +342,7 @@ foreach ($questionList as $questionId) {
// Start buffer // Start buffer
ob_start(); ob_start();
/* Use switch // Use switch
switch ($answerType) {
}*/
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_result = $objExercise->manage_answer( $question_result = $objExercise->manage_answer(
@ -334,7 +354,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -349,7 +371,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -363,7 +387,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -378,7 +404,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -392,7 +420,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -406,7 +436,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -420,7 +452,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -434,7 +468,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -448,12 +484,14 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) { } elseif ($answerType == HOT_SPOT) {
if ($show_results) { if ($show_results || $showTotalScoreAndUserChoices) {
echo '<table width="500" border="0"><tr> echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" > <td valign="top" align="center" style="padding-left:0px;" >
<table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">'; <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
@ -467,7 +505,9 @@ foreach ($questionList as $questionId) {
false, false,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg() $objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -508,7 +548,9 @@ foreach ($questionList as $questionId) {
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg(), $objExercise->selectPropagateNeg(),
'database' 'database',
[],
$showTotalScoreAndUserChoices
); );
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
@ -776,7 +818,7 @@ foreach ($questionList as $questionId) {
} }
} }
$my_total_score = $questionScore; $my_total_score = $questionScore;
$my_total_weight = $questionWeighting; $my_total_weight = $questionWeighting;
$totalWeighting += $questionWeighting; $totalWeighting += $questionWeighting;
$category_was_added_for_this_test = false; $category_was_added_for_this_test = false;
@ -850,7 +892,7 @@ $total_score_text = null;
//Total score //Total score
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score) { if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) {
$total_score_text .= '<div class="question_row">'; $total_score_text .= '<div class="question_row">';
$my_total_score_temp = $totalScore; $my_total_score_temp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
@ -866,7 +908,7 @@ if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type'])))
} }
} }
if (!empty($category_list) && ($show_results || $show_only_total_score)) { if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices)) {
// Adding total // Adding total
$category_list['total'] = array( $category_list['total'] = array(
'score' => $my_total_score_temp, 'score' => $my_total_score_temp,

@ -725,7 +725,7 @@ class FillBlanks extends Question
return $listAnswerResults; return $listAnswerResults;
} }
/** /**
* Return an array of student state answers for fill the blank questions * Return an array of student state answers for fill the blank questions
* for each students that answered the question * for each students that answered the question
@ -1037,14 +1037,23 @@ class FillBlanks extends Question
* return the HTML display of the answer * return the HTML display of the answer
* @param string $answer * @param string $answer
* @param bool $resultsDisabled * @param bool $resultsDisabled
* @param bool $showTotalScoreAndUserChoices
* *
* @return string * @return string
*/ */
public static function getHtmlDisplayForAnswer($answer, $resultsDisabled = false) public static function getHtmlDisplayForAnswer($answer, $resultsDisabled = false, $showTotalScoreAndUserChoices = false)
{ {
$result = ""; $result = '';
$listStudentAnswerInfo = self::getAnswerInfo($answer, true); $listStudentAnswerInfo = self::getAnswerInfo($answer, true);
if ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
if ($showTotalScoreAndUserChoices) {
$resultsDisabled = true;
} else {
$resultsDisabled = false;
}
}
// rebuild the answer with good HTML style // rebuild the answer with good HTML style
// this is the student answer, right or wrong // this is the student answer, right or wrong
for ($i=0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) { for ($i=0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) {
@ -1094,7 +1103,7 @@ class FillBlanks extends Question
$type = FillBlanks::getFillTheBlankAnswerType($correct); $type = FillBlanks::getFillTheBlankAnswerType($correct);
switch ($type) { switch ($type) {
case self::FILL_THE_BLANK_MENU: case self::FILL_THE_BLANK_MENU:
$correctAnswerHtml = ""; $correctAnswerHtml = '';
$listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false); $listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false);
$correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>"; $correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>";
$correctAnswerHtml .= " <span style='font-weight:normal'>("; $correctAnswerHtml .= " <span style='font-weight:normal'>(";

@ -171,7 +171,7 @@ if ($current_browser == 'Internet Explorer') {
$blockShowAnswers = false; $blockShowAnswers = false;
if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) { if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
if (count($attempts) < $objExercise->attempts ) { if (count($attempts) < $objExercise->attempts) {
$blockShowAnswers = true; $blockShowAnswers = true;
} }
} }

@ -3500,8 +3500,11 @@ HOTSPOT;
$show_only_score = false; $show_only_score = false;
} }
$show_total_score_and_user_choices = false;
if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) { if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
$show_only_score = true; $show_only_score = true;
$show_results = true;
if ($objExercise->attempts > 0) { if ($objExercise->attempts > 0) {
$attempts = Event::getExerciseResultsByUser( $attempts = Event::getExerciseResultsByUser(
api_get_user_id(), api_get_user_id(),
@ -3521,7 +3524,10 @@ HOTSPOT;
if ($numberAttempts >= $objExercise->attempts) { if ($numberAttempts >= $objExercise->attempts) {
$show_results = true; $show_results = true;
$show_only_score = false; $show_only_score = false;
}; $show_total_score_and_user_choices = false;
} else {
$show_total_score_and_user_choices = true;
}
} }
} }
} }
@ -3540,7 +3546,6 @@ HOTSPOT;
); );
} }
// Display text when test is finished #4074 and for LP #4227 // Display text when test is finished #4074 and for LP #4227
$end_of_message = $objExercise->selectTextWhenFinished(); $end_of_message = $objExercise->selectTextWhenFinished();
if (!empty($end_of_message)) { if (!empty($end_of_message)) {
@ -3558,7 +3563,7 @@ HOTSPOT;
// creates a temporary Question object // creates a temporary Question object
$objQuestionTmp = Question::read($questionId); $objQuestionTmp = Question::read($questionId);
// This variable came from exercise_submit_modal.php // This variable came from exercise_submit_modal.php
ob_start(); ob_start();
@ -3568,23 +3573,19 @@ HOTSPOT;
$questionId, $questionId,
null, null,
'exercise_result', 'exercise_result',
array(), [],
$save_user_result, $save_user_result,
true, true,
$show_results, $show_results,
$objExercise->selectPropagateNeg(), $objExercise->selectPropagateNeg(),
array() [],
$show_total_score_and_user_choices
); );
if (empty($result)) { if (empty($result)) {
continue; continue;
} }
// In case of global score, make sure the calculated total score is integer
/*if (!is_int($result['score'])) {
$result['score'] = round($result['score']);
}*/
$total_score += $result['score']; $total_score += $result['score'];
$total_weight += $result['weight']; $total_weight += $result['weight'];
@ -3670,13 +3671,7 @@ HOTSPOT;
$question_content = ''; $question_content = '';
if ($show_results) { if ($show_results) {
$question_content = '<div class="question_row_answer">'; $question_content = '<div class="question_row_answer">';
// Shows question title an description
$show_media = false;
/*if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) {
$show_media = true;
$media_list[] = $objQuestionTmp->parent_id;
}*/
//Shows question title an description
$question_content .= $objQuestionTmp->return_header( $question_content .= $objQuestionTmp->return_header(
null, null,
$counter, $counter,

@ -4,8 +4,8 @@
* EVENTS LIBRARY * EVENTS LIBRARY
* *
* This is the events library for Chamilo. * This is the events library for Chamilo.
* Functions of this library are used to record informations when some kind * Functions of this library are used to record information when some kind
* of event occur. Each event has his own types of informations then each event * of event occur.
* use its own function. * use its own function.
* *
* @package chamilo.library * @package chamilo.library
@ -19,16 +19,25 @@ class ExerciseShowFunctions
{ {
/** /**
* Shows the answer to a fill-in-the-blanks question, as HTML * Shows the answer to a fill-in-the-blanks question, as HTML
* @param string Answer text * @param int $feedbackType
* @param int Exercise ID * @param string $answer
* @param int Question ID * @param int $id Exercise ID
* @param int $questionId Question ID
* @param int $resultsDisabled * @param int $resultsDisabled
* @param string $originalStudentAnswer * @param string $originalStudentAnswer
*
* @return void * @return void
*/ */
public static function display_fill_in_blanks_answer($feedbackType, $answer, $id, $questionId, $resultsDisabled, $originalStudentAnswer = '') public static function display_fill_in_blanks_answer(
{ $feedbackType,
$answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $resultsDisabled); $answer,
$id,
$questionId,
$resultsDisabled,
$originalStudentAnswer = '',
$showTotalScoreAndUserChoices
) {
$answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $resultsDisabled, $showTotalScoreAndUserChoices);
if (strpos($originalStudentAnswer, 'font color') !== false) { if (strpos($originalStudentAnswer, 'font color') !== false) {
$answerHTML = $originalStudentAnswer; $answerHTML = $originalStudentAnswer;
} }
@ -47,9 +56,9 @@ class ExerciseShowFunctions
<?php <?php
if (!api_is_allowed_to_edit(null,true) && $feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> if (!api_is_allowed_to_edit(null,true) && $feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td> <td>
<?php <?php
$comm = Event::get_comments($id, $questionId); $comm = Event::get_comments($id, $questionId);
?> ?>
</td> </td>
<?php } ?> <?php } ?>
</tr> </tr>
@ -64,8 +73,14 @@ class ExerciseShowFunctions
* @param int Question ID * @param int Question ID
* @return void * @return void
*/ */
public static function display_calculated_answer($feedback_type, $answer, $id, $questionId) public static function display_calculated_answer(
{ $feedback_type,
$answer,
$id,
$questionId,
$results_disabled,
$showTotalScoreAndUserChoices
) {
if (empty($id)) { if (empty($id)) {
echo '<tr><td>'. Security::remove_XSS($answer).'</td></tr>'; echo '<tr><td>'. Security::remove_XSS($answer).'</td></tr>';
} else { } else {
@ -97,8 +112,14 @@ class ExerciseShowFunctions
* @param int Question ID * @param int Question ID
* @return void * @return void
*/ */
public static function display_free_answer($feedback_type, $answer, $exe_id, $questionId, $questionScore = null) public static function display_free_answer(
{ $feedback_type,
$answer,
$exe_id,
$questionId,
$questionScore = null,
$results_disabled = 0
) {
$comments = Event::get_comments($exe_id, $questionId); $comments = Event::get_comments($exe_id, $questionId);
if (!empty($answer)) { if (!empty($answer)) {
@ -117,8 +138,22 @@ class ExerciseShowFunctions
} }
} }
public static function display_oral_expression_answer($feedback_type, $answer, $id, $questionId, $nano = null) /**
{ * @param $feedback_type
* @param $answer
* @param $id
* @param $questionId
* @param null $nano
* @param int $results_disabled
*/
public static function display_oral_expression_answer(
$feedback_type,
$answer,
$id,
$questionId,
$nano = null,
$results_disabled = 0
) {
if (isset($nano)) { if (isset($nano)) {
echo $nano->show_audio_file(); echo $nano->show_audio_file();
} }
@ -158,7 +193,7 @@ class ExerciseShowFunctions
* @param string $answer * @param string $answer
* @param string $studentChoice * @param string $studentChoice
* @param string $answerComment * @param string $answerComment
* @param string $in_results_disabled * @param int $resultsDisabled
* @param int $orderColor * @param int $orderColor
*/ */
public static function display_hotspot_answer( public static function display_hotspot_answer(
@ -167,15 +202,23 @@ class ExerciseShowFunctions
$answer, $answer,
$studentChoice, $studentChoice,
$answerComment, $answerComment,
$in_results_disabled, $resultsDisabled,
$orderColor $orderColor,
) $showTotalScoreAndUserChoices
{ ) {
$hide_expected_answer = false; $hide_expected_answer = false;
if ($feedback_type == 0 && $in_results_disabled == 2) { if ($feedback_type == 0 && $resultsDisabled == 2) {
$hide_expected_answer = true; $hide_expected_answer = true;
} }
if ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
if ($showTotalScoreAndUserChoices) {
$hide_expected_answer = true;
} else {
$hide_expected_answer = false;
}
}
$hotspot_colors = array( $hotspot_colors = array(
"", // $i starts from 1 on next loop (ugly fix) "", // $i starts from 1 on next loop (ugly fix)
"#4271B5", "#4271B5",
@ -190,7 +233,9 @@ class ExerciseShowFunctions
"#F4EB24", "#F4EB24",
"#ED2024", "#ED2024",
"#3B3B3B", "#3B3B3B",
"#F7BDE2"); "#F7BDE2"
);
?> ?>
<table class="data_table"> <table class="data_table">
<tr> <tr>
@ -203,7 +248,7 @@ class ExerciseShowFunctions
<td class="text-left" width="10%"> <td class="text-left" width="10%">
<?php <?php
if (!$hide_expected_answer) { if (!$hide_expected_answer) {
$my_choice = ($studentChoice)?get_lang('Correct'):get_lang('Fault'); $my_choice = $studentChoice ? get_lang('Correct') : get_lang('Fault');
echo $my_choice; echo $my_choice;
} }
?> ?>
@ -246,19 +291,29 @@ class ExerciseShowFunctions
$id, $id,
$questionId, $questionId,
$ans, $ans,
$in_results_disabled $resultsDisabled,
$showTotalScoreAndUserChoices
) { ) {
$hide_expected_answer = false; $hide_expected_answer = false;
if ($feedback_type == 0 && $in_results_disabled == 2) { if ($feedback_type == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) {
$hide_expected_answer = true; $hide_expected_answer = true;
} }
if ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
if ($showTotalScoreAndUserChoices) {
$hide_expected_answer = true;
} else {
$hide_expected_answer = false;
}
}
$icon = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; $icon = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox';
$icon .= $studentChoice?'_on':'_off'; $icon .= $studentChoice?'_on':'_off';
$icon .= '.gif'; $icon .= '.gif';
$iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox';
$iconAnswer .= $answerCorrect?'_on':'_off'; $iconAnswer .= $answerCorrect ? '_on' : '_off';
$iconAnswer .= '.gif'; $iconAnswer .= '.gif';
?> ?>
@ -290,14 +345,10 @@ class ExerciseShowFunctions
$color = 'black'; $color = 'black';
//echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br($answerComment).'</span>'; //echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br($answerComment).'</span>';
} }
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; if ($hide_expected_answer) {
$color = '';
} else {
if ($answerCorrect) {
//echo '<span style="font-weight: bold; color: #000;">'.nl2br($answerComment).'</span>';
} else {
//echo '<span style="font-weight: normal; color: #000;">'.nl2br($answerComment).'</span>';
} }
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
} }
?> ?>
</td> </td>
@ -336,19 +387,28 @@ class ExerciseShowFunctions
$id, $id,
$questionId, $questionId,
$ans, $ans,
$in_results_disabled $resultsDisabled,
$showTotalScoreAndUserChoices
) { ) {
$hide_expected_answer = false; $hide_expected_answer = false;
if ($feedback_type == 0 && $in_results_disabled == 2) {
if ($feedback_type == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) {
$hide_expected_answer = true; $hide_expected_answer = true;
} }
if ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
if ($showTotalScoreAndUserChoices) {
$hide_expected_answer = true;
} else {
$hide_expected_answer = false;
}
}
?> ?>
<tr> <tr>
<td width="5%"> <td width="5%">
<?php <?php
$course_id = api_get_course_int_id();
$question = new MultipleAnswerTrueFalse();
$course_id = api_get_course_int_id();
$new_options = Question::readQuestionOption($questionId, $course_id); $new_options = Question::readQuestionOption($questionId, $course_id);
//Your choice //Your choice
@ -363,7 +423,7 @@ class ExerciseShowFunctions
<td width="5%"> <td width="5%">
<?php <?php
//Expected choice // Expected choice
if (!$hide_expected_answer) { if (!$hide_expected_answer) {
if (isset($new_options[$answerCorrect])) { if (isset($new_options[$answerCorrect])) {
echo get_lang($new_options[$answerCorrect]['name']); echo get_lang($new_options[$answerCorrect]['name']);
@ -387,6 +447,11 @@ class ExerciseShowFunctions
if ($studentChoice == $answerCorrect) { if ($studentChoice == $answerCorrect) {
$color = "green"; $color = "green";
} }
if ($hide_expected_answer) {
$color = '';
}
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
} }
?> ?>
@ -416,7 +481,7 @@ class ExerciseShowFunctions
* @param boolean Whether to show the answer comment or not * @param boolean Whether to show the answer comment or not
* @return void * @return void
*/ */
static function display_multiple_answer_combination_true_false( public static function display_multiple_answer_combination_true_false(
$feedback_type, $feedback_type,
$answerType, $answerType,
$studentChoice, $studentChoice,
@ -426,12 +491,22 @@ class ExerciseShowFunctions
$id, $id,
$questionId, $questionId,
$ans, $ans,
$in_results_disabled $resultsDisabled,
$showTotalScoreAndUserChoices
) { ) {
$hide_expected_answer = false; $hide_expected_answer = false;
if ($feedback_type == 0 && $in_results_disabled == 2) { if ($feedback_type == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) {
$hide_expected_answer = true; $hide_expected_answer = true;
} }
if ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
if ($showTotalScoreAndUserChoices) {
$hide_expected_answer = true;
} else {
$hide_expected_answer = false;
}
}
?> ?>
<tr> <tr>
<td width="5%"> <td width="5%">
@ -447,7 +522,7 @@ class ExerciseShowFunctions
</td> </td>
<td width="5%"> <td width="5%">
<?php <?php
//Expected choice // Expected choice
if (!$hide_expected_answer) { if (!$hide_expected_answer) {
if (isset($question->options[$answerCorrect])) { if (isset($question->options[$answerCorrect])) {
echo $question->options[$answerCorrect]; echo $question->options[$answerCorrect];
@ -476,17 +551,12 @@ class ExerciseShowFunctions
if ($studentChoice == $answerCorrect) { if ($studentChoice == $answerCorrect) {
$color = "green"; $color = "green";
} }
if ($hide_expected_answer) {
$color = '';
}
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
} }
if ($studentChoice == 2 || $studentChoice == '') {
//echo '<span style="font-weight: bold; color: #000;">'.nl2br($answerComment).'</span>';
} else {
if ($studentChoice == $answerCorrect) {
//echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>';
} else {
//echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br($answerComment).'</span>';
}
}
?> ?>
</td> </td>
<?php <?php

Loading…
Cancel
Save