24include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
   41        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyMultipleChoiceQuestion.php";
 
   58        $orientation->setRequired(
false);
 
   59        $orientation->addOption(
new ilRadioOption($this->lng->txt(
'vertical'), 0));
 
   60        $orientation->addOption(
new ilRadioOption($this->lng->txt(
'horizontal'), 1));
 
   64        $minanswers = 
new ilCheckboxInputGUI($this->lng->txt(
"use_min_answers"), 
"use_min_answers");
 
   65        $minanswers->setValue(1);
 
   66        $minanswers->setOptionTitle($this->lng->txt(
"use_min_answers_option"));
 
   67        $minanswers->setRequired(
false);
 
   69        $nranswers = 
new ilNumberInputGUI($this->lng->txt(
"nr_min_answers"), 
"nr_min_answers");
 
   70        $nranswers->setSize(5);
 
   71        $nranswers->setDecimals(0);
 
   72        $nranswers->setRequired(
false);
 
   73        $nranswers->setMinValue(1);
 
   74        $minanswers->addSubItem($nranswers);
 
   76        $nrmaxanswers = 
new ilNumberInputGUI($this->lng->txt(
"nr_max_answers"), 
"nr_max_answers");
 
   77        $nrmaxanswers->setSize(5);
 
   78        $nrmaxanswers->setDecimals(0);
 
   79        $nrmaxanswers->setRequired(
false);
 
   80        $nrmaxanswers->setMinValue(1);
 
   81        $minanswers->addSubItem($nrmaxanswers);
 
   86        include_once 
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
 
   88        $answers->setRequired(
false);
 
   89        $answers->setAllowMove(
true);
 
   90        $answers->setShowWizard(
false);
 
   91        $answers->setShowSavePhrase(
false);
 
   92        $answers->setUseOtherAnswer(
true);
 
   93        $answers->setShowNeutralCategory(
true);
 
   94        $answers->setNeutralCategoryTitle($this->lng->txt(
'svy_neutral_answer'));
 
   95        $answers->setDisabledScale(
false);
 
  100        $orientation->setValue($this->object->getOrientation());
 
  101        $minanswers->setChecked($this->object->use_min_answers);
 
  102        $nranswers->setValue($this->object->nr_min_answers);
 
  103        $nrmaxanswers->setValue($this->object->nr_max_answers);
 
  104        if (!$this->object->getCategories()->getCategoryCount()) {
 
  105            $this->
object->getCategories()->addCategory(
"");
 
  107        $answers->setValues($this->object->getCategories());
 
  112        if ($a_form->
getInput(
"use_min_answers")) {
 
  115            foreach (
$_POST[
'answers'][
'answer'] as 
$key => $value) {
 
  116                if (strlen($value)) {
 
  120            if (strlen(
$_POST[
'answers'][
'neutral'])) {
 
  127            $min_anwers = $a_form->
getInput(
"nr_min_answers");
 
  128            $max_anwers = $a_form->
getInput(
"nr_max_answers");
 
  131                $min_anwers > $cnt_answers) {
 
  132                $a_form->
getItemByPostVar(
"nr_min_answers")->setAlert($this->lng->txt(
'err_minvalueganswers'));
 
  135            if ($max_anwers > 0 &&
 
  136                ($max_anwers > $cnt_answers || $max_anwers < $min_anwers)) {
 
  137                $a_form->
getItemByPostVar(
"nr_max_answers")->setAlert($this->lng->txt(
'err_maxvaluegeminvalue'));
 
  148        $this->
object->setOrientation($a_form->
getInput(
"orientation"));
 
  149        $this->
object->use_other_answer = ($a_form->
getInput(
'use_other_answer')) ? 1 : 0;
 
  150        $this->
object->other_answer_label = $this->
object->use_other_answer ? $a_form->
getInput(
'other_answer_label') : 
null;
 
  151        $this->
object->use_min_answers = ($a_form->
getInput(
'use_min_answers')) ? 
true : 
false;
 
  152        $this->
object->nr_min_answers = ($a_form->
getInput(
'nr_min_answers') > 0) ? $a_form->
getInput(
'nr_min_answers') : 
null;
 
  153        $this->
object->nr_max_answers = ($a_form->
getInput(
'nr_max_answers') > 0) ? $a_form->
getInput(
'nr_max_answers') : 
null;
 
  154        $this->
object->label = $a_form->
getInput(
'label');
 
  156        $this->
object->categories->flushCategories();
 
  158        foreach (
$_POST[
'answers'][
'answer'] as 
$key => $value) {
 
  159            if (strlen($value)) {
 
  160                $this->
object->getCategories()->addCategory($value, 
$_POST[
'answers'][
'other'][
$key], 0, 
null, 
$_POST[
'answers'][
'scale'][
$key]);
 
  163        if (strlen(
$_POST[
'answers'][
'neutral'])) {
 
  164            $this->
object->getCategories()->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, 
null, 
$_POST[
'answers_neutral_scale']);
 
  168    public function getParsedAnswers(array $a_working_data = 
null, $a_only_user_anwers = 
false)
 
  170        if (is_array($a_working_data)) {
 
  171            $user_answers = $a_working_data;
 
  175        for (
$i = 0; 
$i < $this->
object->categories->getCategoryCount(); 
$i++) {
 
  176            $cat = $this->
object->categories->getCategory(
$i);
 
  177            $value = ($cat->scale) ? ($cat->scale - 1) : 
$i;
 
  179            $checked = 
"unchecked";
 
  181            if (is_array($a_working_data)) {
 
  182                foreach ($user_answers as $user_answer) {
 
  183                    if ($value == $user_answer[
"value"]) {
 
  184                        $checked = 
"checked";
 
  185                        if ($user_answer[
"textanswer"]) {
 
  186                            $text = $user_answer[
"textanswer"];
 
  194            $idx = $cat->other . 
"_" . $value;
 
  196            if (!$a_only_user_anwers || $checked == 
"checked") {
 
  199                ,
"title" => trim($cat->title)
 
  200                ,
"other" => (
bool) $cat->other
 
  201                ,
"checked" => $checked
 
  202                ,
"textanswer" => 
$text 
  217    public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = 
null, array $a_working_data = 
null)
 
  221        $template = 
new ilTemplate(
"tpl.il_svy_qpl_mc_printview.html", 
true, 
true, 
"Modules/SurveyQuestionPool");
 
  222        switch ($this->object->getOrientation()) {
 
  226                    if ($option[
"other"]) {
 
  229                        $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt($option[
"checked"]));
 
  230                        $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($option[
"checked"]));
 
  232                        $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
 
  239                        $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt($option[
"checked"]));
 
  240                        $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($option[
"checked"]));
 
  249                    $template->setCurrentBlock(
"checkbox_col");
 
  251                    $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt($option[
"checked"]));
 
  252                    $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($option[
"checked"]));
 
  256                    if ($option[
"other"]) {
 
  257                        $template->setCurrentBlock(
"other_text_col");
 
  259                        $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
 
  272        if ($this->object->use_min_answers) {
 
  273            $template->setCurrentBlock(
'min_max_msg');
 
  274            if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0) {
 
  275                $template->setVariable(
'MIN_MAX_MSG', 
sprintf($this->lng->txt(
'msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers));
 
  276            } elseif ($this->object->nr_min_answers > 0) {
 
  277                $template->setVariable(
'MIN_MAX_MSG', 
sprintf($this->lng->txt(
'msg_min_nr_answers'), $this->object->nr_min_answers));
 
  278            } elseif ($this->object->nr_max_answers > 0) {
 
  279                $template->setVariable(
'MIN_MAX_MSG', 
sprintf($this->lng->txt(
'msg_max_nr_answers'), $this->object->nr_max_answers));
 
  283        if ($show_questiontext) {
 
  286        if ($question_title) {
 
  303    public function getWorkingForm($working_data = 
"", $question_title = 1, $show_questiontext = 1, $error_message = 
"", $survey_id = 
null)
 
  305        $template = 
new ilTemplate(
"tpl.il_svy_out_mc.html", 
true, 
true, 
"Modules/SurveyQuestionPool");
 
  309        switch ($this->object->getOrientation()) {
 
  312                for (
$i = 0; 
$i < $this->
object->categories->getCategoryCount(); 
$i++) {
 
  313                    $cat = $this->
object->categories->getCategory(
$i);
 
  316                        if (strlen($cat->title)) {
 
  317                            $template->setVariable(
"OTHER_LABEL", $cat->title);
 
  319                        $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : 
$i);
 
  320                        $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  321                        if (is_array($working_data)) {
 
  322                            foreach ($working_data as $value) {
 
  323                                if (strlen($value[
"value"])) {
 
  324                                    if ($value[
"value"] == $cat->scale-1) {
 
  326                                        if (!$value[
'uncheck']) {
 
  327                                            $template->setVariable(
"CHECKED_MC", 
" checked=\"checked\"");
 
  337                            $template->setVariable(
'ROWCLASS', 
' class="neutral"');
 
  340                        $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : 
$i);
 
  341                        $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  342                        if (is_array($working_data)) {
 
  343                            foreach ($working_data as $value) {
 
  344                                if (strlen($value[
"value"])) {
 
  345                                    if ($value[
"value"] == $cat->scale-1) {
 
  346                                        if (!$value[
'uncheck']) {
 
  347                                            $template->setVariable(
"CHECKED_MC", 
" checked=\"checked\"");
 
  362                for (
$i = 0; 
$i < $this->
object->categories->getCategoryCount(); 
$i++) {
 
  363                    $cat = $this->
object->categories->getCategory(
$i);
 
  366                    $template->setCurrentBlock(
"checkbox_col");
 
  368                        $template->setVariable(
'COLCLASS', 
' neutral');
 
  370                    $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : 
$i);
 
  371                    $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  372                    if (is_array($working_data)) {
 
  373                        foreach ($working_data as $value) {
 
  374                            if (strlen($value[
"value"])) {
 
  375                                if ($value[
"value"] == $cat->scale-1) {
 
  376                                    if (!$value[
'uncheck']) {
 
  377                                        $template->setVariable(
"CHECKED_MC", 
" checked=\"checked\"");
 
  387                        $template->setCurrentBlock(
"text_other_col");
 
  388                        $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : 
$i);
 
  389                        $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  390                        if (strlen($cat->title)) {
 
  391                            $template->setVariable(
"OTHER_LABEL", $cat->title);
 
  393                        if (is_array($working_data)) {
 
  394                            foreach ($working_data as $value) {
 
  395                                if (strlen($value[
"value"])) {
 
  396                                    if ($value[
"value"] == $cat->scale-1) {
 
  408                            $template->setVariable(
'COLCLASS', 
' neutral');
 
  410                        $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : 
$i);
 
  412                        $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  420        $template->setCurrentBlock(
"question_data");
 
  421        if ($this->object->use_min_answers) {
 
  422            $template->setCurrentBlock(
'min_max_msg');
 
  423            if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0) {
 
  424                if ($this->object->nr_min_answers == $this->object->nr_max_answers) {
 
  425                    $template->setVariable(
'MIN_MAX_MSG', 
sprintf($this->lng->txt(
'msg_min_max_exact_answers'), $this->object->nr_min_answers));
 
  427                    $template->setVariable(
'MIN_MAX_MSG', 
sprintf($this->lng->txt(
'msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers));
 
  429            } elseif ($this->object->nr_min_answers > 0) {
 
  430                $template->setVariable(
'MIN_MAX_MSG', 
sprintf($this->lng->txt(
'msg_min_nr_answers'), $this->object->nr_min_answers));
 
  431            } elseif ($this->object->nr_max_answers > 0) {
 
  432                $template->setVariable(
'MIN_MAX_MSG', 
sprintf($this->lng->txt(
'msg_max_nr_answers'), $this->object->nr_max_answers));
 
  436        if (strcmp($error_message, 
"") != 0) {
 
  437            $template->setVariable(
"ERROR_MESSAGE", 
"<p class=\"warning\">$error_message</p>");
 
  439        if ($show_questiontext) {
 
  442        if ($question_title) {
 
  443            $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
 
sprintf('%.4f', $callTime)
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
An exception for terminatinating execution or to throw for unit testing.
MultipleChoice survey question GUI representation.
getPrintView($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
Creates a HTML representation of the question.
importEditFormValues(ilPropertyFormGUI $a_form)
addFieldsToEditForm(ilPropertyFormGUI $a_form)
getWorkingForm($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
Creates the question output form for the learner.
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
validateEditForm(ilPropertyFormGUI $a_form)
MultipleChoice survey question.
Basic class for all survey question types.
getPrintViewQuestionTitle($question_title=1)
outQuestionText($template)
setQuestionTabsForClass($guiclass)
getMaterialOutput()
Creates the HTML output of the question material(s)
This class represents an option in a radio group.
special template class to simplify handling of ITX/PEAR
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getHtmlPath($relative_path)
get url of path
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public