Fixing feedback issue see #3846

skala
Julio Montoya 14 years ago
parent 30adb21db7
commit c158de40e4
  1. 150
      main/inc/lib/exercise_show_functions.lib.php

@ -61,14 +61,14 @@ class ExerciseShowFunctions {
global $feedback_type;
if (empty($id)) {
if (!empty($answer)) {
echo '<tr>';
echo Display::tag('td',nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)), array('width'=>'55%'));
echo '<tr>';
echo Display::tag('td',nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)), array('width'=>'55%'));
echo '</tr>';
}
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<tr>';
echo Display::tag('td',get_lang('notCorrectedYet'), array('width'=>'45%'));
echo '</tr>';
echo Display::tag('td',get_lang('notCorrectedYet'), array('width'=>'45%'));
echo '</tr>';
} else {
echo '<tr><td>&nbsp;</td></tr>';
}
@ -79,7 +79,7 @@ class ExerciseShowFunctions {
echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY));
echo '</td>';
}
if(!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
if (!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = get_comments($id,$questionId);
echo '</td>';
@ -87,16 +87,16 @@ class ExerciseShowFunctions {
echo '</tr>';
}
}
function display_oral_expression_answer($answer,$id,$questionId, $nano = null) {
global $feedback_type;
if (isset($nano)) {
echo $nano->show_audio_file();
}
if (empty($id)) {
echo '<tr>';
echo Display::tag('td',nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)), array('width'=>'55%'));
echo '</tr>';
@ -114,8 +114,8 @@ class ExerciseShowFunctions {
echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY));
}
echo '</td>';
if(!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
if (!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = get_comments($id,$questionId);
echo '</td>';
@ -162,20 +162,19 @@ class ExerciseShowFunctions {
</td>
<td width="50px" style="padding-right:15px" valign="top" align="left">
<?php
$my_choice = ($studentChoice)?get_lang('Correct'):get_lang('Fault');
$my_choice = ($studentChoice)?get_lang('Correct'):get_lang('Fault');
echo $my_choice;
?>
</td>
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td valign="top" align="left" >
<?php
if($studentChoice) {
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>';
}
<?php
if ($studentChoice) {
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 } else { ?>
@ -199,7 +198,7 @@ class ExerciseShowFunctions {
* @param boolean Whether to show the answer comment or not
* @return void
*/
function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
global $feedback_type;
?>
<tr>
@ -212,25 +211,30 @@ class ExerciseShowFunctions {
border="0" alt=" " />
</td>
<td width="40%" style="border-bottom: 1px solid #4171B5;">
<?php
<?php
echo $answer;
?>
</td>
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
if ($studentChoice) {
if($answerCorrect) {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
<?php
if ($studentChoice) {
if ($answerCorrect) {
$color = 'green';
//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>';
$color = 'black';
//echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
if($answerCorrect) {
echo '<span style="font-weight: bold; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
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>';
//echo '<span style="font-weight: normal; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
}
?>
@ -244,9 +248,9 @@ class ExerciseShowFunctions {
<td>&nbsp;</td>
<?php } ?>
</tr>
<?php
}
<?php
}
/**
* Display the answers to a multiple choice question
*
@ -261,33 +265,33 @@ class ExerciseShowFunctions {
* @return void
*/
function display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
global $feedback_type;
global $feedback_type;
?>
<tr>
<td width="5%" align="center">
<?php
$question = new MultipleAnswerTrueFalse();
<?php
$question = new MultipleAnswerTrueFalse();
$course_id = api_get_course_int_id();
$new_options = Question::readQuestionOption($questionId, $course_id);
//Your choice
//Your choice
if (isset($new_options[$studentChoice])) {
echo get_lang($new_options[$studentChoice]['name']);
} else {
echo '-';
}
?>
}
?>
</td>
<td width="5%" align="center">
<?php
<?php
//Expected choice
if (isset($new_options[$answerCorrect])) {
echo get_lang($new_options[$answerCorrect]['name']);
} else {
echo '-';
}
?>
}
?>
</td>
<td width="40%" style="border-bottom: 1px solid #4171B5;">
<?php echo $answer; ?>
@ -295,16 +299,26 @@ class ExerciseShowFunctions {
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
<?php
//@todo replace this harcoded value
if ($studentChoice) {
$color = "black";
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br(make_clickable($answerComment)).'</span>';
if ($studentChoice == $answerCorrect) {
$color = "green";
// echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br(make_clickable($answerComment)).'</span>';
}
}
if ($studentChoice == 3 || $studentChoice == '') {
echo '<span style="font-weight: bold; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
//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>';
//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>';
//echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
}
?>
@ -320,7 +334,7 @@ class ExerciseShowFunctions {
</tr>
<?php
}
/**
* Display the answers to a multiple choice question
*
@ -334,20 +348,20 @@ class ExerciseShowFunctions {
* @param boolean Whether to show the answer comment or not
* @return void
*/
function display_multiple_answer_combination_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
global $feedback_type;
function display_multiple_answer_combination_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
global $feedback_type;
?>
<tr>
<td width="5%" align="center">
<?php
<?php
//Your choice
$question = new MultipleAnswerCombinationTrueFalse();
$question = new MultipleAnswerCombinationTrueFalse();
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
echo $question->options[2];
}
?>
}
?>
</td>
<td width="5%" align="center">
<?php
@ -356,12 +370,12 @@ class ExerciseShowFunctions {
echo $question->options[$answerCorrect];
} else {
echo $question->options[2];
}
?>
}
?>
</td>
<td width="40%" style="border-bottom: 1px solid #4171B5;">
<?php
//my answer
//my answer
echo $answer;
?>
</td>
@ -370,17 +384,22 @@ class ExerciseShowFunctions {
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
//@todo replace this harcoded value
if ($studentChoice) {
$color = "black";
if ($studentChoice == $answerCorrect) {
$color = "green";
}
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br(make_clickable($answerComment)).'</span>';
}
if ($studentChoice == 2 || $studentChoice == '') {
echo '<span style="font-weight: bold; color: #000;">'.nl2br(make_clickable($answerComment)).'</span>';
//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>';
//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>';
//echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
}
?>
</td>
<?php
@ -394,5 +413,4 @@ class ExerciseShowFunctions {
</tr>
<?php
}
}

Loading…
Cancel
Save