From 646b42e07ae7fdea53ad053248e7d37ba8950c12 Mon Sep 17 00:00:00 2001 From: markusfluer Date: Fri, 2 Feb 2018 14:44:04 +0100 Subject: [PATCH] Fixed issue #13185: Rendering issue when adding new questions (Preview) --- application/controllers/admin/database.php | 8 +++++++- application/controllers/survey/index.php | 10 +++++----- application/helpers/SurveyRuntimeHelper.php | 3 ++- application/helpers/expressions/em_core_helper.php | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/application/controllers/admin/database.php b/application/controllers/admin/database.php index 24a4a1af276..d4248fbf140 100644 --- a/application/controllers/admin/database.php +++ b/application/controllers/admin/database.php @@ -1443,6 +1443,12 @@ private function _resetEM(){ $oEM =& LimeExpressionManager::singleton(); LimeExpressionManager::UpgradeConditionsToRelevance($this->iSurveyID); LimeExpressionManager::StartSurvey($oSurvey->sid,'survey',$oSurvey->attributes,true); - + LimeExpressionManager::StartProcessingPage(true,true); + $aGrouplist = QuestionGroup::model()->getGroups($this->iSurveyID); + foreach ($aGrouplist as $iGID => $aGroup) { + LimeExpressionManager::StartProcessingGroup($aGroup['gid'], $oSurvey->anonymized != 'Y', $this->iSurveyID); + LimeExpressionManager::FinishProcessingGroup(); + } + LimeExpressionManager::FinishProcessingPage(); } } diff --git a/application/controllers/survey/index.php b/application/controllers/survey/index.php index 594ff39964d..0c63de91e71 100644 --- a/application/controllers/survey/index.php +++ b/application/controllers/survey/index.php @@ -570,7 +570,7 @@ public function action() } // Preview action : Preview right already tested before - if ($previewmode === true) { + if ($previewmode == 'previewgroup' || $previewmode == 'previewquestion') { // Unset all SESSION: be sure to have the last version unset($_SESSION['fieldmap-'.$surveyid.App()->language]); // Needed by createFieldMap: else fieldmap can be outdated @@ -594,11 +594,11 @@ public function action() $redata = compact(array_keys(get_defined_vars())); Yii::import('application.helpers.SurveyRuntimeHelper'); $tmp = new SurveyRuntimeHelper(); - try { + // try { $tmp->run($surveyid, $redata); - } catch (WrongTemplateVersionException $ex) { - echo $ex->getMessage(); - } + // } catch (WrongTemplateVersionException $ex) { + // echo $ex->getMessage(); + // } if (App()->request->getPost('saveall')) { App()->clientScript->registerScript("saveflashmessage", "alert('".gT("Your responses were successfully saved.", "js")."');", CClientScript::POS_READY); diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index e8325d21b60..49f3b4a71ce 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -112,6 +112,7 @@ public function run($surveyid, $args) $this->setNotAnsweredAndNotValidated(); } else { + $this->initMove(); // main methods to init session, LEM, moves, errors, etc $this->setPreview(); } @@ -668,7 +669,7 @@ private function initFirstStep() { // First time the survey is loaded - if (!isset($_SESSION[$this->LEMsessid]['step'])) { + if (!isset($_SESSION[$this->LEMsessid]['step']) || ($this->previewquestion || $this->previewgrp) ) { // Init session, randomization and filed array buildsurveysession($this->iSurveyid); $fieldmap = randomizationGroupsAndQuestions($this->iSurveyid); diff --git a/application/helpers/expressions/em_core_helper.php b/application/helpers/expressions/em_core_helper.php index 1890dfef092..2132a415fdb 100644 --- a/application/helpers/expressions/em_core_helper.php +++ b/application/helpers/expressions/em_core_helper.php @@ -406,7 +406,7 @@ public function RDP_EvaluateBinary(array $token) break; case '*': if ($bBothNumeric) { - $result = array(($arg1[0] * $arg2[0]), $token[1], 'NUMBER'); + $result = array((doubleVal($arg1[0]) * doubleVal($arg2[0])), $token[1], 'NUMBER'); } else { $result = array(NAN, $token[1], 'NUMBER'); }