/** * return necessaries html objects that represent the object * * @access protected * * @param $ref reference to the object that will contain this rendered object * @param $feedback "show feedback" flag on rendering * @param $rating "show rating" flag on rendering * @param $rating_answer "show correct answer" on rendering * * @return an object of CDOMElement */ protected function renderingHtml(&$ref = null, $feedback = false, $rating = false, $rating_answer = false) { if (!$this->display) { return new CText(''); } //if we don't have to display this question, let's return an empty item return parent::renderingHtml($ref, $feedback, $rating, $rating_answer); }
/** * return necessaries html objects that represent the object * * @access protected * * @param $ref reference to the object that will contain this rendered object * @param $feedback "show feedback" flag on rendering * @param $rating "show rating" flag on rendering * @param $rating_answer "show correct answer" on rendering * * @return an object of CDOMElement */ protected function renderingHtml(&$ref = null, $feedback = false, $rating = false, $rating_answer = false) { if (!$this->display) { return new CText(''); } //if we don't have to display this question, let's return an empty item $out = parent::renderingHtml($ref, $feedback, $rating, $rating_answer); $name = $this->getPostFieldName(); $post_data = $this->getPostData(); $li = CDOMElement::create('li', 'class:answer_open_test'); $textArea = CDOMElement::create('textarea'); $textArea->setAttribute('name', $name . '[' . self::POST_ANSWER_VAR . ']'); $textArea->setAttribute('class', 'open_answer_test'); if ($this->feedback) { $textArea->addChild(new CText($this->givenAnswer['risposta'][self::POST_ANSWER_VAR])); $textArea->setAttribute('readonly', ''); } else { if (!empty($post_data[self::POST_ANSWER_VAR])) { $textArea->addChild(new CText($post_data[self::POST_ANSWER_VAR])); } } $li->addChild($textArea); if ($_SESSION['sess_id_user_type'] != AMA_TYPE_STUDENT) { $span = CDOMElement::create('span', 'class:clozePopup,title:' . $this->id_nodo); $html .= $span->getHtml(); $div = CDOMElement::create('div', 'id:popup_' . $this->id_nodo); $div->setAttribute('style', 'display:none;'); $risposte = array(); if (!empty($this->_children)) { foreach ($this->_children as $k => $v) { $risposte[] = $v->testo . ' (' . $v->correttezza . ' ' . translateFN('Punti') . ')'; } } $div->addChild(new CText(implode('<br/>', $risposte))); $html .= $div->getHtml(); } $ref->addChild($li); return $out; }
/** * return necessaries html objects that represent the object * * @access protected * * @param $ref reference to the object that will contain this rendered object * @param $feedback "show feedback" flag on rendering * @param $rating "show rating" flag on rendering * @param $rating_answer "show correct answer" on rendering * * @return an object of CDOMElement */ protected function renderingHtml(&$ref = null, $feedback = false, $rating = false, $rating_answer = false) { if (!$this->display) { return new CText(''); } //if we don't have to display this question, let's return an empty item $out = parent::renderingHtml($ref, $feedback, $rating, $rating_answer); $name = $this->getPostFieldName(); $post_data = $this->getPostData(); $li = CDOMElement::create('li', 'class:answer_open_test'); $textArea = CDOMElement::create('textarea'); $textArea->setAttribute('name', $name . '[' . self::POST_ANSWER_VAR . ']'); $textArea->setAttribute('class', 'open_answer_test'); $li->addChild($textArea); if ($feedback) { $textArea->addChild(new CText($this->givenAnswer['risposta'][self::POST_ANSWER_VAR])); $textArea->setAttribute('disabled', ''); if ($_SESSION['sess_id_user_type'] == AMA_TYPE_TUTOR) { $textAreaCorrect = CDOMElement::create('textarea', 'id:open_answer_test_point_textarea_' . $this->givenAnswer['id_answer']); $textAreaCorrect->setAttribute('class', 'open_answer_test fright'); $textAreaCorrect->addChild(new CText($this->givenAnswer['correzione_risposta'])); $li->addChild($textAreaCorrect); $button = CDOMElement::create('input_button'); $button->setAttribute('class', 'test_button fright'); $button->setAttribute('onclick', 'saveCorrectOpenAnswer(' . $this->givenAnswer['id_answer'] . ');'); $button->setAttribute('value', translateFN('Salva correzione risposta')); $li->addChild($button); $punti = $this->givenAnswer['punteggio']; $input = CDOMElement::create('text', 'id:open_answer_test_point_input_' . $this->givenAnswer['id_answer']); $input->setAttribute('size', 4); $input->setAttribute('maxlength', 4); $input->setAttribute('value', $punti); $button = CDOMElement::create('input_button', 'class:test_button'); $button->setAttribute('onclick', 'saveOpenAnswerPoints(' . $this->givenAnswer['id_answer'] . ');'); $button->setAttribute('value', translateFN('Assegna punti')); $span = CDOMElement::create('span', 'id:open_answer_test_point_span_' . $this->givenAnswer['id_answer']); if (is_null($punti)) { $punti = translateFN('Nessun punteggio assegnato'); } $span->addChild(new CText($punti)); $div = CDOMElement::create('div', 'class:open_answer_test_point'); $div->addChild($input); $div->addChild($button); $div->addChild(new CText(' ' . translateFN('Punti già assegnati') . ': ')); $div->addChild($span); $li->addChild($div); } else { if (!empty($this->givenAnswer['correzione_risposta'])) { $divCorrectAnswer = CDOMElement::create('div', 'id:open_answer_test_point_textarea_' . $this->givenAnswer['id_answer']); $divCorrectAnswer->setAttribute('class', 'open_answer_test fright'); $divCorrectAnswer->addChild(new CText('<b>' . translateFN('Risposta corretta:') . '</b> ' . $this->givenAnswer['correzione_risposta'])); $li->addChild($divCorrectAnswer); } } } if (!empty($post_data[self::POST_ANSWER_VAR])) { $textArea->addChild(new CText($post_data[self::POST_ANSWER_VAR])); } $ref->addChild($li); return $out; }
/** * return necessaries html objects that represent the object * * @access protected * * @param $ref reference to the object that will contain this rendered object * @param $feedback "show feedback" flag on rendering * @param $rating "show rating" flag on rendering * @param $rating_answer "show correct answer" on rendering * * @return an object of CDOMElement */ protected function renderingHtml(&$ref = null, $feedback = false, $rating = false, $rating_answer = false) { if (!$this->display) { return new CText(''); } //if we don't have to display this question, let's return an empty item $out = parent::renderingHtml($ref, $feedback, $rating, $rating_answer); $name = $this->getPostFieldName(); $post_data = $this->getPostData(); if (!empty($this->_children)) { $_children = $this->_children; if ($this->searchParent('RootTest')->shuffle_answers) { shuffle($_children); } while (!empty($_children)) { foreach ($_children as $k => $v) { if ($v->extra_answer && count($_children) > 1) { continue; } $inputId = $name . '[' . $k . ']'; $answer = CDOMElement::create('label', 'for:' . $inputId); $answer->addChild(new CText($v->testo)); $input = CDOMElement::create('checkbox', 'id:' . $inputId); $input->setAttribute('class', 'radio_multiple_test'); $input->setAttribute('style', 'vertical-align:middle; margin-top:0px;'); $input->setAttribute('name', $name . '[' . self::POST_ANSWER_VAR . '][]'); $input->setAttribute('value', $v->id_nodo); //feedback section if ($feedback) { $input->setAttribute('disabled', ''); if ($this->givenAnswer['risposta'][self::POST_ANSWER_VAR] && in_array($v->id_nodo, $this->givenAnswer['risposta'][self::POST_ANSWER_VAR])) { $input->setAttribute('checked', ''); if ($v->correttezza > 0) { $answer->setAttribute('class', 'right_answer_test'); } else { $answer->setAttribute('class', 'wrong_answer_test'); } } } else { if ($post_data[self::POST_ANSWER_VAR] == $v->id_nodo) { $input->setAttribute('checked', ''); } } $li = CDOMElement::create('li'); $class = 'answer_multiple_test'; switch ($this->variation) { case ADA_ERASE_TEST_VARIATION: $class .= ' erase_variation_test'; break; case ADA_HIGHLIGHT_TEST_VARIATION: $class .= ' highlight_variation_test'; break; } $li->setAttribute('class', $class); $li->addChild($input); $li->addChild($answer); $string = $answer->getAttribute('class'); if ($_SESSION['sess_id_user_type'] == AMA_TYPE_STUDENT) { if ($feedback && $rating_answer && !strstr($string, 'right_answer_test')) { $correctAnswer = $this->getMostCorrectAnswer(); if ($correctAnswer) { $popup = CDOMElement::create('div', 'id:popup_' . $this->id_nodo); $popup->setAttribute('style', 'display:none;'); $popup->addChild(new CText($correctAnswer->testo)); $answer->setAttribute('class', $string . ' answerPopup'); $answer->setAttribute('title', $this->id_nodo); $li->addChild(new CText($popup->getHtml())); } } else { if ($feedback && $rating) { $li->addChild(new CText(' (' . $v->correttezza . ' ' . translateFN('Punti') . ')')); } } } if ($v->extra_answer && $this->variation == ADA_NORMAL_TEST_VARIATION) { $answer = CDOMElement::create('text'); $answer->setAttribute('class', 'text_standard_test'); $answer->setAttribute('name', $name . '[' . self::POST_OTHER_VAR . '][' . $v->id_nodo . ']'); $answer->setAttribute('onkeyup', 'autoCheckForOtherAnswer(this);'); if ($feedback && isset($this->givenAnswer['risposta'][self::POST_OTHER_VAR][$v->id_nodo])) { $answer->setAttribute('disabled', ''); $answer->setAttribute('value', $this->givenAnswer['risposta'][self::POST_OTHER_VAR][$v->id_nodo]); } else { if (!empty($post_data[self::POST_OTHER_VAR])) { $answer->setAttribute('value', $post_data[self::POST_OTHER_VAR]); } } $li->addChild(new CText(' ')); $li->addChild($answer); } if ($_SESSION['sess_id_user_type'] != AMA_TYPE_STUDENT) { $v->correttezza = is_null($v->correttezza) ? 0 : $v->correttezza; $li->addChild(new CText(' (' . $v->correttezza . ' ' . translateFN('punti') . ')')); } $ref->addChild($li); unset($_children[$k]); } $ref->addChild(CDOMElement::create('li', 'class:clear')); } } return $out; }
<?php $GLOBALS['dirpre'] = isset($GLOBALS['dirpre']) ? $GLOBALS['dirpre'] : '../'; require_once $GLOBALS['dirpre'] . 'includes/header.php'; Model::$test = true; require_once $GLOBALS['dirpre'] . 'tests/models/StudentModelTest.php'; StudentModelTest::run(); require_once $GLOBALS['dirpre'] . 'tests/controllers/modules/application/QuestionTest.php'; QuestionTest::run(); require_once $GLOBALS['dirpre'] . 'tests/controllers/modules/application/StudentProfileTest.php'; StudentProfileTest::run(); require_once $GLOBALS['dirpre'] . 'tests/controllers/modules/application/ApplicationTest.php'; ApplicationTest::run();
public static function end() { self::$MQuestionTest = null; }
/** * return necessaries html objects that represent the object * * @access protected * * @param $ref reference to the object that will contain this rendered object * @param $feedback "show feedback" flag on rendering * @param $rating "show rating" flag on rendering * @param $rating_answer "show correct answer" on rendering * * @return an object of CDOMElement */ protected function renderingHtml(&$ref = null, $feedback = false, $rating = false, $rating_answer = false) { if (!$this->display) { return new CText(''); } //if we don't have to display this question, let's return an empty item $out = parent::renderingHtml($ref, $feedback, $rating, $rating_answer); $name = $this->getPostFieldName(); $post_data = $this->getPostData(); if (!empty($this->_children)) { foreach ($this->_children as $k => $v) { $answer = new CText($v->testo); $input = CDOMElement::create('radio'); $input->setAttribute('class', 'radio_liker_test'); $input->setAttribute('style', 'vertical-align:top;'); $input->setAttribute('name', $name . '[' . self::POST_ANSWER_VAR . ']'); $input->setAttribute('value', $v->id_nodo); //feedback section if ($feedback) { $input->setAttribute('disabled', ''); if ($this->givenAnswer['risposta'][self::POST_ANSWER_VAR] == $v->id_nodo) { $input->setAttribute('checked', ''); $tmp = CDOMElement::create('span'); if ($this->givenAnswer['punteggio'] > 0) { $tmp->setAttribute('class', 'right_answer_test'); } else { $tmp->setAttribute('class', 'wrong_answer_test'); } $tmp->addChild($answer); $answer = $tmp; } } if ($post_data[self::POST_ANSWER_VAR] == $v->id_nodo) { $input->setAttribute('checked', ''); } $li = CDOMElement::create('li'); $class = 'answer_likert_test'; if ($k == 0) { $class .= ' first_test'; $li->addChild($answer); $li->addChild($input); } else { if ($k == count($this->_children) - 1) { $class .= ' last_test'; $li->addChild($input); $li->addChild($answer); } else { $li->addChild($input); $li->addChild($answer); } } if ($_SESSION['sess_id_user_type'] != AMA_TYPE_STUDENT) { $v->correttezza = is_null($v->correttezza) ? 0 : $v->correttezza; $li->addChild(new CText(' (' . $v->correttezza . ' ' . translateFN('punti') . ')')); } $li->setAttribute('class', $class); $ref->addChild($li); } } return $out; }