Skip to content

Commit

Permalink
Dev: twigged submit preview
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Apr 11, 2017
1 parent bb87a9f commit 7d50962
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 18 deletions.
24 changes: 6 additions & 18 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -1177,33 +1177,22 @@ private function moveSubmitIfNeeded()
if ($thissurvey['active'] != "Y"){

sendCacheHeaders();
doHeader();

echo templatereplace(file_get_contents($sTemplateViewPath."startpage.pstpl"), array(), $redata, 'SubmitStartpageI', false, NULL, array(), true );

//Check for assessments

// TODO: TWIG ASSESSMENTS !!!!!
if ($thissurvey['assessments'] == "Y"){
$assessments = $this->assessments = doAssessment($thissurvey['sid']);
if ($assessments ) {
echo templatereplace(file_get_contents($sTemplateViewPath."assessment.pstpl"), array(), $redata, 'SubmitAssessmentI', false, NULL, array(), true );
}
$thissurvey['aAssessments']['show'] = true;
$thissurvey['aAssessments'] = $this->assessments = doAssessment($surveyid, true);
}

$redata = compact(array_keys(get_defined_vars()));
// can't kill session before end message, otherwise INSERTANS doesn't work.
$completed = templatereplace($thissurvey['surveyls_endtext'], array(), $redata, 'SubmitEndtextI', false, NULL, array(), true );
$completed .= "<br /><strong><font size='2' color='red'>" . gT("Did Not Save") . "</font></strong><br /><br />\n\n";
$completed .= gT("Your survey responses have not been recorded. This survey is not yet active.") . "<br /><br />\n";

if ($thissurvey['printanswers'] == 'Y'){
// 'Clear all' link is only relevant for survey with printanswers enabled
// in other cases the session is cleared at submit time
$completed .= "<a href='" . Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}/move/clearall") . "'>" . gT("Clear Responses") . "</a><br /><br />\n";
}

$this->completed = $completed;

$redata = compact(array_keys(get_defined_vars()));
echo templatereplace(file_get_contents($sTemplateViewPath."layout-submit.twig"), array(), $redata);
App()->end();
}else{

//Update the token if needed and send a confirmation email
Expand All @@ -1219,7 +1208,6 @@ private function moveSubmitIfNeeded()
if ($thissurvey['assessments'] == "Y"){
$thissurvey['aAssessments']['show'] = true;

// TODO : TWIG
//$assessments = $this->assessments = doAssessment($surveyid);
$thissurvey['aAssessments'] = $this->assessments = doAssessment($surveyid, true);
}
Expand Down
84 changes: 84 additions & 0 deletions templates/default/views/layout-submit-preview.twig
@@ -0,0 +1,84 @@
{#
LimeSurvey
Copyright (C) 2007-2017 The LimeSurvey Project Team / Louis Gac
All rights reserved.
License: GNU/GPL License v2 or later, see LICENSE.php
LimeSurvey is free software. This version may have been modified pursuant
to the GNU General Public License, and as distributed it includes or
is derivative of works licensed under the GNU General Public License or
other free or open source software licenses.
See COPYRIGHT.php for copyright notices and details.
#}
<!DOCTYPE html>
<html lang="{{ aSurveyInfo.languagecode }}" dir="{{ aSurveyInfo.dir }}" class="no-js {{ aSurveyInfo.languagecode }} dir-{{ aSurveyInfo.dir }} ">

{# Headers, metadatas, etc #}
{{ include('./subviews/head.twig') }}

<body class="default lang-{{surveylanguage}} {{surveyformat}}">

{# Bootstrap Navigation Bar: the top menu #}
{{ include('./subviews/nav_bar.twig') }}

{# Top Container: in this template, it contains only #}
{{ include('./subviews/top_container.twig') }}

<!-- Outer Frame Container -->
<div class="outerframe container" id="outerframeContainer">

<!-- Main Row -->
<div id="main-row">

<!-- Main Col -->
<div class="col-centered" id="main-col">

{# include the various Warnings (preview mode, unanswered mandatory questions, etc) #}
{{ include('./subviews/warnings.twig') }}

{# include the form opening tag #}
<!-- main form -->
{{ include('./subviews/start_form.twig') }}


<div class="completed-wrapper">
<div class='completed-text'>
{# Assessments #}
{% if (aSurveyInfo.aAssessments.show) %}
{{ include('./subviews/assessments.twig') }}
{% endif %}

<br />
<strong>
<font size='2' color='red'>
{{ "Did Not Save" | t }}
</font>
</strong>
<br /><br />

{{ "Your survey responses have not been recorded. This survey is not yet active." | t }})
<br /><br />
</div>
</div>


</form> <!-- main form -->
</div> <!-- main col -->
</div> <!-- main row -->
</div> <!-- outer frame container -->

{# Bootstrap alert modal #}
{{ include('./subviews/bootstrap_alert_modal.twig') }}

<!-- some template.js function launched before ready -->
<script type="text/javascript">
/*<![CDATA[*/
sliderSuffixClone();
fixBodyPadding();
hideQuestionWithRelevanceSubQuestion();
hideEmptyPart();
/*]]>*/
</script>
</body>
</html>
<!-- end of startpage.twig -->

0 comments on commit 7d50962

Please sign in to comment.