diff --git a/application/controllers/admin/quotas.php b/application/controllers/admin/quotas.php index 4ed4f6fff47..dc79476fd26 100644 --- a/application/controllers/admin/quotas.php +++ b/application/controllers/admin/quotas.php @@ -82,6 +82,11 @@ function _redirectToIndex($iSurveyId) } } + /** + * + * @param integer $iSurveyId the survey id + * @param boolean $quickreport : quick export a csv with actual quotas + */ function index($iSurveyId, $quickreport = false) { $iSurveyId = sanitize_int($iSurveyId); @@ -198,10 +203,8 @@ function index($iSurveyId, $quickreport = false) } else { - - //// WHY ??????? - - header("Content-Disposition: attachment; filename=results-survey" . $iSurveyId . ".csv"); + /* Export a quickly done csv file */ + header("Content-Disposition: attachment; filename=quotas-survey" . $iSurveyId . ".csv"); header("Content-type: text/comma-separated-values; charset=UTF-8"); header("Pragma: public"); echo gT("Quota name") . "," . gT("Limit") . "," . gT("Completed") . "," . gT("Remaining") . "\r\n"; @@ -209,7 +212,7 @@ function index($iSurveyId, $quickreport = false) { echo $line; } - die; + App()->end(); } } diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 5f982bdeb9b..8867a78bc50 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -182,6 +182,11 @@ function run($surveyid,$args) $_SESSION[$LEMsessid]['prevstep']=$_SESSION[$LEMsessid]['step']-1; // this only happens on re-load } + /* quota submitted */ + if(isset($move) && $move=='confirmquota'){ + checkCompletedQuota($surveyid); + } + if (isset($_SESSION[$LEMsessid]['LEMtokenResume'])) { LimeExpressionManager::StartSurvey($thissurvey['sid'], $surveyMode, $surveyOptions, false,$LEMdebugLevel); diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index 570063b5365..cb2f0dc7d69 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -8596,6 +8596,7 @@ static function ProcessCurrentResponses() $relevant=false; $qid = $qinfo['info']['qid']; $gseq = $qinfo['info']['gseq']; + /* Never use posted value : must be fixed and find real actual relevance */ $relevant = (isset($_POST['relevance' . $qid]) ? ($_POST['relevance' . $qid] == 1) : false); $grelevant = (isset($_POST['relevanceG' . $gseq]) ? ($_POST['relevanceG' . $gseq] == 1) : false); $_SESSION[$LEM->sessid]['relevanceStatus'][$qid] = $relevant; diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index da2418b4df8..ca48eacc8f6 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -2061,15 +2061,16 @@ function checkCompletedQuota($surveyid,$return=false) return; } static $aMatchedQuotas; // EM call 2 times quotas with 3 lines of php code, then use static. + static $aPostedQuotaFields=array(); // Keep the posted field for the quota submit if(!$aMatchedQuotas) { $aMatchedQuotas=array(); - $quota_info=$aQuotasInfo = getQuotaInformation($surveyid, $_SESSION['survey_'.$surveyid]['s_lang']); + $aQuotasInfo = getQuotaInformation($surveyid, $_SESSION['survey_'.$surveyid]['s_lang']); // $aQuotasInfo have an 'active' key, we don't use it ? if(!$aQuotasInfo || empty($aQuotasInfo)) return $aMatchedQuotas; // OK, we have some quota, then find if this $_SESSION have some set - $aPostedFields = explode("|",Yii::app()->request->getPost('fieldnames','')); // Needed for quota allowing update + //$aPostedFields = explode("|",Yii::app()->request->getPost('fieldnames','')); // Needed for quota allowing update foreach ($aQuotasInfo as $aQuotaInfo) { if(!$aQuotaInfo['active']) @@ -2099,8 +2100,10 @@ function checkCompletedQuota($surveyid,$return=false) { $iMatchedAnswers++; } - if(in_array($sFieldName,$aPostedFields))// Need only one posted value + if(!is_null(App()->request->getPost($sFieldName))){// Need only one posted value $bPostedField=true; + $aPostedQuotaFields[$sFieldName]=App()->getRequest()->getPost($sFieldName); + } } // Condition to count quota : Answers are the same in quota + an answer is submitted at this time (bPostedField) OR all questions is hidden (bAllHidden) $bAllHidden=QuestionAttribute::model()->countByAttributes(array('qid'=>$aQuotaQid),'attribute=:attribute',array(':attribute'=>'hidden'))==count($aQuotaQid); @@ -2160,11 +2163,13 @@ function checkCompletedQuota($surveyid,$return=false) $sUrl=$event->get('url',$aMatchedQuota['quotals_url']); $sUrlDescription=$event->get('urldescrip',$aMatchedQuota['quotals_urldescrip']); $sAction=$event->get('action',$aMatchedQuota['action']); + /* Tag if we close or not the survey */ + $closeSurvey=($sAction=="1" || App()->getRequest()->getPost('move')=='confirmquota'); $sAutoloadUrl=$event->get('autoloadurl',$aMatchedQuota['autoload_url']); - // Doing the action and show the page - if ($sAction == "1" && $sClientToken) + if ($closeSurvey && $sClientToken){ submittokens(true); + } // Construct the default message $sMessage = templatereplace($sMessage,array(),$aDataReplacement, 'QuotaMessage', $aSurveyInfo['anonymized']!='N', NULL, array(), true ); $sUrl = passthruReplace($sUrl, $aSurveyInfo); @@ -2174,7 +2179,7 @@ function checkCompletedQuota($surveyid,$return=false) // Construction of default message inside quotamessage class $sHtmlQuotaMessage = "
- {ANSWERSCLEARED}
- - {RESTART} - |
-