24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
107 if($minimum !== NULL)
109 $minimum = (float)$minimum;
127 if($maximum !== NULL)
129 $maximum = (float)$maximum;
159 if ((strlen($this->minimum) == 0) && ($this->
getSubtype() > 3))
163 return (strlen($this->minimum)) ? $this->minimum : NULL;
175 return (strlen($this->maximum)) ? $this->maximum : NULL;
195 return $ilDB->fetchAssoc(
$result);
226 $this->label =
$data[
'label'];
227 include_once(
"./Services/RTE/classes/class.ilRTE.php");
234 $result = $ilDB->queryF(
"SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s",
242 $this->minimum =
$data[
"value1"];
243 if ((
$data[
"value2"] < 0)
or (strcmp(
$data[
"value2"],
"") == 0))
249 $this->maximum =
$data[
"value2"];
254 parent::loadFromDb(
$id);
288 $affectedRows = parent::saveToDb($original_id);
289 if ($affectedRows == 1)
291 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
295 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, subtype) VALUES (%s, %s)",
296 array(
'integer',
'text'),
304 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_variable WHERE question_fi = %s",
309 if (preg_match(
"/[\D]/", $this->maximum)
or (strcmp($this->maximum,
"∞") == 0))
317 $next_id = $ilDB->nextId(
'svy_variable');
318 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, value2, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
319 array(
'integer',
'integer',
'integer',
'float',
'float',
'integer',
'integer'),
331 function toXML($a_include_header = TRUE, $obligatory_state =
"")
333 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
336 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
337 $xml = $a_xml_writer->xmlDumpMem(FALSE);
338 if (!$a_include_header)
340 $pos = strpos($xml,
"?>");
341 $xml = substr($xml, $pos + 2);
353 function insertXML(&$a_xml_writer, $a_include_header = TRUE)
356 "id" => $this->
getId(),
358 "type" => $this->getQuestiontype(),
362 $a_xml_writer->xmlStartTag(
"question", $attrs);
364 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
365 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
366 $a_xml_writer->xmlStartTag(
"questiontext");
368 $a_xml_writer->xmlEndTag(
"questiontext");
370 $a_xml_writer->xmlStartTag(
"responses");
404 "format" =>
"integer" 416 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
417 $a_xml_writer->xmlEndTag(
"response_num");
419 $a_xml_writer->xmlEndTag(
"responses");
421 if (count($this->material))
423 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
426 "label" => $this->material[
"title"]
428 $a_xml_writer->xmlStartTag(
"material", $attrs);
429 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
430 if (strcmp($matches[1],
"") != 0)
432 $intlink = $this->material[
"internal_link"];
434 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
435 $a_xml_writer->xmlEndTag(
"material");
439 $a_xml_writer->xmlEndTag(
"question");
451 $result = $ilDB->queryF(
"SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
456 return $row[
"questiontype_id"];
467 return "SurveyMetricQuestion";
478 return "svy_qst_metric";
489 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
491 if (strlen($entered_value))
493 array_push(
$data,
array(
"value" => $entered_value));
509 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
511 $entered_value = str_replace(
",",
".", $entered_value);
515 if (strlen($entered_value) == 0)
return $this->lng->txt(
"survey_question_obligatory");
521 return $this->lng->txt(
"metric_question_out_of_bounds");
535 return $this->lng->txt(
"metric_question_out_of_bounds");
540 if (!is_numeric($entered_value))
542 return $this->lng->txt(
"metric_question_not_a_value");
545 if (($this->getSubType() == self::SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value)))
547 return $this->lng->txt(
"metric_question_floating_point");
556 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
559 $entered_value = str_replace(
",",
".", $entered_value);
563 return array(
array(
"value"=>$entered_value,
"textanswer"=>null));
565 if (strlen($entered_value) == 0)
return;
567 $next_id = $ilDB->nextId(
'svy_answer');
570 $fields[
'answer_id'] =
array(
"integer", $next_id);
571 $fields[
'question_fi'] =
array(
"integer", $this->
getId());
572 $fields[
'active_fi'] =
array(
"integer", $active_id);
573 $fields[
'value'] =
array(
"float", (strlen($entered_value)) ? $entered_value : NULL);
574 $fields[
'textanswer'] =
array(
"clob", NULL);
575 $fields[
'tstamp'] =
array(
"integer",
time());
577 $affectedRows = $ilDB->insert(
"svy_answer", $fields);
614 return array(
"<",
"<=",
"=",
"<>",
">=",
">");
625 $template->setCurrentBlock(
"textfield");
626 $template->setVariable(
"TEXTFIELD_VALUE",
"");
627 $template->parseCurrentBlock();
638 include_once
"./Services/Form/classes/class.ilNumberInputGUI.php";
640 $step3->setValue($default);
654 if (strlen($min) && strlen($max))
656 return "(" . $min .
" " . strtolower($this->lng->txt(
"to")) .
" " . $max .
")";
658 else if (strlen($min))
660 return "(>= " . $min .
")";
662 else if (strlen($max))
664 return "(<= " . $max .
")";
getQuestionTypeID()
Returns the question type ID of the question.
outPreconditionSelectValue(&$template)
Creates a value selection for preconditions.
const SUBTYPE_RATIO_NON_ABSOLUTE
getAuthor()
Gets the authors name of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.
setSubtype($subtype=self::SUBTYPE_NON_RATIO)
Sets the question subtype.
getMaximum()
Returns the maximum value of the question.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
setId($id=-1)
Sets the id of the SurveyQuestion object.
getAvailableRelations()
Returns the available relations for the question.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getSubtype()
Gets the question subtype.
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...
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
isComplete()
Returns true if the question is complete for use.
setComplete($a_complete)
Sets the complete state of the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setMinimum($minimum=0)
Sets the minimum value.
loadFromDb($id)
Loads a SurveyMetricQuestion object from the database.
setOriginalId($original_id)
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
getMinimum()
Returns the minimum value of the question.
saveToDb($original_id="")
Saves a SurveyMetricQuestion object to a database.
importResponses($a_data)
Import response data from the question import file.
Basic class for all survey question types.
saveMaterial()
save material to db
xmlHeader()
Writes xml header public.
toXML($a_include_header=TRUE, $obligatory_state="")
Returns an xml representation of the question.
usableForPrecondition()
Returns if the question is usable for preconditions.
getQuestionType()
Returns the question type of the question.
Create styles array
The data for the language used.
saveUserInput($post_data, $active_id, $a_return=false)
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
const SUBTYPE_RATIO_ABSOLUTE
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.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
insertXML(&$a_xml_writer, $a_include_header=TRUE)
Adds the question XML to a given XMLWriter object.
checkUserInput($post_data, $survey_id)
Checks the input of the active user for obligatory status and entered values.
getMinMaxText()
Creates a text for the input range of the metric question.
getPreconditionSelectValue($default="", $title, $variable)
Creates a form property for the precondition value.
__construct($title="", $description="", $author="", $questiontext="", $owner=-1, $subtype=self::SUBTYPE_NON_RATIO)
SurveyMetricQuestion constructor.
getDescription()
Gets the description string of the SurveyQuestion object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setObjId($obj_id=0)
Set the reference id of the container object.
getQuestionDataArray($id)
Returns the question data fields from the database.
setMaximum($maximum="")
Sets the maximum value.
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
setTitle($title="")
Sets the title string of the SurveyQuestion object.