24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
86 $this->db = $DIC->database();
163 if ((strlen($this->minimum) == 0) && ($this->
getSubtype() > 3)) {
166 return (strlen($this->minimum)) ? $this->minimum : null;
178 return (strlen($this->maximum)) ? $this->maximum : null;
227 $this->label =
$data[
'label'];
228 include_once(
"./Services/RTE/classes/class.ilRTE.php");
236 "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)) {
246 $this->maximum =
$data[
"value2"];
251 parent::loadFromDb(
$id);
282 $affectedRows = parent::saveToDb($original_id);
283 if ($affectedRows == 1) {
284 $affectedRows =
$ilDB->manipulateF(
289 $affectedRows =
$ilDB->manipulateF(
291 array(
'integer',
'text'),
299 $affectedRows =
$ilDB->manipulateF(
300 "DELETE FROM svy_variable WHERE question_fi = %s",
305 if (preg_match(
"/[\D]/", $this->maximum) or (strcmp($this->maximum,
"∞") == 0)) {
310 $next_id =
$ilDB->nextId(
'svy_variable');
311 $affectedRows =
$ilDB->manipulateF(
312 "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, value2, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
313 array(
'integer',
'integer',
'integer',
'float',
'float',
'integer',
'integer'),
325 public function toXML($a_include_header =
true, $obligatory_state =
"")
327 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
330 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
331 $xml = $a_xml_writer->xmlDumpMem(
false);
332 if (!$a_include_header) {
333 $pos = strpos(
$xml,
"?>");
346 public function insertXML(&$a_xml_writer, $a_include_header =
true)
349 "id" => $this->
getId(),
351 "type" => $this->getQuestiontype(),
355 $a_xml_writer->xmlStartTag(
"question", $attrs);
357 $a_xml_writer->xmlElement(
"description", null, $this->
getDescription());
358 $a_xml_writer->xmlElement(
"author", null, $this->
getAuthor());
359 $a_xml_writer->xmlStartTag(
"questiontext");
361 $a_xml_writer->xmlEndTag(
"questiontext");
363 $a_xml_writer->xmlStartTag(
"responses");
392 "format" =>
"integer" 402 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
403 $a_xml_writer->xmlEndTag(
"response_num");
405 $a_xml_writer->xmlEndTag(
"responses");
407 if (count($this->material)) {
408 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
410 "label" => $this->material[
"title"]
412 $a_xml_writer->xmlStartTag(
"material", $attrs);
413 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
414 if (strcmp($matches[1],
"") != 0) {
415 $intlink = $this->material[
"internal_link"];
417 $a_xml_writer->xmlElement(
"mattext", null, $intlink);
418 $a_xml_writer->xmlEndTag(
"material");
422 $a_xml_writer->xmlEndTag(
"question");
435 "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
440 return $row[
"questiontype_id"];
451 return "SurveyMetricQuestion";
462 return "svy_qst_metric";
473 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
475 if (strlen($entered_value)) {
476 array_push(
$data,
array(
"value" => $entered_value));
492 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
494 $entered_value = str_replace(
",",
".", $entered_value);
500 if (strlen($entered_value) == 0) {
501 return $this->lng->txt(
"survey_question_obligatory");
506 return $this->lng->txt(
"metric_question_out_of_bounds");
515 return $this->lng->txt(
"metric_question_out_of_bounds");
520 if (!is_numeric($entered_value)) {
521 return $this->lng->txt(
"metric_question_not_a_value");
524 if (($this->getSubType() == self::SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value))) {
525 return $this->lng->txt(
"metric_question_floating_point");
534 $entered_value = $post_data[$this->
getId() .
"_metric_question"];
537 $entered_value = str_replace(
",",
".", $entered_value);
540 return array(
array(
"value"=>$entered_value,
"textanswer"=>null));
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", null);
554 $fields[
'tstamp'] =
array(
"integer",
time());
556 $affectedRows =
$ilDB->insert(
"svy_answer", $fields);
592 return array(
"<",
"<=",
"=",
"<>",
">=",
">");
604 $template->setVariable(
"TEXTFIELD_VALUE",
"");
616 include_once
"./Services/Form/classes/class.ilNumberInputGUI.php";
618 $step3->setValue($default);
632 if (strlen($min) && strlen($max)) {
633 return "(" . $min .
" " . strtolower($this->lng->txt(
"to")) .
" " . $max .
")";
634 } elseif (strlen($min)) {
635 return "(>= " . $min .
")";
636 } elseif (strlen($max)) {
637 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.
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
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.
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.