162        $this->
user = $DIC->user();
 
  163        $this->db = 
$DIC->database();
 
  173        $this->cumulated = array();
 
  174        if (!$this->author) {
 
  175            $this->author = 
$ilUser->fullname;
 
  178        if ($this->owner == -1) {
 
  179            $this->owner = 
$ilUser->getId();
 
  182        $this->survey_id = -1;
 
  183        $this->obligatory = 1;
 
  184        $this->orientation = 0;
 
  185        $this->materials = array();
 
  186        $this->material = array();
 
  187        $this->arrData = array();
 
  200        $this->complete = ($a_complete) ? 1 : 0;
 
  227        if (strcmp($questionpool_object, 
"") != 0) {
 
  230                $ilDB->quote($questionpool_object, 
'integer')
 
  234            "SELECT question_id FROM svy_question WHERE title = %s$refwhere",
 
  238        return (
$result->numRows() > 0) ? true : 
false;
 
  298        $this->survey_id = 
$id;
 
  323        if (empty($materials_name)) {
 
  324            $materials_name = $materials_file;
 
  326        if ((!empty($materials_name)) && (!array_key_exists($materials_name, $this->materials))) {
 
  327            $this->materials[$materials_name] = $materials_file;
 
  338    public function setMaterialsfile($materials_filename, $materials_tempfilename = 
"", $materials_name = 
"")
 
  340        if (!empty($materials_filename)) {
 
  342            if (!file_exists($materialspath)) {
 
  345            if (ilUtil::moveUploadedFile(
 
  346                $materials_tempfilename,
 
  348                $materialspath . $materials_filename
 
  350                print "image not uploaded!!!! ";
 
  352                $this->
addMaterials($materials_filename, $materials_name);
 
  366        foreach ($this->materials as 
$key => $value) {
 
  367            if (strcmp(
$key, $materials_name) == 0) {
 
  371                unset($this->materials[
$key]);
 
  384        $this->materials = array();
 
  465        return ($this->obligatory) ? 1 : 0;
 
  489        switch ($this->orientation) {
 
  495                $this->orientation = 0;
 
  511        return (strlen($this->description)) ? $this->description : 
null;
 
  523        return (strlen($this->author)) ? $this->author : 
null;
 
  547        return (strlen($this->questiontext)) ? $this->questiontext : 
null;
 
  581        if ($this->
getId() <= 0) {
 
  587        $original_id = $this->
getId();
 
  589        if ($a_survey_id > 0) {
 
  590            $clone->setObjId($a_survey_id);
 
  602            $clone->saveToDb($original_id);
 
  607        $clone->duplicateMaterials($original_id);
 
  609        $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
 
  610        return $clone->getId();
 
  620        if ($this->
getId() <= 0) {
 
  627        $source_questionpool = $this->
getObjId();
 
  628        $clone->setObjId($target_questionpool);
 
  636        $clone->duplicateMaterials($original_id);
 
  638        $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
 
  639        return $clone->getId();
 
  650        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
  652        foreach (
$mobs as $mob) {
 
  668            "SELECT * FROM svy_material WHERE question_fi = %s",
 
  670            array($this->
getId())
 
  672        $this->material = array();
 
  674            include_once 
"./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
 
  677                $mat->type = 
$row[
'material_type'];
 
  678                $mat->internal_link = 
$row[
'internal_link'];
 
  679                $mat->title = 
$row[
'material_title'];
 
  680                $mat->import_id = 
$row[
'import_id'];
 
  681                $mat->text_material = 
$row[
'text_material'];
 
  682                $mat->external_link = 
$row[
'external_link'];
 
  683                $mat->file_material = 
$row[
'file_material'];
 
  684                array_push($this->material, $mat);
 
  702            "SELECT complete FROM svy_question WHERE question_id = %s",
 
  708            if (
$row[
"complete"] == 1) {
 
  724        $question_id = $this->
getId();
 
  725        if (strlen($original_id)) {
 
  726            $question_id = $original_id;
 
  729        if ($this->
getId() > 0) {
 
  730            $this->log->debug(
"UPDATE svy_question question_id=" . $question_id);
 
  733            $affectedRows = 
$ilDB->manipulateF(
 
  734                "UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
 
  735                array(
'text', 
'integer', 
'integer'),
 
  736                array($this->
isComplete(), time(), $question_id)
 
  752        include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  755        if ($this->
getId() == -1) {
 
  757            $next_id = 
$ilDB->nextId(
'svy_question');
 
  758            $affectedRows = 
$ilDB->insert(
"svy_question", array(
 
  759                "question_id" => array(
"integer", $next_id),
 
  761                "obj_fi" => array(
"integer", $this->
getObjId()),
 
  762                "owner_fi" => array(
"integer", $this->
getOwner()),
 
  763                "title" => array(
"text", $this->
getTitle()),
 
  764                "label" => array(
"text", (strlen($this->label)) ? $this->label : 
null),
 
  766                "author" => array(
"text", $this->
getAuthor()),
 
  769                "complete" => array(
"text", $this->
isComplete()),
 
  770                "created" => array(
"integer", time()),
 
  771                "original_id" => array(
"integer", ($original_id) ? $original_id : 
null),
 
  772                "tstamp" => array(
"integer", time())
 
  777            $this->
setId($next_id);
 
  780            $affectedRows = 
$ilDB->update(
"svy_question", array(
 
  781                "title" => array(
"text", $this->
getTitle()),
 
  782                "label" => array(
"text", (strlen($this->label)) ? $this->label : 
null),
 
  784                "author" => array(
"text", $this->
getAuthor()),
 
  787                "complete" => array(
"text", $this->
isComplete()),
 
  788                "tstamp" => array(
"integer", time())
 
  790            "question_id" => array(
"integer", $this->
getId())
 
  793            $this->log->debug(
"UPDATE svy_question id=" . $this->
getId() . 
" SET: title=" . $this->
getTitle() . 
" ...");
 
  796        return $affectedRows;
 
  806        include_once 
"./Services/Link/classes/class.ilInternalLink.php";
 
  808        $this->log->debug(
"DELETE: svy_material question_fi=" . $this->
getId());
 
  810        $affectedRows = 
$ilDB->manipulateF(
 
  811            "DELETE FROM svy_material WHERE question_fi = %s",
 
  813            array($this->
getId())
 
  818            $next_id = 
$ilDB->nextId(
'svy_material');
 
  820            $this->log->debug(
"INSERT: svy_material question_fi=" . $this->
getId());
 
  822            $affectedRows = 
$ilDB->manipulateF(
 
  823                "INSERT INTO svy_material " .
 
  824                "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
 
  825                "text_material, external_link, file_material, material_type) " .
 
  826                "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
 
  827                array(
'integer',
'integer',
'text',
'text',
'text',
'integer',
'text',
'text',
'text',
'integer'),
 
  829                    $next_id, $this->
getId(), $material->internal_link, 
$material->import_id,
 
  833            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", 
$material->internal_link, $matches)) {
 
  851            $next_id = 
$ilDB->nextId(
'svy_question');
 
  852            $affectedRows = 
$ilDB->manipulateF(
 
  853                "INSERT INTO svy_question (question_id, questiontype_fi, " .
 
  854                "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
 
  855                "created, original_id, tstamp) VALUES " .
 
  856                "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
 
  857                array(
'integer', 
'integer', 
'integer', 
'integer', 
'text', 
'text', 
'text', 
'text',
 
  858                    'text', 
'text', 
'integer', 
'integer', 
'integer'),
 
  875            $this->log->debug(
"INSERT INTO svy_question question_id= " . $next_id . 
" questiontype_fi= " . $this->
getQuestionTypeID());
 
  877            $this->
setId($next_id);
 
  879        return $this->
getId();
 
  900        return CLIENT_WEB_DIR . 
"/survey/$this->obj_id/$this->id/images/";
 
  911        return CLIENT_WEB_DIR . 
"/survey/$this->obj_id/$this->id/materials/";
 
  952            "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
 
  953            array(
'text',
'text',
'integer'),
 
  954            array($categorytext, $neutral, 
$ilUser->getId())
 
  961                if (strcmp(
$row[
"title"], $categorytext) == 0) {
 
  962                    $returnvalue = 
$row[
"category_id"];
 
  970            $next_id = 
$ilDB->nextId(
'svy_category');
 
  971            $affectedRows = 
$ilDB->manipulateF(
 
  972                "INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
  973                array(
'integer',
'text',
'text',
'integer',
'integer'),
 
  974                array($next_id, $categorytext, $neutral, 
$ilUser->getId(), time())
 
  977            $this->log->debug(
"INSERT INTO svy_category id=" . $next_id);
 
  979            $returnvalue = $next_id;
 
  994        $this->log->debug(
"DELETE FROM " . $this->getAdditionalTableName());
 
  996        $affectedRows = 
$ilDB->manipulateF(
 
  997            "DELETE FROM " . $this->getAdditionalTableName() . 
" WHERE question_fi = %s",
 
 1009    public function delete($question_id)
 
 1013        if ($question_id < 1) {
 
 1018            "SELECT obj_fi FROM svy_question WHERE question_id = %s",
 
 1022        if (
$result->numRows() == 1) {
 
 1029        $affectedRows = 
$ilDB->manipulateF(
 
 1030            "DELETE FROM svy_answer WHERE question_fi = %s",
 
 1035        $affectedRows = 
$ilDB->manipulateF(
 
 1036            "DELETE FROM svy_constraint WHERE question_fi = %s",
 
 1042            "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s",
 
 1047            $affectedRows = 
$ilDB->manipulateF(
 
 1048                "DELETE FROM svy_constraint WHERE constraint_id = %s",
 
 1050                array(
$row->constraint_fi)
 
 1054        $affectedRows = 
$ilDB->manipulateF(
 
 1055            "DELETE FROM svy_qst_constraint WHERE question_fi = %s",
 
 1059        $affectedRows = 
$ilDB->manipulateF(
 
 1060            "DELETE FROM svy_qblk_qst WHERE question_fi = %s",
 
 1064        $affectedRows = 
$ilDB->manipulateF(
 
 1065            "DELETE FROM svy_svy_qst WHERE question_fi = %s",
 
 1069        $affectedRows = 
$ilDB->manipulateF(
 
 1070            "DELETE FROM svy_variable WHERE question_fi = %s",
 
 1074        $affectedRows = 
$ilDB->manipulateF(
 
 1075            "DELETE FROM svy_question WHERE question_id = %s",
 
 1082        $affectedRows = 
$ilDB->manipulateF(
 
 1083            "DELETE FROM svy_material WHERE question_fi = %s",
 
 1088        $this->log->debug(
"SET OF DELETES svy_answer, svy_constraint, svy_qst_constraint, svy_qblk_qst, svy_qst_oblig, svy_svy_qst, svy_variable, svy_question, svy_material WHERE question_fi = " . $question_id);
 
 1090        include_once 
"./Services/Link/classes/class.ilInternalLink.php";
 
 1093        $directory = CLIENT_WEB_DIR . 
"/survey/" . 
$obj_id . 
"/$question_id";
 
 1094        if (preg_match(
"/\d+/", 
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory)) {
 
 1098        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1104        foreach (
$mobs as $mob) {
 
 1110        include_once(
"./Modules/Survey/classes/class.ilSurveySkill.php");
 
 1113        $this->log->debug(
"UPDATE svy_question");
 
 1116        $ilDB->manipulate(
"UPDATE svy_question" .
 
 1117            " SET original_id = NULL" .
 
 1118            " WHERE original_id  = " . 
$ilDB->quote($question_id, 
"integer"));
 
 1134        if ($question_id < 1) {
 
 1139            "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
 
 1143        if (
$result->numRows() == 1) {
 
 1145            return $data[
"type_tag"];
 
 1164        if ($question_id < 1) {
 
 1169            "SELECT title FROM svy_question WHERE svy_question.question_id = %s",
 
 1173        if (
$result->numRows() == 1) {
 
 1175            return $data[
"title"];
 
 1188    public static function _getOriginalId($question_id, $a_return_question_id_if_no_original = 
true)
 
 1194            "SELECT * FROM svy_question WHERE question_id = %s",
 
 1200            if (
$row[
"original_id"] > 0) {
 
 1201                return $row[
"original_id"];
 
 1202            } elseif ((
bool) $a_return_question_id_if_no_original) { 
 
 1203                return $row[
"question_id"];
 
 1225            $this->log->debug(
"DELETE FROM svy_material WHERE question_fi = " . $this->
getOriginalId());
 
 1227            include_once 
"./Services/Link/classes/class.ilInternalLink.php";
 
 1228            $affectedRows = 
$ilDB->manipulateF(
 
 1229                "DELETE FROM svy_material WHERE question_fi = %s",
 
 1234            if (strlen($this->material[
"internal_link"])) {
 
 1235                $next_id = 
$ilDB->nextId(
'svy_material');
 
 1236                $affectedRows = 
$ilDB->manipulateF(
 
 1237                    "INSERT INTO svy_material (material_id, question_fi, internal_link, import_id, material_title, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
 1238                    array(
'integer', 
'integer', 
'text', 
'text', 
'text', 
'integer'),
 
 1239                    array($next_id, $this->
getOriginalId(), $this->material[
"internal_link"], $this->material[
"import_id"], $this->material[
"title"], time())
 
 1242                $this->log->debug(
"INSERT svy_material material_id=" . $next_id . 
" question_fi=" . $this->
getOriginalId());
 
 1244                if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
 
 1262            "SELECT title FROM svy_phrase WHERE phrase_id = %s",
 
 1267            return $row[
"title"];
 
 1285            "SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
 
 1286            array(
'text', 
'integer'),
 
 1289        return (
$result->numRows() == 0) ? false : 
true;
 
 1305        if ($question_id < 1) {
 
 1310            "SELECT question_id FROM svy_question WHERE question_id = %s",
 
 1314        return (
$result->numRows() == 1) ? true : 
false;
 
 1319        if (strlen($material_id)) {
 
 1320            if (strcmp($material_title, 
"") == 0) {
 
 1321                if (preg_match(
"/il__(\w+)_(\d+)/", $material_id, $matches)) {
 
 1322                    $type = $matches[1];
 
 1324                    $material_title = $this->lng->txt(
"obj_$type") . 
": ";
 
 1327                            include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
 1329                            $cont_obj = $cont_obj_gui->object;
 
 1330                            $material_title .= $cont_obj->getTitle();
 
 1333                            include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
 
 1334                            include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
 
 1336                            include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
 1338                            $cont_obj = $cont_obj_gui->object;
 
 1340                            $material_title .= $pg_obj->getTitle();
 
 1343                            include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
 
 1344                            include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
 
 1346                            include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
 1348                            $cont_obj = $cont_obj_gui->object;
 
 1350                            $material_title .= $st_obj->getTitle();
 
 1353                            include_once 
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
 
 1361            include_once 
"./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
 
 1364            $mat->internal_link = $material_id;
 
 1365            $mat->title = $material_title;
 
 1378        foreach ($a_array as $idx) {
 
 1379            unset($this->material[$idx]);
 
 1381        $this->material = array_values($this->material);
 
 1393        foreach ($this->materials as 
$filename) {
 
 1395            $materialspath_original = preg_replace(
"/([^\d])$this->id([^\d])/", 
"\${1}$question_id\${2}", $materialspath);
 
 1396            if (!file_exists($materialspath)) {
 
 1400                print "material could not be duplicated!!!! ";
 
 1407        array_push($this->material, $obj_material);
 
 1417    public function setMaterial($material_id = 
"", $is_import = 
false, $material_title = 
"")
 
 1419        if (strcmp($material_id, 
"") != 0) {
 
 1422                $import_id = $material_id;
 
 1425            if (strcmp($material_title, 
"") == 0) {
 
 1426                if (preg_match(
"/il__(\w+)_(\d+)/", $material_id, $matches)) {
 
 1427                    $type = $matches[1];
 
 1429                    $material_title = $this->lng->txt(
"obj_$type") . 
": ";
 
 1432                            include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
 1434                            $cont_obj = $cont_obj_gui->object;
 
 1435                            $material_title .= $cont_obj->getTitle();
 
 1438                            include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
 
 1439                            include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
 
 1441                            include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
 1443                            $cont_obj = $cont_obj_gui->object;
 
 1445                            $material_title .= $pg_obj->getTitle();
 
 1448                            include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
 
 1449                            include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
 
 1451                            include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
 1453                            $cont_obj = $cont_obj_gui->object;
 
 1455                            $material_title .= $st_obj->getTitle();
 
 1458                            include_once 
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
 
 1466            $this->material = array(
 
 1467                "internal_link" => $material_id,
 
 1468                "import_id" => $import_id,
 
 1469                "title" => $material_title
 
 1477        if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches)) {
 
 1478            include_once 
"./Services/Link/classes/class.ilInternalLink.php";
 
 1479            include_once 
"./Modules/LearningModule/classes/class.ilLMObject.php";
 
 1480            include_once 
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
 
 1481            switch ($matches[2]) {
 
 1498            if (strcmp($resolved_link, 
"") == 0) {
 
 1499                $resolved_link = $internal_link;
 
 1502            $resolved_link = $internal_link;
 
 1504        return $resolved_link;
 
 1514            "SELECT * FROM svy_material WHERE question_fi = %s",
 
 1520                $internal_link = 
$row[
"internal_link"];
 
 1521                include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 1523                if (strcmp($internal_link, $resolved_link) != 0) {
 
 1525                    $affectedRows = 
$ilDB->manipulateF(
 
 1526                        "UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
 
 1527                        array(
'text', 
'integer', 
'integer'),
 
 1528                        array($resolved_link, time(), 
$row[
"material_id"])
 
 1534        if ($resolvedlinks) {
 
 1538            include_once 
"./Services/Link/classes/class.ilInternalLink.php";
 
 1542                "SELECT * FROM svy_material WHERE question_fi = %s",
 
 1548                    if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", 
$row[
"internal_link"], $matches)) {
 
 1562            "lm" => 
"LearningModule",
 
 1563            "pg" => 
"PageObject",
 
 1564            "st" => 
"StructureObject",
 
 1565            "git" => 
"GlossaryItem",
 
 1566            "mob" => 
"MediaObject" 
 1569        if (preg_match(
"/il__(\w+)_(\d+)/", 
$target, $matches)) {
 
 1570            $type = $matches[1];
 
 1572            switch ($linktypes[$matches[1]]) {
 
 1573                case "LearningModule":
 
 1577                case "StructureObject":
 
 1580                case "GlossaryItem":
 
 1605        if (($question_id < 1) || ($user_id < 1)) {
 
 1610            "SELECT obj_fi FROM svy_question WHERE question_id = %s",
 
 1614        if (
$result->numRows() == 1) {
 
 1616            $qpl_object_id = 
$row[
"obj_fi"];
 
 1617            include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
 1634            "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
 
 1638        if (
$result->numRows() == 1) {
 
 1640            return $row[
"questiontype_id"];
 
 1666        $type = $question_type;
 
 1669        } elseif ($gui == 2) {
 
 1670            $type .= 
"Evaluation";
 
 1672        if (file_exists(
"./Modules/SurveyQuestionPool/classes/class." . 
$type . 
".php")) {
 
 1673            include_once 
"./Modules/SurveyQuestionPool/classes/class." . 
$type . 
".php";
 
 1678            $ilPluginAdmin = 
$DIC[
"ilPluginAdmin"];
 
 1679            $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE, 
"SurveyQuestionPool", 
"svyq");
 
 1680            foreach ($pl_names as $pl_name) {
 
 1682                if (strcmp($pl->getQuestionType(), $question_type) == 0) {
 
 1683                    $pl->includeClass(
"class." . 
$type . 
".php");
 
 1699        if (file_exists(
"./Modules/SurveyQuestionPool/classes/class." . $type_tag . 
".php")) {
 
 1703            return $lng->txt($type_tag);
 
 1707            $ilPluginAdmin = 
$DIC[
"ilPluginAdmin"];
 
 1708            $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE, 
"SurveyQuestionPool", 
"svyq");
 
 1709            foreach ($pl_names as $pl_name) {
 
 1711                if (strcmp($pl->getQuestionType(), $type_tag) == 0) {
 
 1712                    return $pl->getQuestionTypeTranslation();
 
 1730        if ($question_type) {
 
 1732            $question = 
new $question_type();
 
 1733            $question->loadFromDb($question_id);
 
 1748        if ($question_type) {
 
 1750            $guitype = $question_type . 
"GUI";
 
 1751            $question = 
new $guitype($question_id);
 
 1769            $class = $question_type . 
"Evaluation";
 
 1770            $ev = 
new $class($question, $a_finished_ids);
 
 1785        if (preg_match(
"/<[^>]*?>/", $a_text)) {
 
 1802        $svy_log->debug(
"material count: " . $a_material->getMaterialCount());
 
 1805        for (
$i = 0; 
$i < $a_material->getMaterialCount(); 
$i++) {
 
 1807            if (strcmp(
$material[
"type"], 
"mattext") == 0) {
 
 1810            if (strcmp(
$material[
"type"], 
"matimage") == 0) {
 
 1812                if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches)) {
 
 1814                    if (!is_array(
$_SESSION[
"import_mob_xhtml"])) {
 
 1815                        $_SESSION[
"import_mob_xhtml"] = array();
 
 1817                    array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(), 
"uri" => $matimage->getUri()));
 
 1832    public function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = 
true, $add_mobs = 
true, $a_attrs = 
null)
 
 1834        include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
 1835        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1837        $a_xml_writer->xmlStartTag(
"material");
 
 1839            "type" => 
"text/plain" 
 1841        if ($this->
isHTML($a_material)) {
 
 1842            $attrs[
"type"] = 
"text/xhtml";
 
 1844        if (is_array($a_attrs)) {
 
 1845            $attrs = array_merge($attrs, $a_attrs);
 
 1851            foreach (
$mobs as $mob) {
 
 1854                    "label" => 
"il_" . IL_INST_ID . 
"_mob_" . $mob,
 
 1855                    "uri" => 
"objects/" . 
"il_" . IL_INST_ID . 
"_mob_" . $mob . 
"/" . $mob_obj->getTitle(),
 
 1856                    "type" => 
"spl:html",
 
 1857                    "id" => $this->getId()
 
 1859                $a_xml_writer->xmlElement(
"matimage", $imgattrs, 
null);
 
 1862        if ($close_material_tag) {
 
 1863            $a_xml_writer->xmlEndTag(
"material");
 
 2010        $this->original_id = $original_id;
 
 2015        return $this->original_id;
 
 2041                if (array_key_exists($value, $this->arrData)) {
 
 2042                    return $this->arrData[$value];
 
 2057                $this->arrData[
$key] = $value;
 
 2075        $ilDB->manipulate(
"UPDATE svy_question" .
 
 2076            " SET original_id = " . 
$ilDB->quote($a_original_id, 
"integer") . 
"," .
 
 2077            " obj_fi = " . 
$ilDB->quote($a_object_id, 
"integer") .
 
 2078            " WHERE question_id = " . 
$ilDB->quote($a_question_id, 
"integer"));
 
 2085        $set = 
$ilDB->query(
"SELECT q.question_id,s.obj_fi" .
 
 2086            " FROM svy_question q" .
 
 2087            " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)" .
 
 2088            " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)" .
 
 2089            " WHERE original_id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
 2091        while (
$row = 
$ilDB->fetchAssoc($set)) {
 
 2092            if (!$a_group_by_survey) {
 
 2112        $set = 
$ilDB->query(
"SELECT svy_svy.obj_fi FROM svy_svy_qst" .
 
 2113            " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)" .
 
 2114            " WHERE svy_svy_qst.question_fi = " . 
$ilDB->quote($a_question_id, 
"integer"));
 
 2116        if (
$ilDB->numRows($set)) {
 
 2117            return $row[
"obj_fi"];
 
 2133        $set = 
$ilDB->query(
 
 2134            "SELECT obj_fi FROM svy_question " .
 
 2135            " WHERE question_id = " . 
$ilDB->quote($a_qid, 
"integer")
 
 2137        $rec = 
$ilDB->fetchAssoc($set);
 
 2138        return $rec[
"obj_fi"];
 
 2151        if ($str != $a_str) {
 
An exception for terminatinating execution or to throw for unit testing.
Basic class for all survey question types.
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
getPreconditionValueOutput($value)
Returns the output for a precondition value.
setId($id=-1)
Sets the id of the SurveyQuestion object.
static _getTitle($question_id)
Returns the question title of a question with a given id.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
getOwner()
Gets the creator/owner ID of the SurveyQuestion object.
copyXHTMLMediaObjectsOfQuestion($a_q_id)
Increases the media object usage counter when a question is duplicated.
static _questionExists($question_id)
Returns true if the question already exists in the database.
getQuestionType()
Returns the question type of the question.
getObjId()
Get the reference id of the container object.
static _instanciateQuestionGUI($question_id)
Creates an instance of a question GUI with a given question id.
saveWorkingData($limit_to=LIMIT_NO_LIMIT)
Saves the learners input of the question to the database.
$arrData
data array containing the question data
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
stripSlashesAddSpaceFallback($a_str)
Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mant...
getDescription()
Gets the description string of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
getQuestionTypeID()
Returns the question type ID of the question.
setMaterialsfile($materials_filename, $materials_tempfilename="", $materials_name="")
Sets and uploads the materials uri.
static lookupObjFi($a_qid)
Lookip obj fi.
importResponses($a_data)
Import response data from the question import file.
static _getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.
addMaterials($materials_file, $materials_name="")
Sets the materials uri.
addMaterial($obj_material)
importAdjectives($a_data)
Import bipolar adjectives from the question import file.
__construct($title="", $description="", $author="", $questiontext="", $owner=-1)
SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the Sur...
duplicateMaterials($question_id)
Duplicates the materials of a question.
createNewQuestion()
Creates a new question with a 0 timestamp when a new question is created This assures that an ID is g...
setDescription($description="")
Sets the description string of the SurveyQuestion object.
static _resolveInternalLink($internal_link)
setSurveyId($id=-1)
Sets the survey id of the SurveyQuestion object.
isHTML($a_text)
Checks if a given string contains HTML or not.
addInternalLink($material_id, $title="")
getMaterialsPath()
Returns the materials path for web accessable materials of a question.
phraseExists($title)
Returns true if the phrase title already exists for the current user.
setObjId($obj_id=0)
Set the reference id of the container object.
getAuthor()
Gets the authors name of the SurveyQuestion object.
setMaterial($material_id="", $is_import=false, $material_title="")
Sets a material link for the question.
isComplete()
Returns 1, if a question is complete for use.
getPhrase($phrase_id)
Returns a phrase for a given database id.
static _getInternalLinkHref($target="", $a_parent_ref_id=null)
setOriginalId($original_id)
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getMaterialsPathWeb()
Returns the web image path for web accessable images of a question.
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
QTIMaterialToString($a_material)
Reads an QTI material tag an creates a text string.
getObligatory($survey_id="")
Gets the obligatory state of the question.
getImagePath()
Returns the image path for web accessable images of a question.
deleteMaterial($materials_name="")
Deletes a materials uri with a given name.
setOrientation($orientation=0)
Sets the orientation of the question output.
loadFromDb($question_id)
Loads a SurveyQuestion object from the database.
saveCategoryToDb($categorytext, $neutral=0)
Saves a category to the database.
static _resolveIntLinks($question_id)
static _isComplete($question_id)
Checks whether the question is complete or not.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
getTitle()
Gets the title string of the SurveyQuestion object.
setComplete($a_complete)
Sets the complete state of the question.
prepareTextareaOutput($txt_output, $prepare_for_latex_output=false)
Prepares a string for a text area output in surveys.
importAdditionalMetadata($a_meta)
Import additional meta data from the question import file.
questionTitleExists($title, $questionpool_object="")
Returns TRUE if the question title exists in the database.
duplicate($for_survey=true, $title="", $author="", $owner="", $a_survey_id=0)
Duplicates a survey question.
getPreconditionOptions()
Returns the options for preconditions.
saveMaterial()
save material to db
deleteMaterials($a_array)
Deletes materials.
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
static _lookupSurveyObjId($a_question_id)
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
static _changeOriginalId($a_question_id, $a_original_id, $a_object_id)
Change original id of existing question in db.
saveCompletionStatus($original_id="")
Saves the complete flag to the database.
getSurveyId()
Gets the survey id of the SurveyQuestion object.
saveToDb($original_id="")
Saves a SurveyQuestion object to a database.
getAvailableRelations()
Returns the available relations for the question.
getQuestionDataArray($id)
Returns the question data fields from the database.
$cumulated
An array containing the cumulated results of the question for a given survey.
getOrientation()
Gets the orientation of the question output.
getPreconditionSelectValue($default="", $title, $variable)
Creates a form property for the precondition value.
getCopyIds($a_group_by_survey=false)
addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true, $a_attrs=null)
Creates an XML material tag from a plain text or xhtml text.
usableForPrecondition()
Returns if the question is usable for preconditions.
copyObject($target_questionpool, $title="")
Copies an assOrderingQuestion object.
flushMaterials()
Deletes all materials uris.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
deleteAdditionalTableData($question_id)
Deletes datasets from the additional question table in the database.
static _instanciateQuestionEvaluation($question_id, array $a_finished_ids=null)
Creates an instance of a question evaluation with a given question id.
__set($key, $value)
Object setter.
importMatrix($a_data)
Import matrix rows from the question import file.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
__get($value)
Object getter.
static _lookGlossaryTerm($term_id)
get glossary term
static _saveLink( $a_source_type, $a_source_id, $a_target_type, $a_target_id, $a_target_inst=0, $a_source_lang="-")
save internal link information
static _deleteAllLinksOfSource($a_source_type, $a_source_id, $a_lang="-")
Delete all links of a given source.
static _getIdForImportId($a_type, $a_target)
Get current id for an import id.
static _getIdForImportId($a_import_id)
get current object id for import id (static)
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static getLogger($a_component_id)
Get component logger.
Class ilObjContentObjectGUI.
static _isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
Synchronises appearances of media objects in $a_text with media object usage table.
static handleQuestionDeletion($a_question_id, $a_obj_id)
Remove question skill assignment.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static removeTrailingPathSeparators($path)
const LIMIT_NO_LIMIT
Assessment constants.
foreach($_POST as $key=> $value) $res