Fixing new QCM questions comments see BT#2803

skala
Julio Montoya 14 years ago
parent 5b4a5cdceb
commit cddd938460
  1. 40
      main/exercice/exercise.class.php
  2. 56
      main/inc/lib/exercise_show_functions.lib.php

@ -1846,7 +1846,7 @@ class Exercise {
$questionScore = 0;
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$answerWeighting = $objAnswerTmp->selectWeighting($answerId);
@ -1865,8 +1865,6 @@ class Exercise {
$resultans = Database::query($queryans);
$choice = Database::result($resultans,0,"answer");
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice=($choice == $numAnswer)?1:0;
if ($studentChoice) {
$questionScore+=$answerWeighting;
@ -1883,8 +1881,8 @@ class Exercise {
// for multiple answers
case MULTIPLE_ANSWER_TRUE_FALSE :
if ($from_database) {
$choice=array();
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$choice = array();
$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'];
@ -1892,24 +1890,30 @@ class Exercise {
$my_answer_id = $result[0];
$option = $result[1];
$choice[$my_answer_id] = $option;
}
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
}
$studentChoice =$choice[$numAnswer];
} else {
$studentChoice =$choice[$numAnswer];
}
if ($studentChoice == $answerCorrect ) {
$questionScore += $true_score;
} else {
if ($quiz_question_options[$studentChoice]['name'] != "Don't know") {
$questionScore += $false_score;
if (!empty($studentChoice)) {
if ($studentChoice == $answerCorrect ) {
$questionScore += $true_score;
} else {
$questionScore += $doubt_score;
if ($quiz_question_options[$studentChoice]['name'] != "Don't know") {
$questionScore += $false_score;
} else {
$questionScore += $doubt_score;
}
}
} else {
//if no result then the user just hit don't know
$studentChoice = 3;
$questionScore += $doubt_score;
}
$totalScore = $questionScore;
/*error_log('$totalScore '.$totalScore);
error_log('$$questionScore '.$questionScore);*/
$totalScore = $questionScore;
break;
case MULTIPLE_ANSWER :
if ($from_database) {
@ -2318,7 +2322,7 @@ class Exercise {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,0,0);
}
} elseif($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
if ($origin!='learnpath') {
if ($origin!='learnpath') {
ExerciseShowFunctions::display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,$questionId,0);
}
} elseif($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
@ -2527,7 +2531,7 @@ class Exercise {
ExerciseShowFunctions::display_multiple_answer_combination_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,"");
}
break;
case MULTIPLE_ANSWER_TRUE_FALSE :
case MULTIPLE_ANSWER_TRUE_FALSE :
if ($answerId==1) {
ExerciseShowFunctions::display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,$answerId);
} else {

@ -167,32 +167,34 @@ class ExerciseShowFunctions {
?>
<tr>
<td width="5%" align="center">
<img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $studentChoice?'_on':'_off'; ?>.gif"
<img src="../img/<?php echo (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION))) ? 'radio':'checkbox'; echo $studentChoice?'_on':'_off'; ?>.gif"
border="0" alt="" />
</td>
<td width="5%" align="center">
<img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $answerCorrect?'_on':'_off'; ?>.gif"
<img src="../img/<?php echo (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION))) ? 'radio':'checkbox'; echo $answerCorrect?'_on':'_off'; ?>.gif"
border="0" alt=" " />
</td>
<td width="40%" style="border-bottom: 1px solid #4171B5;">
<?php
$answer=text_filter($answer);
<?php
echo $answer;
?>
</td>
<?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>';
<?php
if ($studentChoice) {
if($answerCorrect) {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
} else {
echo '&nbsp;';
if($answerCorrect) {
echo '<span style="font-weight: bold; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
echo '<span style="font-weight: normal; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
}
?>
</td>
@ -230,7 +232,8 @@ class ExerciseShowFunctions {
$question = new MultipleAnswerTrueFalse();
$new_options = Question::readQuestionOption($questionId);
//Your choice
//Your choice
if (isset($new_options[$studentChoice])) {
echo get_lang($new_options[$studentChoice]['name']);
} else {
@ -239,7 +242,7 @@ class ExerciseShowFunctions {
?>
</td>
<td width="5%" align="center">
<?php
<?php
//Expected choice
if (isset($new_options[$answerCorrect])) {
echo get_lang($new_options[$answerCorrect]['name']);
@ -255,10 +258,16 @@ class ExerciseShowFunctions {
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
if ($studentChoice == $answerCorrect) {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
//@todo replace this harcoded value
if ($studentChoice == 3 || $studentChoice == '') {
echo '<span style="font-weight: bold; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
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>
@ -322,12 +331,17 @@ class ExerciseShowFunctions {
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
//@todo replace this harcoded value
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>';
}
if ($studentChoice == 2 || $studentChoice == '') {
echo '<span style="font-weight: bold; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
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>

Loading…
Cancel
Save