ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assMatchingQuestion.php
Go to the documentation of this file.
1 <?php
2 /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
25 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
26 
37 {
46 
56 
62  var $terms;
63 
77  $title = "",
78  $comment = "",
79  $author = "",
80  $owner = -1,
81  $question = "",
83  )
84  {
86  $this->matchingpairs = array();
87  $this->matching_type = $matching_type;
88  $this->terms = array();
89  }
90 
99  function isComplete()
100  {
101  if (($this->title) and ($this->author) and ($this->question) and (count($this->matchingpairs)) and ($this->getMaximumPoints() > 0))
102  {
103  return true;
104  }
105  else
106  {
107  return false;
108  }
109  }
110 
119  function saveToDb($original_id = "")
120  {
121  global $ilDB;
122 
123  $complete = 0;
124  if ($this->isComplete())
125  {
126  $complete = 1;
127  }
128  $estw_time = $this->getEstimatedWorkingTime();
129  $estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
130 
131  if ($original_id)
132  {
133  $original_id = $ilDB->quote($original_id);
134  }
135  else
136  {
137  $original_id = "NULL";
138  }
139 
140  // cleanup RTE images which are not inserted into the question text
141  include_once("./Services/RTE/classes/class.ilRTE.php");
142  if ($this->id == -1)
143  {
144  // Neuen Datensatz schreiben
145  $now = getdate();
146  $question_type = $this->getQuestionTypeID();
147  $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
148  $query = sprintf("INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, question_text, working_time, points, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
149  $ilDB->quote($question_type. ""),
150  $ilDB->quote($this->obj_id. ""),
151  $ilDB->quote($this->title. ""),
152  $ilDB->quote($this->comment. ""),
153  $ilDB->quote($this->author. ""),
154  $ilDB->quote($this->owner. ""),
155  $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->question, 0)),
156  $ilDB->quote($estw_time. ""),
157  $ilDB->quote($this->getMaximumPoints() . ""),
158  $ilDB->quote($complete. ""),
159  $ilDB->quote($created. ""),
161  );
162 
163  $result = $ilDB->query($query);
164  if (PEAR::isError($result))
165  {
166  global $ilias;
167  $ilias->raiseError($result->getMessage());
168  }
169  else
170  {
171  $this->id = $ilDB->getLastInsertId();
172  $query = sprintf("INSERT INTO qpl_question_matching (question_fi, shuffle, matching_type) VALUES (%s, %s, %s)",
173  $ilDB->quote($this->id . ""),
174  $ilDB->quote($this->shuffle . ""),
175  $ilDB->quote($this->matching_type. "")
176  );
177  $ilDB->query($query);
178 
179  // create page object of question
180  $this->createPageObject();
181 
182  // Falls die Frage in einen Test eingefügt werden soll, auch diese Verbindung erstellen
183  if ($this->getTestId() > 0)
184  {
185  $this->insertIntoTest($this->getTestId());
186  }
187  }
188  }
189  else
190  {
191  // Vorhandenen Datensatz aktualisieren
192  $query = sprintf("UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, working_time=%s, points = %s, complete = %s WHERE question_id = %s",
193  $ilDB->quote($this->obj_id. ""),
194  $ilDB->quote($this->title. ""),
195  $ilDB->quote($this->comment. ""),
196  $ilDB->quote($this->author. ""),
197  $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->question, 0)),
198  $ilDB->quote($estw_time. ""),
199  $ilDB->quote($this->getMaximumPoints() . ""),
200  $ilDB->quote($complete. ""),
201  $ilDB->quote($this->id. "")
202  );
203  $result = $ilDB->query($query);
204  $query = sprintf("UPDATE qpl_question_matching SET shuffle = %s, matching_type = %s WHERE question_fi = %s",
205  $ilDB->quote($this->shuffle . ""),
206  $ilDB->quote($this->matching_type. ""),
207  $ilDB->quote($this->id . "")
208  );
209  $result = $ilDB->query($query);
210  }
211 
212  if (PEAR::isError($result))
213  {
214  global $ilias;
215  $ilias->raiseError($result->getMessage());
216  }
217  else
218  {
219  // Antworten schreiben
220 
221  // delete old terms
222  $query = sprintf("DELETE FROM qpl_answer_matching_term WHERE question_fi = %s",
223  $ilDB->quote($this->id)
224  );
225  $result = $ilDB->query($query);
226 
227  // write terms
228  $newterms = array();
229  foreach ($this->terms as $key => $value)
230  {
231  $query = sprintf("INSERT INTO qpl_answer_matching_term (term_id, question_fi, term) VALUES (NULL, %s, %s)",
232  $ilDB->quote($this->getId()),
233  $ilDB->quote($value . "")
234  );
235  $term_result = $ilDB->query($query);
236  $newTermID = $ilDB->getLastInsertId();
237  $newterms[$newTermID] = $value;
238  foreach ($this->matchingpairs as $mkey => $mvalue)
239  {
240  if (strcmp($this->matchingpairs[$mkey]->getTerm(), $key) == 0)
241  {
242  $this->matchingpairs[$mkey]->setTerm($newTermID);
243  }
244  }
245  }
246  $this->terms = $newterms;
247 
248  // alte Antworten löschen
249  $query = sprintf("DELETE FROM qpl_answer_matching WHERE question_fi = %s",
250  $ilDB->quote($this->id)
251  );
252  $result = $ilDB->query($query);
253 
254  // Anworten wegschreiben
255  foreach ($this->matchingpairs as $key => $value)
256  {
257  $matching_obj = $this->matchingpairs[$key];
258  $query = sprintf("INSERT INTO qpl_answer_matching (answer_id, question_fi, answertext, points, aorder, matchingtext, matching_order) VALUES (NULL, %s, %s, %s, %s, %s, %s)",
259  $ilDB->quote($this->id),
260  $ilDB->quote($matching_obj->getTerm() . ""),
261  $ilDB->quote($matching_obj->getPoints() . ""),
262  $ilDB->quote($matching_obj->getTerm() . ""),
263  $ilDB->quote($matching_obj->getDefinition() . ""),
264  $ilDB->quote($matching_obj->getDefinitionId() . "")
265  );
266  $matching_result = $ilDB->query($query);
267  }
268  }
270  }
271 
281  function loadFromDb($question_id)
282  {
283  global $ilDB;
284 
285  $query = sprintf("SELECT qpl_questions.*, qpl_question_matching.* FROM qpl_questions, qpl_question_matching WHERE question_id = %s AND qpl_questions.question_id = qpl_question_matching.question_fi",
286  $ilDB->quote($question_id)
287  );
288  $result = $ilDB->query($query);
289  if ($result->numRows() == 1)
290  {
291  $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
292  $this->id = $question_id;
293  $this->title = $data->title;
294  $this->comment = $data->comment;
295  $this->author = $data->author;
296  $this->solution_hint = $data->solution_hint;
297  $this->obj_id = $data->obj_fi;
298  $this->original_id = $data->original_id;
299  $this->owner = $data->owner;
300  $this->matching_type = $data->matching_type;
301  include_once("./Services/RTE/classes/class.ilRTE.php");
302  $this->question = ilRTE::_replaceMediaObjectImageSrc($data->question_text, 1);
303  $this->points = $data->points;
304  $this->shuffle = $data->shuffle;
305  $this->setEstimatedWorkingTime(substr($data->working_time, 0, 2), substr($data->working_time, 3, 2), substr($data->working_time, 6, 2));
306 
307  $query = sprintf("SELECT * FROM qpl_answer_matching WHERE question_fi = %s ORDER BY answer_id ASC",
308  $ilDB->quote($question_id)
309  );
310  $result = $ilDB->query($query);
311  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatching.php";
312  if ($result->numRows() > 0)
313  {
314  while ($data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
315  {
316  array_push($this->matchingpairs, new ASS_AnswerMatching($data->answertext, $data->points, $data->aorder, $data->matchingtext, $data->matching_order));
317  }
318  }
319 
320  $query = sprintf("SELECT * FROM qpl_answer_matching_term WHERE question_fi = %s ORDER BY term ASC",
321  $ilDB->quote($question_id)
322  );
323  $result = $ilDB->query($query);
324  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatching.php";
325  if ($result->numRows() > 0)
326  {
327  while ($data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
328  {
329  $this->terms[$data->term_id] = $data->term;
330  }
331  }
332  }
333  parent::loadFromDb($question_id);
334  }
335 
336 
344  function duplicate($for_test = true, $title = "", $author = "", $owner = "")
345  {
346  if ($this->id <= 0)
347  {
348  // The question has not been saved. It cannot be duplicated
349  return;
350  }
351  // duplicate the question in database
352  $this_id = $this->getId();
353  $clone = $this;
354  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
356  $clone->id = -1;
357  if ($title)
358  {
359  $clone->setTitle($title);
360  }
361  if ($author)
362  {
363  $clone->setAuthor($author);
364  }
365  if ($owner)
366  {
367  $clone->setOwner($owner);
368  }
369  if ($for_test)
370  {
371  $clone->saveToDb($original_id);
372  }
373  else
374  {
375  $clone->saveToDb();
376  }
377 
378  // copy question page content
379  $clone->copyPageOfQuestion($this_id);
380  // copy XHTML media objects
381  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
382  // duplicate the generic feedback
383  $clone->duplicateFeedbackGeneric($this_id);
384 
385  // duplicate the image
386  $clone->duplicateImages($this_id);
387  return $clone->id;
388  }
389 
397  function copyObject($target_questionpool, $title = "")
398  {
399  if ($this->id <= 0)
400  {
401  // The question has not been saved. It cannot be duplicated
402  return;
403  }
404  // duplicate the question in database
405  $clone = $this;
406  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
408  $clone->id = -1;
409  if ($title)
410  {
411  $clone->setTitle($title);
412  }
413  $source_questionpool = $this->getObjId();
414  $clone->setObjId($target_questionpool);
415  $clone->saveToDb();
416 
417  // copy question page content
418  $clone->copyPageOfQuestion($original_id);
419  // copy XHTML media objects
420  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
421  // duplicate the generic feedback
422  $clone->duplicateFeedbackGeneric($original_id);
423 
424  // duplicate the image
425  $clone->copyImages($original_id, $source_questionpool);
426  return $clone->id;
427  }
428 
429  function duplicateImages($question_id)
430  {
431  if ($this->get_matching_type() == MT_TERMS_PICTURES)
432  {
433  $imagepath = $this->getImagePath();
434  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
435  foreach ($this->matchingpairs as $answer)
436  {
437  $filename = $answer->getPicture();
438  if (!file_exists($imagepath))
439  {
440  ilUtil::makeDirParents($imagepath);
441  }
442  if (!copy($imagepath_original . $filename, $imagepath . $filename))
443  {
444  print "image could not be duplicated!!!! ";
445  }
446  if (!copy($imagepath_original . $filename . ".thumb.jpg", $imagepath . $filename . ".thumb.jpg"))
447  {
448  print "image thumbnail could not be duplicated!!!! ";
449  }
450  }
451  }
452  }
453 
454  function copyImages($question_id, $source_questionpool)
455  {
456  if ($this->get_matching_type() == MT_TERMS_PICTURES)
457  {
458  $imagepath = $this->getImagePath();
459  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
460  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
461  foreach ($this->matchingpairs as $answer)
462  {
463  $filename = $answer->getPicture();
464  if (!file_exists($imagepath))
465  {
466  ilUtil::makeDirParents($imagepath);
467  }
468  if (!copy($imagepath_original . $filename, $imagepath . $filename))
469  {
470  print "image could not be duplicated!!!! ";
471  }
472  if (!copy($imagepath_original . $filename . ".thumb.jpg", $imagepath . $filename . ".thumb.jpg"))
473  {
474  print "image thumbnail could not be duplicated!!!! ";
475  }
476  }
477  }
478  }
479 
490  {
491  $this->matching_type = $matching_type;
492  }
493 
503  function get_matching_type()
504  {
505  return $this->matching_type;
506  }
507 
508  function getMatchingType()
509  {
510  return $this->matching_type;
511  }
512 
527  function addMatchingPair(
528  $term = "",
529  $picture_or_definition = "",
530  $points = 0.0,
531  $term_id = 0,
532  $picture_or_definition_id = 0
533  )
534  {
535  // append answer
536  if ($term_id == 0)
537  {
538  $term_id = $this->get_random_id();
539  }
540 
541  if ($picture_or_definition_id == 0)
542  {
543  $picture_or_definition_id = $this->get_random_id();
544  }
545  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatching.php";
546  $matchingpair = new ASS_AnswerMatching($term, $points, $term_id, $picture_or_definition, $picture_or_definition_id);
547  array_push($this->matchingpairs, $matchingpair);
548  }
549 
561  function get_matchingpair($index = 0)
562  {
563  return $this->getMatchingPair($index);
564  }
565 
577  function getMatchingPair($index = 0)
578  {
579  if ($index < 0)
580  {
581  return NULL;
582  }
583  if (count($this->matchingpairs) < 1)
584  {
585  return NULL;
586  }
587  if ($index >= count($this->matchingpairs))
588  {
589  return NULL;
590  }
591  return $this->matchingpairs[$index];
592  }
593 
604  function delete_matchingpair($index = 0)
605  {
606  if ($index < 0)
607  {
608  return;
609  }
610  if (count($this->matchingpairs) < 1)
611  {
612  return;
613  }
614  if ($index >= count($this->matchingpairs))
615  {
616  return;
617  }
618  unset($this->matchingpairs[$index]);
619  $this->matchingpairs = array_values($this->matchingpairs);
620  }
621 
631  {
632  $this->matchingpairs = array();
633  }
634 
645  {
646  return count($this->matchingpairs);
647  }
648 
658  function getTerms()
659  {
660  natcasesort($this->terms);
661  return $this->terms;
662  }
663 
674  function getTermWithID($id)
675  {
676  return $this->terms[$id];
677  }
678 
688  function getTermCount()
689  {
690  return count($this->terms);
691  }
692 
702  function addTerm($term)
703  {
704  $newkey = count($this->terms);
705  while (array_key_exists("term_" . $newkey, $this->terms))
706  {
707  $newkey += 11;
708  }
709  $this->terms["term_" . $newkey] = $term;
710  }
711 
720  function flushTerms()
721  {
722  $this->terms = array();
723  }
724 
734  function deleteTerm($term_id)
735  {
736  unset($this->terms[$term_id]);
737  }
738 
749  function setTerm($term, $index)
750  {
751  $this->terms[$index] = $term;
752  }
753 
765  function calculateReachedPoints($active_id, $pass = NULL)
766  {
767  global $ilDB;
768 
769  $found_value1 = array();
770  $found_value2 = array();
771  if (is_null($pass))
772  {
773  $pass = $this->getSolutionMaxPass($active_id);
774  }
775  $query = sprintf("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
776  $ilDB->quote($active_id . ""),
777  $ilDB->quote($this->getId() . ""),
778  $ilDB->quote($pass . "")
779  );
780  $result = $ilDB->query($query);
781  while ($data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
782  {
783  if (strcmp($data->value1, "") != 0)
784  {
785  array_push($found_value1, $data->value1);
786  array_push($found_value2, $data->value2);
787  }
788  }
789  $points = 0;
790  foreach ($found_value2 as $key => $value)
791  {
792  foreach ($this->matchingpairs as $answer_key => $answer_value)
793  {
794  if (($answer_value->getDefinitionId() == $value) and ($answer_value->getTerm() == $found_value1[$key]))
795  {
796  $points += $answer_value->getPoints();
797  }
798  }
799  }
800 
801  $points = parent::calculateReachedPoints($active_id, $pass = NULL, $points);
802  return $points;
803  }
804 
813  function getMaximumPoints()
814  {
815  $points = 0;
816  foreach ($this->matchingpairs as $key => $value)
817  {
818  if ($value->getPoints() > 0)
819  {
820  $points += $value->getPoints();
821  }
822  }
823  return $points;
824  }
825 
836  function setImageFile($image_filename, $image_tempfilename = "")
837  {
838  $result = 0;
839  if (!empty($image_tempfilename))
840  {
841  $image_filename = str_replace(" ", "_", $image_filename);
842  $imagepath = $this->getImagePath();
843  if (!file_exists($imagepath))
844  {
845  ilUtil::makeDirParents($imagepath);
846  }
847  //if (!move_uploaded_file($image_tempfilename, $imagepath . $image_filename))
848  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath.$image_filename))
849  {
850  $result = 2;
851  }
852  else
853  {
854  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
855  $mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
856  if (!preg_match("/^image/", $mimetype))
857  {
858  unlink($imagepath . $image_filename);
859  $result = 1;
860  }
861  else
862  {
863  // create thumbnail file
864  $thumbpath = $imagepath . $image_filename . "." . "thumb.jpg";
865  ilUtil::convertImage($imagepath.$image_filename, $thumbpath, "JPEG", 100);
866  }
867  }
868  }
869  return $result;
870  }
871 
881  function checkSaveData()
882  {
883  $result = true;
884  $matching_values = array();
885  foreach ($_POST as $key => $value)
886  {
887  if (preg_match("/^sel_matching_(\d+)/", $key, $matches))
888  {
889  if ((strcmp($value, "") != 0) && ($value != -1))
890  {
891  array_push($matching_values, $value);
892  }
893  }
894  }
895  $check_matching = array_flip($matching_values);
896  if (count($check_matching) != count($matching_values))
897  {
898  // duplicate matching values!!!
899  $result = false;
900  ilUtil::sendInfo($this->lng->txt("duplicate_matching_values_selected"), TRUE);
901  }
902  return $result;
903  }
904 
915  function saveWorkingData($active_id, $pass = NULL)
916  {
917  global $ilDB;
918  global $ilUser;
919 
920  $saveWorkingDataResult = $this->checkSaveData();
921  $entered_values = 0;
922  if ($saveWorkingDataResult)
923  {
924  if (is_null($pass))
925  {
926  include_once "./Modules/Test/classes/class.ilObjTest.php";
927  $pass = ilObjTest::_getPass($active_id);
928  }
929 
930  $query = sprintf("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
931  $ilDB->quote($active_id . ""),
932  $ilDB->quote($this->getId() . ""),
933  $ilDB->quote($pass . "")
934  );
935  $result = $ilDB->query($query);
936  foreach ($_POST as $key => $value)
937  {
938  if (preg_match("/^sel_matching_(\d+)/", $key, $matches))
939  {
940  if ($value > -1) // -1 is the unselected value in the non javascript version
941  {
942  $entered_values++;
943  $query = sprintf("INSERT INTO tst_solutions (solution_id, active_fi, question_fi, value1, value2, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
944  $ilDB->quote($active_id),
945  $ilDB->quote($this->getId()),
946  $ilDB->quote(trim($value)),
947  $ilDB->quote(trim($matches[1])),
948  $ilDB->quote($pass . "")
949  );
950  $result = $ilDB->query($query);
951  }
952  }
953  }
954  $saveWorkingDataResult = true;
955  }
956  if ($entered_values)
957  {
958  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
960  {
961  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
962  }
963  }
964  else
965  {
966  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
968  {
969  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
970  }
971  }
972  parent::saveWorkingData($active_id, $pass);
973  return $saveWorkingDataResult;
974  }
975 
976  function get_random_id()
977  {
978  mt_srand((double)microtime()*1000000);
979  $random_number = mt_rand(1, 100000);
980  $found = FALSE;
981  while ($found)
982  {
983  $found = FALSE;
984  foreach ($this->matchingpairs as $key => $value)
985  {
986  if (($value->getTermId() == $random_number) || ($value->getDefinitionId() == $random_number))
987  {
988  $found = TRUE;
989  $random_number++;
990  }
991  }
992  }
993  return $random_number;
994  }
995 
996  function pc_array_shuffle($array) {
997  $i = count($array);
998  mt_srand((double)microtime()*1000000);
999  while(--$i)
1000  {
1001  $j = mt_rand(0, $i);
1002  if ($i != $j)
1003  {
1004  // swap elements
1005  $tmp = $array[$j];
1006  $array[$j] = $array[$i];
1007  $array[$i] = $tmp;
1008  }
1009  }
1010  return $array;
1011  }
1012 
1023  {
1024  switch ($shuffle)
1025  {
1026  case 0:
1027  case 1:
1028  case 2:
1029  case 3:
1030  $this->shuffle = $shuffle;
1031  break;
1032  default:
1033  $this->shuffle = 1;
1034  break;
1035  }
1036  }
1037 
1046  function getQuestionType()
1047  {
1048  return "assMatchingQuestion";
1049  }
1050 
1060  {
1061  return "qpl_question_matching";
1062  }
1063 
1073  {
1074  return array("qpl_answer_matching", "qpl_answer_matching_term");
1075  }
1076 
1082  {
1084  }
1085 
1089  function &getMatchingPairs()
1090  {
1091  return $this->matchingpairs;
1092  }
1093 
1103  {
1104  return TRUE;
1105  }
1106 
1119  public function setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
1120  {
1121  include_once ("./classes/class.ilExcelUtils.php");
1122  $solutions = $this->getSolutionValues($active_id, $pass);
1123  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1124  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1125  $imagepath = $this->getImagePath();
1126  $i = 1;
1127  $terms = $this->getTerms();
1128  foreach ($solutions as $solution)
1129  {
1130  $matches_written = FALSE;
1131  foreach ($this->getMatchingPairs() as $idx => $answer)
1132  {
1133  if (!$matches_written) $worksheet->writeString($startrow + $i, 1, ilExcelUtils::_convert_text($this->lng->txt("matches")));
1134  $matches_written = TRUE;
1135  if ($answer->getDefinitionId() == $solution["value2"])
1136  {
1137  if (strlen($answer->getDefinition())) $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($answer->getDefinition()));
1138  }
1139  if ($answer->getTermId() == $solution["value1"])
1140  {
1141  if (strlen($answer->getTerm())) $worksheet->writeString($startrow + $i, 2, ilExcelUtils::_convert_text($terms[$answer->getTermId()]));
1142  }
1143  }
1144  $i++;
1145  }
1146  return $startrow + $i + 1;
1147  }
1148 }
1149 
1150 ?>