New changes for the new type of questions + some code for the exercise_min and exercise_max variables

skala
Julio Montoya 14 years ago
parent 6fd0357f7c
commit 2a05677ae5
  1. 8
      main/exercice/admin.php
  2. 151
      main/exercice/exercise.class.php
  3. 89
      main/exercice/exercise.lib.php
  4. 4
      main/exercice/exercise_show.php
  5. 13
      main/exercice/multiple_answer_combination.class.php
  6. 42
      main/exercice/multiple_answer_combination_true_false.class.php
  7. 11
      main/exercice/multiple_answer_true_false.class.php
  8. 3
      main/exercice/question.class.php
  9. 81
      main/inc/lib/exercise_show_functions.lib.php

@ -293,11 +293,15 @@ $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jqu
$htmlHeadXtra[] = '<script type="text/javascript">
function multiple_answer_true_false_onchange(variable) {
var result = variable.value;
var result = variable.checked;
var id = variable.id;
var weight_id = "weighting_" + id;
var array_result=new Array(); array_result[1]="1"; array_result[0]= "-0.50"; array_result[-1]= "0";
if (result) {
result = 1;
} else {
result = 0;
}
document.getElementById(weight_id).value = array_result[result];
}

@ -1698,6 +1698,7 @@ class Exercise {
switch ($answerType) {
// for unique answer
case UNIQUE_ANSWER :
case UNIQUE_ANSWER_NO_OPTION :
if ($from_database) {
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$resultans = Database::query($queryans);
@ -1719,35 +1720,114 @@ class Exercise {
}
break;
// for multiple answers
case MULTIPLE_ANSWER_TRUE_FALSE :
case MULTIPLE_ANSWER_ :
case MULTIPLE_ANSWER_TRUE_FALSE :
if ($from_database) {
$choice=array();
$queryans = "SELECT * 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'];
$result = explode(':',$ind);
$my_answer_id = $result[0];
$option = $result[1];
$choice[$my_answer_id] = $option;
}
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice =$choice[$numAnswer];
} else {
$studentChoice =$choice[$numAnswer]; // 0, 1 or 2
//echo $studentChoice.' - '.$answerCorrect.'<br />';
}
if ($studentChoice == $answerCorrect ) {
if ($studentChoice == 1) {
$questionScore +=1;
$totalScore +=1;
}
} else {
if ($studentChoice == 0 || $studentChoice == 1) {
$questionScore +=-0.5;
$totalScore +=-0.5;
}
}
break;
case MULTIPLE_ANSWER :
if ($from_database) {
$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'];
$choice[$ind] = 1;
}
}
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice=$choice[$numAnswer];
if ($studentChoice) {
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
$questionScore +=$answerWeighting;
$totalScore +=$answerWeighting;
}
} else {
} else {
$studentChoice=$choice[$numAnswer];
if ($studentChoice) {
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
$questionScore +=$answerWeighting;
$totalScore +=$answerWeighting;
}
}
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."'";
$resultans = Database::query($queryans);
while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer'];
$result = explode(':',$ind);
$my_answer_id = $result[0];
$option = $result[1];
$choice[$my_answer_id] = $option;
}
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice=$choice[$numAnswer];
if ($answerCorrect == 1) {
if ($studentChoice) {
$real_answers[$answerId] = true;
} else {
$real_answers[$answerId] = false;
}
} else {
if ($studentChoice) {
$real_answers[$answerId] = false;
} else {
$real_answers[$answerId] = true;
}
}
} else {
$studentChoice=$choice[$numAnswer];
if ($answerCorrect == 1) {
if ($studentChoice) {
$real_answers[$answerId] = true;
} else {
$real_answers[$answerId] = false;
}
} else {
if ($studentChoice) {
$real_answers[$answerId] = false;
} 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) {
$queryans = "SELECT * FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
if ($from_database) {
$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'];
@ -2046,8 +2126,7 @@ class Exercise {
}
// for hotspot with no order
case HOT_SPOT :
case HOT_SPOT :
if ($from_database) {
if ($show_result) {
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
@ -2083,10 +2162,14 @@ class Exercise {
if ($from == 'exercise_result') {
//display answers (if not matching type, or if the answer is correct)
if ($answerType != MATCHING || $answerCorrect) {
if (in_array($answerType, array(UNIQUE_ANSWER, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, MULTIPLE_ANSWER_TRUE_FALSE))) {
if (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION))) {
if ($origin!='learnpath') {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,0,0);
}
} elseif($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($origin!='learnpath') {
ExerciseShowFunctions::display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,0,0);
}
} elseif($answerType == FILL_IN_BLANKS) {
if ($origin!='learnpath') {
ExerciseShowFunctions::display_fill_in_blanks_answer($answer,0,0);
@ -2114,16 +2197,24 @@ class Exercise {
}
} else {
switch($answerType) {
case UNIQUE_ANSWER :
case MULTIPLE_ANSWER :
case MULTIPLE_ANSWER_TRUE_FALSE :
case UNIQUE_ANSWER :
case UNIQUE_ANSWER_NO_OPTION:
case MULTIPLE_ANSWER :
case MULTIPLE_ANSWER_COMBINATION :
if ($answerId==1) {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,$answerId);
} else {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,"");
}
break;
break;
case MULTIPLE_ANSWER_COMBINATION_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 {
ExerciseShowFunctions::display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,"");
}
break;
case FILL_IN_BLANKS:
echo '<tr><td>';
ExerciseShowFunctions::display_fill_in_blanks_answer($answer,$exeId,$questionId);
@ -2169,12 +2260,12 @@ class Exercise {
}
//we add the total score after dealing with the answers
if ($answerType == MULTIPLE_ANSWER_COMBINATION) {
if ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($final_answer) {
//getting only the first score where we save the weight of all the question
$answerWeighting=$objAnswerTmp->selectWeighting(1);
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
$answerWeighting = $objAnswerTmp->selectWeighting(1);
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
}
}
@ -2229,7 +2320,17 @@ class Exercise {
if (empty ($choice)) {
$choice = 0;
}
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($choice != 0) {
$reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i];
exercise_attempt($questionScore, $ans.':'.$choice[$ans], $quesId, $exeId, $i, $this->id);
}
} else {
exercise_attempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
}
} elseif ($answerType == MULTIPLE_ANSWER) {
if ($choice != 0) {
$reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) {

@ -84,6 +84,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
if ($answerType == FREE_ANSWER && $freeze) {
return '';
}
$s .= '<table width="720" class="exercise_options" style="width: 720px;'.$option_ie.' background-color:#fff;">';
// construction of the Answer object (also gets all answers details)
$objAnswerTmp=new Answer($questionId);
@ -220,6 +221,15 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
// answers for the question as a limiter
$lines_count=1; // a counter for matching-type answers
$question_list = array();
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$header .= Display::tag('th', get_lang('Options'));
foreach ($objQuestionTmp->options as $key=>$item) {
$header .= Display::tag('th', $item);
}
$s.=Display::tag('tr',$header);
}
for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
@ -248,6 +258,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
}
$answer = text_filter($answer);
$answer = Security::remove_XSS($answer, STUDENT);
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
'<tr><td colspan="3"><div class="u-m-answer"><p style="float: '.($is_ltr_text_direction ? 'left' : 'right').'; padding-'.($is_ltr_text_direction ? 'right' : 'left').': 4px;">'.
'<span><input class="checkbox" type="radio" name="choice['.$questionId.']" value="'.$numAnswer.'" '.$selected.' /></span></p>'.
@ -266,16 +277,35 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$help = 'x-';
$selected = 'checked="checked"';
}
}
}
$answer = text_filter($answer);
$answer = Security::remove_XSS($answer, STUDENT);
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
'<tr><td colspan="3"><div class="u-m-answer"><p style="float: '.($is_ltr_text_direction ? 'left' : 'right').'; padding-'.($is_ltr_text_direction ? 'right' : 'left').': 4px;">'.
'<span><input class="checkbox" type="checkbox" name="choice['.$questionId.']['.$numAnswer.']" value="1" '.$selected.' /></span></p>'.
'<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'.
$answer.
'</div></div></td></tr>';
if ($answerType == MULTIPLE_ANSWER) {
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$s .= '<tr><td colspan="3"><div class="u-m-answer"><p style="float: '.($is_ltr_text_direction ? 'left' : 'right').'; padding-'.($is_ltr_text_direction ? 'right' : 'left').': 4px;">';
$options = array('type'=>'checkbox','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
if ($answerCorrect) {
$options['checked'] = 'checked';
}
$s .= Display::tag('span', Display::tag('input','',$options ));
$s .= '</p>';
$s .= '<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'.
$answer.
'</div></div></td></tr>';
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
$s .='<tr>';
$s .= Display::tag('td', $answer);
foreach ($objQuestionTmp->options as $key=>$item) {
$options['value'] = $key;
$s .= Display::tag('td', Display::tag('input','',$options ));
}
$s.='<tr>';
}
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
// multiple answers
// set $debug_mark_answer to true at function start to
@ -295,7 +325,28 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
'<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'.
$answer.
'</div></div></td></tr>';
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
// multiple answers
// set $debug_mark_answer to true at function start to
// show the correct answer with a suffix '-x'
$help = $selected = '';
if ($debug_mark_answer) {
if ($answerCorrect) {
$help = 'x-';
$selected = 'checked="checked"';
}
}
$answer = text_filter($answer);
$answer = Security::remove_XSS($answer, STUDENT);
$options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
$s .='<tr>';
$s .= Display::tag('td', $answer);
foreach ($objQuestionTmp->options as $key=>$item) {
$options['value'] = $key;
$s .= Display::tag('td', Display::tag('input','',$options ));
}
$s.='<tr>';
} elseif ($answerType == FILL_IN_BLANKS) {
// fill in blanks
$s .= '<tr><td colspan="3">'.$answer.'</td></tr>';
@ -957,7 +1008,9 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
$my_res = float_format($results[$i]['exresult'],1);
$my_total = float_format($results[$i]['exweight'],1);
$result_list = round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ')';
$ex = show_score($my_res, $my_total);
$result_list = round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ') --> '.$ex;
$html_link = '';
if ($is_allowedToEdit || $is_tutor) {
@ -1014,3 +1067,19 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
}
return $list_info;
}
function show_score($score, $weight, $show_porcentage = true) {
$html = '';
$score_rounded = $score;
if ($score != '' && $weight != '') {
$max_note = api_get_setting('exercise_max_note');
$min_note = api_get_setting('exercise_min_note');
if ($max_note != '' && $min_note != '') {
$score = $min_note + ($max_note - $min_note) * $score /$weight;
$score_rounded = round($score, 2);
$weight = $max_note;
}
$html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')';
}
return $html;
}

@ -372,7 +372,7 @@ if ($show_results) {
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
echo '</table>';
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice=array();
?>
<table width="100%" border="0" cellspacing="3" cellpadding="3">
@ -395,7 +395,7 @@ if ($show_results) {
$totalScore += $question_result['score'];
echo '</table>';
} elseif ($answerType == UNIQUE_ANSWER) {
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
?>
<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>

@ -116,10 +116,7 @@ class MultipleAnswerCombination extends Question {
$answer_number=$form->addElement('text', null,null,'value="'.$i.'"');
$answer_number->freeze();
//$form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"');
$options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
$form->addElement('select', 'correct['.$i.']',null, $options);
$form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"');
$boxes_names[] = 'correct['.$i.']';
$form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
@ -154,11 +151,15 @@ class MultipleAnswerCombination extends Question {
$form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"');
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="minus"');
} else {
$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'style="float:right"; class="minus"');
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'style="float:right"; class="plus"');
// setting the save button here and not in the question class.php
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'style="float:right"; class="plus"');
// setting the save button here and not in the question class.php
}
}
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers');

@ -0,0 +1,42 @@
<?php // $Id: document.php 16494 2008-10-10 22:07:36Z yannoo $
/* For licensing terms, see /chamilo_license.txt */
/**
* File containing the MultipleAnswer class.
* @package dokeos.exercise
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('MultipleAnswerCombinationTrueFalse')):
/**
CLASS MultipleAnswer
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package dokeos.exercise
**/
require 'multiple_answer_combination.class.php';
class MultipleAnswerCombinationTrueFalse extends MultipleAnswerCombination {
static $typePicture = 'mcmac.gif';
static $explanationLangVar = 'MultipleAnswerCombinationTrueFalse';
var $options;
/**
* Constructor
*/
function MultipleAnswerCombinationTrueFalse(){
parent::question();
$this -> type = MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE;
$this -> isContent = $this-> getIsContent();
$this->options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
}
}
endif;
?>

@ -23,7 +23,7 @@ class MultipleAnswerTrueFalse extends Question {
static $typePicture = 'mcma.gif';
static $explanationLangVar = 'MultipleAnswerTrueFalseSelect';
var $options;
/**
* Constructor
*/
@ -31,6 +31,7 @@ class MultipleAnswerTrueFalse extends Question {
parent::question();
$this -> type = MULTIPLE_ANSWER_TRUE_FALSE;
$this -> isContent = $this-> getIsContent();
$this->options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
}
/**
@ -112,11 +113,11 @@ class MultipleAnswerTrueFalse extends Question {
$answer_number=$form->addElement('text', null,null,'value="'.$i.'"');
$answer_number->freeze();
//$form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"');
$options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
$form->addElement('select', 'correct['.$i.']',null, $options, array('id'=>$i,'onchange'=>'multiple_answer_true_false_onchange(this)'));
$form->addElement('checkbox', 'correct['.$i.']', null, null, 'id="'.$i.'" class="checkbox" style="margin-left: 0em;" onchange="multiple_answer_true_false_onchange(this);" ' );
//$form->addElement('select', 'correct['.$i.']',null, $this->options, array('id'=>$i,'onchange'=>'multiple_answer_true_false_onchange(this)'));
//$boxes_names[] = 'correct['.$i.']';
$boxes_names[] = 'correct['.$i.']';
$form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');

@ -23,6 +23,8 @@ define('HOT_SPOT_DELINEATION', 8);
define('MULTIPLE_ANSWER_COMBINATION', 9);
define('UNIQUE_ANSWER_NO_OPTION', 10);
define('MULTIPLE_ANSWER_TRUE_FALSE', 11);
define('MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE', 12);
/**
QUESTION CLASS
@ -57,6 +59,7 @@ abstract class Question
MULTIPLE_ANSWER_COMBINATION => array('multiple_answer_combination.class.php' , 'MultipleAnswerCombination'),
UNIQUE_ANSWER_NO_OPTION => array('unique_answer_no_option.class.php' , 'UniqueAnswerNoOption'),
MULTIPLE_ANSWER_TRUE_FALSE => array('multiple_answer_true_false.class.php' , 'MultipleAnswerTrueFalse'),
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE => array('multiple_answer_combination_true_false.class.php' , 'MultipleAnswerCombinationTrueFalse'),
);

@ -165,7 +165,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>
@ -209,5 +209,82 @@ class ExerciseShowFunctions {
<?php } ?>
</tr>
<?php
}
}
/**
* Display the answers to a multiple choice question
*
* @param integer Answer type
* @param integer Student choice
* @param string Textual answer
* @param string Comment on answer
* @param string Correct answer comment
* @param integer Exercise ID
* @param integer Question ID
* @param boolean Whether to show the answer comment or not
* @return void
*/
function display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
global $feedback_type;
?>
<tr>
<td width="5%" align="center">
<?php
//var_dump($studentChoice);
if ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
$question = new MultipleAnswerCombinationTrueFalse();
} else {
$question = new MultipleAnswerTrueFalse();
}
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
echo $question->options[2];
}
?>
</td>
<td width="5%" align="center">
<?php
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);
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>';
} else {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
} else {
echo '&nbsp;';
}
?>
</td>
<?php
if ($ans==1) {
$comm = get_comments($id,$questionId);
}
?>
<?php } else { ?>
<td>&nbsp;</td>
<?php } ?>
</tr>
<?php
}
}
Loading…
Cancel
Save