/
answer.twig
79 lines (69 loc) · 2.41 KB
/
answer.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{#
!!!! BECAREFUL: ONLY FOR TESTING !!!!!
!!!! DON'T START TO TRANSLATE ALL VIEWS BASED ON THIS MODEL !!!!!
!!!! IT WILL PROBABLY FIRST NEED TO CHANGE THE TWIG TEMPLATE SYNTAX TO AVOID CONFLICT WITH EXPRESSION MANAGER !!!!
/**
* Ranking question, item list header Html
*
* @var $sOptions : the select options, generated with the view answer_row.php
*
* @var $name
* @var $myfname
* @var $labeltext
* @var $rankId
* @var $rankingName
* @var $max_answers
* @var $min_answers
* @var $qid
* @var $choice_title
* @var $rank_title
* @var $rank_help
* @var $showpopups
* @var $samechoiceheight
* @var $samelistheight
**** Additional attributes:
* @var question_template_attribute.show_handle
* @var question_template_attribute.only_pull
* @var question_template_attribute.visualize
*/
#}
{% set show_handle=question_template_attribute.show_handle %}
{% set show_number=question_template_attribute.show_number %}
{# {% set show_handle="yes" %} #}
{# {% set show_number="yes" %} #}
<!-- answer -->
<div class="{{coreClass}} ranking-advanced-style">
<ul class="list-unstyled ls-js-hidden-sr answers-list select-list " role="group" aria-labelledby="ls-question-text-{{basename}}">
{# rows/answer_row.twig #}
{{sSelects}}
</ul>
{% set visualization = (question_template_attribute.visualize is not empty) ? question_template_attribute.visualize : "blocks" %}
{% set rankingView = './views/' ~ visualization ~ '.twig' %}
{{ include(rankingView) }}
</div>
{% set script %}
try{
var ranking{{qId}} = new AdvancedRankingQuestion({
max_answers : {{max_answers}},
min_answers : {{min_answers}},
showpopups : "{{showpopups}}",
samechoiceheight : "{{samechoiceheight}}",
samelistheight : "{{samelistheight}}",
rankingName : "{{rankingName}}",
questionId : "{{qId}}",
numbersActive : {{ ((show_number is same as('yes'))) ? 1 : 0 }},
withHandle : {{ ((show_handle is same as('yes'))) ? 1 : 0 }}
});
ranking{{qId}}.init()
console.ls.log("Ranking advances initialized for qid {{qId}}");
} catch(e){
console.ls.error(e);
}
{% endset %}
{# DEBUG #}
<div class="hidden">
{{script}}
</div>
{{ registerScript( 'RankingQuestion'~qId, script, 'POS_POSTSCRIPT') }}
{{ registerPackage( 'sortable' ) }}
<!-- end of answer -->