From b3c4dad3709d81038397f63146f094fc095ccb89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fl=C3=BCr?= Date: Mon, 21 Jan 2019 14:48:46 +0100 Subject: [PATCH] Dev: QuestionType modelation has begun --- application/config/internal.php | 7 +- .../controllers/admin/questionedit.php | 5 + application/core/LSETwigViewRenderer.php | 2 +- .../5PointChoice/DataSetFivePointChoice.php | 5 + .../5PointChoice}/RenderFivePointChoice.php | 2 + .../DataSetArray5ChoiceQuestion.php | 5 + .../RenderArray10ChoiceQuestion.php | 53 ++++ .../DataSetArray5ChoiceQuestion.php | 5 + .../RenderArray5ChoiceQuestion.php | 53 ++++ .../DataSetArrayFlexibleColumn.php | 5 + .../RendererArrayFlexibleColumn.php | 53 ++++ .../DataSetArrayFlexibleRow.php | 5 + .../RenderArrayFlexibleRow.php | 53 ++++ .../DataSetArrayMultiFlexNumbers.php | 5 + .../RenderArrayMultiFlexNumbers.php | 53 ++++ .../DataSetArrayMultiFlexText.php | 5 + .../RenderArrayMultiFlexText.php | 53 ++++ .../DataSetArrayMultiscale.php | 5 + .../RenderArrayMultiscale.php} | 4 +- .../DataSetArrayOfIncSameDecQuestions.php | 5 + .../RenderArrayOfIncSameDecQuestions.php | 53 ++++ .../DataSetArrayYesUncertainNo.php | 5 + .../RenderArrayYesUncertainNo.php | 53 ++++ .../DataSetBoilerplate.php | 5 + .../RenderBoilerplate.php | 2 + .../core/QuestionTypes/Date/DataSetDate.php | 5 + .../QuestionTypes/Date}/RenderDate.php | 2 + .../DummyQuestion/DataSetDummyQuestion.php | 5 + .../DummyQuestion/RenderDummyQuestion.php} | 2 + .../Equation/DataSetEquation.php | 5 + .../Equation}/RenderEquation.php | 2 + .../FileUpload/DataSetFileUpload.php | 5 + .../FileUpload/RenderFileUpload.php | 53 ++++ .../GenderDropdown/DataSetGenderDropdown.php | 5 + .../GenderDropdown/RenderGenderDropdown.php | 53 ++++ .../HugeFreeText/DataSetHugeFreeText.php | 5 + .../HugeFreeText/RenderHugeFreeText.php} | 4 +- .../Language/DataSetLanguage.php | 5 + .../Language}/RenderLanguageSelector.php | 2 + .../ListDropdown/DataSetListDropdown.php | 5 + .../ListDropdown}/RenderListDropdown.php | 4 +- .../ListRadio/DataSetListRadio.php | 5 + .../ListRadio}/RenderListRadio.php | 2 + .../DataSetListRadioFlexible.php | 5 + .../RenderListRadioFlexible.php | 53 ++++ .../DataSetListWithComment.php | 5 + .../ListWithComment}/RenderListComment.php | 2 + .../core/QuestionTypes/LoadQuestionTypes.php | 37 +++ .../LongFreeText/DataSetLongFreeText.php | 5 + .../LongFreeText/RenderLongFreeText.php | 95 +++++++ .../MultipleChoice/DataSetMultipleChoice.php | 5 + .../MultipleChoice}/RenderMultipleChoice.php | 2 + .../DataSetMultipleChoiceWithComments.php | 5 + .../RenderMultipleChoiceWithComments.php | 2 + .../DataSetMultipleNumericalQuestion.php | 5 + .../RenderMultipleNumerical.php | 2 + .../DataSetMultipleShortText.php | 5 + .../RenderMultipleShortText.php | 6 +- .../Numerical/DataSetNumerical.php | 5 + .../Numerical/RenderNumerical.php | 53 ++++ .../RankingStyle/DataSetRankingStyle.php | 5 + .../RankingStyle}/RenderRanking.php | 2 + .../ShortFreeText/DataSetShortFreeText.php | 5 + .../ShortFreeText/RenderShortFreeText.php | 53 ++++ .../YesNoRadio/DataSetYesNoRadio.php | 5 + .../YesNoRadio/RenderYesNoRadio.php | 53 ++++ .../core/QuestionTypes/applyMinimumContent.js | 41 +++ .../core/QuestionTypes/package-lock.json | 11 + .../questionTypes/listRadio/config.xml | 26 -- .../questionTypes/listRadio/listRadio.php | 228 ---------------- application/models/Question.php | 84 ++++-- application/models/QuestionBaseDataSet.php | 250 ++++++++++++++++++ application/models/QuestionBaseRenderer.php | 9 + .../questioneditor/build/lsquestioneditor.js | 91 +++++-- assets/packages/questioneditor/src/App.vue | 1 + .../src/components/generalSettings.vue | 15 +- .../src/components/mainEditor.vue | 38 ++- .../questioneditor/src/storage/actions.js | 22 +- .../questioneditor/src/storage/mutations.js | 3 + .../questioneditor/src/storage/store.js | 1 + 80 files changed, 1587 insertions(+), 318 deletions(-) create mode 100644 application/core/QuestionTypes/5PointChoice/DataSetFivePointChoice.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/5PointChoice}/RenderFivePointChoice.php (99%) create mode 100644 application/core/QuestionTypes/Array10ChoiceQuestions/DataSetArray5ChoiceQuestion.php create mode 100644 application/core/QuestionTypes/Array10ChoiceQuestions/RenderArray10ChoiceQuestion.php create mode 100644 application/core/QuestionTypes/Array5ChoiceQuestions/DataSetArray5ChoiceQuestion.php create mode 100644 application/core/QuestionTypes/Array5ChoiceQuestions/RenderArray5ChoiceQuestion.php create mode 100644 application/core/QuestionTypes/ArrayFlexibleColumn/DataSetArrayFlexibleColumn.php create mode 100644 application/core/QuestionTypes/ArrayFlexibleColumn/RendererArrayFlexibleColumn.php create mode 100644 application/core/QuestionTypes/ArrayFlexibleRow/DataSetArrayFlexibleRow.php create mode 100644 application/core/QuestionTypes/ArrayFlexibleRow/RenderArrayFlexibleRow.php create mode 100644 application/core/QuestionTypes/ArrayMultiFlexNumbers/DataSetArrayMultiFlexNumbers.php create mode 100644 application/core/QuestionTypes/ArrayMultiFlexNumbers/RenderArrayMultiFlexNumbers.php create mode 100644 application/core/QuestionTypes/ArrayMultiFlexText/DataSetArrayMultiFlexText.php create mode 100644 application/core/QuestionTypes/ArrayMultiFlexText/RenderArrayMultiFlexText.php create mode 100644 application/core/QuestionTypes/ArrayMultiscale/DataSetArrayMultiscale.php rename application/{views/QuestionTypeRenderer/RenderArrayDual.php => core/QuestionTypes/ArrayMultiscale/RenderArrayMultiscale.php} (99%) create mode 100644 application/core/QuestionTypes/ArrayOfIncSameDecQuestions/DataSetArrayOfIncSameDecQuestions.php create mode 100644 application/core/QuestionTypes/ArrayOfIncSameDecQuestions/RenderArrayOfIncSameDecQuestions.php create mode 100644 application/core/QuestionTypes/ArrayYesUncertainNo/DataSetArrayYesUncertainNo.php create mode 100644 application/core/QuestionTypes/ArrayYesUncertainNo/RenderArrayYesUncertainNo.php create mode 100644 application/core/QuestionTypes/BoilerplateQuestion/DataSetBoilerplate.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/BoilerplateQuestion}/RenderBoilerplate.php (99%) create mode 100644 application/core/QuestionTypes/Date/DataSetDate.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/Date}/RenderDate.php (99%) create mode 100644 application/core/QuestionTypes/DummyQuestion/DataSetDummyQuestion.php rename application/{views/QuestionTypeRenderer/DummyQuestionEditContainer.php => core/QuestionTypes/DummyQuestion/RenderDummyQuestion.php} (99%) create mode 100644 application/core/QuestionTypes/Equation/DataSetEquation.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/Equation}/RenderEquation.php (99%) create mode 100644 application/core/QuestionTypes/FileUpload/DataSetFileUpload.php create mode 100644 application/core/QuestionTypes/FileUpload/RenderFileUpload.php create mode 100644 application/core/QuestionTypes/GenderDropdown/DataSetGenderDropdown.php create mode 100644 application/core/QuestionTypes/GenderDropdown/RenderGenderDropdown.php create mode 100644 application/core/QuestionTypes/HugeFreeText/DataSetHugeFreeText.php rename application/{views/QuestionTypeRenderer/RenderFreeText.php => core/QuestionTypes/HugeFreeText/RenderHugeFreeText.php} (98%) create mode 100644 application/core/QuestionTypes/Language/DataSetLanguage.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/Language}/RenderLanguageSelector.php (99%) create mode 100644 application/core/QuestionTypes/ListDropdown/DataSetListDropdown.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/ListDropdown}/RenderListDropdown.php (98%) create mode 100644 application/core/QuestionTypes/ListRadio/DataSetListRadio.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/ListRadio}/RenderListRadio.php (99%) create mode 100644 application/core/QuestionTypes/ListRadioFlexible/DataSetListRadioFlexible.php create mode 100644 application/core/QuestionTypes/ListRadioFlexible/RenderListRadioFlexible.php create mode 100644 application/core/QuestionTypes/ListWithComment/DataSetListWithComment.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/ListWithComment}/RenderListComment.php (99%) create mode 100644 application/core/QuestionTypes/LoadQuestionTypes.php create mode 100644 application/core/QuestionTypes/LongFreeText/DataSetLongFreeText.php create mode 100644 application/core/QuestionTypes/LongFreeText/RenderLongFreeText.php create mode 100644 application/core/QuestionTypes/MultipleChoice/DataSetMultipleChoice.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/MultipleChoice}/RenderMultipleChoice.php (99%) create mode 100644 application/core/QuestionTypes/MultipleChoiceWithComments/DataSetMultipleChoiceWithComments.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/MultipleChoiceWithComments}/RenderMultipleChoiceWithComments.php (99%) create mode 100644 application/core/QuestionTypes/MultipleNumericalQuestion/DataSetMultipleNumericalQuestion.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/MultipleNumericalQuestion}/RenderMultipleNumerical.php (99%) create mode 100644 application/core/QuestionTypes/MultipleShortText/DataSetMultipleShortText.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/MultipleShortText}/RenderMultipleShortText.php (98%) create mode 100644 application/core/QuestionTypes/Numerical/DataSetNumerical.php create mode 100644 application/core/QuestionTypes/Numerical/RenderNumerical.php create mode 100644 application/core/QuestionTypes/RankingStyle/DataSetRankingStyle.php rename application/{views/QuestionTypeRenderer => core/QuestionTypes/RankingStyle}/RenderRanking.php (99%) create mode 100644 application/core/QuestionTypes/ShortFreeText/DataSetShortFreeText.php create mode 100644 application/core/QuestionTypes/ShortFreeText/RenderShortFreeText.php create mode 100644 application/core/QuestionTypes/YesNoRadio/DataSetYesNoRadio.php create mode 100644 application/core/QuestionTypes/YesNoRadio/RenderYesNoRadio.php create mode 100644 application/core/QuestionTypes/applyMinimumContent.js create mode 100644 application/core/QuestionTypes/package-lock.json delete mode 100644 application/extensions/questionTypes/listRadio/config.xml delete mode 100644 application/extensions/questionTypes/listRadio/listRadio.php create mode 100644 application/models/QuestionBaseDataSet.php diff --git a/application/config/internal.php b/application/config/internal.php index 66d1c4e087e..a7acfcefb30 100644 --- a/application/config/internal.php +++ b/application/config/internal.php @@ -15,7 +15,6 @@ } if (!date_default_timezone_set(@date_default_timezone_get())) { - date_default_timezone_set('Europe/London'); } @@ -26,7 +25,6 @@ if (ini_get('mbstring.internal_encoding')) { ini_set('mbstring.internal_encoding', 'UTF-8'); } - } else { // Do nothing, will be checked in installation } @@ -46,12 +44,13 @@ // yiistrap configuration 'bootstrap' => realpath(__DIR__.'/../extensions/bootstrap'), - 'questiontypes' => realpath(__DIR__.'/../extensions/questionTypes'), 'vendor.twbs.bootstrap.dist' => realpath(__DIR__.'/../extensions/bootstrap'), // yiiwheels configuration 'yiiwheels' => realpath(__DIR__.'/../extensions/yiiwheels'), 'vendor.twbs.bootstrap.dist', + //Basic questiontype objects + 'questiontypes' => realpath(__DIR__.'/../core/QuestionTypes'), // Twig aliases. We don't want to change the file ETwigViewRenderer, so we can update it without difficulties // However, LimeSurvey directory tree is not a standard Yii Application tree. // we use 'third_party' instead of 'vendor' @@ -105,7 +104,7 @@ 'application.helpers.*', 'application.controllers.*', 'application.modules.*', - 'application.views.QuestionTypeRenderer.*', + 'application.core.questiontypes.*', 'bootstrap.helpers.*', 'bootstrap.widgets.*', 'bootstrap.behaviors.*', diff --git a/application/controllers/admin/questionedit.php b/application/controllers/admin/questionedit.php index 043de84cf62..9df933c9b0b 100644 --- a/application/controllers/admin/questionedit.php +++ b/application/controllers/admin/questionedit.php @@ -111,6 +111,11 @@ public function getQuestionAttributeData($iQuestionId){ public function getQuestionTypeList() { $this->renderJSON(QuestionType::modelsAttributes()); } + + public function getGeneralOptions($iQuestionId, $sQuestionType=null){ + $oQuestion = Question::model()->findByPk($iQuestionId); + $this->renderJSON($oQuestion->getDataSetObject()->getGeneralSettingsArray(null, $sQuestionType)); + } /** * Live preview rendering diff --git a/application/core/LSETwigViewRenderer.php b/application/core/LSETwigViewRenderer.php index 07e6f937111..6a5b242e369 100644 --- a/application/core/LSETwigViewRenderer.php +++ b/application/core/LSETwigViewRenderer.php @@ -97,7 +97,7 @@ public function renderTemplateForQuestionEditPreview($sLayout, $aDatas, $root = $line .= ''; //if($root === true) { $line = '' - . '' + . '' . file_get_contents($oLayoutTemplate->viewPath.'/subviews/header/head.twig') . $line; $line .= ''; diff --git a/application/core/QuestionTypes/5PointChoice/DataSetFivePointChoice.php b/application/core/QuestionTypes/5PointChoice/DataSetFivePointChoice.php new file mode 100644 index 00000000000..2e2f706d8be --- /dev/null +++ b/application/core/QuestionTypes/5PointChoice/DataSetFivePointChoice.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArray10ChoiceQuestion extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/Array5ChoiceQuestions/DataSetArray5ChoiceQuestion.php b/application/core/QuestionTypes/Array5ChoiceQuestions/DataSetArray5ChoiceQuestion.php new file mode 100644 index 00000000000..5ebb92dcb6a --- /dev/null +++ b/application/core/QuestionTypes/Array5ChoiceQuestions/DataSetArray5ChoiceQuestion.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArray5ChoiceQuestion extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/ArrayFlexibleColumn/DataSetArrayFlexibleColumn.php b/application/core/QuestionTypes/ArrayFlexibleColumn/DataSetArrayFlexibleColumn.php new file mode 100644 index 00000000000..5998fd1c2f9 --- /dev/null +++ b/application/core/QuestionTypes/ArrayFlexibleColumn/DataSetArrayFlexibleColumn.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArrayFlexibleColumn extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/ArrayFlexibleRow/DataSetArrayFlexibleRow.php b/application/core/QuestionTypes/ArrayFlexibleRow/DataSetArrayFlexibleRow.php new file mode 100644 index 00000000000..eac0d39f7d3 --- /dev/null +++ b/application/core/QuestionTypes/ArrayFlexibleRow/DataSetArrayFlexibleRow.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArrayFlexibleRow extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/ArrayMultiFlexNumbers/DataSetArrayMultiFlexNumbers.php b/application/core/QuestionTypes/ArrayMultiFlexNumbers/DataSetArrayMultiFlexNumbers.php new file mode 100644 index 00000000000..9707adcb36b --- /dev/null +++ b/application/core/QuestionTypes/ArrayMultiFlexNumbers/DataSetArrayMultiFlexNumbers.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArrayMultiFlexNumbers extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/ArrayMultiFlexText/DataSetArrayMultiFlexText.php b/application/core/QuestionTypes/ArrayMultiFlexText/DataSetArrayMultiFlexText.php new file mode 100644 index 00000000000..13753f7ae9f --- /dev/null +++ b/application/core/QuestionTypes/ArrayMultiFlexText/DataSetArrayMultiFlexText.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArrayMultiFlexText extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/ArrayMultiscale/DataSetArrayMultiscale.php b/application/core/QuestionTypes/ArrayMultiscale/DataSetArrayMultiscale.php new file mode 100644 index 00000000000..e75f74f3419 --- /dev/null +++ b/application/core/QuestionTypes/ArrayMultiscale/DataSetArrayMultiscale.php @@ -0,0 +1,5 @@ + string new group id for question in randomization group (GroupbyGroup Mode) * */ -class RenderArrayDual extends QuestionBaseRenderer +class RenderArrayMultiscale extends QuestionBaseRenderer { protected $aLabels; protected $numrows; diff --git a/application/core/QuestionTypes/ArrayOfIncSameDecQuestions/DataSetArrayOfIncSameDecQuestions.php b/application/core/QuestionTypes/ArrayOfIncSameDecQuestions/DataSetArrayOfIncSameDecQuestions.php new file mode 100644 index 00000000000..731230fc581 --- /dev/null +++ b/application/core/QuestionTypes/ArrayOfIncSameDecQuestions/DataSetArrayOfIncSameDecQuestions.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArrayOfIncSameDecQuestions extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/ArrayYesUncertainNo/DataSetArrayYesUncertainNo.php b/application/core/QuestionTypes/ArrayYesUncertainNo/DataSetArrayYesUncertainNo.php new file mode 100644 index 00000000000..d83cd4b970f --- /dev/null +++ b/application/core/QuestionTypes/ArrayYesUncertainNo/DataSetArrayYesUncertainNo.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderArrayYesUncertainNo extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/BoilerplateQuestion/DataSetBoilerplate.php b/application/core/QuestionTypes/BoilerplateQuestion/DataSetBoilerplate.php new file mode 100644 index 00000000000..8e3b9aea327 --- /dev/null +++ b/application/core/QuestionTypes/BoilerplateQuestion/DataSetBoilerplate.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderFileUpload extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/GenderDropdown/DataSetGenderDropdown.php b/application/core/QuestionTypes/GenderDropdown/DataSetGenderDropdown.php new file mode 100644 index 00000000000..bf3495de7d0 --- /dev/null +++ b/application/core/QuestionTypes/GenderDropdown/DataSetGenderDropdown.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class DummyQuestionEditContainer extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/HugeFreeText/DataSetHugeFreeText.php b/application/core/QuestionTypes/HugeFreeText/DataSetHugeFreeText.php new file mode 100644 index 00000000000..2745f08c31e --- /dev/null +++ b/application/core/QuestionTypes/HugeFreeText/DataSetHugeFreeText.php @@ -0,0 +1,5 @@ + string new group id for question in randomization group (GroupbyGroup Mode) * */ -class RenderFreeText extends QuestionBaseRenderer +class RenderHugeFreeText extends QuestionBaseRenderer { public function getMainView() { diff --git a/application/core/QuestionTypes/Language/DataSetLanguage.php b/application/core/QuestionTypes/Language/DataSetLanguage.php new file mode 100644 index 00000000000..a9f2245d2d7 --- /dev/null +++ b/application/core/QuestionTypes/Language/DataSetLanguage.php @@ -0,0 +1,5 @@ +getQuestionAttribute('dropdown_size')) && $this->getQuestionAttribute('dropdown_size') > 0) { + if ($this->getQuestionAttribute('dropdown_size') !== null && $this->getQuestionAttribute('dropdown_size') > 0) { $_height = sanitize_int($this->getQuestionAttribute('dropdown_size')); $_maxHeight = $this->getAnswerCount(); diff --git a/application/core/QuestionTypes/ListRadio/DataSetListRadio.php b/application/core/QuestionTypes/ListRadio/DataSetListRadio.php new file mode 100644 index 00000000000..c51bc23f40c --- /dev/null +++ b/application/core/QuestionTypes/ListRadio/DataSetListRadio.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderListRadioFlexible extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/ListWithComment/DataSetListWithComment.php b/application/core/QuestionTypes/ListWithComment/DataSetListWithComment.php new file mode 100644 index 00000000000..b99a0d4be8e --- /dev/null +++ b/application/core/QuestionTypes/ListWithComment/DataSetListWithComment.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderLongFreeText extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/longfreetext/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + $kpclass = ""; + $extraclass = ""; + $maxlength = ""; + $withColumn = false; + $inputsize = null; + + $drows = $this->setDefaultIfEmpty( + $this->getQuestionAttribute('display_rows'), + ($this->oQuestion->type == Question::QT_T_LONG_FREE_TEXT ? 4 : 30) + ); + + if ($this->oQuestion->survey->nokeyboard == 'Y') { + $this->includeKeypad(); + $kpclass = "text-keypad"; + $extraclass .= " inputkeypad"; + } + + // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea + if (intval(trim($this->getQuestionAttribute('maximum_chars'))) > 0) { + $maxlength = intval(trim($this->getQuestionAttribute('maximum_chars'))); + $extraclass .= " ls-input-maxchars"; + } + + // text_input_width can not be empty, except with old survey (wher can be empty or up to 12 see bug #11743 + if (trim($this->getQuestionAttribute('text_input_width')) != '') { + $col = ($this->getQuestionAttribute('text_input_width') <= 12) ? $this->getQuestionAttribute('text_input_width') : 12; + $extraclass .= " col-sm-".trim($col); + $withColumn = true; + } + + if (ctype_digit(trim($this->getQuestionAttribute('input_size')))) { + $inputsize = trim($this->getQuestionAttribute('input_size')); + $extraclass .= " ls-input-sized"; + } + + $answer = Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'extraclass' => $extraclass, + 'coreClass' => "ls-answers answer-item text-item ".$sCoreClasses, + 'withColumn' => $withColumn, + 'kpclass' => $kpclass, + 'name' => $this->sSGQA, + 'basename' => $this->sSGQA, + 'drows' => $drows, + 'checkconditionFunction' => 'checkconditions(this.value, this.name, this.type)', + 'dispVal' => htmlspecialchars($this->mSessionValue), + 'inputsize' => $inputsize, + 'maxlength' => $maxlength, + ), true); + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $inputnames[] = $this->sSGQA; + + $this->registerAssets(); + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/MultipleChoice/DataSetMultipleChoice.php b/application/core/QuestionTypes/MultipleChoice/DataSetMultipleChoice.php new file mode 100644 index 00000000000..769c87bcb27 --- /dev/null +++ b/application/core/QuestionTypes/MultipleChoice/DataSetMultipleChoice.php @@ -0,0 +1,5 @@ +setDefaultIfEmpty($this->getQuestionAttribute('prefix', $this->sLanguage), ''); + $sPrefix = $this->getQuestionAttribute('prefix', $this->sLanguage); if ($sPrefix != '') { $this->prefix = $sPrefix; $this->extraclass .= " withprefix"; } - $sSuffix = $this->setDefaultIfEmpty($this->getQuestionAttribute('suffix', $this->sLanguage), ''); + $sSuffix = $this->getQuestionAttribute('suffix', $this->sLanguage); if ($sSuffix != '') { $this->suffix = $sSuffix; $this->extraclass .= " withsuffix"; diff --git a/application/core/QuestionTypes/Numerical/DataSetNumerical.php b/application/core/QuestionTypes/Numerical/DataSetNumerical.php new file mode 100644 index 00000000000..cadcdad81fe --- /dev/null +++ b/application/core/QuestionTypes/Numerical/DataSetNumerical.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderNumerical extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/RankingStyle/DataSetRankingStyle.php b/application/core/QuestionTypes/RankingStyle/DataSetRankingStyle.php new file mode 100644 index 00000000000..18dc12cc0f0 --- /dev/null +++ b/application/core/QuestionTypes/RankingStyle/DataSetRankingStyle.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderShortFreeText extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/YesNoRadio/DataSetYesNoRadio.php b/application/core/QuestionTypes/YesNoRadio/DataSetYesNoRadio.php new file mode 100644 index 00000000000..194b21a0451 --- /dev/null +++ b/application/core/QuestionTypes/YesNoRadio/DataSetYesNoRadio.php @@ -0,0 +1,5 @@ + string qid + * 1 => string sgqa + * 2 => string questioncode + * 3 => string question + * 4 => string type + * 5 => string gid + * 6 => string mandatory, + * 7 => string conditionsexist, + * 8 => string usedinconditions + * 0 => string used in group.php for question count + * 10 => string new group id for question in randomization group (GroupbyGroup Mode) + * + */ +class RenderYesNoRadio extends QuestionBaseRenderer +{ + public function getMainView() + { + return '/survey/questions/answer/dummy/answer'; + } + + public function getRows() + { + return; + } + + public function render($sCoreClasses = '') + { + $answer = ''; + $inputnames = []; + + if (!empty($this->getQuestionAttribute('time_limit', 'value'))) { + $answer .= $this->getTimeSettingRender(); + } + + $answer .= Yii::app()->twigRenderer->renderQuestion($this->getMainView(), array( + 'ia'=>$this->aFieldArray, + 'name'=>$this->sSGQA, + 'basename'=>$this->sSGQA, + 'content' => $this->oQuestion, + 'coreClass'=> 'ls-answers '.$sCoreClasses, + ), true); + + $inputnames[] = []; + return array($answer, $inputnames); + } +} diff --git a/application/core/QuestionTypes/applyMinimumContent.js b/application/core/QuestionTypes/applyMinimumContent.js new file mode 100644 index 00000000000..dbe2223d629 --- /dev/null +++ b/application/core/QuestionTypes/applyMinimumContent.js @@ -0,0 +1,41 @@ +const fs = require('fs'); +const path = require('path'); +const cwd = process.cwd(); + +const minimalContent = ` { + if(/^NameSpace.*$/.test(file)) { + fs.unlinkSync(path.join(cwd, folderDirent, file)); + } else if(/^LoadQuestionTypes.*$/.test(file)) { + fs.unlinkSync(path.join(cwd, folderDirent, file)); + } else { + console.log(`${file}`) + let filecontent = fs.readFileSync(path.join(cwd, folderDirent, file), {encoding: 'utf8'}); + let toWrite = filecontent.replace(/namespace QuestionTypes;\n/, ''); + fs.writeFileSync(path.join(cwd, folderDirent, file), toWrite); + } + }); + return sQuestionTypes; +} + + +fs.readdir(path.normalize(cwd) ,(err, files) => { + if(err) throw err; + let toWrite = ''; + files.forEach((file, i) => { + //console.log(file); + if(fs.statSync(path.join(cwd,file)).isDirectory()) { + //toWrite += applyDataSetFile(file); + toWrite += `Yii::import('questiontypes.${file.toLowerCase()}.*'); +` + } + }); + let filecontent = fs.readFileSync(path.join(cwd, 'LoadQuestionTypes.php'), {encoding: 'utf8'}); + fs.writeFileSync(path.join(cwd, 'LoadQuestionTypes.php'), filecontent+"\n"+toWrite); +}); \ No newline at end of file diff --git a/application/core/QuestionTypes/package-lock.json b/application/core/QuestionTypes/package-lock.json new file mode 100644 index 00000000000..4c1da7b25da --- /dev/null +++ b/application/core/QuestionTypes/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + } + } +} diff --git a/application/extensions/questionTypes/listRadio/config.xml b/application/extensions/questionTypes/listRadio/config.xml deleted file mode 100644 index c1b2282b57a..00000000000 --- a/application/extensions/questionTypes/listRadio/config.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - List Radio External - 12/12/2015 - Louis-Sébastien Gac Artigas - louis.gac@limesurvey.org - http://www.limesurvey.org - Copyright (C) 2005 - 2016 LimeSurvey Gmbh, Inc. All rights reserved. - GNU General Public License version 2 or later - 1.0 - Just the normal list radio question, but as an external component. - TODO - - - listRadio - L_M - L - New list radio - Single choice questions - 0 - 1 - 1 - 1 - - diff --git a/application/extensions/questionTypes/listRadio/listRadio.php b/application/extensions/questionTypes/listRadio/listRadio.php deleted file mode 100644 index 54923b5fdf6..00000000000 --- a/application/extensions/questionTypes/listRadio/listRadio.php +++ /dev/null @@ -1,228 +0,0 @@ -getQuestionAttributes($ia[0]); - - $query = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' "; - $result = Yii::app()->db->createCommand($query)->query(); - foreach ($result->readAll() as $row) - { - $other = $row['other']; - } - - //question attribute random order - $sQuestion = Question::model()->findAllByPk($ia[0]); - $ansresult = $sQuestion->getOrderedAnswers($aQuestionAttributes['random_order'],$aQuestionAttributes['alphasort']); - $anscount = count($ansresult); - - $dcols = $aQuestionAttributes['display_columns']; - - if (trim($aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') - { - $othertext=$aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; - } - else - { - $othertext=gT('Other:'); - } - - if (isset($other) && $other=='Y') {$anscount++;} //Count up for the Other answer - if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {$anscount++;} //Count up if "No answer" is showing - - $wrapper = setupColumns($dcols , $anscount,"answers-list radio-list","answer-item radio-item"); - - $iBootCols = round(12/$dcols); - $ansByCol = round($anscount/$dcols); $ansByCol = ($ansByCol > 0)?$ansByCol:1; - - //$answer = 'IKI: '.$iBootCols.' '.$ansByCol.' '.$wrapper['whole-start']; - $answer = '
'; - $answer .= '
AAAAAAAAAAAAAA'; - - //Time Limit Code - if (trim($aQuestionAttributes['time_limit'])!='') - { - $answer .= return_timer_script($aQuestionAttributes, $ia); - } - //End Time Limit Code - - // Get array_filter stuff - - $rowcounter = 0; - $colcounter = 1; - $trbc=''; - - foreach ($ansresult as $ansrow) - { - $myfname = $ia[1].$ansrow['code']; - $check_ans = ''; - if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $ansrow['code']) - { - $check_ans = CHECKED; - } - list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "div","form-group answer-item radio-item"); - /* if(substr($wrapper['item-start'],0,4) == "\t'.$ansrow['answer'].''; - $answer .= ' '; - $answer .= $wrapper['item-end']; - $answer .= '
'; - - ++$rowcounter; - if ($rowcounter == $ansByCol && $colcounter < $wrapper['cols']) - { - if($colcounter == $wrapper['cols'] ) - { - $answer .= '
'; - } - else - { - $answer .= ' '; - $answer .= '
'; - } - $rowcounter = 0; - ++$colcounter; - } - } - - if (isset($other) && $other=='Y') - { - - $sSeparator = getRadixPointData($thissurvey['surveyls_numberformat']); - $sSeparator = $sSeparator['separator']; - - if ($aQuestionAttributes['other_numbers_only']==1) - { - $oth_checkconditionFunction = 'fixnum_checkconditions'; - } - else - { - $oth_checkconditionFunction = 'checkconditions'; - } - - - if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == '-oth-') - { - $check_ans = CHECKED; - } - else - { - $check_ans = ''; - } - - $thisfieldname=$ia[1].'other'; - if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname])) - { - $dispVal = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname]; - if ($aQuestionAttributes['other_numbers_only']==1) - { - $dispVal = str_replace('.',$sSeparator,$dispVal); - } - $answer_other = ' value="'.htmlspecialchars($dispVal,ENT_QUOTES).'"'; - } - else - { - $answer_other = ' value=""'; - } - - list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, array("code"=>"other"), $thisfieldname, $trbc, $myfname, "div", "form-group answer-item radio-item other-item other"); - - $answer .= "\t$hiddenfield\n"; - $answer .= '
'; - $answer .= ' '; - $answer .= ' '; - $answer .= ' '; - $answer .= $wrapper['item-end']; - $answer .= '
'; - $inputnames[]=$thisfieldname; - - ++$rowcounter; - if ($rowcounter == $ansByCol && $colcounter < $wrapper['cols']) - { - if($colcounter == $wrapper['cols'] ) - { - $answer .= '
'; - } - else - { - $answer .= ' '; - $answer .= '
'; - } - $rowcounter = 0; - ++$colcounter; - } - } - - if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) - { - if ((!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == '') || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == ' ' )) - { - $check_ans = CHECKED; //Check the "no answer" radio button if there is no answer in session. - } - else - { - $check_ans = ''; - } - - $answer .= '
'; - $answer .= ' '; - $answer .= ' '; - $answer .= $wrapper['item-end']; - $answer .= '
'; - - // --> END NEW FEATURE - SAVE - - ++$rowcounter; - //if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) - if ($rowcounter == $ansByCol && $colcounter < $wrapper['cols']) - { - if($colcounter == $wrapper['cols'] ) - { - //$answer .= $wrapper['col-devide-last']; - $answer .= '
'; - } - else - { - //$answer .= $wrapper['col-devide']; - $answer .= ' '; - $answer .= '
'; - } - $rowcounter = 0; - ++$colcounter; - } - - } - //END OF ITEMS - //$answer .= $wrapper['whole-end'].' - $answer .= ' getConfig('surveyID')][$ia[1]]."\" />\n"; - $answer .= '
'; - - $inputnames[]=$ia[1]; - return array($answer, $inputnames); - - } -} diff --git a/application/models/Question.php b/application/models/Question.php index e53b6b2a773..a8763f8c03e 100644 --- a/application/models/Question.php +++ b/application/models/Question.php @@ -133,7 +133,7 @@ public function rules() array('title', 'required', 'on' => 'update, insert', 'message'=>gT('The question code is mandatory.', 'unescaped')), array('title', 'length', 'min' => 1, 'max'=>20, 'on' => 'update, insert'), array('qid,sid,gid,parent_qid', 'numerical', 'integerOnly'=>true), - array('qid', 'unique','message'=>sprintf(gT("Question id (qid) : '%s' is already in use."),$this->qid)),// Still needed ? + array('qid', 'unique','message'=>sprintf(gT("Question id (qid) : '%s' is already in use."), $this->qid)),// Still needed ? array('other', 'in', 'range'=>array('Y', 'N'), 'allowEmpty'=>true), array('mandatory', 'in', 'range'=>array('Y', 'N'), 'allowEmpty'=>true), array('question_order', 'numerical', 'integerOnly'=>true, 'allowEmpty'=>true), @@ -205,7 +205,7 @@ public function rules() 'SGQ', 'TOKEN', ), - 'message'=> sprintf(gT("Code: '%s' is a reserved word."),$this->title), // Usage of {attribute} need attributeLabels, {value} never exist in message + 'message'=> sprintf(gT("Code: '%s' is a reserved word."), $this->title), // Usage of {attribute} need attributeLabels, {value} never exist in message 'except' => 'archiveimport' ); } else { @@ -507,14 +507,14 @@ public function getTypedesc() */ public static function typeList($language = null) { - $questionTypes = QuestionType::modelsAttributes($language); + $QuestionTypes = QuestionType::modelsAttributes($language); /** * @todo Check if this actually does anything, since the values are arrays. */ - asort($questionTypes); + asort($QuestionTypes); - return $questionTypes; + return $QuestionTypes; } /** @@ -910,13 +910,14 @@ public function getAllSubQuestionIds() public function getRenderererObject($aFieldArray, $type = null) { + LoadQuestionTypes::loadAll(); $type = $type === null ? $this->type : $type; switch ($type) { case Question::QT_X_BOILERPLATE_QUESTION: return new RenderBoilerplate($aFieldArray); case Question::QT_5_POINT_CHOICE: return new RenderFivePointChoice($aFieldArray); case Question::QT_ASTERISK_EQUATION: return new RenderEquation($aFieldArray); case Question::QT_D_DATE: return new RenderDate($aFieldArray); - case Question::QT_1_ARRAY_MULTISCALE: return new RenderArrayDual($aFieldArray); + case Question::QT_1_ARRAY_MULTISCALE: return new RenderArrayMultiscale($aFieldArray); case Question::QT_L_LIST_DROPDOWN: return new RenderListRadio($aFieldArray); case Question::QT_EXCLAMATION_LIST_DROPDOWN: return new RenderListDropdown($aFieldArray); case Question::QT_O_LIST_WITH_COMMENT: return new RenderListComment($aFieldArray); @@ -925,23 +926,62 @@ public function getRenderererObject($aFieldArray, $type = null) case Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS: return new RenderMultipleChoiceWithComments($aFieldArray); case Question::QT_I_LANGUAGE: return new RenderLanguageSelector($aFieldArray); case Question::QT_Q_MULTIPLE_SHORT_TEXT: return new RenderMultipleShortText($aFieldArray); - case Question::QT_T_LONG_FREE_TEXT: //fallthrough - case Question::QT_U_HUGE_FREE_TEXT: return new RenderFreeText($aFieldArray); + case Question::QT_T_LONG_FREE_TEXT: return new RenderLongFreeText($aFieldArray); + case Question::QT_U_HUGE_FREE_TEXT: return new RenderHugeFreeText($aFieldArray); case Question::QT_K_MULTIPLE_NUMERICAL_QUESTION: return new RenderMultipleNumerical($aFieldArray); - case Question::QT_A_ARRAY_5_CHOICE_QUESTIONS: - case Question::QT_B_ARRAY_10_CHOICE_QUESTIONS: - case Question::QT_C_ARRAY_YES_UNCERTAIN_NO: - case Question::QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS: - case Question::QT_F_ARRAY_FLEXIBLE_ROW: - case Question::QT_G_GENDER_DROPDOWN: - case Question::QT_H_ARRAY_FLEXIBLE_COLUMN: - case Question::QT_N_NUMERICAL: - case Question::QT_S_SHORT_FREE_TEXT: - case Question::QT_Y_YES_NO_RADIO: - case Question::QT_Z_LIST_RADIO_FLEXIBLE: - case Question::QT_COLON_ARRAY_MULTI_FLEX_NUMBERS: - case Question::QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT: - case Question::QT_VERTICAL_FILE_UPLOAD: + case Question::QT_A_ARRAY_5_CHOICE_QUESTIONS: return new RenderArray5ChoiceQuestion($aFieldArray); + case Question::QT_B_ARRAY_10_CHOICE_QUESTIONS: return new RenderArray10ChoiceQuestion($aFieldArray); + case Question::QT_C_ARRAY_YES_UNCERTAIN_NO: return new RenderArrayYesUncertainNo($aFieldArray); + case Question::QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS: return new RenderArrayOfIncSameDecQuestions($aFieldArray); + case Question::QT_F_ARRAY_FLEXIBLE_ROW: return new RenderArrayFlexibleRow($aFieldArray); + case Question::QT_G_GENDER_DROPDOWN: return new RenderGenderDropdown($aFieldArray); + case Question::QT_H_ARRAY_FLEXIBLE_COLUMN: return new RendererArrayFlexibleColumn($aFieldArray); + case Question::QT_N_NUMERICAL: return new RenderNumerical($aFieldArray); + case Question::QT_S_SHORT_FREE_TEXT: return new RenderShortFreeText($aFieldArray); + case Question::QT_Y_YES_NO_RADIO: return new RenderYesNoRadio($aFieldArray); + case Question::QT_Z_LIST_RADIO_FLEXIBLE: return new RenderListRadioFlexible($aFieldArray); + case Question::QT_COLON_ARRAY_MULTI_FLEX_NUMBERS: return new RenderArrayMultiFlexNumbers($aFieldArray); + case Question::QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT: return new RenderArrayMultiFlexText($aFieldArray); + case Question::QT_VERTICAL_FILE_UPLOAD: return new RenderFileUpload($aFieldArray); + default: return new DummyQuestionEditContainer($aFieldArray); + }; + } + + public function getDataSetObject($type = null) + { + LoadQuestionTypes::loadAll(); + $type = $type === null ? $this->type : $type; + switch ($type) { + case Question::QT_X_BOILERPLATE_QUESTION: return new DataSetBoilerplate($this->qid); + case Question::QT_5_POINT_CHOICE: return new DataSetFivePointChoice($this->qid); + case Question::QT_ASTERISK_EQUATION: return new DataSetEquation($this->qid); + case Question::QT_D_DATE: return new DataSetDate($this->qid); + case Question::QT_1_ARRAY_MULTISCALE: return new DataSetArrayMultiscale($this->qid); + case Question::QT_L_LIST_DROPDOWN: return new DataSetListDropdown($this->qid); + case Question::QT_EXCLAMATION_LIST_DROPDOWN: return new DataSetListRadio($this->qid); + case Question::QT_O_LIST_WITH_COMMENT: return new DataSetListWithComment($this->qid); + case Question::QT_R_RANKING_STYLE: return new RenderRanking($aFieldArray); + case Question::QT_M_MULTIPLE_CHOICE: return new DataSetMultipleChoice($this->qid); + case Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS: return new DataSetMultipleChoiceWithComments($this->qid); + case Question::QT_I_LANGUAGE: return new DataSetLanguage($this->qid); + case Question::QT_Q_MULTIPLE_SHORT_TEXT: new DataSetMultipleShortText($this->qid); + case Question::QT_T_LONG_FREE_TEXT: return new DataSetHugeFreeText($this->qid); + case Question::QT_U_HUGE_FREE_TEXT: return new DataSetLongFreeText($this->qid); + case Question::QT_K_MULTIPLE_NUMERICAL_QUESTION: return new RenderMultipleNumerical($aFieldArray); + case Question::QT_A_ARRAY_5_CHOICE_QUESTIONS: return new DataSetArray5ChoiceQuestion($this->qid); + case Question::QT_B_ARRAY_10_CHOICE_QUESTIONS: return new DataSetArray10ChoiceQuestion($this->qid); + case Question::QT_C_ARRAY_YES_UNCERTAIN_NO: return new DataSetArrayYesUncertainNo($this->qid); + case Question::QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS: return new DataSetArrayOfIncSameDecQuestions($this->qid); + case Question::QT_F_ARRAY_FLEXIBLE_ROW: return new DataSetArrayFlexibleRow($this->qid); + case Question::QT_G_GENDER_DROPDOWN: return new DataSetGenderDropdown($this->qid); + case Question::QT_H_ARRAY_FLEXIBLE_COLUMN: return new DataSetArrayFlexibleColumn($this->qid); + case Question::QT_N_NUMERICAL: return new DataSetNumerical($this->qid); + case Question::QT_S_SHORT_FREE_TEXT: return new DataSetShortFreeText($this->qid); + case Question::QT_Y_YES_NO_RADIO: return new DataSetYesNoRadio($this->qid); + case Question::QT_Z_LIST_RADIO_FLEXIBLE: return new DataSetListRadioFlexible($this->qid); + case Question::QT_COLON_ARRAY_MULTI_FLEX_NUMBERS: return new DataSetArrayMultiFlexNumbers($this->qid); + case Question::QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT: return new DataSetArrayMultiFlexText($this->qid); + case Question::QT_VERTICAL_FILE_UPLOAD: return new DataSetFileUpload($this->qid); default: return new DummyQuestionEditContainer($aFieldArray); }; } diff --git a/application/models/QuestionBaseDataSet.php b/application/models/QuestionBaseDataSet.php new file mode 100644 index 00000000000..f45a592d68b --- /dev/null +++ b/application/models/QuestionBaseDataSet.php @@ -0,0 +1,250 @@ +iQuestionId = $iQuestionId; + $this->oQuestion = Question::model()->findByPk($iQuestionId); + } + + /** + * Returns a preformatted block of the general settings for the question editor + * + * @param int $iQuestionID + * @param int $sQuestionType + * @param int $iSurveyID + * @param string $sLanguage + * @return array + */ + public function getGeneralSettingsArray($iQuestionID = null, $sQuestionType = null, $sLanguage = null) + { + if ($iQuestionID != null) { + $this->oQuestion = Question::model()->findByPk($iQuestionID); + } + + $this->sQuestionType = $sQuestionType == null ? $this->oQuestion->type : $sQuestionType; + $this->sLanguage = $sLanguage == null ? $this->oQuestion->survey->language : $sLanguage; + + /* + @todo Discussion: + General options currently are + - Question theme => this should have a seperate advanced tab in my opinion + - Question group + - Mandatory switch + - Relevance equation + - Validation => this is clearly a logic function + + Better add to general options: + - Hide Tip => VERY OFTEN asked for + - Always hide question => if available + */ + return [ + $this->getQuestionThemeOption(), + $this->getQuestionGroupSelector(), + $this->getOtherSwitch(), + $this->getMandatorySwitch(), + $this->getRelevanceEquationInput(), + $this->getValidationInput(), + ]; + } + + //Question theme + public function getQuestionThemeOption() + { + $aQuestionTemplateList = QuestionTemplate::getQuestionTemplateList($this->sQuestionType); + $aQuestionTemplateAttributes = Question::model()->getAdvancedSettingsWithValues($this->oQuestion->qid, $this->sQuestionType, $this->oQuestion->survey->sid)['question_template']; + + $sQuestionTemplateSettingsItemHtml = '

'.gT("Use a customized question theme for this question").'

' + .'' + .'
' + .''.gT("Preview:").'' + .'
' + .'' + .'
' + .'
'; + + return [ + 'name' => 'QuestionTheme', + 'title' => gT('Question theme'), + 'formElementId' => 'question_template', + 'formElementName' => false, //false means identical to id + 'formElementHelp' => gT("Use a customized question theme for this question"), + 'formElement' => 'select', + 'formElementOptions' => [ + 'classes' => ['form-control'], + 'options' => $aOptionsArray, + ], + 'formElementHtml' => $sQuestionTemplateSettingsItemHtml //just for proof of concept + ]; + } + + //Question group + public function getQuestionGroupSelector() + { + $aGroupsToSelect = QuestionGroup::model()->findAllByAttributes(array('sid' => $this->oQuestion->sid), array('order'=>'group_order')); + $aGroupOptions = array_map( + function ($oQuestionGroup) { + return [ + 'name' => $oQuestionGroup->questionGroupL10ns[$this->sLanguage]->group_name, + 'value' => $oQuestionGroup->gid, + 'selected' => $oQuestionGroup->gid == $this->oQuestion->gid + ]; + }, + $aGroupsToSelect + ); + $QuestionGroupSettingsItemHtml = ''; + $QuestionGroupSettingsItemHtml = '
' + .''; + if ($this->oQuestion->survey->isActive) { + $QuestionGroupSettingsItemHtml .= ''; + } + $QuestionGroupSettingsItemHtml .= '
'; + return [ + 'name' => 'QuestionGroup', + 'title' => gT('Question group'), + 'formElementId' => 'gid', + 'formElementName' => false, + 'formElementHelp' => gT("If you want to change the question group this question is in."), + 'formElement' => 'select', + 'formElementOptions' => [ + 'classes' => ['form-control'], + 'options' => $aGroupOptions, + ], + 'formElementHtml' => $QuestionGroupSettingsItemHtml + ]; + } + + public function getOtherSwitch() + { + return [ + 'name' => 'other', + 'title' => gT('Other'), + 'formElementId' => 'other', + 'formElementName' => false, + 'formElementHelp' => gT('Activate the "other" option for your question'), + 'formElement' => 'switcher', + 'formElementOptions' => [ + 'classes' => [], + 'switchData' => [ + 'on-text' => "On", + 'off-text' => "Off", + 'on-color' => "primary", + 'off-color' => "warning", + 'size' => "small", + ], + ], + 'formElementHtml' => '' + ]; + } + + public function getMandatorySwitch() + { + return [ + 'name' => 'mandatory', + 'title' => gT('Mandatory'), + 'formElementId' => 'mandatory', + 'formElementName' => false, + 'formElementHelp' => gT('Makes this question mandatory in your survey'), + 'formElement' => 'switcher', + 'formElementOptions' => [ + 'classes' => [], + 'switchData' => [ + 'on-text' => "On", + 'off-text' => "Off", + 'on-color' => "primary", + 'off-color' => "warning", + 'size' => "small", + ], + ], + 'formElementHtml' =>'' + ]; + } + + public function getRelevanceEquationInput() + { + $relevanceIntputHtml = '' + .'
+
{
+ ' + .'
}
' + .'
'; + if (count($this->oQuestion->conditions) > 0) { + $relevanceIntputHtml .= '
' + . gT("Note: You can't edit the relevance equation because there are currently conditions set for this question.") + .'
'; + } + + return [ + 'name' => 'RelevanceEquation', + 'title' => gT('Relevance equation'), + 'formElementId' => 'relevance', + 'formElementName' => false, + 'formElementHelp' => (count($this->oQuestion->conditions)>0 + ? gT("Note: You can't edit the relevance equation because there are currently conditions set for this question.") + : gT("The relevance equation can be used to add branching logic. This is a rather advanced topic. If you are unsure, just leave it be.")), + 'formElement' => 'textarea', + 'formElementOptions' => [ + 'classes' => 'form-control', + 'attributes' => [ + 'rows' => 1, + 'readonly' => count($this->oQuestion->conditions)>0 + ], + 'inputGroup' => [ + 'prefix' => '{', + 'suffix' => '}', + ] + ], + 'formElementHtml' => $relevanceIntputHtml + ]; + } + + public function getValidationInput() + { + return [ + 'name' => 'RelevanceEquation', + 'title' => gT('Relevance equation'), + 'formElementId' => 'preg', + 'formElementName' => false, + 'formElementHelp' => gT('You can add any regular expression based validation in here'), + 'formElement' => 'input', + 'formElementOptions' => [ + 'classes' => 'form-control', + 'inputGroup' => [ + 'prefix' => 'RegExp', + ] + ], + 'formElementHtml' => '' + ]; + } +} diff --git a/application/models/QuestionBaseRenderer.php b/application/models/QuestionBaseRenderer.php index 3de2eee7f3f..78dfd379f13 100644 --- a/application/models/QuestionBaseRenderer.php +++ b/application/models/QuestionBaseRenderer.php @@ -48,11 +48,17 @@ public function __construct($aFieldArray, $bRenderDirect = false) $this->oQuestion = Question::model()->findByPk($aFieldArray[0]); $this->bRenderDirect = $bRenderDirect; $this->sLanguage = $this->setDefaultIfEmpty(@$aFieldArray['language'], @$_SESSION['survey_'.$this->oQuestion->sid]['s_lang']); + if(!$this->sLanguage) { + $this->sLanguage = $this->oQuestion->survey->language; + } + $this->aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($this->oQuestion->qid); $this->aSurveySessionArray = @$_SESSION['survey_'.$this->oQuestion->sid]; $this->mSessionValue = @$this->setDefaultIfEmpty($this->aSurveySessionArray[$this->sSGQA], ''); + $oQuestionTemplate = QuestionTemplate::getNewInstance($this->oQuestion); $oQuestionTemplate->registerAssets(); // Register the custom assets of the question template, if needed + } protected function getTimeSettingRender() @@ -310,6 +316,9 @@ protected function applyStyles() protected function setDefaultIfEmpty($value, $default) { + if(!$value) { + return $default; + } return trim($value) == '' ? $default : $value; } diff --git a/assets/packages/questioneditor/build/lsquestioneditor.js b/assets/packages/questioneditor/build/lsquestioneditor.js index 49b5164a909..0ed22efc93e 100644 --- a/assets/packages/questioneditor/build/lsquestioneditor.js +++ b/assets/packages/questioneditor/build/lsquestioneditor.js @@ -11440,7 +11440,7 @@ exports = module.exports = __webpack_require__(2)(true); // module -exports.push([module.i, "\n.loading-back-greyed[data-v-05c0cfb0] {\r\n background-color: rgba(200,200,200,0.4);\r\n width: 100%;\r\n height: 100%;\r\n min-height: 60vh;\n}\r\n", "", {"version":3,"sources":["C:/IISPages/LimeSurveyDevelop/assets/packages/questioneditor/src/App.vue?6aaf0f4f"],"names":[],"mappings":";AAiDA;IACA,wCAAA;IACA,YAAA;IACA,aAAA;IACA,iBAAA;CACA","file":"App.vue","sourcesContent":["\r\n\r\n\r\n\r\n\r\n"],"sourceRoot":""}]); +exports.push([module.i, "\n.loading-back-greyed[data-v-05c0cfb0] {\r\n background-color: rgba(200,200,200,0.4);\r\n width: 100%;\r\n height: 100%;\r\n min-height: 60vh;\n}\r\n", "", {"version":3,"sources":["C:/IISPages/LimeSurveyDevelop/assets/packages/questioneditor/src/App.vue?0cda2e56"],"names":[],"mappings":";AAkDA;IACA,wCAAA;IACA,YAAA;IACA,aAAA;IACA,iBAAA;CACA","file":"App.vue","sourcesContent":["\r\n\r\n\r\n\r\n\r\n"],"sourceRoot":""}]); // exports @@ -11524,6 +11524,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); created() { this.$store.dispatch('loadQuestion'); this.$store.dispatch('getQuestionTypes'); + this.$store.dispatch('getQuestionGeneralSettings'); } }); @@ -11643,7 +11644,6 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); data() { return { currentQuestionCode: '', - currentQuestionType: '', editorQuestion: __WEBPACK_IMPORTED_MODULE_0__ckeditor_ckeditor5_build_classic___default.a, editorQuestionData: '', editorQuestionConfig: {}, @@ -11678,25 +11678,32 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); currentQuestionI10N() { return this.$store.state.currentQuestionI10N[this.$store.state.activeLanguage]; }, - questionImmutableI10N() { - return this.$store.state.questionImmutableI10N[this.$store.state.activeLanguage]; + questionImmutableI10NQuestion() { + return this.$store.state.questionImmutableI10N[this.$store.state.activeLanguage].question; + }, + questionImmutableI10NHelp() { + return this.$store.state.questionImmutableI10N[this.$store.state.activeLanguage].help; } }, methods: { changedParts() { let changed = {}; - this.$log.log('COMPARING', { - 'this.$store.state.questionImmutable': this.$store.state.questionImmutable, - 'this.currentQuestionType': this.currentQuestionType, - 'this.currentQuestionI10N': this.currentQuestionI10N, - 'this.questionImmutableI10N': this.questionImmutableI10N + this.$log.log('CHANGE!', { + currentQuestionQuestion: this.currentQuestionQuestion, + questionImmutableI10NQuestion: this.questionImmutableI10NQuestion, + currentQuestionHelp: this.currentQuestionHelp, + questionImmutableI10NHelp: this.questionImmutableI10NHelp, + 'questionEqal': __WEBPACK_IMPORTED_MODULE_2_lodash_isEqual___default.a(this.currentQuestionQuestion, this.questionImmutableI10NQuestion), + 'helpEqual': __WEBPACK_IMPORTED_MODULE_2_lodash_isEqual___default.a(this.currentQuestionHelp, this.questionImmutableI10NHelp) }); - if (!__WEBPACK_IMPORTED_MODULE_2_lodash_isEqual___default.a(this.currentQuestionI10N, this.questionImmutableI10N)) { + if (!(__WEBPACK_IMPORTED_MODULE_2_lodash_isEqual___default.a(this.currentQuestionQuestion, this.questionImmutableI10NQuestion) && __WEBPACK_IMPORTED_MODULE_2_lodash_isEqual___default.a(this.currentQuestionHelp, this.questionImmutableI10NHelp))) { changed['changedText'] = this.currentQuestionI10N; } - if (!__WEBPACK_IMPORTED_MODULE_2_lodash_isEqual___default.a(this.currentQuestionType, this.$store.state.questionImmutable.type)) { - changed['changedType'] = this.currentQuestionType; + if (!__WEBPACK_IMPORTED_MODULE_2_lodash_isEqual___default.a(this.$store.state.currentQuestion.type, this.$store.state.questionImmutable.type)) { + changed['changedType'] = this.$store.state.currentQuestion.type; } + this.$log.log('CHANGEOBJECT', changed); + return changed; }, triggerPreview() { @@ -11708,7 +11715,11 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); questionTypeChangeTriggered(newValue) { this.$log.log('CHANGE OF TYPE', newValue); this.currentQuestionType = newValue; + let tempQuestionObject = this.$store.state.currentQuestion; + tempQuestionObject.type = newValue; + this.$store.commit('setCurrentQuestion', tempQuestionObject); this.getQuestionPreview(); + this.$store.dispatch('getQuestionGeneralSettingsWithType'); }, changeTriggered: __WEBPACK_IMPORTED_MODULE_1_lodash_debounce___default.a(function (content, event) { this.$log.log('Debounced load triggered', { content, event }); @@ -11731,7 +11742,6 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); this.selectLanguage(this.$store.state.languages[0]); this.getQuestionPreview(); this.currentQuestionCode = this.$store.state.currentQuestion.title; - this.currentQuestionType = this.$store.state.currentQuestion.type; } }); @@ -14492,7 +14502,7 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c "name": "type" }, domProps: { - "value": _vm.currentQuestionType + "value": _vm.$store.state.currentQuestion.type }, on: { "change": _vm.questionTypeChangeTriggered @@ -14701,7 +14711,7 @@ exports = module.exports = __webpack_require__(2)(true); // module -exports.push([module.i, "\n.scope-set-min-height[data-v-df131e4a] {\n min-height: 40vh;\n}\n", "", {"version":3,"sources":["C:/IISPages/LimeSurveyDevelop/assets/packages/questioneditor/src/components/generalSettings.vue"],"names":[],"mappings":";AAAA;EACE,iBAAiB;CAAE","file":"generalSettings.vue","sourcesContent":[".scope-set-min-height {\n min-height: 40vh; }\n"],"sourceRoot":""}]); +exports.push([module.i, "\n.scope-general-setting-block[data-v-df131e4a] {\n margin: 1rem 0.1rem;\n}\n.scope-set-min-height[data-v-df131e4a] {\n min-height: 40vh;\n}\n", "", {"version":3,"sources":["C:/IISPages/LimeSurveyDevelop/assets/packages/questioneditor/src/components/generalSettings.vue"],"names":[],"mappings":";AAAA;EACE,qBAAqB;CAAE;AAEzB;EACE,iBAAiB;CAAE","file":"generalSettings.vue","sourcesContent":[".scope-general-setting-block {\n margin: 1rem 0.1rem; }\n\n.scope-set-min-height {\n min-height: 40vh; }\n"],"sourceRoot":""}]); // exports @@ -14727,7 +14737,30 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h; return _c('div', { staticClass: "col-sm-4 col-xs-12 scope-border-simple scope-set-min-height" - }) + }, [_c('div', { + staticClass: "panel panel-default" + }, [_c('div', { + staticClass: "panel-heading" + }, [_vm._v(" " + _vm._s(_vm._f("translate")("General Settings")))]), _vm._v(" "), _c('div', { + staticClass: "panel-body" + }, [_c('div', { + staticClass: "list-group" + }, _vm._l((_vm.$store.state.questionGeneralSettings), function(generalSetting) { + return _c('div', { + key: generalSetting.name, + staticClass: "list-group-item scope-general-setting-block" + }, [_c('label', { + staticClass: "list-group-item-heading", + attrs: { + "for": generalSetting.formElementId + } + }, [_vm._v(" " + _vm._s(generalSetting.title) + " ")]), _vm._v(" "), _c('div', { + staticClass: "list-group-item-text form-row", + domProps: { + "innerHTML": _vm._s(generalSetting.formElement) + } + })]) + }))])])]) },staticRenderFns: []} module.exports.render._withStripped = true if (false) { @@ -14930,6 +14963,7 @@ __WEBPACK_IMPORTED_MODULE_0_vue__["a" /* default */].use(__WEBPACK_IMPORTED_MODU currentQuestionSettings: {}, currentQuestionI10N: {}, questionAttributes: {}, + questionGeneralSettings: [], questionImmutable: {}, questionImmutableI10N: {}, languages: [], @@ -18657,6 +18691,9 @@ process.umask = function() { return 0; }; setQuestionTypeList : (state, newValue) => { state.questionTypes = newValue; }, + setQuestionGeneralSettings : (state, newValue) => { + state.questionGeneralSettings = newValue; + }, setActiveLanguage : (state, newValue) => { state.activeLanguage = newValue; }, @@ -18709,7 +18746,7 @@ process.umask = function() { return 0; }; context.commit('unsetQuestionImmutable') context.commit('setQuestionImmutable',result.data.question) context.commit('unsetQuestionImmutableI10N') - context.commit('setQuestionImmutableI10N',result.data.i10n) + context.commit('setQuestionImmutableI10N', __WEBPACK_IMPORTED_MODULE_1_lodash___default.a.cloneDeep(result.data.i10n)) context.commit('setLanguages',__WEBPACK_IMPORTED_MODULE_1_lodash___default.a.map(result.data.i10n, (value, language) => { return language; })); @@ -18722,6 +18759,26 @@ process.umask = function() { return 0; }; context.commit('setQuestionAttributes', result.data); }); }, + getQuestionGeneralSettings: (context) => { + __WEBPACK_IMPORTED_MODULE_0__mixins_runAjax_js__["a" /* default */].methods.$_get( + window.QuestionEditData.connectorBaseUrl+'/getGeneralOptions', + {'iQuestionId' : window.QuestionEditData.qid} + ).then((result) => { + context.commit('setQuestionGeneralSettings', result.data); + }); + }, + getQuestionGeneralSettingsWithType: (context) => { + context.commit('setQuestionGeneralSettings', []); + __WEBPACK_IMPORTED_MODULE_0__mixins_runAjax_js__["a" /* default */].methods.$_get( + window.QuestionEditData.connectorBaseUrl+'/getGeneralOptions', + { + 'iQuestionId' : window.QuestionEditData.qid, + 'sQuestionType' : context.store.currentQuestion.type + } + ).then((result) => { + context.commit('setQuestionGeneralSettings', result.data); + }); + }, getQuestionTypes: (context) => { __WEBPACK_IMPORTED_MODULE_0__mixins_runAjax_js__["a" /* default */].methods.$_get( window.QuestionEditData.connectorBaseUrl+'/getQuestionTypeList' diff --git a/assets/packages/questioneditor/src/App.vue b/assets/packages/questioneditor/src/App.vue index 7fe58b1ecc6..691210d24d7 100644 --- a/assets/packages/questioneditor/src/App.vue +++ b/assets/packages/questioneditor/src/App.vue @@ -32,6 +32,7 @@ export default { created(){ this.$store.dispatch('loadQuestion'); this.$store.dispatch('getQuestionTypes'); + this.$store.dispatch('getQuestionGeneralSettings'); } } diff --git a/assets/packages/questioneditor/src/components/generalSettings.vue b/assets/packages/questioneditor/src/components/generalSettings.vue index 5879313098a..1b524f91044 100644 --- a/assets/packages/questioneditor/src/components/generalSettings.vue +++ b/assets/packages/questioneditor/src/components/generalSettings.vue @@ -9,11 +9,24 @@ export default {