ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
SurveyMetricQuestion Class Reference

Metric survey question. More...

+ Inheritance diagram for SurveyMetricQuestion:
+ Collaboration diagram for SurveyMetricQuestion:

Public Member Functions

 SurveyMetricQuestion ( $title="", $description="", $author="", $questiontext="", $owner=-1, $subtype=self::SUBTYPE_NON_RATIO)
 SurveyMetricQuestion constructor. More...
 
 setSubtype ($subtype=self::SUBTYPE_NON_RATIO)
 Sets the question subtype. More...
 
 setMinimum ($minimum=0)
 Sets the minimum value. More...
 
 setMaximum ($maximum="")
 Sets the maximum value. More...
 
 getSubtype ()
 Gets the question subtype. More...
 
 getMinimum ()
 Returns the minimum value of the question. More...
 
 getMaximum ()
 Returns the maximum value of the question. More...
 
 _getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
 loadFromDb ($id)
 Loads a SurveyMetricQuestion object from the database. More...
 
 isComplete ()
 Returns true if the question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a SurveyMetricQuestion object to a database. More...
 
 toXML ($a_include_header=TRUE, $obligatory_state="")
 Returns an xml representation of the question. More...
 
 insertXML (&$a_xml_writer, $a_include_header=TRUE, $obligatory_state="")
 Adds the question XML to a given XMLWriter object. More...
 
 getQuestionTypeID ()
 Returns the question type ID of the question. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 checkUserInput ($post_data, $survey_id)
 Checks the input of the active user for obligatory status and entered values. More...
 
 saveRandomData ($active_id)
 Saves random answers for a given active user in the database. More...
 
 saveUserInput ($post_data, $active_id, $a_return=false)
 
getCumulatedResults ($survey_id, $nr_of_users, $finished_ids)
 
 setExportDetailsXLS (&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 addUserSpecificResultsData (&$a_array, &$resultset)
 Adds the values for the user specific results export for a given user. More...
 
getUserAnswers ($survey_id, $finished_ids)
 Returns an array containing all answers to this question in a given survey. More...
 
 importResponses ($a_data)
 Import response data from the question import file. More...
 
 usableForPrecondition ()
 Returns if the question is usable for preconditions. More...
 
 getAvailableRelations ()
 Returns the available relations for the question. More...
 
 outPreconditionSelectValue (&$template)
 Creates a value selection for preconditions. More...
 
 getPreconditionSelectValue ($default="", $title, $variable)
 Creates a form property for the precondition value. More...
 
 getMinMaxText ()
 Creates a text for the input range of the metric question. More...
 
- Public Member Functions inherited from SurveyQuestion
 SurveyQuestion ( $title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyQuestion object. More...
 
 _SurveyQuestion ()
 
 setComplete ($a_complete)
 Sets the complete state of the question. More...
 
 isComplete ()
 Returns 1, if a question is complete for use. More...
 
 questionTitleExists ($title, $questionpool_object="")
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the SurveyQuestion object. More...
 
 setObligatory ($obligatory=1)
 Sets the obligatory state of the question. More...
 
 setOrientation ($orientation=0)
 Sets the orientation of the question output. More...
 
 setId ($id=-1)
 Sets the id of the SurveyQuestion object. More...
 
 setSurveyId ($id=-1)
 Sets the survey id of the SurveyQuestion object. More...
 
 setDescription ($description="")
 Sets the description string of the SurveyQuestion object. More...
 
 addMaterials ($materials_file, $materials_name="")
 Sets the materials uri. More...
 
 setMaterialsfile ($materials_filename, $materials_tempfilename="", $materials_name="")
 Sets and uploads the materials uri. More...
 
 deleteMaterial ($materials_name="")
 Deletes a materials uri with a given name. More...
 
 flushMaterials ()
 Deletes all materials uris. More...
 
 setAuthor ($author="")
 Sets the authors name of the SurveyQuestion object. More...
 
 setQuestiontext ($questiontext="")
 Sets the questiontext of the SurveyQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the SurveyQuestion object. More...
 
 getTitle ()
 Gets the title string of the SurveyQuestion object. More...
 
 getId ()
 Gets the id of the SurveyQuestion object. More...
 
 getObligatory ($survey_id="")
 Gets the obligatory state of the question. More...
 
 getSurveyId ()
 Gets the survey id of the SurveyQuestion object. More...
 
 getOrientation ()
 Gets the orientation of the question output. More...
 
 getDescription ()
 Gets the description string of the SurveyQuestion object. More...
 
 getAuthor ()
 Gets the authors name of the SurveyQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the SurveyQuestion object. More...
 
 getQuestiontext ()
 Gets the questiontext of the SurveyQuestion object. More...
 
 getObjId ()
 Get the reference id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the reference id of the container object. More...
 
 duplicate ($for_survey=true, $title="", $author="", $owner="")
 Duplicates a survey question. More...
 
 copyObject ($target_questionpool, $title="")
 Copies an assOrderingQuestion object. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 Increases the media object usage counter when a question is duplicated. More...
 
 loadFromDb ($question_id)
 Loads a SurveyQuestion object from the database. More...
 
 _isComplete ($question_id)
 Checks whether the question is complete or not. More...
 
 saveCompletionStatus ($original_id="")
 Saves the complete flag to the database. More...
 
 saveToDb ($original_id="")
 Saves a SurveyQuestion object to a database. More...
 
 saveMaterial ()
 save material to db More...
 
 createNewQuestion ()
 Creates a new question with a 0 timestamp when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveWorkingData ($limit_to=LIMIT_NO_LIMIT)
 Saves the learners input of the question to the database. More...
 
 getImagePath ()
 Returns the image path for web accessable images of a question. More...
 
 getMaterialsPath ()
 Returns the materials path for web accessable materials of a question. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getMaterialsPathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 saveCategoryToDb ($categorytext, $neutral=0)
 Saves a category to the database. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 _getOriginalId ($question_id, $a_return_question_id_if_no_original=true)
 Returns the original id of a question. More...
 
 syncWithOriginal ()
 
 getPhrase ($phrase_id)
 Returns a phrase for a given database id. More...
 
 phraseExists ($title)
 Returns true if the phrase title already exists for the current user. More...
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 addInternalLink ($material_id, $title="")
 
 deleteMaterials ($a_array)
 Deletes materials. More...
 
 duplicateMaterials ($question_id)
 Duplicates the materials of a question. More...
 
 addMaterial ($obj_material)
 
 setMaterial ($material_id="", $is_import=false, $material_title="")
 Sets a material link for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 _getInternalLinkHref ($target="", $a_parent_ref_id=null)
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 getQuestionTypeID ()
 Returns the question type ID of the question. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
_instanciateQuestionGUI ($question_id)
 Creates an instance of a question GUI with a given question id. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 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. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in surveys. More...
 
 _getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
 addUserSpecificResultsExportTitles (&$a_array, $a_use_label=false, $a_substitute=true)
 Adds the entries for the title row of the user specific results. More...
 
 addUserSpecificResultsData (&$a_array, &$resultset)
 Adds the values for the user specific results export for a given user. More...
 
getUserAnswers ($survey_id)
 Returns an array containing all answers to this question in a given survey. More...
 
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 importAdditionalMetadata ($a_meta)
 Import additional meta data from the question import file. More...
 
 importResponses ($a_data)
 Import response data from the question import file. More...
 
 importAdjectives ($a_data)
 Import bipolar adjectives from the question import file. More...
 
 importMatrix ($a_data)
 Import matrix rows from the question import file. More...
 
 setExportCumulatedXLS (&$worksheet, &$format_title, &$format_bold, &$eval_data, $row, $export_label)
 Creates the Excel output for the cumulated results of this question. More...
 
setExportCumulatedCVS (&$eval_data, $export_label)
 Creates the CSV output for the cumulated results of this question. More...
 
 setExportDetailsXLS (&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 usableForPrecondition ()
 Returns if the question is usable for preconditions. More...
 
 getAvailableRelations ()
 Returns the available relations for the question. More...
 
 getPreconditionOptions ()
 Returns the options for preconditions. More...
 
 getPreconditionValueOutput ($value)
 Returns the output for a precondition value. More...
 
 getPreconditionSelectValue ($default="", $title, $variable)
 Creates a form property for the precondition value. More...
 
 outChart ($survey_id, $type="")
 Creates an image visualising the results of the question. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 saveRandomData ($active_id)
 Saves random answers for a given active user in the database. More...
 
 getMaterial ()
 
 setSubtype ($a_subtype)
 
 getSubtype ()
 
 getCumulatedResultData ($survey_id, $counter, $finished_ids)
 Creates a the cumulated results data for the question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getCopyIds ($a_group_by_survey=false)
 
 hasCopies ()
 
 getSkippedValue ()
 

Data Fields

const SUBTYPE_NON_RATIO = 3
 
const SUBTYPE_RATIO_NON_ABSOLUTE = 4
 
const SUBTYPE_RATIO_ABSOLUTE = 5
 
 $subtype
 
 $minimum
 
 $maximum
 
- Data Fields inherited from SurveyQuestion
 $id
 
 $title
 
 $description
 
 $owner
 
 $author
 
 $materials
 
 $survey_id
 
 $obj_id
 
 $questiontext
 
 $obligatory
 
 $ilias
 
 $tpl
 
 $lng
 
 $orientation
 
 $material
 
 $complete
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestion
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static _changeOriginalId ($a_question_id, $a_original_id, $a_object_id)
 Change original id of existing question in db. More...
 
- Protected Member Functions inherited from SurveyQuestion
calculateCumulatedResults ($survey_id, $finished_ids)
 
- Protected Attributes inherited from SurveyQuestion
 $cumulated
 An array containing the cumulated results of the question for a given survey. More...
 

Detailed Description

Metric survey question.

The SurveyMetricQuestion class defines and encapsulates basic methods and attributes for metric survey question types.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 37 of file class.SurveyMetricQuestion.php.

Member Function Documentation

◆ _getQuestionDataArray()

SurveyMetricQuestion::_getQuestionDataArray (   $id)

Returns the question data fields from the database.

Parameters
integer$idThe question ID from the database
Returns
array Array containing the question fields and data from the database public

Definition at line 191 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\$id, $result, and getAdditionalTableName().

192  {
193  global $ilDB;
194 
195  $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question, " . $this->getAdditionalTableName() . " WHERE svy_question.question_id = %s AND svy_question.question_id = " . $this->getAdditionalTableName() . ".question_fi",
196  array('integer'),
197  array($id)
198  );
199  if ($result->numRows() == 1)
200  {
201  return $ilDB->fetchAssoc($result);
202  }
203  else
204  {
205  return array();
206  }
207  }
$result
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:

◆ addUserSpecificResultsData()

SurveyMetricQuestion::addUserSpecificResultsData ( $a_array,
$resultset 
)

Adds the values for the user specific results export for a given user.

Parameters
array$a_arrayAn array which is used to append the values
array$resultsetThe evaluation data for a given user public

Definition at line 791 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\getId(), and SurveyQuestion\getSkippedValue().

792  {
793  if (count($resultset["answers"][$this->getId()]))
794  {
795  foreach ($resultset["answers"][$this->getId()] as $key => $answer)
796  {
797  array_push($a_array, $answer["value"]);
798  }
799  }
800  else
801  {
802  array_push($a_array, $this->getSkippedValue());
803  }
804  }
getId()
Gets the id of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ checkUserInput()

SurveyMetricQuestion::checkUserInput (   $post_data,
  $survey_id 
)

Checks the input of the active user for obligatory status and entered values.

Parameters
array$post_dataThe contents of the $_POST array
integer$survey_idThe database ID of the active survey
Returns
string Empty string if the input is ok, an error message otherwise public

Definition at line 514 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\$survey_id, SurveyQuestion\getId(), getMaximum(), getMinimum(), and SurveyQuestion\getObligatory().

515  {
516  $entered_value = $post_data[$this->getId() . "_metric_question"];
517  // replace german notation with international notation
518  $entered_value = str_replace(",", ".", $entered_value);
519 
520  if ((!$this->getObligatory($survey_id)) && (strlen($entered_value) == 0)) return "";
521 
522  if (strlen($entered_value) == 0) return $this->lng->txt("survey_question_obligatory");
523 
524  if (strlen($this->getMinimum()))
525  {
526  if ($entered_value < $this->getMinimum())
527  {
528  return $this->lng->txt("metric_question_out_of_bounds");
529  }
530  }
531 
532  if (strlen($this->getMaximum()))
533  {
534  if (($this->getMaximum() == 1) && ($this->getMaximum() < $this->getMinimum()))
535  {
536  // old &infty; values as maximum
537  }
538  else
539  {
540  if ($entered_value > $this->getMaximum())
541  {
542  return $this->lng->txt("metric_question_out_of_bounds");
543  }
544  }
545  }
546 
547  if (!is_numeric($entered_value))
548  {
549  return $this->lng->txt("metric_question_not_a_value");
550  }
551 
552  if (($this->getSubType() == self::SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value)))
553  {
554  return $this->lng->txt("metric_question_floating_point");
555  }
556  return "";
557  }
getObligatory($survey_id="")
Gets the obligatory state of the question.
getMaximum()
Returns the maximum value of the question.
getId()
Gets the id of the SurveyQuestion object.
getMinimum()
Returns the minimum value of the question.
+ Here is the call graph for this function:

◆ getAdditionalTableName()

SurveyMetricQuestion::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Returns
string The additional table name public

Definition at line 483 of file class.SurveyMetricQuestion.php.

Referenced by _getQuestionDataArray(), loadFromDb(), and saveToDb().

484  {
485  return "svy_qst_metric";
486  }
+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyMetricQuestion::getAvailableRelations ( )

Returns the available relations for the question.

Returns
array An array containing the available relations public

Definition at line 868 of file class.SurveyMetricQuestion.php.

869  {
870  return array("<", "<=", "=", "<>", ">=", ">");
871  }

◆ getCumulatedResults()

& SurveyMetricQuestion::getCumulatedResults (   $survey_id,
  $nr_of_users,
  $finished_ids 
)

Definition at line 598 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\$cumulated, $result, $row, SurveyQuestion\$survey_id, $total, and SurveyQuestion\getId().

599  {
600  global $ilDB;
601 
602  $question_id = $this->getId();
603 
604  $result_array = array();
605  $cumulated = array();
606 
607  $sql = "SELECT svy_answer.* FROM svy_answer".
608  " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
609  " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id, "integer").
610  " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
611  if($finished_ids)
612  {
613  $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
614  }
615 
616  $result = $ilDB->query($sql);
617  while ($row = $ilDB->fetchAssoc($result))
618  {
619  $cumulated[$row["value"]]++;
620  }
621  asort($cumulated, SORT_NUMERIC);
622  end($cumulated);
623  $numrows = $result->numRows();
624  $result_array["USERS_ANSWERED"] = $result->numRows();
625  $result_array["USERS_SKIPPED"] = $nr_of_users - $result->numRows();
626  if(sizeof($cumulated))
627  {
628  $result_array["MODE"] = key($cumulated);
629  $result_array["MODE_VALUE"] = key($cumulated);
630  $result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
631  ksort($cumulated, SORT_NUMERIC);
632  }
633  $counter = 0;
634  foreach ($cumulated as $value => $nr_of_users)
635  {
636  $percentage = 0;
637  if ($numrows > 0)
638  {
639  $percentage = (float)($nr_of_users/$numrows);
640  }
641  $result_array["values"][$counter++] = array("value" => $value, "selected" => (int)$nr_of_users, "percentage" => $percentage);
642  }
643  $median = array();
644  $total = 0;
645  $x_i = 0;
646  $p_i = 1;
647  $x_i_inv = 0;
648  $sum_part_zero = false;
649  foreach ($cumulated as $value => $key)
650  {
651  $total += $key;
652  for ($i = 0; $i < $key; $i++)
653  {
654  array_push($median, $value);
655  $x_i += $value;
656  $p_i *= $value;
657  if ($value != 0)
658  {
659  $sum_part_zero = true;
660  $x_i_inv += 1/$value;
661  }
662  }
663  }
664  if ($total > 0)
665  {
666  if (($total % 2) == 0)
667  {
668  $median_value = 0.5 * ($median[($total/2)-1] + $median[($total/2)]);
669  }
670  else
671  {
672  $median_value = $median[(($total+1)/2)-1];
673  }
674  }
675  else
676  {
677  $median_value = "";
678  }
679  if ($total > 0)
680  {
681  if (($x_i/$total) == (int)($x_i/$total))
682  {
683  $result_array["ARITHMETIC_MEAN"] = $x_i/$total;
684  }
685  else
686  {
687  $result_array["ARITHMETIC_MEAN"] = sprintf("%.2f", $x_i/$total);
688  }
689  }
690  else
691  {
692  $result_array["ARITHMETIC_MEAN"] = "";
693  }
694  $result_array["MEDIAN"] = $median_value;
695  $result_array["QUESTION_TYPE"] = "SurveyMetricQuestion";
696  return $result_array;
697  }
$cumulated
An array containing the cumulated results of the question for a given survey.
$result
getId()
Gets the id of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ getMaximum()

SurveyMetricQuestion::getMaximum ( )

Returns the maximum value of the question.

Returns
double The maximum value of the question public
See also
$maximum

Definition at line 179 of file class.SurveyMetricQuestion.php.

Referenced by checkUserInput(), getMinMaxText(), insertXML(), saveRandomData(), and saveToDb().

180  {
181  return (strlen($this->maximum)) ? $this->maximum : NULL;
182  }
+ Here is the caller graph for this function:

◆ getMinimum()

SurveyMetricQuestion::getMinimum ( )

Returns the minimum value of the question.

Returns
double The minimum value of the question public
See also
$minimum

Definition at line 163 of file class.SurveyMetricQuestion.php.

References getSubtype().

Referenced by checkUserInput(), getMinMaxText(), insertXML(), saveRandomData(), and saveToDb().

164  {
165  if ((strlen($this->minimum) == 0) && ($this->getSubtype() > 3))
166  {
167  $this->minimum = 0;
168  }
169  return (strlen($this->minimum)) ? $this->minimum : NULL;
170  }
getSubtype()
Gets the question subtype.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMinMaxText()

SurveyMetricQuestion::getMinMaxText ( )

Creates a text for the input range of the metric question.

Returns
string Range text private

Definition at line 906 of file class.SurveyMetricQuestion.php.

References getMaximum(), and getMinimum().

907  {
908  $min = $this->getMinimum();
909  $max = $this->getMaximum();
910  if (strlen($min) && strlen($max))
911  {
912  return "(" . $min . " " . strtolower($this->lng->txt("to")) . " " . $max . ")";
913  }
914  else if (strlen($min))
915  {
916  return "(&gt;= " . $min . ")";
917  }
918  else if (strlen($max))
919  {
920  return "(&lt;= " . $max . ")";
921  }
922  else
923  {
924  return "";
925  }
926  }
getMaximum()
Returns the maximum value of the question.
getMinimum()
Returns the minimum value of the question.
+ Here is the call graph for this function:

◆ getPreconditionSelectValue()

SurveyMetricQuestion::getPreconditionSelectValue (   $default = "",
  $title,
  $variable 
)

Creates a form property for the precondition value.

Returns
The ILIAS form element public

Definition at line 892 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\$title.

893  {
894  include_once "./Services/Form/classes/class.ilNumberInputGUI.php";
895  $step3 = new ilNumberInputGUI($title, $variable);
896  $step3->setValue($default);
897  return $step3;
898  }
This class represents a number property in a property form.

◆ getQuestionType()

SurveyMetricQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 472 of file class.SurveyMetricQuestion.php.

Referenced by getQuestionTypeID().

473  {
474  return "SurveyMetricQuestion";
475  }
+ Here is the caller graph for this function:

◆ getQuestionTypeID()

SurveyMetricQuestion::getQuestionTypeID ( )

Returns the question type ID of the question.

Returns
integer The question type of the question public

Definition at line 455 of file class.SurveyMetricQuestion.php.

References $result, $row, and getQuestionType().

456  {
457  global $ilDB;
458  $result = $ilDB->queryF("SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
459  array('text'),
460  array($this->getQuestionType())
461  );
462  $row = $ilDB->fetchAssoc($result);
463  return $row["questiontype_id"];
464  }
$result
getQuestionType()
Returns the question type of the question.
+ Here is the call graph for this function:

◆ getSubtype()

SurveyMetricQuestion::getSubtype ( )

Gets the question subtype.

Returns
integer The question subtype public
See also
$subtype

Definition at line 151 of file class.SurveyMetricQuestion.php.

References $subtype.

Referenced by getMinimum(), insertXML(), and setExportDetailsXLS().

152  {
153  return $this->subtype;
154  }
+ Here is the caller graph for this function:

◆ getUserAnswers()

& SurveyMetricQuestion::getUserAnswers (   $survey_id,
  $finished_ids 
)

Returns an array containing all answers to this question in a given survey.

Parameters
integer$survey_idThe database ID of the survey
Returns
array An array containing the answers to the question. The keys are either the user id or the anonymous id public

Definition at line 813 of file class.SurveyMetricQuestion.php.

References $result, $row, SurveyQuestion\$survey_id, and SurveyQuestion\getId().

814  {
815  global $ilDB;
816 
817  $answers = array();
818 
819  $sql = "SELECT svy_answer.* FROM svy_answer".
820  " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
821  " WHERE svy_answer.question_fi = ".$ilDB->quote($this->getId(), "integer").
822  " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
823  if($finished_ids)
824  {
825  $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
826  }
827 
828  $result = $ilDB->query($sql);
829  while ($row = $ilDB->fetchAssoc($result))
830  {
831  $answers[$row["active_fi"]] = $row["value"];
832  }
833  return $answers;
834  }
$result
getId()
Gets the id of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ getWorkingDataFromUserInput()

& SurveyMetricQuestion::getWorkingDataFromUserInput (   $post_data)

Creates the user data of the svy_answer table from the POST data.

Returns
array User data according to the svy_answer table public

Definition at line 494 of file class.SurveyMetricQuestion.php.

References $data, and SurveyQuestion\getId().

495  {
496  $entered_value = $post_data[$this->getId() . "_metric_question"];
497  $data = array();
498  if (strlen($entered_value))
499  {
500  array_push($data, array("value" => $entered_value));
501  }
502  return $data;
503  }
getId()
Gets the id of the SurveyQuestion object.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:

◆ importResponses()

SurveyMetricQuestion::importResponses (   $a_data)

Import response data from the question import file.

Returns
array $a_data Array containing the response data public

Definition at line 842 of file class.SurveyMetricQuestion.php.

References $data, SurveyQuestion\$id, setMaximum(), and setMinimum().

843  {
844  foreach ($a_data as $id => $data)
845  {
846  $this->setMinimum($data["min"]);
847  $this->setMaximum($data["max"]);
848  }
849  }
setMinimum($minimum=0)
Sets the minimum value.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
setMaximum($maximum="")
Sets the maximum value.
+ Here is the call graph for this function:

◆ insertXML()

SurveyMetricQuestion::insertXML ( $a_xml_writer,
  $a_include_header = TRUE,
  $obligatory_state = "" 
)

Adds the question XML to a given XMLWriter object.

Parameters
object$a_xml_writerThe XMLWriter object
boolean$a_include_headerDetermines wheather or not the XML should be used
string$obligatory_stateThe value of the obligatory state public

Definition at line 360 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\addMaterialTag(), SurveyQuestion\getAuthor(), SurveyQuestion\getDescription(), SurveyQuestion\getId(), getMaximum(), getMinimum(), SurveyQuestion\getObligatory(), SurveyQuestion\getQuestiontext(), getSubtype(), and SurveyQuestion\getTitle().

Referenced by toXML().

361  {
362  $attrs = array(
363  "id" => $this->getId(),
364  "title" => $this->getTitle(),
365  "type" => $this->getQuestiontype(),
366  "subtype" => $this->getSubtype(),
367  "obligatory" => $this->getObligatory()
368  );
369  $a_xml_writer->xmlStartTag("question", $attrs);
370 
371  $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
372  $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
373  $a_xml_writer->xmlStartTag("questiontext");
374  $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
375  $a_xml_writer->xmlEndTag("questiontext");
376 
377  $a_xml_writer->xmlStartTag("responses");
378  switch ($this->getSubtype())
379  {
380  case 3:
381  $attrs = array(
382  "id" => "0",
383  "format" => "double"
384  );
385  if (strlen($this->getMinimum()))
386  {
387  $attrs["min"] = $this->getMinimum();
388  }
389  if (strlen($this->getMaximum()))
390  {
391  $attrs["max"] = $this->getMaximum();
392  }
393  break;
394  case 4:
395  $attrs = array(
396  "id" => "0",
397  "format" => "double"
398  );
399  if (strlen($this->getMinimum()))
400  {
401  $attrs["min"] = $this->getMinimum();
402  }
403  if (strlen($this->getMaximum()))
404  {
405  $attrs["max"] = $this->getMaximum();
406  }
407  break;
408  case 5:
409  $attrs = array(
410  "id" => "0",
411  "format" => "integer"
412  );
413  if (strlen($this->getMinimum()))
414  {
415  $attrs["min"] = $this->getMinimum();
416  }
417  if (strlen($this->getMaximum()))
418  {
419  $attrs["max"] = $this->getMaximum();
420  }
421  break;
422  }
423  $a_xml_writer->xmlStartTag("response_num", $attrs);
424  $a_xml_writer->xmlEndTag("response_num");
425 
426  $a_xml_writer->xmlEndTag("responses");
427 
428  if (count($this->material))
429  {
430  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
431  {
432  $attrs = array(
433  "label" => $this->material["title"]
434  );
435  $a_xml_writer->xmlStartTag("material", $attrs);
436  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
437  if (strcmp($matches[1], "") != 0)
438  {
439  $intlink = $this->material["internal_link"];
440  }
441  $a_xml_writer->xmlElement("mattext", NULL, $intlink);
442  $a_xml_writer->xmlEndTag("material");
443  }
444  }
445 
446  $a_xml_writer->xmlEndTag("question");
447  }
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.
getMaximum()
Returns the maximum value of the question.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getSubtype()
Gets the question subtype.
getId()
Gets the id of the SurveyQuestion object.
getMinimum()
Returns the minimum value of the question.
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.
getDescription()
Gets the description string of the SurveyQuestion object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isComplete()

SurveyMetricQuestion::isComplete ( )

Returns true if the question is complete for use.

Returns
boolean True if the question is complete for use, otherwise false public

Definition at line 269 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\getAuthor(), SurveyQuestion\getQuestiontext(), and SurveyQuestion\getTitle().

270  {
271  if (
272  strlen($this->getTitle()) &&
273  strlen($this->getAuthor()) &&
274  strlen($this->getQuestiontext())
275  )
276  {
277  return 1;
278  }
279  else
280  {
281  return 0;
282  }
283  }
getAuthor()
Gets the authors name of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ loadFromDb()

SurveyMetricQuestion::loadFromDb (   $id)

Loads a SurveyMetricQuestion object from the database.

Parameters
integer$idThe database id of the metric survey question public

Definition at line 215 of file class.SurveyMetricQuestion.php.

References $data, SurveyQuestion\$id, $result, ilRTE\_replaceMediaObjectImageSrc(), ilDB\fetchAssoc(), getAdditionalTableName(), SurveyQuestion\setAuthor(), SurveyQuestion\setComplete(), SurveyQuestion\setDescription(), SurveyQuestion\setId(), SurveyQuestion\setObjId(), SurveyQuestion\setObligatory(), SurveyQuestion\setOriginalId(), SurveyQuestion\setOwner(), SurveyQuestion\setQuestiontext(), setSubtype(), and SurveyQuestion\setTitle().

216  {
217  global $ilDB;
218 
219  $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = svy_question.question_id WHERE svy_question.question_id = %s",
220  array('integer'),
221  array($id)
222  );
223  if ($result->numRows() == 1)
224  {
225  $data = $ilDB->fetchAssoc($result);
226  $this->setId($data["question_id"]);
227  $this->setTitle($data["title"]);
228  $this->setDescription($data["description"]);
229  $this->setObjId($data["obj_fi"]);
230  $this->setAuthor($data["author"]);
231  $this->setOwner($data["owner_fi"]);
232  $this->label = $data['label'];
233  include_once("./Services/RTE/classes/class.ilRTE.php");
234  $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
235  $this->setObligatory($data["obligatory"]);
236  $this->setComplete($data["complete"]);
237  $this->setOriginalId($data["original_id"]);
238  $this->setSubtype($data["subtype"]);
239 
240  $result = $ilDB->queryF("SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s",
241  array('integer'),
242  array($id)
243  );
244  if ($result->numRows() > 0)
245  {
246  if ($data = $ilDB->fetchAssoc($result))
247  {
248  $this->minimum = $data["value1"];
249  if (($data["value2"] < 0) or (strcmp($data["value2"], "") == 0))
250  {
251  $this->maximum = "";
252  }
253  else
254  {
255  $this->maximum = $data["value2"];
256  }
257  }
258  }
259  }
260  parent::loadFromDb($id);
261  }
$result
setSubtype($subtype=self::SUBTYPE_NON_RATIO)
Sets the question subtype.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
setId($id=-1)
Sets the id of the SurveyQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setComplete($a_complete)
Sets the complete state of the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setOriginalId($original_id)
fetchAssoc($a_set)
Fetch row as associative array from result set.
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
setAuthor($author="")
Sets the authors name 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.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ outPreconditionSelectValue()

SurveyMetricQuestion::outPreconditionSelectValue ( $template)

Creates a value selection for preconditions.

Parameters
object$templateThe template for the value selection (usually tpl.svy_svy_add_constraint.html) public

Definition at line 879 of file class.SurveyMetricQuestion.php.

880  {
881  $template->setCurrentBlock("textfield");
882  $template->setVariable("TEXTFIELD_VALUE", "");
883  $template->parseCurrentBlock();
884  }

◆ saveRandomData()

SurveyMetricQuestion::saveRandomData (   $active_id)

Saves random answers for a given active user in the database.

Parameters
integer$active_idThe database ID of the active user

Definition at line 564 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\getId(), getMaximum(), and getMinimum().

565  {
566  global $ilDB;
567  // single response
568  $number = rand($this->getMinimum(), (strlen($this->getMaximum())) ? $this->getMaximum() : 100);
569  $next_id = $ilDB->nextId('svy_answer');
570  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
571  array('integer','integer','integer','float','text','integer'),
572  array($next_id, $this->getId(), $active_id, $number, NULL, time())
573  );
574  }
getMaximum()
Returns the maximum value of the question.
getId()
Gets the id of the SurveyQuestion object.
getMinimum()
Returns the minimum value of the question.
+ Here is the call graph for this function:

◆ saveToDb()

SurveyMetricQuestion::saveToDb (   $original_id = "")

Saves a SurveyMetricQuestion object to a database.

public

Definition at line 290 of file class.SurveyMetricQuestion.php.

References getAdditionalTableName(), SurveyQuestion\getId(), getMaximum(), getMinimum(), and SurveyQuestion\saveMaterial().

291  {
292  global $ilDB;
293 
294  $affectedRows = parent::saveToDb($original_id);
295  if ($affectedRows == 1)
296  {
297  $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
298  array('integer'),
299  array($this->getId())
300  );
301  $affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, subtype) VALUES (%s, %s)",
302  array('integer', 'text'),
303  array($this->getId(), $this->getSubType())
304  );
305 
306  // saving material uris in the database
307  $this->saveMaterial();
308 
309  // save categories
310  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
311  array('integer'),
312  array($this->getId())
313  );
314 
315  if (preg_match("/[\D]/", $this->maximum) or (strcmp($this->maximum, "&infin;") == 0))
316  {
317  $max = -1;
318  }
319  else
320  {
321  $max = $this->getMaximum();
322  }
323  $next_id = $ilDB->nextId('svy_variable');
324  $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)",
325  array('integer','integer','integer','float','float','integer','integer'),
326  array($next_id, 0, $this->getId(), $this->getMinimum(), $max, 0, time())
327  );
328  }
329  }
getMaximum()
Returns the maximum value of the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getId()
Gets the id of the SurveyQuestion object.
getMinimum()
Returns the minimum value of the question.
saveMaterial()
save material to db
+ Here is the call graph for this function:

◆ saveUserInput()

SurveyMetricQuestion::saveUserInput (   $post_data,
  $active_id,
  $a_return = false 
)

Definition at line 576 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\getId().

577  {
578  global $ilDB;
579 
580  $entered_value = $post_data[$this->getId() . "_metric_question"];
581 
582  // replace german notation with international notation
583  $entered_value = str_replace(",", ".", $entered_value);
584 
585  if($a_return)
586  {
587  return array(array("value"=>$entered_value, "textanswer"=>null));
588  }
589  if (strlen($entered_value) == 0) return;
590 
591  $next_id = $ilDB->nextId('svy_answer');
592  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
593  array('integer','integer','integer','float','text','integer'),
594  array($next_id, $this->getId(), $active_id, (strlen($entered_value)) ? $entered_value : NULL, NULL, time())
595  );
596  }
getId()
Gets the id of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

SurveyMetricQuestion::setExportDetailsXLS ( $workbook,
$format_title,
$format_bold,
$eval_data,
  $export_label 
)

Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$workbookReference to the parent excel workbook
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data public

Definition at line 708 of file class.SurveyMetricQuestion.php.

References ilExcelUtils\_convert_text(), SurveyQuestion\getQuestiontext(), getSubtype(), and SurveyQuestion\getTitle().

709  {
710  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
711  $worksheet =& $workbook->addWorksheet();
712  $rowcounter = 0;
713  switch ($export_label)
714  {
715  case 'label_only':
716  $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
717  $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->label));
718  break;
719  case 'title_only':
720  $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
721  $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
722  break;
723  default:
724  $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
725  $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
726  $rowcounter++;
727  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
728  $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->label));
729  break;
730  }
731  $rowcounter++;
732  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question")), $format_bold);
733  $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->getQuestiontext()));
734  $rowcounter++;
735  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question_type")), $format_bold);
736  $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())));
737  $rowcounter++;
738  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered")), $format_bold);
739  $worksheet->write($rowcounter, 1, $eval_data["USERS_ANSWERED"]);
740  $rowcounter++;
741  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped")), $format_bold);
742  $worksheet->write($rowcounter, 1, $eval_data["USERS_SKIPPED"]);
743  $rowcounter++;
744 
745  $worksheet->write($rowcounter, 0, $this->lng->txt("subtype"), $format_bold);
746  switch ($this->getSubtype())
747  {
748  case self::SUBTYPE_NON_RATIO:
749  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("non_ratio")), $format_bold);
750  break;
751  case self::SUBTYPE_RATIO_NON_ABSOLUTE:
752  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_non_absolute")), $format_bold);
753  break;
754  case self::SUBTYPE_RATIO_ABSOLUTE:
755  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_absolute")), $format_bold);
756  break;
757  }
758  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode")), $format_bold);
759  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE"]));
760  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text")), $format_bold);
761  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE"]));
762  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections")), $format_bold);
763  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE_NR_OF_SELECTIONS"]));
764  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median")), $format_bold);
765  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MEDIAN"]));
766  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("arithmetic_mean")), $format_bold);
767  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["ARITHMETIC_MEAN"]));
768  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("values")), $format_bold);
769  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
770  $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected")), $format_title);
771  $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections")), $format_title);
772  $values = "";
773  if (is_array($eval_data["values"]))
774  {
775  foreach ($eval_data["values"] as $key => $value)
776  {
777  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["value"]));
778  $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($value["selected"]));
779  $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($value["percentage"]), $format_percent);
780  }
781  }
782  }
getTitle()
Gets the title string of the SurveyQuestion object.
_convert_text($a_text, $a_target="has been removed")
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getSubtype()
Gets the question subtype.
+ Here is the call graph for this function:

◆ setMaximum()

SurveyMetricQuestion::setMaximum (   $maximum = "")

Sets the maximum value.

Parameters
double$maximumThe maximum value public
See also
$maximum

Definition at line 131 of file class.SurveyMetricQuestion.php.

References $maximum.

Referenced by importResponses().

132  {
133  if($maximum !== NULL)
134  {
135  $maximum = (float)$maximum;
136  }
137  if(!$maximum)
138  {
139  $maximum = NULL;
140  }
141  $this->maximum = $maximum;
142  }
+ Here is the caller graph for this function:

◆ setMinimum()

SurveyMetricQuestion::setMinimum (   $minimum = 0)

Sets the minimum value.

Parameters
double$minimumThe minimum value public
See also
$minimum

Definition at line 111 of file class.SurveyMetricQuestion.php.

References $minimum.

Referenced by importResponses().

112  {
113  if($minimum !== NULL)
114  {
115  $minimum = (float)$minimum;
116  }
117  if(!$minimum)
118  {
119  $minimum = NULL;
120  }
121  $this->minimum = $minimum;
122  }
+ Here is the caller graph for this function:

◆ setSubtype()

SurveyMetricQuestion::setSubtype (   $subtype = self::SUBTYPE_NON_RATIO)

Sets the question subtype.

Parameters
integer$subtypeThe question subtype public
See also
$subtype

Definition at line 99 of file class.SurveyMetricQuestion.php.

References $subtype.

Referenced by loadFromDb().

100  {
101  $this->subtype = $subtype;
102  }
+ Here is the caller graph for this function:

◆ SurveyMetricQuestion()

SurveyMetricQuestion::SurveyMetricQuestion (   $title = "",
  $description = "",
  $author = "",
  $questiontext = "",
  $owner = -1,
  $subtype = self::SUBTYPE_NON_RATIO 
)

SurveyMetricQuestion constructor.

The constructor takes possible arguments an creates an instance of the SurveyMetricQuestion object.

Parameters
string$titleA title string to describe the question
string$descriptionA description string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator public

Definition at line 77 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\$author, SurveyQuestion\$description, SurveyQuestion\$owner, SurveyQuestion\$questiontext, $subtype, SurveyQuestion\$title, and SurveyQuestion\SurveyQuestion().

85  {
87  $this->subtype = $subtype;
88  $this->minimum = "";
89  $this->maximum = "";
90  }
SurveyQuestion( $title="", $description="", $author="", $questiontext="", $owner=-1)
SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the Sur...
+ Here is the call graph for this function:

◆ toXML()

SurveyMetricQuestion::toXML (   $a_include_header = TRUE,
  $obligatory_state = "" 
)

Returns an xml representation of the question.

Returns
string The xml representation of the question public

Definition at line 337 of file class.SurveyMetricQuestion.php.

References insertXML(), and ilXmlWriter\xmlHeader().

338  {
339  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
340  $a_xml_writer = new ilXmlWriter;
341  $a_xml_writer->xmlHeader();
342  $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
343  $xml = $a_xml_writer->xmlDumpMem(FALSE);
344  if (!$a_include_header)
345  {
346  $pos = strpos($xml, "?>");
347  $xml = substr($xml, $pos + 2);
348  }
349  return $xml;
350  }
XML writer class.
insertXML(&$a_xml_writer, $a_include_header=TRUE, $obligatory_state="")
Adds the question XML to a given XMLWriter object.
xmlHeader()
Writes xml header public.
+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyMetricQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Returns
boolean TRUE if the question is usable for a precondition, FALSE otherwise public

Definition at line 857 of file class.SurveyMetricQuestion.php.

858  {
859  return TRUE;
860  }

Field Documentation

◆ $maximum

SurveyMetricQuestion::$maximum

Definition at line 64 of file class.SurveyMetricQuestion.php.

Referenced by setMaximum().

◆ $minimum

SurveyMetricQuestion::$minimum

Definition at line 57 of file class.SurveyMetricQuestion.php.

Referenced by setMinimum().

◆ $subtype

SurveyMetricQuestion::$subtype

Definition at line 50 of file class.SurveyMetricQuestion.php.

Referenced by getSubtype(), setSubtype(), and SurveyMetricQuestion().

◆ SUBTYPE_NON_RATIO

const SurveyMetricQuestion::SUBTYPE_NON_RATIO = 3

◆ SUBTYPE_RATIO_ABSOLUTE

const SurveyMetricQuestion::SUBTYPE_RATIO_ABSOLUTE = 5

◆ SUBTYPE_RATIO_NON_ABSOLUTE

const SurveyMetricQuestion::SUBTYPE_RATIO_NON_ABSOLUTE = 4

The documentation for this class was generated from the following file: