4 require_once 
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
 
    5 require_once 
'./Modules/Test/classes/inc.AssessmentConstants.php';
 
    6 require_once 
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
 
    7 require_once 
'./Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
 
   67                 $this->answers = array();
 
   68                 $this->coords = array();
 
   99                 if (strlen($this->title) 
 
  102                         && ($this->image_filename) 
 
  103                         && (count($this->answers)) 
 
  132                 $ilDB->manipulateF( 
"DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
 
  134                                                         array( $this->
getId() )
 
  138                 foreach ($this->answers as $key => $value)
 
  140                         $answer_obj   = $this->answers[$key];
 
  141                         $next_id      = $ilDB->nextId( 
'qpl_a_imagemap' );
 
  142                         $ilDB->manipulateF( 
"INSERT INTO qpl_a_imagemap (answer_id, question_fi, answertext, points, aorder, coords, area, points_unchecked) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
 
  143                                                                         array( 
"integer", 
"integer", 
"text", 
"float", 
"integer", 
"text", 
"text", 
"float" ),
 
  144                                                                         array( $next_id, $this->
id, $answer_obj->getAnswertext(
 
  145                                                                         ), $answer_obj->getPoints(), $answer_obj->getOrder(
 
  146                                                                         ), $answer_obj->getCoords(), $answer_obj->getArea(
 
  147                                                                         ), $answer_obj->getPointsUnchecked() )
 
  158                                                         array( $this->
getId() )
 
  162                                                                                                                                                 ) . 
" (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
 
  163                                                         array( 
"integer", 
"text", 
'integer' ),
 
  166                                                                 $this->image_filename,
 
  167                                                                 (
int)$this->is_multiple_choice
 
  185                 $this_id = $this->
getId();
 
  189                 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  193                 if( (
int)$testObjId > 0 )
 
  195                         $clone->setObjId($testObjId);
 
  220                 $clone->copyPageOfQuestion($this_id);
 
  222                 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
 
  224                 $clone->duplicateImage($this_id, $thisObjId);
 
  226                 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
 
  247                 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  250                 $source_questionpool_id = $this->
getObjId();
 
  251                 $clone->setObjId($target_questionpool_id);
 
  263                 $clone->copyImage(
$original_id, $source_questionpool_id);
 
  265                 $clone->onCopy($source_questionpool_id, 
$original_id, $clone->getObjId(), $clone->getId());
 
  278                 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  281                 $sourceParentId = $this->
getObjId();
 
  287                 $clone->setObjId($targetParentId);
 
  289                 if ($targetQuestionTitle)
 
  291                         $clone->setTitle($targetQuestionTitle);
 
  296                 $clone->copyPageOfQuestion($sourceQuestionId);
 
  298                 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
 
  300                 $clone->copyImage($sourceQuestionId, $sourceParentId);
 
  302                 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
 
  310                 $imagepath_original = str_replace(
"/$this->id/images", 
"/$question_id/images", $imagepath);
 
  312                 if( (
int)$objectId > 0 )
 
  314                         $imagepath_original = str_replace(
"/$this->obj_id/", 
"/$objectId/", $imagepath_original);
 
  317                 if (!file_exists($imagepath)) {
 
  321                 if (!copy($imagepath_original . 
$filename, $imagepath . $filename)) {
 
  322                         print 
"image could not be duplicated!!!! ";
 
  329                 $imagepath_original = str_replace(
"/$this->id/images", 
"/$question_id/images", $imagepath);
 
  330                 $imagepath_original = str_replace(
"/$this->obj_id/", 
"/$source_questionpool/", $imagepath_original);
 
  331                 if (!file_exists($imagepath)) 
 
  336                 if (!copy($imagepath_original . 
$filename, $imagepath . $filename)) 
 
  338                         print 
"image could not be copied!!!! ";
 
  361                         $data = $ilDB->fetchAssoc(
$result);
 
  362                         $this->
setId($question_id);
 
  372                         include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  375                         $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
 
  385                         $result = $ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
 
  389                         include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
 
  392                                 while ($data = $ilDB->fetchAssoc(
$result)) 
 
  394                                         array_push($this->answers, 
new ASS_AnswerImagemap($data[
"answertext"], $data[
"points"], $data[
"aorder"], $data[
"coords"], $data[
"area"], $data[
'question_fi'], $data[
'points_unchecked']));
 
  410                 if (!empty($imagemap_filename)) 
 
  412                         $fp = fopen($imagemap_filename, 
"r");
 
  413                         $contents = fread($fp, filesize($imagemap_filename));
 
  415                         if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches)) 
 
  417                                 for ($i=0; $i< count($matches[1]); $i++) 
 
  419                                         preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
 
  420                                         preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], 
$coords);
 
  421                                         preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
 
  422                                         $this->
addAnswer($alt[1], 0.0, count($this->answers), 
$coords[1], $shape[1]);
 
  449                 if (!empty($image_tempfilename)) 
 
  452                         if (!file_exists($imagepath)) 
 
  458                                 $this->ilias->raiseError(
"The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
 
  460                         global 
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
 
  475                 for ($i = 0; $i < count($this->answers); $i++) {
 
  479                         $imagemap_contents .= 
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() . 
"\" /> ";
 
  505                 $points_unchecked = 0.0
 
  508                 include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
 
  509                 if (array_key_exists($order, $this->answers)) 
 
  513                         for ($i = count($this->answers) - 1; $i >= $order; $i--) 
 
  515                                 $this->answers[$i+1] = $this->answers[$i];
 
  516                                 $this->answers[$i+1]->setOrder($i+1);
 
  518                         $this->answers[$order] = $answer;
 
  524                         array_push($this->answers, $answer);
 
  538                 return count($this->answers);
 
  553                 if ($index < 0) 
return NULL;
 
  554                 if (count($this->answers) < 1) 
return NULL;
 
  555                 if ($index >= count($this->answers)) 
return NULL;
 
  556                 return $this->answers[$index];
 
  585                 if ($index < 0) 
return;
 
  586                 if (count($this->answers) < 1) 
return;
 
  587                 if ($index >= count($this->answers)) 
return;
 
  588                 unset($this->answers[$index]);
 
  589                 $this->answers = array_values($this->answers);
 
  590                 for ($i = 0; $i < count($this->answers); $i++) {
 
  591                         if ($this->answers[$i]->getOrder() > $index) {
 
  592                                 $this->answers[$i]->setOrder($i);
 
  606                 $this->answers = array();
 
  619                 foreach ($this->answers as $key => $value) {
 
  620                         if($this->is_multiple_choice)
 
  622                                 if($value->getPoints() > $value->getPointsUnchecked())
 
  624                                         $points += $value->getPoints();
 
  628                                         $points += $value->getPointsUnchecked();
 
  633                                 if($value->getPoints() > 
$points)
 
  656                         throw new ilTestException(
'return details not implemented for '.__METHOD__);
 
  661                 $found_values = array();
 
  666                 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
  667                         array(
"integer",
"integer",
"integer"),
 
  670                 while ($data = $ilDB->fetchAssoc(
$result))
 
  672                         if (strcmp($data[
"value1"], 
"") != 0)
 
  674                                 array_push($found_values, $data[
"value1"]);
 
  678                 if (count($found_values) > 0)
 
  680                         foreach ($this->answers as $key => $answer)
 
  682                                 if (in_array($key, $found_values))
 
  684                                         $points += $answer->getPoints();
 
  688                                         $points += $answer->getPointsUnchecked();
 
  711                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  717                 if($this->is_multiple_choice && strlen(
$_GET[
'remImage']))
 
  719                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s",
 
  720                                 array(
"integer", 
"integer", 
"integer", 
"integer"),
 
  724                 elseif(!$this->is_multiple_choice)
 
  726                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
  727                                 array(
"integer", 
"integer", 
"integer"),
 
  732                 if (strlen(
$_GET[
"selImage"]))
 
  734                         $imageWasSelected = 
true;
 
  736                         $types = array(
'integer', 
'integer', 
'integer', 
'integer');
 
  737                         $values = array($active_id, $this->
getId(), 
$pass,  (
int)
$_GET[
'selImage']);
 
  738                         $query = 
'DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s';
 
  740                         $ilDB->manipulateF(
$query, $types, $values);
 
  742                         $next_id = $ilDB->nextId(
'tst_solutions');
 
  743                         $affectedRows = $ilDB->insert(
"tst_solutions", array(
 
  744                                 "solution_id" => array(
"integer", $next_id),
 
  745                                 "active_fi" => array(
"integer", $active_id),
 
  746                                 "question_fi" => array(
"integer", $this->
getId()),
 
  747                                 "value1" => array(
"clob", $_GET[
'selImage']),
 
  748                                 "value2" => array(
"clob", null),
 
  749                                 "pass" => array(
"integer", 
$pass),
 
  750                                 "tstamp" => array(
"integer", time())
 
  755                         $imageWasSelected = 
false;
 
  760                 require_once 
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
 
  763                         if( $imageWasSelected )
 
  807                 return "assImagemapQuestion";
 
  820                 return "qpl_qst_imagemap";
 
  833                 return "qpl_a_imagemap";
 
  843                 foreach ($this->answers as $index => $answer)
 
  845                         $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
 
  864                 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
 
  871                         $worksheet->writeString($startrow + $i, 0, 
ilExcelUtils::_convert_text($answer->getArea() . 
": " . $answer->getCoords()), $format_bold);
 
  872                         if (
$id == $solution[0][
"value1"])
 
  874                                 $worksheet->write($startrow + $i, 1, 1);
 
  878                                 $worksheet->write($startrow + $i, 1, 0);
 
  882                 return $startrow + $i + 1;
 
  893                 $this->image_filename = 
"";
 
  901                 include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  911                         "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
false),
 
  912                         "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
true)
 
  918                 foreach ($this->
getAnswers() as $key => $answer_obj)
 
  921                                 "answertext"       => (
string)$answer_obj->getAnswertext(),
 
  922                                 "points"           => (float)$answer_obj->getPoints(),
 
  923                                 "points_unchecked" => (float)$answer_obj->getPointsUnchecked(),
 
  924                                 "order"            => (int)$order,
 
  925                                 "coords"           => $answer_obj->getCoords(),
 
  926                                 "state"            => $answer_obj->getState(),
 
  927                                 "area"             => $answer_obj->getArea(),
 
  929                                         $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0