24include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
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;
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)
293 array($this->
getId())
296 array(
'integer',
'text'),
297 array($this->
getId(), $this->getSubType())
304 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM svy_variable WHERE question_fi = %s",
306 array($this->
getId())
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'),
320 array($next_id, 0, $this->
getId(), $this->
getMinimum(), $max, 0, time())
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 .
")";
An exception for terminatinating execution or to throw for unit testing.
getQuestionType()
Returns the question type of the question.
saveToDb($original_id="")
Saves a SurveyMetricQuestion object to a database.
getQuestionTypeID()
Returns the question type ID of the question.
getQuestionDataArray($id)
Returns the question data fields from the database.
getSubtype()
Gets the question subtype.
setMaximum($maximum="")
Sets the maximum value.
outPreconditionSelectValue(&$template)
Creates a value selection for preconditions.
getPreconditionSelectValue($default="", $title, $variable)
Creates a form property for the precondition value.
getAvailableRelations()
Returns the available relations for the question.
checkUserInput($post_data, $survey_id)
Checks the input of the active user for obligatory status and entered values.
const SUBTYPE_RATIO_NON_ABSOLUTE
getMinMaxText()
Creates a text for the input range of the metric question.
__construct($title="", $description="", $author="", $questiontext="", $owner=-1, $subtype=self::SUBTYPE_NON_RATIO)
SurveyMetricQuestion constructor.
getMinimum()
Returns the minimum value of the question.
const SUBTYPE_RATIO_ABSOLUTE
getAdditionalTableName()
Returns the name of the additional question data table in the database.
saveUserInput($post_data, $active_id, $a_return=false)
setSubtype($subtype=self::SUBTYPE_NON_RATIO)
Sets the question subtype.
insertXML(&$a_xml_writer, $a_include_header=TRUE)
Adds the question XML to a given XMLWriter object.
isComplete()
Returns true if the question is complete for use.
getMaximum()
Returns the maximum value of the question.
toXML($a_include_header=TRUE, $obligatory_state="")
Returns an xml representation of the question.
loadFromDb($id)
Loads a SurveyMetricQuestion object from the database.
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
importResponses($a_data)
Import response data from the question import file.
setMinimum($minimum=0)
Sets the minimum value.
usableForPrecondition()
Returns if the question is usable for preconditions.
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.
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.
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.
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.