- Posts: 15
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
{% if(processString("{is_empty(self)}")) %} <div class="{{ aSurveyInfo.class.questionasterix }} pull-left" {{ aSurveyInfo.attr.questionasterix }} > <small style="margin-right: 3px; font-size: 65%;" class="{{ aSurveyInfo.class.questionasterixsmall }} text-danger fa fa-asterisk small" {{ aSurveyInfo.attr.questionasterixsmall }}></small> <span class="{{ aSurveyInfo.class.questionasterixspan }} sr-only text-danger" {{ aSurveyInfo.attr.questionasterixspan }} > {{ gT("(This question is mandatory)") }} </span> </div> {% endif %} {% if(processString("{!is_empty(self)}")) %} <div class="{{ aSurveyInfo.class.questionasterix }} pull-left" {{ aSurveyInfo.attr.questionasterix }} > {{ image('./files/haken.png', 'Question answered') }} </div> {% endif %}
{{ processString("{if(is_empty(self.NAOK),'<span class=\"text-danger\">Mandatory question not answered</span>',' <span class=\"text-success\">question answered</span>')}") }}
{{ processString("{if(count(self.NAOK)>0,'<span>Mandatory question answered</span>',' <span>question not answered</span>')}") }}
{{ processString("{if(count(self.NAOK),' <span class=\"text-success\">'+count(self.NAOK)+' questions answered</span>','<span class=\"text-danger\">No question answered</span>')}") }}
question_text_content.twig
{% if aQuestion.mandatory != '' %} {{ processString("{if(count(self.NAOK)>0,'<span>Mandatory question answered</span>',' <span>question not answered</span>')}") }} <div class="{{ aSurveyInfo.class.questionasterix }} pull-left" {{ aSurveyInfo.attr.questionasterix }} > <small style="margin-right: 3px; font-size: 65%;" class="{{ aSurveyInfo.class.questionasterixsmall }} text-danger fa fa-asterisk small" {{ aSurveyInfo.attr.questionasterixsmall }}></small> <span class="{{ aSurveyInfo.class.questionasterixspan }} sr-only text-danger" {{ aSurveyInfo.attr.questionasterixspan }} > {{ gT("(This question is mandatory)") }} </span> </div> {% endif %}
<script type="text/javascript" charset="utf-8"> function checkAnswered(thisQuestion) { $('.answered-tip', thisQuestion).hide(); var answered = false; if($('input:radio:visible:checked, input:checkbox:visible:checked', thisQuestion).length > 0) { answered = true; } if($('select:visible, input:text:visible, textarea:visible', thisQuestion).filter(function() { return $.trim($(this).val()) != ''; }).length > 0) { answered = true; } if(answered == true) { $('.answered-tip.answered', thisQuestion).show(); } else { $('.answered-tip.unanswered', thisQuestion).show(); } } $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{{ aQuestion.qid }}'); // Initial state checkAnswered(thisQuestion); // Listener on the inputs $('input:visible, select:visible, textarea:visible', thisQuestion).on('click change keyup', function(e) { checkAnswered(thisQuestion); }); }); </script> {# If the question is mandatory, the asterisk will be shown #} {% if aQuestion.mandatory != '' %} <span class="answered-tip answered">Mandatory question answered</span> <span class="answered-tip unanswered">Question not answered</span> <!-- Add a visual information + just Mandatory string for aria : can be improved --> <div class="{{ aSurveyInfo.class.questionasterix }} pull-left" {{ aSurveyInfo.attr.questionasterix }} > <small class="{{ aSurveyInfo.class.questionasterixsmall }} text-danger fa fa-asterisk small" {{ aSurveyInfo.attr.questionasterixsmall }}></small> <span class="{{ aSurveyInfo.class.questionasterixspan }} sr-only text-danger" {{ aSurveyInfo.attr.questionasterixspan }} > {{ gT("(This question is mandatory)") }} </span> </div> {% endif %}
{% set questionCount = processString("{count(self.question)}") %} {{ processString("{if(count(self.NAOK)== 0,'<span class=\"text-danger\">No question answered</span>')}") }} {{ processString("{if(count(self.NAOK) gt 0 and count(self.NAOK) lt "~questionCount~",'<span class=\"text-warning\">'+count(self.NAOK)+' question(s) answered</span>')}") }} {{ processString("{if(count(self.NAOK) == "~questionCount~",'<span class=\"text-success\">All questions answered</span>')}") }}