function exportFeedbackOnly($a_xml_writer)
 {
     $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation($this->object->getId(), true);
     $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation($this->object->getId(), false);
     if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
         $a_xml_writer->xmlStartTag("resprocessing");
         $a_xml_writer->xmlStartTag("outcomes");
         $a_xml_writer->xmlStartTag("decvar");
         $a_xml_writer->xmlEndTag("decvar");
         $a_xml_writer->xmlEndTag("outcomes");
         if (strlen($feedback_allcorrect)) {
             $attrs = array("continue" => "Yes");
             $a_xml_writer->xmlStartTag("respcondition", $attrs);
             // qti conditionvar
             $a_xml_writer->xmlStartTag("conditionvar");
             $attrs = array("respident" => "points");
             $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
             $a_xml_writer->xmlEndTag("conditionvar");
             // qti displayfeedback
             $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_allcorrect");
             $a_xml_writer->xmlElement("displayfeedback", $attrs);
             $a_xml_writer->xmlEndTag("respcondition");
         }
         if (strlen($feedback_onenotcorrect)) {
             $attrs = array("continue" => "Yes");
             $a_xml_writer->xmlStartTag("respcondition", $attrs);
             // qti conditionvar
             $a_xml_writer->xmlStartTag("conditionvar");
             $a_xml_writer->xmlStartTag("not");
             $attrs = array("respident" => "points");
             $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
             $a_xml_writer->xmlEndTag("not");
             $a_xml_writer->xmlEndTag("conditionvar");
             // qti displayfeedback
             $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_onenotcorrect");
             $a_xml_writer->xmlElement("displayfeedback", $attrs);
             $a_xml_writer->xmlEndTag("respcondition");
         }
         $a_xml_writer->xmlEndTag("resprocessing");
     }
     if (strlen($feedback_allcorrect)) {
         $attrs = array("ident" => "response_allcorrect", "view" => "All");
         $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
         // qti flow_mat
         $a_xml_writer->xmlStartTag("flow_mat");
         $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
         $a_xml_writer->xmlEndTag("flow_mat");
         $a_xml_writer->xmlEndTag("itemfeedback");
     }
     if (strlen($feedback_onenotcorrect)) {
         $attrs = array("ident" => "response_onenotcorrect", "view" => "All");
         $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
         // qti flow_mat
         $a_xml_writer->xmlStartTag("flow_mat");
         $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
         $a_xml_writer->xmlEndTag("flow_mat");
         $a_xml_writer->xmlEndTag("itemfeedback");
     }
 }
 /**
  * @param assQuestion $question
  */
 private function deleteTestsParticipantsQuestionData(assQuestion $question)
 {
     $activeIds = $this->getActiveIds();
     if (!count($activeIds)) {
         return null;
     }
     $this->deleteTestsParticipantsResultsForQuestion($activeIds, $question->getId());
     $this->deleteTestsParticipantsTrackingsForQuestion($activeIds, $question->getId());
 }
 /**
  *
  */
 protected function initData()
 {
     $rows = array();
     $total_of_answers = $this->question->getTotalAnswers();
     if ($total_of_answers) {
         $rows[] = array('result' => $this->lng->txt('qpl_assessment_total_of_answers'), 'value' => $total_of_answers);
         $rows[] = array('result' => $this->lng->txt('qpl_assessment_total_of_right_answers'), 'value' => assQuestion::_getTotalRightAnswers($this->question->getId()) * 100.0);
     } else {
         $this->disable('header');
     }
     $this->setData($rows);
 }
 /**
  * @param assQuestion $question
  */
 public function deleteTestsParticipantsResultsForQuestion(assQuestion $question)
 {
     $activeIds = $this->getActiveIds();
     if (!count($activeIds)) {
         return null;
     }
     $inActiveIds = $this->db->in('active_fi', $activeIds, false, 'integer');
     $this->db->manipulateF("DELETE FROM tst_solutions WHERE question_fi = %s AND {$inActiveIds}", array('integer'), array($question->getId()));
     $this->db->manipulateF("DELETE FROM tst_qst_solved WHERE question_fi = %s AND {$inActiveIds}", array('integer'), array($question->getId()));
     $this->db->manipulateF("DELETE FROM tst_test_result WHERE question_fi = %s AND {$inActiveIds}", array('integer'), array($question->getId()));
     $this->db->manipulate("DELETE FROM tst_pass_result WHERE {$inActiveIds}");
     $this->db->manipulate("DELETE FROM tst_result_cache WHERE {$inActiveIds}");
 }
 /**
  * Constructor
  *
  * @access	public
  * @param	assQuestion	$questionOBJ 
  */
 public function __construct(assQuestion $questionOBJ)
 {
     $this->questionId = $questionOBJ->getId();
     if (!isset($_SESSION[__CLASS__])) {
         $_SESSION[__CLASS__] = array();
     }
     if (!isset($_SESSION[__CLASS__][$this->questionId])) {
         $_SESSION[__CLASS__][$this->questionId] = null;
     }
 }
 /**
  * creates a new page object with given page object id and page object type
  * and passed page object content
  * 
  * @final
  * @access protected
  * @param string $pageObjectType
  * @param integer $pageObjectId
  * @param string $pageObjectContent
  */
 protected final function createPageObject($pageObjectType, $pageObjectId, $pageObjectContent)
 {
     $cl = $this->getClassNameByType($pageObjectType);
     require_once 'Modules/TestQuestionPool/classes/feedback/class.' . $cl . '.php';
     $pageObject = new $cl();
     $pageObject->setParentId($this->questionOBJ->getId());
     $pageObject->setId($pageObjectId);
     $pageObject->setXMLContent($pageObjectContent);
     $pageObject->createFromXML();
 }
 /**
  * @param ilUnitConfigurationGUI $controller
  * @param string                 $cmd
  * @param string                 $template_context
  * @param assQuestion            $question
  */
 public function __construct($controller, $cmd, $template_context, assQuestion $question)
 {
     $this->question = $question;
     $this->setId('qst_usage_' . $question->getId());
     parent::__construct($controller, $cmd);
     $this->setRowTemplate('tpl.il_as_qpl_question_usage_table_row.html', 'Modules/TestQuestionPool');
     $this->setLimit(PHP_INT_MAX);
     $this->setDefaultOrderField('title');
     $this->setDefaultOrderDirection('ASC');
     $this->setTitle($this->lng->txt('question_instances_title'));
     $this->disable('sort');
     $this->disable('hits');
     $this->disable('numinfo');
     $this->initColumns();
     $this->initData();
 }
 private function populateSolutionOutput(ilTemplate $tpl)
 {
     // FOR WHAT EXACTLY IS THIS USEFUL?
     $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
     $this->ctrl->setReturnByClass('ilObjQuestionPoolGUI', 'questions');
     include_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
     $pageGUI = new ilAssQuestionPageGUI($this->questionOBJ->getId());
     $pageGUI->setEditPreview(true);
     $pageGUI->setEnabledTabs(false);
     // FOR WHICH SITUATION IS THIS WORKAROUND NECCESSARY? (sure .. imagemaps, but where this can be done?)
     if (strlen($this->ctrl->getCmd()) == 0 && !isset($_POST['editImagemapForward_x'])) {
         $this->ctrl->setCmdClass(get_class($pageGUI));
         $this->ctrl->setCmd('preview');
     }
     $this->questionGUI->setPreviewSession($this->previewSession);
     $pageGUI->setQuestionHTML(array($this->questionOBJ->getId() => $this->questionGUI->getSolutionOutput(0)));
     //$pageGUI->setHeader($this->questionOBJ->getTitle()); // NO ADDITIONAL HEADER
     //$pageGUI->setPresentationTitle($this->questionOBJ->getTitle());
     //$pageGUI->setTemplateTargetVar("ADM_CONTENT"); // NOT REQUIRED, OR IS?
     $tpl->setCurrentBlock('solution_output');
     $tpl->setVariable('SOLUTION_OUTPUT', $pageGUI->preview());
     $tpl->parseCurrentBlock();
 }
 /**
  * Returns the best solution for a given pass of a participant
  * @return array An associated array containing the best solution
  * @access public
  */
 public function getBestSolution($solutions)
 {
     $user_solution = array();
     foreach ($solutions as $idx => $solution_value) {
         if (preg_match("/^(\\\$v\\d+)\$/", $solution_value["value1"], $matches)) {
             $user_solution[$matches[1]] = $solution_value["value2"];
             $varObj = $this->getVariable($matches[1]);
             $varObj->setValue($solution_value["value2"]);
         } else {
             if (preg_match("/^(\\\$r\\d+)\$/", $solution_value["value1"], $matches)) {
                 if (!array_key_exists($matches[1], $user_solution)) {
                     $user_solution[$matches[1]] = array();
                 }
                 $user_solution[$matches[1]]["value"] = $solution_value["value2"];
             } else {
                 if (preg_match("/^(\\\$r\\d+)_unit\$/", $solution_value["value1"], $matches)) {
                     if (!array_key_exists($matches[1], $user_solution)) {
                         $user_solution[$matches[1]] = array();
                     }
                     $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
                 }
             }
         }
     }
     foreach ($this->getResults() as $result) {
         $resVal = $result->calculateFormula($this->getVariables(), $this->getResults(), parent::getId(), false);
         if (is_object($result->getUnit())) {
             $user_solution[$result->getResult()]["unit"] = $result->getUnit()->getId();
             $user_solution[$result->getResult()]["value"] = $resVal;
         } else {
             if ($result->getUnit() == NULL) {
                 $unit_factor = 1;
                 // there is no fix result_unit, any "available unit" is accepted
                 $available_units = $result->getAvailableResultUnits(parent::getId());
                 $result_name = $result->getResult();
                 if ($available_units[$result_name] != NULL) {
                     $check_unit = in_array($user_solution[$result_name]['unit'], $available_units[$result_name]);
                 }
                 if ($check_unit == true) {
                     //get unit-factor
                     $unit_factor = assFormulaQuestionUnit::lookupUnitFactor($user_solution[$result_name]['unit']);
                     $user_solution[$result->getResult()]["value"] = round(ilMath::_div($resVal, $unit_factor), 55);
                 }
             }
         }
         if ($result->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC || $result->getResultType() == assFormulaQuestionResult::RESULT_FRAC) {
             $value = assFormulaQuestionResult::convertDecimalToCoprimeFraction($resVal);
             if (is_array($value)) {
                 $frac_helper = $value[1];
                 $value = $value[0];
             }
             $user_solution[$result->getResult()]["value"] = $value;
             $user_solution[$result->getResult()]["frac_helper"] = $frac_helper;
         } elseif ($result->getPrecision() > 0) {
             $user_solution[$result->getResult()]["value"] = round($resVal, $result->getPrecision());
         } else {
             $user_solution[$result->getResult()]["value"] = round($resVal);
         }
     }
     return $user_solution;
 }
 /**
  * update question result of run
  * @param ilTestSession $session
  * @param assQuestion $qst
  */
 protected function updateQuestionResult(ilTestSession $session, assQuestion $qst)
 {
     foreach ($this->run as $run) {
         if ($run->questionExists($qst->getId())) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': reached points are ' . $qst->getReachedPoints($session->getActiveId(), $session->getPass()));
             $run->setQuestionResult($qst->getId(), $qst->getReachedPoints($session->getActiveId(), $session->getPass()));
             $run->update();
             $res = $run->getResult();
             include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
             include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
             $old_result = ilLOUserResults::lookupResult($this->container_id, $this->user_id, $run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL);
             $ur = new ilLOUserResults($this->container_id, $this->user_id);
             $ur->saveObjectiveResult($run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL, ilLOUtils::isCompleted($this->container_id, $session->getRefId(), $run->getObjectiveId(), $res['max'], $res['reached'], $old_result['limit_perc']) ? ilLOUserResults::STATUS_COMPLETED : ilLOUserResults::STATUS_FAILED, (int) $res['percentage'], $old_result['limit_perc'], $old_result['tries'], $old_result['is_final']);
             $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($run->getResult(), true));
             include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
             ilLPStatusWrapper::_updateStatus($this->container_id, $this->user_id);
         }
     }
     return false;
 }