24include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
   61        $this->db = 
$DIC->database();
 
   62        $this->
user = $DIC->user();
 
   63        $this->lng = 
$DIC->language();
 
   66        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
 
   83            "SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s ORDER BY svy_phrase_cat.sequence",
 
   88            if ((
$row[
"defaultvalue"] == 1) and (
$row[
"owner_fi"] == 0)) {
 
  109            "SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s AND (svy_category.owner_fi = 0 OR svy_category.owner_fi = %s) ORDER BY svy_phrase_cat.sequence",
 
  110            array(
'integer', 
'integer'),
 
  111            array($phrase_id, 
$ilUser->getId())
 
  114            $neutral = 
$row[
"neutral"];
 
  115            if ((
$row[
"defaultvalue"] == 1) and (
$row[
"owner_fi"] == 0)) {
 
  116                $this->categories->addCategory($this->lng->txt(
$row[
"title"]), 0, $neutral);
 
  118                $this->categories->addCategory(
$row[
"title"], 0, $neutral);
 
  165            $this->label = 
$data[
'label'];
 
  170            include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  177            $this->categories->flushCategories();
 
  179                "SELECT svy_variable.*, svy_category.title, svy_category.neutral FROM svy_variable, svy_category WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ORDER BY sequence ASC",
 
  185                    $this->categories->addCategory(
$data[
"title"], 
$data[
"other"], 
$data[
"neutral"], 
null, (
$data[
'scale']) ? 
$data[
'scale'] : (
$data[
'sequence'] + 1));
 
  189        parent::loadFromDb(
$id);
 
  204            $this->categories->getCategoryCount()
 
  221        $affectedRows = parent::saveToDb($original_id);
 
  222        if ($affectedRows == 1) {
 
  223            $this->log->debug(
"Before save Category-> DELETE from svy_qst_sc WHERE question_fi = " . $this->
getId() . 
" AND INSERT again the same id and orientation in svy_qst_sc");
 
  224            $affectedRows = 
$ilDB->manipulateF(
 
  227                array($this->
getId())
 
  229            $affectedRows = 
$ilDB->manipulateF(
 
  231                array(
'integer', 
'text'),
 
  247        $this->log->debug(
"DELETE from svy_variable before the INSERT into svy_variable. if scale > 0  we get scale value else we get null");
 
  249        $affectedRows = 
$ilDB->manipulateF(
 
  250            "DELETE FROM svy_variable WHERE question_fi = %s",
 
  252            array($this->
getId())
 
  255        for (
$i = 0; 
$i < $this->categories->getCategoryCount(); 
$i++) {
 
  256            $cat = $this->categories->getCategory(
$i);
 
  258            $next_id = 
$ilDB->nextId(
'svy_variable');
 
  259            $affectedRows = 
$ilDB->manipulateF(
 
  260                "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
 
  261                array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer', 
'integer',
'integer'),
 
  262                array($next_id, $category_id, $this->
getId(), (
$i + 1), $cat->other, 
$i, ($cat->scale > 0) ? $cat->scale : 
null, time())
 
  265            $debug_scale = ($cat->scale > 0) ? $cat->scale : 
null;
 
  266            $this->log->debug(
"INSERT INTO svy_variable category_fi= " . $category_id . 
" question_fi= " . $this->getId() . 
" value1= " . (
$i + 1) . 
" other= " . $cat->other . 
" sequence= " . 
$i . 
" scale =" . $debug_scale);
 
  277    public function toXML($a_include_header = 
true, $obligatory_state = 
"")
 
  279        include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
  282        $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
 
  283        $xml = $a_xml_writer->xmlDumpMem(
false);
 
  284        if (!$a_include_header) {
 
  285            $pos = strpos(
$xml, 
"?>");
 
  298    public function insertXML(&$a_xml_writer, $a_include_header = 
true)
 
  301            "id" => $this->
getId(),
 
  303            "type" => $this->getQuestiontype(),
 
  306        $a_xml_writer->xmlStartTag(
"question", $attrs);
 
  308        $a_xml_writer->xmlElement(
"description", 
null, $this->
getDescription());
 
  309        $a_xml_writer->xmlElement(
"author", 
null, $this->
getAuthor());
 
  310        if (strlen($this->label)) {
 
  312                "label" => $this->label,
 
  317        $a_xml_writer->xmlStartTag(
"questiontext", $attrs);
 
  319        $a_xml_writer->xmlEndTag(
"questiontext");
 
  321        $a_xml_writer->xmlStartTag(
"responses");
 
  323        for (
$i = 0; 
$i < $this->categories->getCategoryCount(); 
$i++) {
 
  327            if (strlen($this->categories->getCategory(
$i)->other)) {
 
  328                $attrs[
'other'] = $this->categories->getCategory(
$i)->other;
 
  330            if (strlen($this->categories->getCategory(
$i)->neutral)) {
 
  331                $attrs[
'neutral'] = $this->categories->getCategory(
$i)->neutral;
 
  333            if (strlen($this->categories->getCategory(
$i)->label)) {
 
  334                $attrs[
'label'] = $this->categories->getCategory(
$i)->label;
 
  336            if (strlen($this->categories->getCategory(
$i)->scale)) {
 
  337                $attrs[
'scale'] = $this->categories->getCategory(
$i)->scale;
 
  339            $a_xml_writer->xmlStartTag(
"response_single", $attrs);
 
  340            $this->
addMaterialTag($a_xml_writer, $this->categories->getCategory(
$i)->title);
 
  341            $a_xml_writer->xmlEndTag(
"response_single");
 
  344        $a_xml_writer->xmlEndTag(
"responses");
 
  346        if (count($this->material)) {
 
  347            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
 
  349                    "label" => $this->material[
"title"]
 
  351                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  352                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  353                if (strcmp($matches[1], 
"") != 0) {
 
  354                    $intlink = $this->material[
"internal_link"];
 
  356                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  357                $a_xml_writer->xmlEndTag(
"material");
 
  361        $a_xml_writer->xmlStartTag(
"metadata");
 
  362        $a_xml_writer->xmlStartTag(
"metadatafield");
 
  363        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"orientation");
 
  364        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->
getOrientation());
 
  365        $a_xml_writer->xmlEndTag(
"metadatafield");
 
  366        $a_xml_writer->xmlEndTag(
"metadata");
 
  368        $a_xml_writer->xmlEndTag(
"question");
 
  381        foreach ($a_meta as 
$key => $value) {
 
  382            switch ($value[
"label"]) {
 
  399        for (
$i = $lower_limit; 
$i <= $upper_limit; 
$i++) {
 
  400            $this->categories->addCategory(
$i);
 
  416        $next_id = 
$ilDB->nextId(
'svy_phrase');
 
  417        $affectedRows = 
$ilDB->manipulateF(
 
  418            "INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
  419            array(
'integer',
'text',
'text',
'integer',
'integer'),
 
  422        $phrase_id = $next_id;
 
  426            $next_id = 
$ilDB->nextId(
'svy_category');
 
  427            $affectedRows = 
$ilDB->manipulateF(
 
  428                "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
 
  429                array(
'integer',
'text',
'text',
'integer',
'integer',
'text'),
 
  432            $category_id = $next_id;
 
  433            $next_id = 
$ilDB->nextId(
'svy_phrase_cat');
 
  434            $affectedRows = 
$ilDB->manipulateF(
 
  435                "INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence, other, scale) VALUES (%s, %s, %s, %s, %s, %s)",
 
  436                array(
'integer', 
'integer', 
'integer',
'integer', 
'integer', 
'integer'),
 
  437                array($next_id, $phrase_id, $category_id, 
$counter, (
$data[
'other']) ? 1 : 0, 
$data[
'scale'])
 
  451        return "SurveySingleChoiceQuestion";
 
  473        $entered_value = $post_data[$this->
getId() . 
"_value"];
 
  475        if (strlen($entered_value)) {
 
  476            array_push(
$data, array(
"value" => $entered_value, 
"textanswer" => $post_data[$this->
getId() . 
'_' . $entered_value . 
'_other']));
 
  478        for (
$i = 0; 
$i < $this->categories->getCategoryCount(); 
$i++) {
 
  479            $cat = $this->categories->getCategory(
$i);
 
  481                if (
$i != $entered_value) {
 
  482                    if (strlen($post_data[$this->
getId() . 
"_" . 
$i . 
"_other"])) {
 
  483                        array_push(
$data, array(
"value" => 
$i, 
"textanswer" => $post_data[$this->
getId() . 
'_' . 
$i . 
'_other'], 
"uncheck" => 
true));
 
  502        $entered_value = $post_data[$this->
getId() . 
"_value"];
 
  504        $this->log->debug(
"Entered value = " . $entered_value);
 
  510        if (strlen($entered_value) == 0) {
 
  511            return $this->lng->txt(
"question_not_checked");
 
  514        for (
$i = 0; 
$i < $this->categories->getCategoryCount(); 
$i++) {
 
  515            $cat = $this->categories->getCategory(
$i);
 
  517                if (
$i == $entered_value) {
 
  518                    if (array_key_exists($this->
getId() . 
"_" . $entered_value . 
"_other", $post_data) && !strlen($post_data[$this->
getId() . 
"_" . $entered_value . 
"_other"])) {
 
  519                        return $this->lng->txt(
"question_mr_no_other_answer");
 
  522                    if (strlen($post_data[$this->
getId() . 
"_" . 
$i . 
"_other"])) {
 
  523                        return $this->lng->txt(
"question_sr_no_other_answer_checked");
 
  536        $entered_value = $post_data[$this->
getId() . 
"_value"];
 
  539            return array(array(
"value"=>$entered_value,
 
  540                "textanswer"=>$post_data[$this->
getId() . 
"_" . $entered_value . 
"_other"]));
 
  542        if (strlen($entered_value) == 0) {
 
  546        $next_id = 
$ilDB->nextId(
'svy_answer');
 
  549        $fields[
'answer_id'] = array(
"integer", $next_id);
 
  550        $fields[
'question_fi'] = array(
"integer", $this->
getId());
 
  551        $fields[
'active_fi'] = array(
"integer", $active_id);
 
  552        $fields[
'value'] = array(
"float", (strlen($entered_value)) ? $entered_value : 
null);
 
  553        $fields[
'textanswer'] = array(
"clob", ($post_data[$this->
getId() . 
"_" . $entered_value . 
"_other"]) ? $post_data[$this->
getId() . 
"_" . $entered_value . 
"_other"] : 
null);
 
  554        $fields[
'tstamp'] = array(
"integer", time());
 
  556        $affectedRows = 
$ilDB->insert(
"svy_answer", $fields);
 
  558        $debug_value = (strlen($entered_value)) ? $entered_value : 
"NULL";
 
  559        $debug_answer = ($post_data[$this->
getId() . 
"_" . $entered_value . 
"_other"]) ? $post_data[$this->
getId() . 
"_" . $entered_value . 
"_other"] : 
"NULL";
 
  560        $this->log->debug(
"INSERT svy_answer answer_id=" . $next_id . 
" question_fi=" . $this->
getId() . 
" active_fi=" . $active_id . 
" value=" . $debug_value . 
" textanswer=" . $debug_answer);
 
  576            $this->categories->addCategory(
 
  579                strlen(
$data[
'neutral']) ? 
$data[
'neutral'] : 0,
 
  580                strlen(
$data[
'label']) ? 
$data[
'label'] : 
null,
 
  581                strlen(
$data[
'scale']) ? 
$data[
'scale'] : 
null 
  605        return array(
"<", 
"<=", 
"=", 
"<>", 
">=", 
">");
 
  618        for (
$i = 0; 
$i < $this->categories->getCategoryCount(); 
$i++) {
 
  619            $category = $this->categories->getCategory(
$i);
 
  620            $options[$category->scale-1] = $category->scale . 
" - " . $category->title;
 
  633        include_once 
"./Services/Form/classes/class.ilSelectInputGUI.php";
 
  637        $step3->setValue($default);
 
  651        $category = $this->categories->getCategoryForScale($value+1);
 
  654        return $category->scale .
 
  656            ((strlen($category->title)) ? $category->title : $this->lng->txt(
'other_answer'));
 
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
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.
setId($id=-1)
Sets the id of the SurveyQuestion object.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
getDescription()
Gets the description string of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
setObjId($obj_id=0)
Set the reference id of the container object.
getAuthor()
Gets the authors name of the SurveyQuestion object.
setOriginalId($original_id)
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.
setOrientation($orientation=0)
Sets the orientation of the question output.
saveCategoryToDb($categorytext, $neutral=0)
Saves a category to the database.
getTitle()
Gets the title string of the SurveyQuestion object.
setComplete($a_complete)
Sets the complete state of the question.
saveMaterial()
save material to db
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
saveCompletionStatus($original_id="")
Saves the complete flag to the database.
getOrientation()
Gets the orientation of the question output.
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.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
SingleChoice survey question.
getPreconditionOptions()
Returns the options for preconditions.
getQuestionType()
Returns the question type of the question.
addPhrase($phrase_id)
Adds a phrase to the question.
__construct($title="", $description="", $author="", $questiontext="", $owner=-1, $orientation=1)
SurveySingleChoiceQuestion constructor.
isComplete()
Returns true if the question is complete for use.
savePhrase($title)
Saves a set of categories to a default phrase.
importAdditionalMetadata($a_meta)
Import additional meta data from the question import file.
checkUserInput($post_data, $survey_id)
Checks the input of the active user for obligatory status and entered values.
saveUserInput($post_data, $active_id, $a_return=false)
importResponses($a_data)
Import response data from the question import file.
saveToDb($original_id="")
Saves a SurveySingleChoiceQuestion object to a database.
usableForPrecondition()
Returns if the question is usable for preconditions.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getPreconditionSelectValue($default="", $title, $variable)
Creates a form property for the precondition value.
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
insertXML(&$a_xml_writer, $a_include_header=true)
Adds the question XML to a given XMLWriter object.
getAvailableRelations()
Returns the available relations for the question.
addStandardNumbers($lower_limit, $upper_limit)
Adds standard numbers as categories.
& getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
toXML($a_include_header=true, $obligatory_state="")
Returns an xml representation of the question.
getQuestionDataArray($id)
Returns the question data fields from the database.
loadFromDb($id)
Loads a SurveySingleChoiceQuestion object from the database.
getPreconditionValueOutput($value)
Returns the output for a precondition value.
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...
xmlHeader()
Writes xml header @access public.