00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00034 include_once "./classes/class.ilObject.php";
00035 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
00036
00037 class ilObjSurveyQuestionPool extends ilObject
00038 {
00044 var $online;
00045
00052 function ilObjSurveyQuestionPool($a_id = 0,$a_call_by_reference = true)
00053 {
00054 $this->type = "spl";
00055 $this->ilObject($a_id,$a_call_by_reference);
00056 }
00057
00061 function create($a_upload = false)
00062 {
00063 parent::create();
00064 if(!$a_upload)
00065 {
00066 $this->createMetaData();
00067 }
00068 }
00069
00076 function update()
00077 {
00078 $this->updateMetaData();
00079 if (!parent::update())
00080 {
00081 return false;
00082 }
00083
00084
00085
00086 return true;
00087 }
00088
00094 function read($a_force_db = false)
00095 {
00096 parent::read($a_force_db);
00097 $this->loadFromDb();
00098 }
00099
00107 function cloneObject($a_target_id,$a_copy_id = 0)
00108 {
00109 global $ilLog;
00110 $newObj = parent::cloneObject($a_target_id,$a_copy_id);
00111 $newObj->setOnline($this->getOnline());
00112 $newObj->saveToDb();
00113
00114 $questions =& $this->getQuestions();
00115 foreach ($questions as $question_id)
00116 {
00117 $newObj->copyQuestion($question_id, $newObj->getId());
00118 }
00119
00120
00121 include_once "./Services/MetaData/classes/class.ilMD.php";
00122 $md = new ilMD($this->getId(),0,$this->getType());
00123 $new_md =& $md->cloneMD($newObj->getId(),0,$newObj->getType());
00124
00125
00126 $newObj->updateMetaData();
00127 return $newObj;
00128 }
00129
00130 function &createQuestion($question_type, $question_id = -1)
00131 {
00132 if ((!$question_type) and ($question_id > 0))
00133 {
00134 $question_type = $this->getQuestiontype($question_id);
00135 }
00136
00137 include_once "./Modules/SurveyQuestionPool/classes/class.".$question_type."GUI.php";
00138 $question_type_gui = $question_type . "GUI";
00139 $question =& new $question_type_gui();
00140
00141 if ($question_id > 0)
00142 {
00143 $question->object->loadFromDb($question_id);
00144 }
00145
00146 return $question;
00147 }
00148
00158 function copyQuestion($question_id, $questionpool_to)
00159 {
00160 $question_gui =& $this->createQuestion("", $question_id);
00161 if ($question_gui->object->getObjId() == $questionpool_to)
00162 {
00163
00164 $this->duplicateQuestion($question_id);
00165 }
00166 else
00167 {
00168
00169 $newtitle = $question_gui->object->getTitle();
00170 if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to))
00171 {
00172 $counter = 2;
00173 while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() . " ($counter)", $questionpool_to))
00174 {
00175 $counter++;
00176 }
00177 $newtitle = $question_gui->object->getTitle() . " ($counter)";
00178 }
00179 $question_gui->object->copyObject($this->getId(), $newtitle);
00180 }
00181 }
00182
00190 function loadFromDb()
00191 {
00192 global $ilDB;
00193
00194 $query = sprintf("SELECT * FROM survey_questionpool WHERE obj_fi = %s",
00195 $ilDB->quote($this->getId() . "")
00196 );
00197 $result = $ilDB->query($query);
00198 if ($result->numRows() == 1)
00199 {
00200 $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
00201 $this->setOnline($row["online"]);
00202 }
00203 }
00204
00212 function saveToDb()
00213 {
00214 global $ilDB;
00215
00216 $query = sprintf("SELECT * FROM survey_questionpool WHERE obj_fi = %s",
00217 $ilDB->quote($this->getId() . "")
00218 );
00219 $result = $ilDB->query($query);
00220 if ($result->numRows() == 1)
00221 {
00222 $query = sprintf("UPDATE survey_questionpool SET online = %s WHERE obj_fi = %s",
00223 $ilDB->quote($this->getOnline() . ""),
00224 $ilDB->quote($this->getId() . "")
00225 );
00226 $result = $ilDB->query($query);
00227 if ($result != DB_OK)
00228 {
00229 }
00230 }
00231 else
00232 {
00233 $query = sprintf("INSERT INTO survey_questionpool (online, obj_fi) VALUES (%s, %s)",
00234 $ilDB->quote($this->getOnline() . ""),
00235 $ilDB->quote($this->getId() . "")
00236 );
00237 $result = $ilDB->query($query);
00238 if ($result != DB_OK)
00239 {
00240 }
00241 }
00242 }
00243
00250 function delete()
00251 {
00252 $remove = parent::delete();
00253
00254 if (!$remove)
00255 {
00256 return false;
00257 }
00258
00259
00260 $this->deleteAllData();
00261
00262
00263 $this->deleteMetaData();
00264
00265 return true;
00266 }
00267
00268 function deleteAllData()
00269 {
00270 $query = sprintf("SELECT question_id FROM survey_question WHERE obj_fi = %s AND original_id IS NULL",
00271 $this->ilias->db->quote($this->getId())
00272 );
00273 $result = $this->ilias->db->query($query);
00274 $found_questions = array();
00275 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00276 {
00277 $this->removeQuestion($row["question_id"]);
00278 }
00279
00280
00281 include_once "./Services/Utilities/classes/class.ilUtil.php";
00282 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
00283 $directory = $spl_data_dir."/spl_".$this->getId();
00284 if (is_dir($directory))
00285 {
00286 include_once "./Services/Utilities/classes/class.ilUtil.php";
00287 ilUtil::delDir($directory);
00288 }
00289 }
00290
00304 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00305 {
00306 global $tree;
00307
00308 switch ($a_event)
00309 {
00310 case "link":
00311
00312
00313
00314
00315 break;
00316
00317 case "cut":
00318
00319
00320
00321 break;
00322
00323 case "copy":
00324
00325
00326
00327
00328 break;
00329
00330 case "paste":
00331
00332
00333
00334 break;
00335
00336 case "new":
00337
00338
00339
00340 break;
00341 }
00342
00343
00344 if ($a_node_id==$_GET["ref_id"])
00345 {
00346 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00347 $parent_type = $parent_obj->getType();
00348 if($parent_type == $this->getType())
00349 {
00350 $a_node_id = (int) $tree->getParentId($a_node_id);
00351 }
00352 }
00353
00354 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00355 }
00356
00362 function getTitle()
00363 {
00364
00365 return parent::getTitle();
00366 }
00367
00371 function setTitle($a_title)
00372 {
00373 parent::setTitle($a_title);
00374 }
00375
00384 function removeQuestion($question_id)
00385 {
00386 if ($question_id < 1)
00387 return;
00388
00389 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
00390 $question =& SurveyQuestion::_instanciateQuestion($question_id);
00391 $question->delete($question_id);
00392 }
00393
00403 function getQuestiontype($question_id)
00404 {
00405 if ($question_id < 1)
00406 return;
00407
00408 $query = sprintf("SELECT survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.question_id = %s",
00409 $this->ilias->db->quote($question_id)
00410 );
00411 $result = $this->ilias->db->query($query);
00412 if ($result->numRows() == 1) {
00413 $data = $result->fetchRow(DB_FETCHMODE_OBJECT);
00414 return $data->type_tag;
00415 } else {
00416 return;
00417 }
00418 }
00419
00429 function isInUse($question_id)
00430 {
00431
00432 $query = sprintf("SELECT answer_id FROM survey_answer WHERE question_fi = %s",
00433 $this->ilias->db->quote($question_id)
00434 );
00435 $result = $this->ilias->db->query($query);
00436 $answered = $result->numRows();
00437
00438
00439 $query = sprintf("SELECT survey_survey.* FROM survey_survey, survey_survey_question WHERE survey_survey_question.survey_fi = survey_survey.survey_id AND survey_survey_question.question_fi = %s",
00440 $this->ilias->db->quote($question_id)
00441 );
00442 $result = $this->ilias->db->query($query);
00443 $inserted = $result->numRows();
00444 if (($inserted + $answered) == 0)
00445 {
00446 return false;
00447 }
00448 $result_array = array();
00449 while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
00450 {
00451 array_push($result_array, $row);
00452 }
00453 return $result_array;
00454 }
00455
00464 function paste($question_id)
00465 {
00466 $this->duplicateQuestion($question_id, $this->getId());
00467 }
00468
00478 function &getQuestionsInfo($question_array)
00479 {
00480 $result_array = array();
00481 $query = sprintf("SELECT survey_question.*, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.question_id IN ('%s')",
00482 join($question_array, "','")
00483 );
00484 $result = $this->ilias->db->query($query);
00485 while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
00486 {
00487 array_push($result_array, $row);
00488 }
00489 return $result_array;
00490 }
00491
00500 function duplicateQuestion($question_id, $obj_id = "")
00501 {
00502 global $ilUser;
00503 $questiontype = $this->getQuestiontype($question_id);
00504 include_once "./Modules/SurveyQuestionPool/classes/class.$questiontype.php";
00505 $question = new $questiontype();
00506 $question->loadFromDb($question_id);
00507 $suffix = "";
00508 $counter = 1;
00509 while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
00510 {
00511 $counter++;
00512 if ($counter > 1) $suffix = " ($counter)";
00513 }
00514 if ($obj_id)
00515 {
00516 $question->setObjId($obj_id);
00517 }
00518 $question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
00519 }
00520
00528 function getQuestionsTable($sort, $sortorder, $filter_text, $sel_filter_type, $startrow = 0)
00529 {
00530 global $ilUser;
00531 $where = "";
00532 if (strlen($filter_text) > 0)
00533 {
00534 switch($sel_filter_type)
00535 {
00536 case "title":
00537 $where = " AND survey_question.title LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
00538 break;
00539 case "description":
00540 $where = " AND survey_question.description LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
00541 break;
00542 case "author":
00543 $where = " AND survey_question.author LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
00544 break;
00545 }
00546 }
00547
00548
00549 $order = "";
00550 $images = array();
00551 include_once "./Services/Utilities/classes/class.ilUtil.php";
00552 switch ($sort)
00553 {
00554 case "title":
00555 $order = " ORDER BY title $sortorder";
00556 $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
00557 break;
00558 case "description":
00559 $order = " ORDER BY description $sortorder";
00560 $images["description"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
00561 break;
00562 case "type":
00563 $order = " ORDER BY questiontype_id $sortorder";
00564 $images["type"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
00565 break;
00566 case "author":
00567 $order = " ORDER BY author $sortorder";
00568 $images["author"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
00569 break;
00570 case "created":
00571 $order = " ORDER BY created $sortorder";
00572 $images["created"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
00573 break;
00574 case "updated":
00575 $order = " ORDER BY TIMESTAMP14 $sortorder";
00576 $images["updated"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
00577 break;
00578 }
00579 $maxentries = $ilUser->prefs["hits_per_page"];
00580 if ($maxentries < 1)
00581 {
00582 $maxentries = 9999;
00583 }
00584 $query = "SELECT survey_question.question_id, survey_question.TIMESTAMP + 0 AS TIMESTAMP14 FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.obj_fi = " . $this->getId() . " AND ISNULL(survey_question.original_id) $where$order$limit";
00585 $query_result = $this->ilias->db->query($query);
00586 $max = $query_result->numRows();
00587 if ($startrow > $max -1)
00588 {
00589 $startrow = $max - ($max % $maxentries);
00590 }
00591 else if ($startrow < 0)
00592 {
00593 $startrow = 0;
00594 }
00595 $limit = " LIMIT $startrow, $maxentries";
00596 $query = "SELECT survey_question.*, survey_question.TIMESTAMP + 0 AS TIMESTAMP14, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.obj_fi = " . $this->getId() . " AND ISNULL(survey_question.original_id) $where$order$limit";
00597 $query_result = $this->ilias->db->query($query);
00598 $rows = array();
00599 if ($query_result->numRows())
00600 {
00601 while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
00602 {
00603 array_push($rows, $row);
00604 }
00605 }
00606 $nextrow = $startrow + $maxentries;
00607 if ($nextrow > $max - 1)
00608 {
00609 $nextrow = $startrow;
00610 }
00611 $prevrow = $startrow - $maxentries;
00612 if ($prevrow < 0)
00613 {
00614 $prevrow = 0;
00615 }
00616 return array(
00617 "rows" => $rows,
00618 "images" => $images,
00619 "startrow" => $startrow,
00620 "nextrow" => $nextrow,
00621 "prevrow" => $prevrow,
00622 "step" => $maxentries,
00623 "rowcount" => $max
00624 );
00625 }
00626
00632 function createExportDirectory()
00633 {
00634 include_once "./Services/Utilities/classes/class.ilUtil.php";
00635 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
00636 ilUtil::makeDir($spl_data_dir);
00637 if(!is_writable($spl_data_dir))
00638 {
00639 $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
00640 .") not writeable.",$this->ilias->error_obj->FATAL);
00641 }
00642
00643
00644 $spl_dir = $spl_data_dir."/spl_".$this->getId();
00645 ilUtil::makeDir($spl_dir);
00646 if(!@is_dir($spl_dir))
00647 {
00648 $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
00649 }
00650
00651 $export_dir = $spl_dir."/export";
00652 ilUtil::makeDir($export_dir);
00653 if(!@is_dir($export_dir))
00654 {
00655 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
00656 }
00657 }
00658
00662 function getExportDirectory()
00663 {
00664 include_once "./Services/Utilities/classes/class.ilUtil.php";
00665 $export_dir = ilUtil::getDataDir()."/spl_data"."/spl_".$this->getId()."/export";
00666 return $export_dir;
00667 }
00668
00672 function getExportFiles($dir)
00673 {
00674
00675 if (!@is_dir($dir) or
00676 !is_writeable($dir))
00677 {
00678 return array();
00679 }
00680
00681
00682 $dir = dir($dir);
00683
00684
00685 $file = array();
00686
00687
00688 while ($entry = $dir->read())
00689 {
00690 if ($entry != "." and
00691 $entry != ".." and
00692 substr($entry, -4) == ".xml" and
00693 ereg("^[0-9]{10}_{2}[0-9]+_{2}(spl__)*[0-9]+\.xml\$", $entry))
00694 {
00695 $file[] = $entry;
00696 }
00697 }
00698
00699
00700 $dir->close();
00701
00702 sort ($file);
00703 reset ($file);
00704
00705 return $file;
00706 }
00707
00713 function createImportDirectory()
00714 {
00715 include_once "./Services/Utilities/classes/class.ilUtil.php";
00716 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
00717 ilUtil::makeDir($spl_data_dir);
00718
00719 if(!is_writable($spl_data_dir))
00720 {
00721 $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
00722 .") not writeable.",$this->ilias->error_obj->FATAL);
00723 }
00724
00725
00726 $spl_dir = $spl_data_dir."/spl_".$this->getId();
00727 ilUtil::makeDir($spl_dir);
00728 if(!@is_dir($spl_dir))
00729 {
00730 $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
00731 }
00732
00733
00734 $import_dir = $spl_dir."/import";
00735 ilUtil::makeDir($import_dir);
00736 if(!@is_dir($import_dir))
00737 {
00738 $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
00739 }
00740 }
00741
00745 function getImportDirectory()
00746 {
00747 include_once "./Services/Utilities/classes/class.ilUtil.php";
00748 $import_dir = ilUtil::getDataDir()."/spl_data".
00749 "/spl_".$this->getId()."/import";
00750 if(@is_dir($import_dir))
00751 {
00752 return $import_dir;
00753 }
00754 else
00755 {
00756 return false;
00757 }
00758 }
00759
00763 function toXML($questions)
00764 {
00765 if (!is_array($questions))
00766 {
00767 $questions =& $this->getQuestions();
00768 }
00769 if (count($questions) == 0)
00770 {
00771 $questions =& $this->getQuestions();
00772 }
00773 $xml = "";
00774
00775 include_once("./classes/class.ilXmlWriter.php");
00776 $a_xml_writer = new ilXmlWriter;
00777
00778 $a_xml_writer->xmlHeader();
00779 $attrs = array(
00780 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
00781 "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_3_8.xsd"
00782 );
00783 $a_xml_writer->xmlStartTag("surveyobject", $attrs);
00784 $attrs = array(
00785 "id" => "qpl_" . $this->getId(),
00786 "label" => $this->getTitle()
00787 );
00788 $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
00789 $a_xml_writer->xmlElement("dummy", NULL, "dummy");
00790
00791 $a_xml_writer->xmlStartTag("metadata");
00792 $a_xml_writer->xmlStartTag("metadatafield");
00793 $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
00794 include_once "./Services/MetaData/classes/class.ilMD.php";
00795 $md = new ilMD($this->getId(),0, $this->getType());
00796 $writer = new ilXmlWriter();
00797 $md->toXml($writer);
00798 $metadata = $writer->xmlDumpMem();
00799 $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
00800 $a_xml_writer->xmlEndTag("metadatafield");
00801 $a_xml_writer->xmlEndTag("metadata");
00802
00803 $a_xml_writer->xmlEndTag("surveyquestions");
00804 $a_xml_writer->xmlEndTag("surveyobject");
00805
00806 $xml = $a_xml_writer->xmlDumpMem(FALSE);
00807
00808 $questionxml = "";
00809 foreach ($questions as $key => $value)
00810 {
00811 $questiontype = $this->getQuestiontype($value);
00812 include_once "./Modules/SurveyQuestionPool/classes/class.$questiontype.php";
00813 $question = new $questiontype();
00814 $question->loadFromDb($value);
00815 $questionxml .= $question->toXML(false);
00816 }
00817
00818 $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
00819 return $xml;
00820 }
00821
00822 function &getQuestions()
00823 {
00824 $questions = array();
00825 $query = sprintf("SELECT question_id FROM survey_question WHERE obj_fi = %s AND ISNULL(original_id)",
00826 $this->ilias->db->quote($this->getId() . "")
00827 );
00828 $result = $this->ilias->db->query($query);
00829 if ($result->numRows())
00830 {
00831 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00832 {
00833 array_push($questions, $row["question_id"]);
00834 }
00835 }
00836 return $questions;
00837 }
00838
00847 function importObject($source, $spl_exists = FALSE)
00848 {
00849 if (is_file($source))
00850 {
00851 $fh = fopen($source, "r") or die("");
00852 $xml = fread($fh, filesize($source));
00853 fclose($fh) or die("");
00854 if (strpos($xml, "questestinterop") > 0)
00855 {
00856
00857 include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
00858 $import = new SurveyImportParserPre38($this, "", $spl_exists);
00859 $import->setXMLContent($xml);
00860 $import->startParsing();
00861 }
00862 else
00863 {
00864
00865 include_once "./Services/Survey/classes/class.SurveyImportParser.php";
00866 $import = new SurveyImportParser($this, "", $spl_exists);
00867 $import->setXMLContent($xml);
00868 $import->startParsing();
00869 }
00870 }
00871 }
00872
00882 function setOnline($a_online_status)
00883 {
00884 switch ($a_online_status)
00885 {
00886 case 0:
00887 case 1:
00888 $this->online = $a_online_status;
00889 break;
00890 default:
00891 $this->online = 0;
00892 break;
00893 }
00894 }
00895
00896 function getOnline()
00897 {
00898 if (strcmp($this->online, "") == 0) $this->online = "0";
00899 return $this->online;
00900 }
00901
00902 function _lookupOnline($a_obj_id)
00903 {
00904 global $ilDB;
00905
00906 $query = sprintf("SELECT online FROM survey_questionpool WHERE obj_fi = %s",
00907 $ilDB->quote($a_obj_id . "")
00908 );
00909 $result = $ilDB->query($query);
00910 if ($result->numRows() == 1)
00911 {
00912 $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
00913 return $row["online"];
00914 }
00915 return 0;
00916 }
00917
00927 function _isWriteable($object_id, $user_id)
00928 {
00929 global $rbacsystem;
00930 global $ilDB;
00931
00932 $result_array = array();
00933 $query = sprintf("SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.obj_id = %s",
00934 $ilDB->quote($object_id . "")
00935 );
00936 $result = $ilDB->query($query);
00937 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00938 {
00939 include_once "./classes/class.ilObject.php";
00940 if ($rbacsystem->checkAccess("write", $row["ref_id"]) && (ilObject::_hasUntrashedReference($row["obj_id"])))
00941 {
00942 return true;
00943 }
00944 }
00945 return false;
00946 }
00947
00956 function &_getQuestiontypes()
00957 {
00958 global $ilDB;
00959
00960 $questiontypes = array();
00961 $query = "SELECT * FROM survey_questiontype ORDER BY type_tag";
00962 $query_result = $ilDB->query($query);
00963 while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
00964 {
00965 array_push($questiontypes, $row["type_tag"]);
00966 }
00967 return $questiontypes;
00968 }
00969
00978 function &_getAvailableQuestionpools($use_object_id = FALSE, $could_be_offline = FALSE, $showPath = FALSE, $permission = "read")
00979 {
00980 global $ilUser;
00981 global $ilDB;
00982
00983 $result_array = array();
00984 $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
00985 $titles = ilObject::_prepareCloneSelection($qpls, "spl");
00986 if (count($qpls))
00987 {
00988 $query = "";
00989 if ($could_be_offline)
00990 {
00991 $query = sprintf("SELECT object_data.*, object_reference.ref_id FROM object_data, object_reference, survey_questionpool WHERE object_data.obj_id = object_reference.obj_id AND object_reference.ref_id IN ('%s') AND survey_questionpool.obj_fi = object_data.obj_id ORDER BY object_data.title",
00992 implode("','", $qpls)
00993 );
00994 }
00995 else
00996 {
00997 $query = sprintf("SELECT object_data.*, object_reference.ref_id FROM object_data, object_reference, survey_questionpool WHERE object_data.obj_id = object_reference.obj_id AND object_reference.ref_id IN ('%s') AND survey_questionpool.online = '1' AND survey_questionpool.obj_fi = object_data.obj_id ORDER BY object_data.title",
00998 implode("','", $qpls)
00999 );
01000 }
01001 $result = $ilDB->query($query);
01002 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
01003 {
01004 $title = (($showPath) ? $titles[$row["ref_id"]] : $row["title"]);
01005
01006 if ($use_object_id)
01007 {
01008 $result_array[$row["obj_id"]] = $title;
01009 }
01010 else
01011 {
01012 $result_array[$row["ref_id"]] = $title;
01013 }
01014 }
01015 }
01016 return $result_array;
01017 }
01018
01019 }
01020 ?>