197 lines
8.9 KiB
Twig
197 lines
8.9 KiB
Twig
{% extends 'base.html.twig' %}
|
|
|
|
{% block body %}
|
|
{{ form_start(form) }}
|
|
<div class="container">
|
|
<h1 class="title">{{questguest.quest.title}}</h1>
|
|
{% if by=="byuserkey" %}
|
|
<a class="btn btn-secondary mb-3" href={{ path('app_quest') }}>Retour</a>
|
|
{% endif %}
|
|
{{ questguest.quest.description|raw }}
|
|
|
|
<!-- Affichage des erreurs -->
|
|
{% if app.session.flashbag.has('error') %}
|
|
<div class='alert alert-danger'>
|
|
<strong>Erreur</strong><br>
|
|
{% for flashMessage in app.session.flashbag.get('error') %}
|
|
{{ flashMessage }}<br>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Affichage des alertes -->
|
|
{% if app.session.flashbag.has('notice') %}
|
|
<div class='alert alert-info'>
|
|
<strong>Information</strong><br>
|
|
{% for flashMessage in app.session.flashbag.get('notice') %}
|
|
{{ flashMessage|raw }}<br>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% for option in questguest.quest.questoptions %}
|
|
{%set disabled="" %}
|
|
{% if form.submit is not defined %}
|
|
{%set disabled="disabled='disabled'" %}
|
|
{% endif %}
|
|
|
|
<div class="form-group">
|
|
<label class="control-label required" style="font-weight:bold; font-size:150%">
|
|
{{option.name}}
|
|
{% set required="" %}
|
|
{% if option.required %}
|
|
<span class="mandatory">*</span></label>
|
|
{% set required="required='required'" %}
|
|
{% endif %}
|
|
</label>
|
|
|
|
{% if option.type == "10" %}
|
|
<select id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}}>
|
|
<option disabled selected hidden value><i>Veuillez sélectionner une valeur</i></option>
|
|
<option value="0">non</option>
|
|
<option value="1">oui</option>
|
|
</select>
|
|
{% endif %}
|
|
|
|
{% if option.type == "20" %}
|
|
<select id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}}>
|
|
<option disabled selected hidden value><i>Veuillez sélectionner une valeur</i></option>
|
|
<option value="0">non</option>
|
|
<option value="1">oui</option>
|
|
<option value="2">peut-être</option>
|
|
</select>
|
|
{% endif %}
|
|
|
|
{% if option.type == "30" %}
|
|
<select id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}}>
|
|
<option disabled selected hidden value><i>Veuillez sélectionner une valeur</i></option>
|
|
<option value="0">non</option>
|
|
<option value="1">oui</option>
|
|
<option value="2">en partie</option>
|
|
</select>
|
|
{% endif %}
|
|
|
|
{% if option.type == "40" %}
|
|
<select id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}}>
|
|
<option disabled selected hidden value><i>Veuillez sélectionner une valeur</i></option>
|
|
<option value="0">Très Satisfait</option>
|
|
<option value="1">Satisfait</option>
|
|
<option value="2">Peu Satisfait</option>
|
|
<option value="3">Insatisfait</option>
|
|
</select>
|
|
{% endif %}
|
|
|
|
|
|
{% if option.type == "50" %}
|
|
<select id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}}>
|
|
<option disabled selected hidden value><i>Veuillez sélectionner une valeur</i></option>
|
|
<option value="0">Très Satisfait</option>
|
|
<option value="1">Satisfait</option>
|
|
<option value="2">Peu Satisfait</option>
|
|
<option value="3">Insatisfait</option>
|
|
</select>
|
|
<textarea id="optionbis{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionbisval" style="height:100px;"></textarea>
|
|
{% endif %}
|
|
|
|
{% if option.type == "60" %}
|
|
<br><i><small>note sur 5</small></i>
|
|
<input type="number" id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}} min="0" max="5">
|
|
{% endif %}
|
|
|
|
{% if option.type == "70" %}
|
|
<br><i><small>note sur 10</small></i>
|
|
<input type="number" id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}} min="0" max="10">
|
|
{% endif %}
|
|
|
|
{% if option.type == "80" %}
|
|
<br><i><small>note sur 20</small></i>
|
|
<input type="number" id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}} min="0" max="20">
|
|
{% endif %}
|
|
|
|
{% if option.type == "90" %}
|
|
<textarea id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}} style="height:100px;"></textarea>
|
|
{% endif %}
|
|
|
|
{% if option.type == "100" %}
|
|
<textarea id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}} style="height:300px;"></textarea>
|
|
{% endif %}
|
|
|
|
{% if option.type == "110" %}
|
|
<select id="option{{option.code}}" data-code="{{option.code}}" data-type="{{option.type}}" class="form-control optionval" {{required|raw}} {{disabled|raw}}>
|
|
<option disabled selected hidden value><i>Veuillez sélectionner une valeur</i></option>
|
|
{% for parameter in option.parameters %}
|
|
<option value="{{parameter}}">{{parameter}}</option>
|
|
{% endfor %}
|
|
</select>
|
|
{% endif %}
|
|
<br>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
{% if form.submit is defined %}
|
|
{{ form_widget(form.submit) }}
|
|
{%endif%}
|
|
</div>
|
|
{{ form_end(form) }}
|
|
{% endblock %}
|
|
|
|
{% block localjavascript %}
|
|
function nl2br (str, replaceMode=true, isXhtml) {
|
|
var breakTag = (isXhtml) ? '<br />' : '<br>';
|
|
var replaceStr = (replaceMode) ? '$1'+ breakTag : '$1'+ breakTag +'$2';
|
|
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, replaceStr);
|
|
}
|
|
|
|
function br2nl (str, replaceMode=true) {
|
|
|
|
var replaceStr = (replaceMode) ? "\n" : '';
|
|
// Includes <br>, <BR>, <br />, </br>
|
|
return str.replace(/<\s*\/?br\s*[\/]?>/gi, replaceStr);
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
var votes = JSON.parse($("#questguest_jsonquestvotes").val());
|
|
$.each(votes, function(i, vote) {
|
|
if(vote.type==50) {
|
|
val=vote.val.split('||||');
|
|
$("#option"+vote.code).val(val[0]);
|
|
$("#optionbis"+vote.code).val(br2nl(val[1]));
|
|
}
|
|
else {
|
|
$("#option"+vote.code).val(br2nl(vote.val));
|
|
}
|
|
});
|
|
});
|
|
|
|
{% if form.submit is defined %}
|
|
$('#mycontent').on('click', '#questguest_submit', function(event) {
|
|
// Construction du tableau des votes
|
|
var tbvotes=[];
|
|
$(".optionval").each(function() {
|
|
keyvote=$(this).data("code");
|
|
valvote=$(this).val();
|
|
if($("#optionbis"+keyvote).length) {
|
|
valvote=valvote+"||||"+$("#optionbis"+keyvote).val();
|
|
}
|
|
tbvotes[keyvote]=nl2br(valvote);
|
|
});
|
|
|
|
// On recalcul la chaine json
|
|
votes="";
|
|
for (const [keyvote, valvote] of Object.entries(tbvotes)) {
|
|
if(votes!="") votes+=',';
|
|
if(votes=="") votes='[';
|
|
votes+='{ "code":"'+keyvote+'", "val":"'+valvote+'"}';
|
|
}
|
|
|
|
if(votes!="") votes+=']';
|
|
if(votes=="") votes="[]";
|
|
|
|
// Valoriser le formulaire
|
|
$("#questguest_jsonquestvotes").val(votes);
|
|
|
|
//event.preventDefault();
|
|
});
|
|
{%endif%}
|
|
{% endblock %}
|