Skip to content

Commit

Permalink
Dev: added "'Quotas exceeded" screen to vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Sep 23, 2019
1 parent 4467088 commit 7a2a6bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions application/models/TemplateManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public function getDefaultDataForRenderingFromXml($thissurvey=array())
$thissurvey['aGroups'][1]["aQuestions"][1] = $this->parseDefaultData('question_1', $thissurvey['aGroups'][1]["aQuestions"][1]) ;
$thissurvey['aGroups'][1]["aQuestions"][2] = $this->parseDefaultData('question_2', $thissurvey['aGroups'][1]["aQuestions"][2]);
$thissurvey['aAssessments']["datas"]["total"][0] = $this->parseDefaultData('assessments', $thissurvey['aAssessments']["datas"]["total"][0]);
$thissurvey['aQuotas'] = $this->parseDefaultData('quotas', $thissurvey['aQuotas']);

This comment has been minimized.

Copy link
@LouisGac

LouisGac Sep 23, 2019

Contributor

this kind of core hack is not needed anymore. Now, any theme developer can add its own screens with its own default data for preview just by XML:
07b7346

Documented inside the vanilla theme:

<!-- This is an exemple to show you how to add your custom screen in the theme editor with custom values -->
<!-- The name of the array inside aSurveyInfo that feed your twig view is specified as "array-name". If you check quotas.twig, you'll notice the main variable is aSurveyInfo.aQuotas -->
<!-- Notice that the data you parse here are simple. You can't pass complex arrays inside the array, only key => value pairs.-->
<quotas type="custom" arrayName="aQuotas">
<sMessage type="data" twig="on"><![CDATA[ {{ gT("Sorry your responses have exceeded a quota on this survey.") }} ]]></sMessage>
<sUrl type="data">http://limesurvey.org</sUrl>
<sUrlDescription type="data" twig="on"><![CDATA[ {{ gT("End url") }} ]]></sUrlDescription>
<bShowNavigator type="data">false</bShowNavigator>
</quotas>

return $thissurvey;
}
Expand Down Expand Up @@ -399,6 +400,7 @@ public function getDefaultCoreDataForRendering()
$thissurvey['surveyls_url'] = "https://www.limesurvey.org/";
$thissurvey['surveyls_urldescription'] = gT("Some URL description");

$thissurvey['aQuotas'] = array();
return $thissurvey;
}

Expand Down
16 changes: 16 additions & 0 deletions themes/survey/vanilla/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@
<file type="view" role="layout">layout_print.twig</file>
</pdf>

<quotas>
<screen_title type="data" role="title" twig="on"><![CDATA[ {{gT('Quotas exceeded')}} ]]></screen_title>
<file type="view" role="layout">layout_global.twig</file>
<file type="view" role="content">./subviews/content/quotas.twig</file>
<file type="view" role="subview">./subviews/header/start_form.twig</file>
</quotas>

<navigation>
<screen_title type="data" role="title" twig="on"><![CDATA[ {{gT('Navigation')}} ]]></screen_title>
<file type="view" role="layout">layout_global.twig</file>
Expand All @@ -284,6 +291,8 @@
<file type="view" role="subview">./subviews/navigation/question_index_questions_buttons.twig</file>
<file type="view" role="subview">./subviews/navigation/question_index_groups_buttons.twig</file>
</navigation>


</screens>

<!-- Data for preview in Theme Editor and Twig Cache command line generator -->
Expand Down Expand Up @@ -314,6 +323,13 @@
<name type="data" twig="on"><![CDATA[ {{ gT("Welcome to the Assessment") }} ]]></name>
<message type="data" twig="on"><![CDATA[ {{ gT("You got {TOTAL} points out of 3 possible points.") }} ]]></message>
</assessments>

<quotas>
<sMessage type="data" twig="on"><![CDATA[ {{ gT("Sorry your responses have exceeded a quota on this survey.") }} ]]></sMessage>
<sUrl type="data">http://limesurvey.org</sUrl>
<sUrlDescription type="data" twig="on"><![CDATA[ {{ gT("End url") }} ]]></sUrlDescription>
<bShowNavigator type="data">false</bShowNavigator>
</quotas>
</default_data>
</template_editor>
</engine>
Expand Down

0 comments on commit 7a2a6bf

Please sign in to comment.