ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
SurveyMultipleChoiceQuestion Class Reference

MultipleChoice survey question. More...

+ Inheritance diagram for SurveyMultipleChoiceQuestion:
+ Collaboration diagram for SurveyMultipleChoiceQuestion:

Public Member Functions

 SurveyMultipleChoiceQuestion ( $title="", $description="", $author="", $questiontext="", $owner=-1, $orientation=0)
 The constructor takes possible arguments an creates an instance of the SurveyMultipleChoiceQuestion object. More...
 
 _getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
 loadFromDb ($id)
 Loads a SurveyMultipleChoiceQuestion object from the database. More...
 
 isComplete ()
 Returns true if the question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a SurveyMultipleChoiceQuestion object to a database. More...
 
 saveCategoriesToDb ()
 
 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...
 
 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...
 
 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, $finished_ids)
 Returns an array containing all answers to this question in a given survey. 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...
 
 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...
 
 getPreconditionSelectValue ($default="", $title, $variable)
 Creates a form property for the precondition value. More...
 
 getPreconditionValueOutput ($value)
 Returns the output for a precondition value. More...
 
 getCategories ()
 
- 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...
 
 getLabel ()
 
 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

 $categories
 
- 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...
 
static _lookupSurveyObjId ($a_question_id)
 
static lookupObjFi ($a_qid)
 Lookip obj fi. 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

MultipleChoice survey question.

The SurveyMultipleChoiceQuestion class defines and encapsulates basic methods and attributes for multiple choice 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.SurveyMultipleChoiceQuestion.php.

Member Function Documentation

◆ _getQuestionDataArray()

SurveyMultipleChoiceQuestion::_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 @access public

Reimplemented from SurveyQuestion.

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

78 {
79 global $ilDB;
80
81 $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",
82 array('integer'),
83 array($id)
84 );
85 if ($result->numRows() == 1)
86 {
87 return $ilDB->fetchAssoc($result);
88 }
89 else
90 {
91 return array();
92 }
93 }
$result
getAdditionalTableName()
Returns the name of the additional question data table in the database.
global $ilDB

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

+ Here is the call graph for this function:

◆ addUserSpecificResultsData()

SurveyMultipleChoiceQuestion::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 @access public

Reimplemented from SurveyQuestion.

Definition at line 747 of file class.SurveyMultipleChoiceQuestion.php.

748 {
749 if (count($resultset["answers"][$this->getId()]))
750 {
751 array_push($a_array, "");
752 for ($index = 0; $index < $this->categories->getCategoryCount(); $index++)
753 {
754 $category = $this->categories->getCategory($index);
755 $incoming_value = $category->scale ? $category->scale-1 : $index;
756
757 $found = 0;
758 $textanswer = "";
759 foreach ($resultset["answers"][$this->getId()] as $answerdata)
760 {
761 if (strcmp($incoming_value, $answerdata["value"]) == 0)
762 {
763 $found = $answerdata["value"]+1;
764 $textanswer = $answerdata["textanswer"];
765 }
766 }
767 if ($found)
768 {
769 array_push($a_array, $found);
770 }
771 else
772 {
773 array_push($a_array, "0");
774 }
775 if ($category->other)
776 {
777 array_push($a_array, $textanswer);
778 }
779 }
780 }
781 else
782 {
783 array_push($a_array, $this->getSkippedValue());
784 for ($index = 0; $index < $this->categories->getCategoryCount(); $index++)
785 {
786 array_push($a_array, "");
787
788 // add empty text answers for skipped question
789 $category = $this->categories->getCategory($index);
790 if ($category->other)
791 {
792 array_push($a_array, "");
793 }
794 }
795 }
796 }
getId()
Gets the id of the SurveyQuestion object.

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

+ Here is the call graph for this function:

◆ addUserSpecificResultsExportTitles()

SurveyMultipleChoiceQuestion::addUserSpecificResultsExportTitles ( $a_array,
  $a_use_label = false,
  $a_substitute = true 
)

Adds the entries for the title row of the user specific results.

Parameters
array$a_arrayAn array which is used to append the title row entries @access public

Reimplemented from SurveyQuestion.

Definition at line 707 of file class.SurveyMultipleChoiceQuestion.php.

708 {
709 parent::addUserSpecificResultsExportTitles($a_array, $a_use_label, $a_substitute);
710
711 for ($index = 0; $index < $this->categories->getCategoryCount(); $index++)
712 {
713 $category = $this->categories->getCategory($index);
714 $title = $category->title;
715
716 if(!$a_use_label || $a_substitute)
717 {
718 array_push($a_array, $title);
719 }
720 else
721 {
722 array_push($a_array, "");
723 }
724
725 // optionally add headers for text answers
726 if ($category->other)
727 {
728 if(!$a_use_label || $a_substitute)
729 {
730 array_push($a_array, $title . " - ". $this->lng->txt("other"));
731 }
732 else
733 {
734 array_push($a_array, "");
735 }
736 }
737 }
738 }

References SurveyQuestion\$title.

◆ checkUserInput()

SurveyMultipleChoiceQuestion::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 @access public

Definition at line 402 of file class.SurveyMultipleChoiceQuestion.php.

403 {
404 $entered_value = $post_data[$this->getId() . "_value"];
405 if (!$this->getObligatory($survey_id) && count($entered_value) == 0) return "";
406
407 if ($this->use_min_answers && $this->nr_min_answers > 0 && $this->nr_max_answers > 0 && $this->nr_min_answers == $this->nr_max_answers && count($entered_value) != $this->nr_max_answers)
408 {
409 return sprintf($this->lng->txt("err_no_exact_answers"), $this->nr_min_answers);
410 }
411 if ($this->use_min_answers && $this->nr_min_answers > 0 && count($entered_value) < $this->nr_min_answers)
412 {
413 return sprintf($this->lng->txt("err_no_min_answers"), $this->nr_min_answers);
414 }
415 if ($this->use_min_answers && $this->nr_max_answers > 0 && count($entered_value) > $this->nr_max_answers)
416 {
417 return sprintf($this->lng->txt("err_no_max_answers"), $this->nr_max_answers);
418 }
419 if (!is_array($entered_value))
420 {
421 return $this->lng->txt("question_mr_not_checked");
422 }
423 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
424 {
425 $cat = $this->categories->getCategory($i);
426 if ($cat->other)
427 {
428 if (in_array($i, $entered_value))
429 {
430 if (array_key_exists($this->getId() . "_" . $i . "_other", $post_data) && !strlen($post_data[$this->getId() . "_" . $i . "_other"]))
431 {
432 return $this->lng->txt("question_mr_no_other_answer");
433 }
434 }
435 else
436 {
437 if (strlen($post_data[$this->getId() . "_" . $i . "_other"]))
438 {
439 return $this->lng->txt("question_mr_no_other_answer_checked");
440 }
441 }
442 }
443 }
444 return "";
445 }
getObligatory($survey_id="")
Gets the obligatory state of the question.

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

+ Here is the call graph for this function:

◆ getAdditionalTableName()

SurveyMultipleChoiceQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name @access public

Definition at line 353 of file class.SurveyMultipleChoiceQuestion.php.

354 {
355 return "svy_qst_mc";
356 }

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

+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyMultipleChoiceQuestion::getAvailableRelations ( )

Returns the available relations for the question.

Returns
array An array containing the available relations @access public

Reimplemented from SurveyQuestion.

Definition at line 916 of file class.SurveyMultipleChoiceQuestion.php.

917 {
918 return array("=", "<>");
919 }

◆ getCategories()

SurveyMultipleChoiceQuestion::getCategories ( )

◆ getCumulatedResults()

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

Definition at line 513 of file class.SurveyMultipleChoiceQuestion.php.

514 {
515 global $ilDB;
516
517 $question_id = $this->getId();
518
519 $result_array = array();
520 $cumulated = array();
521
522 $sql = "SELECT svy_answer.* FROM svy_answer".
523 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
524 " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id, "integer").
525 " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
526 if($finished_ids)
527 {
528 $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
529 }
530
531 $result = $ilDB->query($sql);
532 $numrows = $result->numRows();
533
534 // count the answers for every answer value
535 $textanswers = array();
536 while ($row = $ilDB->fetchAssoc($result))
537 {
538 $cumulated[$row["value"]]++;
539
540 // add text value to result array
541 if ($row["textanswer"])
542 {
543 $textanswers[$row["value"]][] = $row["textanswer"];
544 }
545 }
546 // sort textanswers by value
547 if (is_array($textanswers))
548 {
549 ksort($textanswers, SORT_NUMERIC);
550 }
551 asort($cumulated, SORT_NUMERIC);
552 end($cumulated);
553
554 $sql = "SELECT svy_answer.answer_id, svy_answer.question_fi, svy_answer.active_fi".
555 " FROM svy_answer".
556 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
557 " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id, "integer").
558 " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
559 if($finished_ids)
560 {
561 $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
562 }
563
564 $mcmr_result = $ilDB->query($sql);
565 $found = array();
566 while ($row = $ilDB->fetchAssoc($mcmr_result))
567 {
568 $found[$row["question_fi"] . "_" . $row["active_fi"]] = 1;
569 }
570 $result_array["USERS_ANSWERED"] = count($found);
571 $result_array["USERS_SKIPPED"] = $nr_of_users - count($found);
572 $numrows = count($found);
573
574 $result_array["MEDIAN"] = "";
575 $result_array["ARITHMETIC_MEAN"] = "";
576 if(sizeof($cumulated))
577 {
578 $prefix = "";
579 if (strcmp(key($cumulated), "") != 0)
580 {
581 $prefix = (key($cumulated)+1) . " - ";
582 }
583 $category = $this->categories->getCategoryForScale(key($cumulated)+1);
584 $result_array["MODE"] = $prefix . $category->title;
585 $result_array["MODE_VALUE"] = key($cumulated)+1;
586 $result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
587 }
588 $result_array["QUESTION_TYPE"] = "SurveyMultipleChoiceQuestion";
589 $maxvalues = 0;
590 for ($key = 0; $key < $this->categories->getCategoryCount(); $key++)
591 {
592 $cat = $this->categories->getCategory($key);
593 $maxvalues += $cumulated[$cat->scale-1];
594 }
595 for ($key = 0; $key < $this->categories->getCategoryCount(); $key++)
596 {
597 $cat = $this->categories->getCategory($key);
598 $percentage = 0;
599 if ($numrows > 0)
600 {
601 if ($maxvalues > 0)
602 {
603 $percentage = ($maxvalues > 0) ? (float)((int)$cumulated[$cat->scale-1]/$maxvalues) : 0;
604 }
605 }
606 if(isset($textanswers[$cat->scale-1]))
607 {
608 // #12138
609 $result_array["textanswers"][$key] = $textanswers[$cat->scale-1];
610 }
611 $result_array["variables"][$key] = array("title" => $cat->title, "selected" => (int)$cumulated[$cat->scale-1], "percentage" => $percentage);
612 }
613 return $result_array;
614 }
$cumulated
An array containing the cumulated results of the question for a given survey.

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

+ Here is the call graph for this function:

◆ getPreconditionOptions()

SurveyMultipleChoiceQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Returns
array

Reimplemented from SurveyQuestion.

Definition at line 926 of file class.SurveyMultipleChoiceQuestion.php.

927 {
928 global $lng;
929
930 $options = array();
931 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
932 {
933 $category = $this->categories->getCategory($i);
934 $options[$category->scale-1] = $category->scale . " - " . $category->title;
935 }
936 return $options;
937 }
if(!is_array($argv)) $options

References SurveyQuestion\$lng, and $options.

Referenced by getPreconditionSelectValue().

+ Here is the caller graph for this function:

◆ getPreconditionSelectValue()

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

Creates a form property for the precondition value.

Returns
The ILIAS form element @access public

Reimplemented from SurveyQuestion.

Definition at line 945 of file class.SurveyMultipleChoiceQuestion.php.

946 {
947 include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
948 $step3 = new ilSelectInputGUI($title, $variable);
950 $step3->setOptions($options);
951 $step3->setValue($default);
952 return $step3;
953 }
getPreconditionOptions()
Returns the options for preconditions.
This class represents a selection list property in a property form.

References $options, SurveyQuestion\$title, and getPreconditionOptions().

+ Here is the call graph for this function:

◆ getPreconditionValueOutput()

SurveyMultipleChoiceQuestion::getPreconditionValueOutput (   $value)

Returns the output for a precondition value.

Parameters
string$valueThe precondition value
Returns
string The output of the precondition value @access public

Reimplemented from SurveyQuestion.

Definition at line 962 of file class.SurveyMultipleChoiceQuestion.php.

963 {
964 // #18136
965 $category = $this->categories->getCategoryForScale($value+1);
966
967 // #17895 - see getPreconditionOptions()
968 return $category->scale .
969 " - " .
970 ((strlen($category->title)) ? $category->title : $this->lng->txt('other_answer'));
971 }

◆ getQuestionType()

SurveyMultipleChoiceQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question @access public

Reimplemented from SurveyQuestion.

Definition at line 342 of file class.SurveyMultipleChoiceQuestion.php.

343 {
344 return "SurveyMultipleChoiceQuestion";
345 }

◆ getUserAnswers()

& SurveyMultipleChoiceQuestion::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 @access public

Definition at line 805 of file class.SurveyMultipleChoiceQuestion.php.

806 {
807 global $ilDB;
808
809 $answers = array();
810
811 $sql = "SELECT svy_answer.* FROM svy_answer".
812 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
813 " WHERE svy_answer.question_fi = ".$ilDB->quote($this->getId(), "integer").
814 " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
815 if($finished_ids)
816 {
817 $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
818 }
819
820 $result = $ilDB->query($sql);
821 while ($row = $ilDB->fetchAssoc($result))
822 {
823 $category = $this->categories->getCategoryForScale($row["value"]+1);
824 if (!is_array($answers[$row["active_fi"]]))
825 {
826 $answers[$row["active_fi"]] = array();
827 }
828 $title = $row["value"] + 1 . " - " . $category->title;
829 if ($category->other) $title .= ": " . $row["textanswer"];
830 $catindex = $this->categories->getIndex($category);
831 if ($catindex !== null)
832 {
833 $answers[$row["active_fi"]][$catindex] = $title;
834 }
835 else
836 {
837 array_push($answers[$row["active_fi"]], $title);
838 }
839 ksort($answers[$row["active_fi"]], SORT_NUMERIC);
840 }
841 return $answers;
842 }

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

+ Here is the call graph for this function:

◆ getWorkingDataFromUserInput()

& SurveyMultipleChoiceQuestion::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 @access public

Reimplemented from SurveyQuestion.

Definition at line 364 of file class.SurveyMultipleChoiceQuestion.php.

365 {
366 $entered_value = $post_data[$this->getId() . "_value"];
367 $data = array();
368 if (is_array($entered_value))
369 {
370 foreach ($entered_value as $idx => $value)
371 {
372 array_push($data, array("value" => $value, "textanswer" => $post_data[$this->getId() . '_' . $value . '_other']));
373 }
374 }
375 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
376 {
377 $cat = $this->categories->getCategory($i);
378 if ($cat->other)
379 {
380 // #18212
381 if (!is_array($entered_value) || !in_array($i, $entered_value))
382 {
383 if (strlen($post_data[$this->getId() . "_" . $i . "_other"]))
384 {
385 array_push($data, array("value" => $i, "textanswer" => $post_data[$this->getId() . '_' . $i . '_other'], "uncheck" => true));
386 }
387 }
388 }
389 }
390 return $data;
391 }
$data

References $data, and SurveyQuestion\getId().

+ Here is the call graph for this function:

◆ importAdditionalMetadata()

SurveyMultipleChoiceQuestion::importAdditionalMetadata (   $a_meta)

Import additional meta data from the question import file.

Usually the meta data section is used to store question elements which are not part of the standard XML schema.

Returns
array $a_meta Array containing the additional meta data @access public

Reimplemented from SurveyQuestion.

Definition at line 852 of file class.SurveyMultipleChoiceQuestion.php.

853 {
854 foreach ($a_meta as $key => $value)
855 {
856 switch ($value["label"])
857 {
858 case "orientation":
859 $this->setOrientation($value["entry"]);
860 break;
861 case "use_min_answers":
862 $this->use_min_answers = $value["entry"];
863 break;
864 case "nr_min_answers":
865 $this->nr_min_answers = $value["entry"];
866 break;
867 case "nr_max_answers":
868 $this->nr_max_answers = $value["entry"];
869 break;
870 }
871 }
872 }
setOrientation($orientation=0)
Sets the orientation of the question output.

References SurveyQuestion\setOrientation().

+ Here is the call graph for this function:

◆ importResponses()

SurveyMultipleChoiceQuestion::importResponses (   $a_data)

Import response data from the question import file.

Returns
array $a_data Array containing the response data @access public

Reimplemented from SurveyQuestion.

Definition at line 880 of file class.SurveyMultipleChoiceQuestion.php.

881 {
882 foreach ($a_data as $id => $data)
883 {
884 $categorytext = "";
885 foreach ($data["material"] as $material)
886 {
887 $categorytext .= $material["text"];
888 }
889 $this->categories->addCategory(
890 $categorytext,
891 strlen($data['other']) ? $data['other'] : 0,
892 strlen($data['neutral']) ? $data['neutral'] : 0,
893 strlen($data['label']) ? $data['label'] : null,
894 strlen($data['scale']) ? $data['scale'] : null
895 );
896 }
897 }

References $data, SurveyQuestion\$id, and SurveyQuestion\$material.

◆ insertXML()

SurveyMultipleChoiceQuestion::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 @access public

Definition at line 252 of file class.SurveyMultipleChoiceQuestion.php.

253 {
254 $attrs = array(
255 "id" => $this->getId(),
256 "title" => $this->getTitle(),
257 "type" => $this->getQuestiontype(),
258 "obligatory" => $this->getObligatory()
259 );
260 $a_xml_writer->xmlStartTag("question", $attrs);
261
262 $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
263 $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
264 if (strlen($this->label))
265 {
266 $attrs = array(
267 "label" => $this->label,
268 );
269 }
270 else
271 {
272 $attrs = array();
273 }
274 $a_xml_writer->xmlStartTag("questiontext", $attrs);
275 $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
276 $a_xml_writer->xmlEndTag("questiontext");
277
278 $a_xml_writer->xmlStartTag("responses");
279
280 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
281 {
282 $attrs = array(
283 "id" => $i
284 );
285 if (strlen($this->categories->getCategory($i)->other)) $attrs['other'] = $this->categories->getCategory($i)->other;
286 if (strlen($this->categories->getCategory($i)->neutral)) $attrs['neutral'] = $this->categories->getCategory($i)->neutral;
287 if (strlen($this->categories->getCategory($i)->label)) $attrs['label'] = $this->categories->getCategory($i)->label;
288 if (strlen($this->categories->getCategory($i)->scale)) $attrs['scale'] = $this->categories->getCategory($i)->scale;
289 $a_xml_writer->xmlStartTag("response_multiple", $attrs);
290 $this->addMaterialTag($a_xml_writer, $this->categories->getCategory($i)->title);
291 $a_xml_writer->xmlEndTag("response_multiple");
292 }
293
294 $a_xml_writer->xmlEndTag("responses");
295
296 if (count($this->material))
297 {
298 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
299 {
300 $attrs = array(
301 "label" => $this->material["title"]
302 );
303 $a_xml_writer->xmlStartTag("material", $attrs);
304 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
305 if (strcmp($matches[1], "") != 0)
306 {
307 $intlink = $this->material["internal_link"];
308 }
309 $a_xml_writer->xmlElement("mattext", NULL, $intlink);
310 $a_xml_writer->xmlEndTag("material");
311 }
312 }
313
314 $a_xml_writer->xmlStartTag("metadata");
315 $a_xml_writer->xmlStartTag("metadatafield");
316 $a_xml_writer->xmlElement("fieldlabel", NULL, "orientation");
317 $a_xml_writer->xmlElement("fieldentry", NULL, $this->getOrientation());
318 $a_xml_writer->xmlEndTag("metadatafield");
319 $a_xml_writer->xmlStartTag("metadatafield");
320 $a_xml_writer->xmlElement("fieldlabel", NULL, "use_min_answers");
321 $a_xml_writer->xmlElement("fieldentry", NULL, $this->use_min_answers);
322 $a_xml_writer->xmlEndTag("metadatafield");
323 $a_xml_writer->xmlStartTag("metadatafield");
324 $a_xml_writer->xmlElement("fieldlabel", NULL, "nr_min_answers");
325 $a_xml_writer->xmlElement("fieldentry", NULL, $this->nr_min_answers);
326 $a_xml_writer->xmlEndTag("metadatafield");
327 $a_xml_writer->xmlStartTag("metadatafield");
328 $a_xml_writer->xmlElement("fieldlabel", NULL, "nr_max_answers");
329 $a_xml_writer->xmlElement("fieldentry", NULL, $this->nr_max_answers);
330 $a_xml_writer->xmlEndTag("metadatafield");
331 $a_xml_writer->xmlEndTag("metadata");
332
333 $a_xml_writer->xmlEndTag("question");
334 }
getDescription()
Gets the description string of the SurveyQuestion object.
getAuthor()
Gets the authors name of the SurveyQuestion object.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getTitle()
Gets 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.
getOrientation()
Gets the orientation of the question output.

References SurveyQuestion\addMaterialTag(), SurveyQuestion\getAuthor(), SurveyQuestion\getDescription(), SurveyQuestion\getId(), SurveyQuestion\getObligatory(), SurveyQuestion\getOrientation(), SurveyQuestion\getQuestiontext(), and SurveyQuestion\getTitle().

Referenced by toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isComplete()

SurveyMultipleChoiceQuestion::isComplete ( )

Returns true if the question is complete for use.

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

Reimplemented from SurveyQuestion.

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

152 {
153 if (
154 strlen($this->getTitle()) &&
155 strlen($this->getAuthor()) &&
156 strlen($this->getQuestiontext()) &&
157 $this->categories->getCategoryCount()
158 )
159 {
160 return 1;
161 }
162 else
163 {
164 return 0;
165 }
166 }

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

+ Here is the call graph for this function:

◆ loadFromDb()

SurveyMultipleChoiceQuestion::loadFromDb (   $id)

Loads a SurveyMultipleChoiceQuestion object from the database.

Parameters
integer$idThe database id of the multiple choice survey question @access public

Reimplemented from SurveyQuestion.

Definition at line 101 of file class.SurveyMultipleChoiceQuestion.php.

102 {
103 global $ilDB;
104
105 $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",
106 array('integer'),
107 array($id)
108 );
109 if ($result->numRows() == 1)
110 {
111 $data = $ilDB->fetchAssoc($result);
112 $this->setId($data["question_id"]);
113 $this->setTitle($data["title"]);
114 $this->label = $data['label'];
115 $this->setDescription($data["description"]);
116 $this->setObjId($data["obj_fi"]);
117 $this->setAuthor($data["author"]);
118 $this->setOwner($data["owner_fi"]);
119 include_once("./Services/RTE/classes/class.ilRTE.php");
120 $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
121 $this->setObligatory($data["obligatory"]);
122 $this->setComplete($data["complete"]);
123 $this->setOriginalId($data["original_id"]);
124 $this->setOrientation($data["orientation"]);
125 $this->use_min_answers = ($data['use_min_answers']) ? true : false;
126 $this->nr_min_answers = $data['nr_min_answers'];
127 $this->nr_max_answers = $data['nr_max_answers'];
128
129 $this->categories->flushCategories();
130 $result = $ilDB->queryF("SELECT svy_variable.*, svy_category.title, svy_category.neutral FROM svy_variable, svy_category WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ORDER BY sequence ASC",
131 array('integer'),
132 array($id)
133 );
134 if ($result->numRows() > 0)
135 {
136 while ($data = $ilDB->fetchAssoc($result))
137 {
138 $this->categories->addCategory($data["title"], $data["other"], $data["neutral"], null, ($data['scale']) ? $data['scale'] : ($data['sequence'] + 1));
139 }
140 }
141 }
142 parent::loadFromDb($id);
143 }
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.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
setObjId($obj_id=0)
Set the reference id of the container object.
setOriginalId($original_id)
setComplete($a_complete)
Sets the complete state of the question.
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
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...

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

+ Here is the call graph for this function:

◆ saveCategoriesToDb()

SurveyMultipleChoiceQuestion::saveCategoriesToDb ( )

Definition at line 201 of file class.SurveyMultipleChoiceQuestion.php.

202 {
203 global $ilDB;
204
205 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
206 array('integer'),
207 array($this->getId())
208 );
209
210 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
211 {
212 $cat = $this->categories->getCategory($i);
213 $category_id = $this->saveCategoryToDb($cat->title, $cat->neutral);
214 $next_id = $ilDB->nextId('svy_variable');
215 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
216 array('integer','integer','integer','float','integer','integer', 'integer','integer'),
217 array($next_id, $category_id, $this->getId(), ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
218 );
219 }
220 $this->saveCompletionStatus();
221 }
saveCategoryToDb($categorytext, $neutral=0)
Saves a category to the database.
saveCompletionStatus($original_id="")
Saves the complete flag to the database.

References $ilDB, SurveyQuestion\getId(), SurveyQuestion\saveCategoryToDb(), and SurveyQuestion\saveCompletionStatus().

Referenced by saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveRandomData()

SurveyMultipleChoiceQuestion::saveRandomData (   $active_id)

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

Parameters
integer$active_idThe database ID of the active user

Reimplemented from SurveyQuestion.

Definition at line 452 of file class.SurveyMultipleChoiceQuestion.php.

453 {
454 global $ilDB;
455 // multiple responses
456 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
457 {
458 if (rand(0,1))
459 {
460 $cat = $this->categories->getCategory($i);
461 $next_id = $ilDB->nextId('svy_answer');
462 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
463 array('integer','integer','integer','float','text','integer'),
464 array($next_id, $this->getId(), $active_id, $i, ($cat->other) ? "Random Data" : null, time())
465 );
466 }
467 }
468 }

References $ilDB, and SurveyQuestion\getId().

+ Here is the call graph for this function:

◆ saveToDb()

SurveyMultipleChoiceQuestion::saveToDb (   $original_id = "")

Saves a SurveyMultipleChoiceQuestion object to a database.

@access public

Reimplemented from SurveyQuestion.

Definition at line 173 of file class.SurveyMultipleChoiceQuestion.php.

174 {
175 global $ilDB;
176
177 $affectedRows = parent::saveToDb($original_id);
178 if ($affectedRows == 1)
179 {
180 $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
181 array('integer'),
182 array($this->getId())
183 );
184 $affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, orientation, use_min_answers, nr_min_answers, nr_max_answers) VALUES (%s, %s, %s, %s, %s)",
185 array('integer', 'text', 'integer', 'integer', 'integer'),
186 array(
187 $this->getId(),
188 $this->getOrientation(),
189 ($this->use_min_answers) ? 1 : 0,
190 ($this->nr_min_answers > 0) ? $this->nr_min_answers : null,
191 ($this->nr_max_answers > 0) ? $this->nr_max_answers : null
192 )
193 );
194
195 // saving material uris in the database
196 $this->saveMaterial();
197 $this->saveCategoriesToDb();
198 }
199 }
saveMaterial()
save material to db

References $ilDB, getAdditionalTableName(), SurveyQuestion\getId(), SurveyQuestion\getOrientation(), saveCategoriesToDb(), and SurveyQuestion\saveMaterial().

+ Here is the call graph for this function:

◆ saveUserInput()

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

Definition at line 470 of file class.SurveyMultipleChoiceQuestion.php.

471 {
472 global $ilDB;
473
474 if($a_return)
475 {
476 $return_data = array();
477 }
478 if (is_array($post_data[$this->getId() . "_value"]))
479 {
480 foreach ($post_data[$this->getId() . "_value"] as $entered_value)
481 {
482 if (strlen($entered_value) > 0)
483 {
484 if(!$a_return)
485 {
486 $next_id = $ilDB->nextId('svy_answer');
487
488 #20216
489 $fields = array();
490 $fields['answer_id'] = array("integer", $next_id);
491 $fields['question_fi'] = array("integer", $this->getId());
492 $fields['active_fi'] = array("integer", $active_id);
493 $fields['value'] = array("float", (strlen($entered_value)) ? $entered_value : NULL);
494 $fields['textanswer'] = array("clob", ($post_data[$this->getId() . "_" . $entered_value . "_other"]) ? $post_data[$this->getId() . "_" . $entered_value . "_other"] : null);
495 $fields['tstamp'] = array("integer", time());
496
497 $affectedRows = $ilDB->insert("svy_answer", $fields);
498 }
499 else
500 {
501 $return_data[] = array("value"=>$entered_value,
502 "textanswer"=>$post_data[$this->getId() . "_" . $entered_value . "_other"]);
503 }
504 }
505 }
506 }
507 if($a_return)
508 {
509 return $return_data;
510 }
511 }

References $ilDB, and SurveyQuestion\getId().

+ Here is the call graph for this function:

◆ setExportDetailsXLS()

SurveyMultipleChoiceQuestion::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 @access public

Reimplemented from SurveyQuestion.

Definition at line 625 of file class.SurveyMultipleChoiceQuestion.php.

626 {
627 include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
628 $worksheet =& $workbook->addWorksheet();
629 $rowcounter = 0;
630 switch ($export_label)
631 {
632 case 'label_only':
633 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
634 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->label));
635 break;
636 case 'title_only':
637 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
638 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
639 break;
640 default:
641 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
642 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
643 $rowcounter++;
644 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
645 $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->label));
646 break;
647 }
648 $rowcounter++;
649 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question")), $format_bold);
650 $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->getQuestiontext()));
651 $rowcounter++;
652 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question_type")), $format_bold);
653 $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())));
654 $rowcounter++;
655 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered")), $format_bold);
656 $worksheet->write($rowcounter, 1, $eval_data["USERS_ANSWERED"]);
657 $rowcounter++;
658 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped")), $format_bold);
659 $worksheet->write($rowcounter, 1, $eval_data["USERS_SKIPPED"]);
660 $rowcounter++;
661
662 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode")), $format_bold);
663 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE_VALUE"]));
664 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text")), $format_bold);
665 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE"]));
666 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections")), $format_bold);
667 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE_NR_OF_SELECTIONS"]));
668 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories")), $format_bold);
669 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_title);
670 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
671 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected")), $format_title);
672 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("svy_fraction_of_selections")), $format_title);
673 foreach ($eval_data["variables"] as $key => $value)
674 {
675 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"]));
676 $category = $this->categories->getCategory($key);
677 $worksheet->write($rowcounter, 2, $category->scale);
678 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"]));
679 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"]), $format_percent);
680 }
681
682 // add text answers to detailed results
683 if (is_array($eval_data["textanswers"]))
684 {
685 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("freetext_answers")), $format_bold);
686 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_title);
687 $worksheet->write($rowcounter++, 2, ilExcelUtils::_convert_text($this->lng->txt("answer")), $format_title);
688
689 foreach ($eval_data["textanswers"] as $key => $answers)
690 {
691 $title = $eval_data["variables"][$key]["title"];
692 foreach ($answers as $answer)
693 {
694 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($title));
695 $worksheet->write($rowcounter++, 2, ilExcelUtils::_convert_text($answer));
696 }
697 }
698 }
699 }
_convert_text($a_text, $a_target="has been removed")

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

+ Here is the call graph for this function:

◆ SurveyMultipleChoiceQuestion()

SurveyMultipleChoiceQuestion::SurveyMultipleChoiceQuestion (   $title = "",
  $description = "",
  $author = "",
  $questiontext = "",
  $owner = -1,
  $orientation = 0 
)

The constructor takes possible arguments an creates an instance of the SurveyMultipleChoiceQuestion 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 @access public

Definition at line 55 of file class.SurveyMultipleChoiceQuestion.php.

63 {
65 $this->orientation = $orientation;
66 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
67 $this->categories = new SurveyCategories();
68 }
Class SurveyCategories.
SurveyQuestion( $title="", $description="", $author="", $questiontext="", $owner=-1)
SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the Sur...

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

+ Here is the call graph for this function:

◆ toXML()

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

Returns an xml representation of the question.

Returns
string The xml representation of the question @access public

Definition at line 229 of file class.SurveyMultipleChoiceQuestion.php.

230 {
231 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
232 $a_xml_writer = new ilXmlWriter;
233 $a_xml_writer->xmlHeader();
234 $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
235 $xml = $a_xml_writer->xmlDumpMem(FALSE);
236 if (!$a_include_header)
237 {
238 $pos = strpos($xml, "?>");
239 $xml = substr($xml, $pos + 2);
240 }
241 return $xml;
242 }
insertXML(&$a_xml_writer, $a_include_header=TRUE, $obligatory_state="")
Adds the question XML to a given XMLWriter object.
XML writer class.
xmlHeader()
Writes xml header @access public.

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

+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyMultipleChoiceQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

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

Reimplemented from SurveyQuestion.

Definition at line 905 of file class.SurveyMultipleChoiceQuestion.php.

906 {
907 return TRUE;
908 }

Field Documentation

◆ $categories

SurveyMultipleChoiceQuestion::$categories

Definition at line 44 of file class.SurveyMultipleChoiceQuestion.php.

Referenced by getCategories().


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