Fixing Combination true/false/don't-know answer's feedback

skala
Julio Montoya 15 years ago
parent b22e701b2e
commit 9e207ae682
  1. 48
      main/exercice/exercise.class.php
  2. 5
      main/exercice/exercise_show.php
  3. 29
      main/inc/lib/exercise_show_functions.lib.php

@ -1779,8 +1779,7 @@ class Exercise {
if ($debug) error_log('manage_answer $from_database '.$from_database);
if ($debug) error_log('manage_answer $show_result '.$show_result);
if ($debug) error_log('manage_answer $propagate_neg '.$propagate_neg);
if ($debug) error_log('manage_answer $$hotspot_delineation_result '.print_r($hotspot_delineation_result, 1));
if ($debug) error_log('manage_answer $$hotspot_delineation_result '.print_r($hotspot_delineation_result, 1));
$extra_data = array();
$html = '';
@ -1791,7 +1790,7 @@ class Exercise {
$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
// Creates a temporary Question object
$objQuestionTmp = Question :: read($questionId);
$objQuestionTmp = Question::read($questionId);
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
@ -1803,7 +1802,7 @@ class Exercise {
$next = 1; //not for now
//Extra information of the question
if (!empty($extra)){
if (!empty($extra)) {
$extra = explode(':', $extra);
$true_score = $extra[0];
$false_score = $extra[1];
@ -1931,7 +1930,7 @@ class Exercise {
break;
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
if ($from_database) {
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = ".$exeId." AND question_id= ".$questionId;
$resultans = Database::query($queryans);
while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer'];
@ -1939,11 +1938,20 @@ class Exercise {
$my_answer_id = $result[0];
$option = $result[1];
$choice[$my_answer_id] = $option;
}
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice=$choice[$numAnswer];
}
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
$studentChoice = $choice[$numAnswer];
if ($answerCorrect == $studentChoice) {
//$answerCorrect = 1;
$real_answers[$answerId] = true;
} else {
//$answerCorrect = 0;
$real_answers[$answerId] = false;
}
/*
if ($answerCorrect == 1) {
if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class
$real_answers[$answerId] = true;
@ -1960,10 +1968,19 @@ class Exercise {
} else {
$real_answers[$answerId] = true;
}
}
}*/
} else {
$studentChoice=$choice[$numAnswer];
if ($answerCorrect == 1) {
$studentChoice = $choice[$numAnswer];
if ($answerCorrect == $studentChoice) {
//$answerCorrect = 1;
$real_answers[$answerId] = true;
} else {
//$answerCorrect = 0;
$real_answers[$answerId] = false;
}
/*if ($answerCorrect == 1) {
if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class
$real_answers[$answerId] = true;
} elseif ($studentChoice == 2) { //false value
@ -1979,14 +1996,15 @@ class Exercise {
} else {
$real_answers[$answerId] = true;
}
}
} */
$final_answer = true;
foreach($real_answers as $my_answer) {
if (!$my_answer) {
$final_answer = false;
}
}
}
}
break;
case MULTIPLE_ANSWER_COMBINATION:
if ($from_database) {

@ -318,7 +318,7 @@ foreach ($questionList as $questionId) {
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice=array();
$choice = array();
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
@ -415,8 +415,7 @@ foreach ($questionList as $questionId) {
if ($final_excess>100) {
$final_excess = 100;
}
}
$table_resume='<table class="data_table">
<tr class="row_odd" >

@ -301,9 +301,8 @@ class ExerciseShowFunctions {
<tr>
<td width="5%" align="center">
<?php
$question = new MultipleAnswerCombinationTrueFalse();
//Your choice
$question = new MultipleAnswerCombinationTrueFalse();
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
@ -313,18 +312,17 @@ class ExerciseShowFunctions {
</td>
<td width="5%" align="center">
<?php
//Expected choice
if (isset($question->options[$answerCorrect])) {
echo $question->options[$answerCorrect];
} else {
echo $question->options[2];
}
?>
?>
</td>
<td width="40%" style="border-bottom: 1px solid #4171B5;">
<?php
$answer=text_filter($answer);
//my answer
echo $answer;
?>
</td>
@ -332,16 +330,13 @@ class ExerciseShowFunctions {
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
$answerComment=text_filter($answerComment);
if($studentChoice) {
if(!$answerCorrect) {
echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
} else {
echo '&nbsp;';
}
if ($studentChoice == $answerCorrect) {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
?>
</td>
<?php

Loading…
Cancel
Save