Rename variable name $showTotalScoreAndUserChoicesInLastAttempt

pull/2487/head
jmontoyaa 9 years ago
parent e1d02d4346
commit 5f1ccfa27e
  1. 73
      main/exercise/exercise.class.php
  2. 35
      main/exercise/exercise_show.php

@ -3095,7 +3095,7 @@ class Exercise
* @param bool $show_result show results or not
* @param int $propagate_neg
* @param array $hotspot_delineation_result
* @param boolean $showTotalScoreAndUserChoices
* @param boolean $showTotalScoreAndUserChoicesInLastAttempt
* @todo reduce parameters of this function
* @return string html code
*/
@ -3110,7 +3110,7 @@ class Exercise
$show_result = true,
$propagate_neg = 0,
$hotspot_delineation_result = array(),
$showTotalScoreAndUserChoices = false
$showTotalScoreAndUserChoicesInLastAttempt = true
) {
global $debug;
//needed in order to use in the exercise_attempt() for the time
@ -3187,9 +3187,6 @@ class Exercise
$totalWeighting = 0;
$totalScore = 0;
// Destruction of the Question object
//unset($objQuestionTmp);
// Construction of the Answer object
$objAnswerTmp = new Answer($questionId);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
@ -3894,12 +3891,13 @@ class Exercise
//no break
case MATCHING:
if ($from_database) {
$sql = 'SELECT id, answer, id_auto
FROM '.$table_ans.'
$sql = "SELECT id, answer, id_auto
FROM $table_ans
WHERE
c_id = '.$course_id.' AND
question_id = "'.$questionId.'" AND
correct = 0';
c_id = $course_id AND
question_id = $questionId AND
correct = 0
";
$res_answer = Database::query($sql);
// Getting the real answer
$real_list = array();
@ -3907,13 +3905,13 @@ class Exercise
$real_list[$real_answer['id_auto']] = $real_answer['answer'];
}
$sql = 'SELECT id, answer, correct, id_auto, ponderation
FROM '.$table_ans.'
$sql = "SELECT id, answer, correct, id_auto, ponderation
FROM $table_ans
WHERE
c_id = '.$course_id.' AND
question_id="'.$questionId.'" AND
c_id = $course_id AND
question_id = $questionId AND
correct <> 0
ORDER BY id_auto';
ORDER BY id_auto";
$res_answers = Database::query($sql);
$questionScore = 0;
@ -3956,9 +3954,20 @@ class Exercise
$questionScore += $i_answerWeighting;
$totalScore += $i_answerWeighting;
// Try with id
if (isset($real_list[$i_answer_id])) {
$user_answer = Display::span($real_list[$i_answer_id]);
}
// Try with $i_answer_id_auto
if (empty($user_answer)) {
if (isset($real_list[$i_answer_id_auto])) {
$user_answer = Display::span(
$real_list[$i_answer_id_auto]
);
}
}
} else {
$user_answer = Display::span(
$real_list[$s_user_answer],
@ -3971,7 +3980,7 @@ class Exercise
}
if ($show_result) {
if ($showTotalScoreAndUserChoices == true) {
if ($showTotalScoreAndUserChoicesInLastAttempt == false) {
$user_answer = '';
}
echo '<tr>';
@ -3979,7 +3988,7 @@ class Exercise
echo '<td>' . $user_answer;
if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
if (isset($real_list[$i_answer_correct_answer]) && $showTotalScoreAndUserChoices == false) {
if (isset($real_list[$i_answer_correct_answer]) && $showTotalScoreAndUserChoicesInLastAttempt == true) {
echo Display::span(
$real_list[$i_answer_correct_answer],
['style' => 'color: #008000; font-weight: bold;']
@ -4209,7 +4218,7 @@ class Exercise
0,
0,
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
ExerciseShowFunctions::display_multiple_answer_true_false(
@ -4223,7 +4232,7 @@ class Exercise
$questionId,
0,
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
ExerciseShowFunctions::display_multiple_answer_combination_true_false(
@ -4237,7 +4246,7 @@ class Exercise
0,
0,
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif ($answerType == FILL_IN_BLANKS) {
ExerciseShowFunctions::display_fill_in_blanks_answer(
@ -4247,7 +4256,7 @@ class Exercise
0,
$results_disabled,
'',
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif ($answerType == CALCULATED_ANSWER) {
ExerciseShowFunctions::display_calculated_answer(
@ -4256,7 +4265,7 @@ class Exercise
0,
0,
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif ($answerType == FREE_ANSWER) {
ExerciseShowFunctions::display_free_answer(
@ -4293,7 +4302,7 @@ class Exercise
$answerComment,
$results_disabled,
$answerId,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif ($answerType == HOT_SPOT_ORDER) {
ExerciseShowFunctions::display_hotspot_order_answer(
@ -4497,7 +4506,7 @@ class Exercise
$questionId,
$answerId,
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} else {
ExerciseShowFunctions::display_unique_or_multiple_answer(
@ -4511,7 +4520,7 @@ class Exercise
$questionId,
'',
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
}
break;
@ -4528,7 +4537,7 @@ class Exercise
$questionId,
$answerId,
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} else {
ExerciseShowFunctions::display_multiple_answer_combination_true_false(
@ -4542,7 +4551,7 @@ class Exercise
$questionId,
'',
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
}
break;
@ -4559,7 +4568,7 @@ class Exercise
$questionId,
$answerId,
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
} else {
ExerciseShowFunctions::display_multiple_answer_true_false(
@ -4573,7 +4582,7 @@ class Exercise
$questionId,
'',
$results_disabled,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
}
break;
@ -4585,7 +4594,7 @@ class Exercise
$questionId,
$results_disabled,
$str,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
break;
case CALCULATED_ANSWER:
@ -4596,7 +4605,7 @@ class Exercise
$questionId,
$results_disabled,
'',
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
break;
case FREE_ANSWER:
@ -4631,7 +4640,7 @@ class Exercise
$answerComment,
$results_disabled,
$answerId,
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
break;
case HOT_SPOT_DELINEATION:

@ -196,7 +196,7 @@ if ($origin != 'learnpath') {
<?php
$show_results = true;
$show_only_total_score = false;
$showTotalScoreAndUserChoices = true;
$showTotalScoreAndUserChoicesInLastAttempt = true;
// Avoiding the "Score 0/0" message when the exe_id is not set
if (!empty($track_exercise_info)) {
@ -204,21 +204,8 @@ if (!empty($track_exercise_info)) {
$result_disabled = $track_exercise_info['results_disabled'];
if (true) {
//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;
if ($origin != 'learnpath') {
/*echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">';
Display::display_warning_message(
get_lang('ThankYouForPassingTheTest') . '<br /><br /><a href="exercise.php">' . (get_lang('BackToExercisesList')) . '</a>',
false
);
echo '</td>
</tr>
</table>';*/
}
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
$show_results = false;
$show_only_total_score = true;
@ -245,11 +232,13 @@ if (!empty($track_exercise_info)) {
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
$show_results = true;
$show_only_total_score = true;
$showTotalScoreAndUserChoices = false;
// Attempt reach max so show score/feedback now
$showTotalScoreAndUserChoicesInLastAttempt = true;
} else {
$show_results = true;
$show_only_total_score = true;
$showTotalScoreAndUserChoices = true;
// Last attempt not reach don't show score/feedback
$showTotalScoreAndUserChoicesInLastAttempt = false;
}
}
}
@ -266,7 +255,7 @@ if ($is_allowedToEdit && in_array($action, ['qualify', 'edit'])) {
$show_results = true;
}
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) {
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
$user_info = api_get_user_info($student_id);
//Shows exercise header
echo $objExercise->show_exercise_result_header(
@ -411,13 +400,13 @@ foreach ($questionList as $questionId) {
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
break;
case HOT_SPOT:
if ($show_results || $showTotalScoreAndUserChoices) {
if ($show_results || $showTotalScoreAndUserChoicesInLastAttempt) {
echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" >
<table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
@ -433,7 +422,7 @@ foreach ($questionList as $questionId) {
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
@ -476,7 +465,7 @@ foreach ($questionList as $questionId) {
$objExercise->selectPropagateNeg(),
'database',
[],
$showTotalScoreAndUserChoices
$showTotalScoreAndUserChoicesInLastAttempt
);
$questionScore = $question_result['score'];
@ -821,7 +810,7 @@ $total_score_text = null;
//Total score
if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) {
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
$total_score_text .= '<div class="question_row">';
$my_total_score_temp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
@ -837,7 +826,7 @@ if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type'])
}
}
if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices)) {
if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt)) {
// Adding total
$category_list['total'] = array(
'score' => $my_total_score_temp,

Loading…
Cancel
Save