* @author Hubert Borderiou 2011-10-21 * @author ivantcholakov2009-07-20 * */ class ExerciseLib { /** * Shows a question * * @param int $questionId question id * @param bool $only_questions if true only show the questions, no exercise title * @param bool $origin i.e = learnpath * @param string $current_item current item from the list of questions * @param bool $show_title * @param bool $freeze * @param array $user_choice * @param bool $show_comment * @param bool $exercise_feedback * @param bool $show_answers * */ public static function showQuestion( $questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false ) { // Change false to true in the following line to enable answer hinting $debug_mark_answer = $show_answers; // Reads question information if (!$objQuestionTmp = Question::read($questionId)) { // Question not found return false; } if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) { $show_comment = false; } $answerType = $objQuestionTmp->selectType(); $pictureName = $objQuestionTmp->selectPicture(); $s = ''; if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) { // Question is not a hotspot if (!$only_questions) { $questionDescription = $objQuestionTmp->selectDescription(); if ($show_title) { TestCategory::displayCategoryAndTitle($objQuestionTmp->id); echo Display::div( $current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title') ); } if (!empty($questionDescription)) { echo Display::div( $questionDescription, array('class' => 'question_description') ); } } if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze ) { return ''; } echo '
';
}
if ($answerType == UNIQUE_ANSWER_IMAGE) {
if ($show_comment) {
if (empty($comment)) {
$s .= ' ';
} else {
$s .= ' ';
}
} else {
$s .= ' ';
}
}
$answer = Security::remove_XSS($answer, STUDENT);
$s .= Display::input(
'hidden',
'choice2[' . $questionId . ']',
'0'
);
$answer_input = null;
if ($answerType == UNIQUE_ANSWER_IMAGE) {
$attributes['style'] = 'display: none;';
$answer = ' ";
}
if ($show_comment) {
$s .= $answer_input;
$s .= '' . $answer . ' ';
}
$answer_input .= '';
if ($answerType == UNIQUE_ANSWER_IMAGE) {
$answer_input .= " | ';
$s .= ''; $s .= $comment; $s .= ' | '; $s .= '|
'; $s .= $answer_input; $s .= ' | '; $s .= ''; $s .= $comment; $s .= ' | '; $s .= '|
'; $s .= $comment; $s .= ' | '; } $s .= '||
'; $s .= $answer_input; $s .= ' | '; $s .= ''; $s .= $comment; $s .= ' | '; $s .= '|
'; $s .= $comment; $s .= ' | '; } $s .= '||
'; $parsed_answer = $answer; //left part questions $s .= ' ' . $lines_count . '. ' . $parsed_answer . ' | '; //middle part (matches selects) $s .= ''; $s .= ' | '; if (isset($select_items[$lines_count])) { $s .= '' . $select_items[$lines_count]['letter'] . '.' . '' . $select_items[$lines_count]['answer'] . ''; } else { $s .= ' '; } $s .= ' | '; $s .= '
'; $s .= '' . $select_items[$lines_count]['letter'] . '. ' . $select_items[$lines_count]['answer']; $s .= " |
'; echo $questionDescription; echo ' | |||
|