62 $this->db = $DIC->database();
139 if ((strlen($this->minimum) == 0) && ($this->
getSubtype() > 3)) {
142 return (strlen($this->minimum)) ? $this->minimum : null;
154 return (strlen($this->maximum)) ? $this->maximum : null;
203 $this->label =
$data[
'label'];
211 "SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s",
217 $this->minimum =
$data[
"value1"];
218 if ((
$data[
"value2"] < 0) or (strcmp(
$data[
"value2"],
"") == 0)) {
221 $this->maximum =
$data[
"value2"];
226 parent::loadFromDb(
$id);
257 $affectedRows = parent::saveToDb($original_id);
258 if ($affectedRows == 1) {
259 $affectedRows =
$ilDB->manipulateF(
262 array($this->
getId())
264 $affectedRows =
$ilDB->manipulateF(
266 array(
'integer',
'text'),
267 array($this->
getId(), $this->getSubType())
274 $affectedRows =
$ilDB->manipulateF(
275 "DELETE FROM svy_variable WHERE question_fi = %s",
277 array($this->
getId())
280 if (preg_match(
"/[\D]/", $this->maximum) or (strcmp($this->maximum,
"∞") == 0)) {
285 $next_id =
$ilDB->nextId(
'svy_variable');
286 $affectedRows =
$ilDB->manipulateF(
287 "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, value2, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
288 array(
'integer',
'integer',
'integer',
'float',
'float',
'integer',
'integer'),
289 array($next_id, 0, $this->
getId(), $this->
getMinimum(), $max, 0, time())
300 public function toXML($a_include_header =
true, $obligatory_state =
"")
304 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
305 $xml = $a_xml_writer->xmlDumpMem(
false);
306 if (!$a_include_header) {
307 $pos = strpos(
$xml,
"?>");
320 public function insertXML(&$a_xml_writer, $a_include_header =
true)
323 "id" => $this->
getId(),
325 "type" => $this->getQuestiontype(),
329 $a_xml_writer->xmlStartTag(
"question", $attrs);
331 $a_xml_writer->xmlElement(
"description", null, $this->
getDescription());
332 $a_xml_writer->xmlElement(
"author", null, $this->
getAuthor());
333 $a_xml_writer->xmlStartTag(
"questiontext");
335 $a_xml_writer->xmlEndTag(
"questiontext");
337 $a_xml_writer->xmlStartTag(
"responses");
366 "format" =>
"integer" 376 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
377 $a_xml_writer->xmlEndTag(
"response_num");
379 $a_xml_writer->xmlEndTag(
"responses");
381 if (count($this->material)) {
382 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
384 "label" => $this->material[
"title"]
386 $a_xml_writer->xmlStartTag(
"material", $attrs);
387 $intlink =
"il_" .
IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
388 if (strcmp($matches[1],
"") != 0) {
389 $intlink = $this->material[
"internal_link"];
391 $a_xml_writer->xmlElement(
"mattext", null, $intlink);
392 $a_xml_writer->xmlEndTag(
"material");
396 $a_xml_writer->xmlEndTag(
"question");
409 "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
414 return $row[
"questiontype_id"];
425 return "SurveyMetricQuestion";
436 return "svy_qst_metric";
447 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
449 if (strlen($entered_value)) {
450 array_push(
$data, array(
"value" => $entered_value));
466 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
468 $entered_value = str_replace(
",",
".", $entered_value);
474 if (strlen($entered_value) == 0) {
475 return $this->lng->txt(
"survey_question_obligatory");
480 return $this->lng->txt(
"metric_question_out_of_bounds");
489 return $this->lng->txt(
"metric_question_out_of_bounds");
494 if (!is_numeric($entered_value)) {
495 return $this->lng->txt(
"metric_question_not_a_value");
498 if (($this->getSubType() == self::SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value))) {
499 return $this->lng->txt(
"metric_question_floating_point");
508 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
511 $entered_value = str_replace(
",",
".", $entered_value);
514 return array(array(
"value" => $entered_value,
"textanswer" => null));
516 if (strlen($entered_value) == 0) {
520 $next_id =
$ilDB->nextId(
'svy_answer');
523 $fields[
'answer_id'] = array(
"integer", $next_id);
524 $fields[
'question_fi'] = array(
"integer", $this->
getId());
525 $fields[
'active_fi'] = array(
"integer", $active_id);
526 $fields[
'value'] = array(
"float", (strlen($entered_value)) ? $entered_value : null);
527 $fields[
'textanswer'] = array(
"clob", null);
528 $fields[
'tstamp'] = array(
"integer", time());
530 $affectedRows =
$ilDB->insert(
"svy_answer", $fields);
566 return array(
"<",
"<=",
"=",
"<>",
">=",
">");
577 $template->setCurrentBlock(
"textfield");
578 $template->setVariable(
"TEXTFIELD_VALUE",
"");
579 $template->parseCurrentBlock();
591 $step3->setValue($default);
605 if (strlen($min) && strlen($max)) {
606 return "(" . $min .
" " . strtolower($this->lng->txt(
"to")) .
" " . $max .
")";
607 } elseif (strlen($min)) {
608 return "(>= " . $min .
")";
609 } elseif (strlen($max)) {
610 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)
toXML($a_include_header=true, $obligatory_state="")
Returns an xml representation of the question.
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.
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.
importResponses($a_data)
Import response data from the question import file.
Basic class for all survey question types.
saveMaterial()
save material to db
insertXML(&$a_xml_writer, $a_include_header=true)
Adds the question XML to a given XMLWriter object.
xmlHeader()
Writes xml header public.
usableForPrecondition()
Returns if the question is usable for preconditions.
getQuestionType()
Returns the question type of the question.
saveUserInput($post_data, $active_id, $a_return=false)
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
const SUBTYPE_RATIO_ABSOLUTE
__construct(Container $dic, ilPlugin $plugin)
setDescription($description="")
Sets the description string of the SurveyQuestion 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.
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.