Skip to content

Commit

Permalink
Dev: some fix to old default template
Browse files Browse the repository at this point in the history
Dev: separation of class (Thansk Tammo)
  • Loading branch information
Shnoulle committed Nov 2, 2016
1 parent a76dfed commit 9c261a6
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 245 deletions.
13 changes: 8 additions & 5 deletions application/controllers/admin/quotas.php
Expand Up @@ -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);
Expand Down Expand Up @@ -198,18 +203,16 @@ 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";
foreach ($csvoutput as $line)
{
echo $line;
}
die;
App()->end();
}
}

Expand Down
5 changes: 5 additions & 0 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -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;
Expand Down
40 changes: 25 additions & 15 deletions application/helpers/frontend_helper.php
Expand Up @@ -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'])
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -2174,7 +2179,7 @@ function checkCompletedQuota($surveyid,$return=false)
// Construction of default message inside quotamessage class
$sHtmlQuotaMessage = "<div class='quotamessage limesurveycore'>\n";
$sHtmlQuotaMessage.= "\t".$sMessage."\n";
if($sUrl)
if($sUrl && $closeSurvey)
{
$sHtmlQuotaUrl = App()->getController()->renderPartial("/survey/system/url",array(
'url'=>$sUrl,
Expand All @@ -2187,16 +2192,13 @@ function checkCompletedQuota($surveyid,$return=false)
}

// Add the navigator with Previous button if quota allow modification.
if ($sAction == "2")
if (!$closeSurvey )
{
$sQuotaStep = isset($_SESSION['survey_'.$surveyid]['step'])?$_SESSION['survey_'.$surveyid]['step']:0; // Surely not needed
$sMovePrev = App()->getController()->renderPartial("/survey/system/actionButton/movePrevious",array('value'=>$sQuotaStep,'class'=>"ls-move-btn ls-move-previous-btn"),true);
/* Not completly tested submit : @todo test it */
$sMoveSubmit = App()->getController()->renderPartial("/survey/system/actionButton/moveSubmit",array('value'=>"movesubmit",'class'=>"ls-move-btn ls-move-submit-btn"),true);
$sMoveSubmit = "";
$sMoveSubmit = App()->getController()->renderPartial("/survey/system/actionButton/moveSubmit",array('value'=>"confirmquota",'class'=>"ls-move-btn ls-move-submit-btn"),true);
$sNavigator = "$sMovePrev $sMoveSubmit";

//$sNavigator .= " ".CHtml::htmlButton(gT("Submit"),array('type'=>'submit','id'=>"movesubmit",'value'=>"movesubmit",'name'=>"movesubmit",'accesskey'=>'l','class'=>"submit button"));
$sHtmlQuotaMessage.= CHtml::form(array("/survey/index","sid"=>$surveyid), 'post', array('id'=>'limesurvey','name'=>'limesurvey','class'=>'survey-form-container QuotaMessage'));
$sHtmlQuotaMessage.= templatereplace(file_get_contents($sTemplateViewPath."/navigator.pstpl"),array(
'MOVEPREVBUTTON' => $sMovePrev,
Expand All @@ -2206,6 +2208,10 @@ function checkCompletedQuota($surveyid,$return=false)
),$aDataReplacement);
$sHtmlQuotaMessage.= CHtml::hiddenField('sid',$surveyid);
$sHtmlQuotaMessage.= CHtml::hiddenField('token',$sClientToken);// Did we really need it ?
foreach($aPostedQuotaFields as $field=>$post){
$sHtmlQuotaMessage.= CHtml::hiddenField($field,$post);
}
$sHtmlQuotaMessage.= CHtml::hiddenField('thisstep',$sQuotaStep);
$sHtmlQuotaMessage.= CHtml::endForm();
}

Expand All @@ -2215,19 +2221,19 @@ function checkCompletedQuota($surveyid,$return=false)

// Send page to user and end.
sendCacheHeaders();
if($sAutoloadUrl == 1 && $sUrl != "")
if($closeSurvey && $sAutoloadUrl == 1 && $sUrl != "")
{
if ($sAction == "1")
killSurveySession($surveyid);
killSurveySession($surveyid);
header("Location: ".$sUrl);
}
doHeader();
echo templatereplace(file_get_contents($sTemplateViewPath."/startpage.pstpl"),array(),$aDataReplacement);
echo templatereplace(file_get_contents($sTemplateViewPath."/completed.pstpl"),array("COMPLETED"=>$sHtmlQuotaMessage,"URL"=>$sHtmlQuotaUrl),$aDataReplacement);
echo templatereplace(file_get_contents($sTemplateViewPath."/endpage.pstpl"),array(),$aDataReplacement);
doFooter();
if ($sAction == "1")
if ($closeSurvey){
killSurveySession($surveyid);
}
Yii::app()->end();
}

Expand Down Expand Up @@ -2423,21 +2429,25 @@ function SetSurveyLanguage($surveyid, $sLanguage)

/**
* getMove get move button clicked
* @return string
**/
function getMove()
{
$aAcceptedMove=array('default','movenext','movesubmit','moveprev','saveall','loadall','clearall','changelang');
// We can control is save and load are OK : todo fix according to survey settings
// Maybe allow $aAcceptedMove in Plugin
$move=Yii::app()->request->getParam('move');
/* @deprecated since we use button and not input with different value. */
foreach($aAcceptedMove as $sAccepteMove)
{
if(Yii::app()->request->getParam($sAccepteMove))
$move=$sAccepteMove;
}
/* Good idea, but used ? */
if($move=='clearall' && App()->request->getPost('confirm-clearall')!='confirm'){
$move="clearcancel";
}
/* default move (user don't click on a button, but use enter in a input:text or a select */
if($move=='default')
{
$surveyid=Yii::app()->getConfig('surveyID');
Expand Down
3 changes: 2 additions & 1 deletion application/views/admin/quotas/editquota_view.php
Expand Up @@ -24,9 +24,10 @@
<div class='col-sm-9'>
<select name="quota_action" id="quota_action" class="form-control">
<option value ="1" <?php if($quotainfo['action'] == 1) echo "selected='selected'"; ?>><?php eT("Terminate survey");?></option>
<option value ="2" <?php if($quotainfo['action'] == 2) echo "selected='selected'"; ?>><?php eT("Terminate survey with warning");?></option>
<option value ="2" <?php if($quotainfo['action'] == 2) echo "selected='selected'"; ?>><?php eT("Allow user to update his last answers before terminate survey.");?></option>
</select>
</div>
<div class="col-sm-9 col-sm-offset-3 help-block"><?php eT("To allow update : one of the question tested must be viewed in the last page before quota.The end url action is done only after confirm survey.");?></div>
</div>
<div class='form-group'>
<label class='control-label col-sm-3' for='autoload_url'><?php eT("Autoload URL:");?></label>
Expand Down
5 changes: 3 additions & 2 deletions application/views/admin/quotas/newquota_view.php
Expand Up @@ -29,9 +29,10 @@
<div class="col-sm-5">
<select id="quota_action" name="quota_action" class="form-control">
<option value ="1"><?php eT("Terminate survey");?></option>
<option value ="2"><?php eT("Terminate survey with warning");?></option>
<option value ="2"><?php eT("Allow user to modify his last answers before terminate survey.");?></option>
</select>
</div>
<div class="col-sm-5 col-sm-offset-2 help-block"><?php eT("To allow update : one of the question tested must be viewed in the last page before quota.The end url action is done only after confirm survey.");?></div>
</div>

<!-- -->
Expand All @@ -41,7 +42,7 @@
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'autoload_url',
'id'=>'autoload_url',
'value' => 1,
'value' => 0,
'onLabel'=>gT('Yes'),
'offLabel' => gT('No')));
?>
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/quotas/viewquotasrow_view.php
Expand Up @@ -17,7 +17,7 @@
<?php if ($quotalisting['action'] == 1) {
eT("Terminate survey");
} elseif ($quotalisting['action'] == 2) {
eT("Terminate survey with warning");
eT("Allow user to update answers before submit.");
} ?>
</td>
<td <?php echo $highlight;?>><?php echo is_null($completed) ? gT("N/A"): $completed ;?></td>
Expand Down
Expand Up @@ -14,7 +14,7 @@
*/
?>
<!-- answer -->
<table class="<?php echo $coreClass; ?> <?php echo $extraclass; ?>table table-bordered table-hover">
<table class="<?php echo $coreClass; ?> <?php echo $extraclass; ?> table table-bordered table-hover">

<colgroup class="col-responses">
<col class="answertext" style='width: <?php echo $answerwidth;?>%;'/>
Expand Down
15 changes: 4 additions & 11 deletions templates/default/views/clearall.pstpl
@@ -1,11 +1,4 @@
<br />
<table class="clearall-result">
<tr>
<td align="center">
<span class="warning-text">{ANSWERSCLEARED}</span>
<br /><br />
{RESTART}
</td>
</tr>
</table>
<br />
<div class="clearall-wrapper">
<div class='warning-text text-center'>{COMPLETED}</div>
<div class='restart-url text-center'>{URL}</div>
</div>
4 changes: 2 additions & 2 deletions templates/default/views/completed.pstpl
@@ -1,4 +1,4 @@
<div class="completed-wrapper">
<div class='completed-text'>{COMPLETED}</div>
<div class='end-url'>"+{URL}+"</div>
<div class='completed-text text-center'>{COMPLETED}</div>
<div class='end-url text-center'>{URL}</div>
</div>
3 changes: 3 additions & 0 deletions templates/flatmodern/css/template-core.css
Expand Up @@ -5,6 +5,9 @@
.ls-answers img,.ls-answers video,.ls-answers svg{
max-width: 100%;height: auto;
}
label, th {
font-weight: normal;
}
/* awesome-bootstrap-checkbox */
li.radio-item,li.checkbox-item{display:block}

Expand Down

0 comments on commit 9c261a6

Please sign in to comment.