diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 4e61021174..ad02b271ce 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -6921,885 +6921,6 @@ class Exercise } } - /** - * Shows a question - * @param Question $objQuestionTmp - * @param bool $only_questions if true only show the questions, no exercise title - * @param bool $origin 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 null $exercise_feedback - * @param bool $show_answers - * @param null $modelType - * @param bool $categoryMinusOne - * @return bool|null|string - */ - public function showQuestion( - Question $objQuestionTmp, - $only_questions = false, - $origin = false, - $current_item = '', - $show_title = true, - $freeze = false, - $user_choice = array(), - $show_comment = false, - $exercise_feedback = null, - $show_answers = false, - $modelType = null, - $categoryMinusOne = true - ) { - // Text direction for the current language - // Change false to true in the following line to enable answer hinting - $debug_mark_answer = $show_answers; //api_is_allowed_to_edit() && false; - // Reads question information - if (!$objQuestionTmp) { - // Question not found - return false; - } - - $html = null; - $questionId = $objQuestionTmp->id; - if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) { - $show_comment = false; - } - - $answerType = $objQuestionTmp->selectType(); - $pictureName = $objQuestionTmp->selectPicture(); - - $s = null; - $form = new FormValidator('question'); - $renderer = $form->defaultRenderer(); - $form_template = '{content}'; - $renderer->setFormTemplate($form_template); - - if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) { - // Question is not a hotspot - if (!$only_questions) { - $questionDescription = $objQuestionTmp->selectDescription(); - if ($show_title) { - $categoryName = TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id, null, true, $categoryMinusOne); - $html .= $categoryName; - $html .= Display::div($current_item.'. '.$objQuestionTmp->selectTitle(), array('class' => 'question_title')); - if (!empty($questionDescription)) { - $html .= Display::div($questionDescription, array('class' => 'question_description')); - } - } else { - $html .= '
'; - $html .= '
'; - $html .= '
'; - $html .= Display::div($current_item, array('class' => 'question_no_title')); - $html .= '
'; - $html .= '
'; - $html .= '
'; - if (!empty($questionDescription)) { - $html .= Display::div($questionDescription, array('class' => 'question_description')); - } - $html .= '
'; - $html .= '
'; - } - } - - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) { - return null; - } - - $html .= '
'; - // construction of the Answer object (also gets all answers details) - $objAnswerTmp = new Answer($questionId, null, $this); - - $nbrAnswers = $objAnswerTmp->selectNbrAnswers(); - $course_id = api_get_course_int_id(); - $sessionId = api_get_session_id(); - $quiz_question_options = Question::readQuestionOption($questionId, $course_id); - - // For "matching" type here, we need something a little bit special - // because the match between the suggestions and the answers cannot be - // done easily (suggestions and answers are in the same table), so we - // have to go through answers first (elems with "correct" value to 0). - $select_items = array(); - //This will contain the number of answers on the left side. We call them - // suggestions here, for the sake of comprehensions, while the ones - // on the right side are called answers - $num_suggestions = 0; - if ($answerType == MATCHING || $answerType == DRAGGABLE) { - if ($answerType == DRAGGABLE) { - $s .= '
-
'; - $counterAnswer = 1; - foreach ($objAnswerTmp->answer as $answerId => $answer_item) { - $answerCorrect = $objAnswerTmp->isCorrect($answerId); - $windowId = $questionId.'_'.$counterAnswer; - if ($answerCorrect == 0) { - $s .= '
'.$counterAnswer.'
'; - $counterAnswer++; - } - } - } - - if ($answerType == MATCHING) { - $s .= '
'; - } - - $s .= '
'; - - // destruction of the Answer object - unset($objAnswerTmp); - // destruction of the Question object - unset($objQuestionTmp); - $html .= $s; - return $html; - } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) { - // Question is a HOT_SPOT - //checking document/images visibility - if (api_is_platform_admin() || api_is_course_admin()) { - $course = api_get_course_info(); - $doc_id = DocumentManager::get_document_id($course, '/images/'.$pictureName); - if (is_numeric($doc_id)) { - $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id()); - if (!$images_folder_visibility) { - //This message is shown only to the course/platform admin if the image is set to visibility = false - Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage')); - } - } - } - $questionName = $objQuestionTmp->selectTitle(); - $questionDescription = $objQuestionTmp->selectDescription(); - - if ($freeze) { - $s .= Display::img($objQuestionTmp->selectPicturePath()); - $html .= $s; - return $html; - } - - // Get the answers, make a list - $objAnswerTmp = new Answer($questionId); - - // get answers of hotpost - $answers_hotspot = array(); - foreach ($objAnswerTmp->answer as $answerId => $answer_item) { - //$answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId)); - $answers_hotspot[$answerId] = $objAnswerTmp->selectAnswer($answerId); - } - - // display answers of hotpost order by id - $answer_list = '
'.get_lang('HotspotZones').'
'; - if (!empty($answers_hotspot)) { - ksort($answers_hotspot); - foreach ($answers_hotspot as $key => $value) { - $answer_list .= '
'.$key.'.- '.$value.'

'; - } - } - $answer_list .= '
'; - - if ($answerType == HOT_SPOT_DELINEATION) { - $answer_list = ''; - $swf_file = 'hotspot_delineation_user'; - $swf_height = 405; - } else { - $swf_file = 'hotspot_user'; - $swf_height = 436; - } - - if (!$only_questions) { - if ($show_title) { - $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id); - $html .= '
'.$current_item.'. '.$questionName.'
'; - $html .= $questionDescription; - } else { - $html .= '
'; - $html .= '
'; - $html .= '
'; - $html .= Display::div($current_item.'. ', array('class' => 'question_no_title')); - $html .= '
'; - $html .= '
'; - $html .= '
'; - if (!empty($questionDescription)) { - $html .= Display::div($questionDescription, array('class' => 'question_description')); - } - $html .= '
'; - $html .= '
'; - } - //@todo I need to the get the feedback type - $html .= ''; - $html .= ' - - '; - } - - $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); - - $s .= ' - - - - - '; - $s .= ''; - $html .= $s; - $html .= '
'; - $html .= '
- -
- - '.$answer_list.'
-
'; - return $html; - } - return $nbrAnswers; - } - /** * @param int $exeId * @return array