This commit is contained in:
Arnaud Fornerot 2022-02-07 17:11:23 +01:00
parent 42a5c7ccdb
commit b40412eba6
6 changed files with 204 additions and 99 deletions

View File

@ -258,6 +258,10 @@ app_quest_byloginkey:
path: /user/quest/byloginkey/{key} path: /user/quest/byloginkey/{key}
defaults: { _controller: App\Controller\QuestController:byloginkey } defaults: { _controller: App\Controller\QuestController:byloginkey }
app_quest_pdf: app_quest_byguestkey_result:
path: /user/pdf/{id} path: /quest/result/byguestkey/{key}
defaults: { _controller: App\Controller\QuestController:result } defaults: { _controller: App\Controller\QuestController:resultbyguestkey }
app_quest_byuserkey_result:
path: /quest/result/byuserkey/{key}
defaults: { _controller: App\Controller\QuestController:resultbyuserkey }

View File

@ -118,7 +118,7 @@ class NotifyQuestCommand extends Command
$questguests=$this->em->getRepository("App:Questguest")->findBy(["quest"=>$quest]); $questguests=$this->em->getRepository("App:Questguest")->findBy(["quest"=>$quest]);
foreach($questguests as $questguest) { foreach($questguests as $questguest) {
$url=$this->router->generate('app_quest_byguestkey', ["key"=>$questguest->getKey()], UrlGeneratorInterface::ABSOLUTE_URL); $url=$this->router->generate('app_quest_byguestkey_result', ["key"=>$questguest->getKey()], UrlGeneratorInterface::ABSOLUTE_URL);
$url=str_replace("http:","https:",$url); $url=str_replace("http:","https:",$url);
$url=str_replace("/localhost/","/".$this->weburl."/".$this->alias."/",$url); $url=str_replace("/localhost/","/".$this->weburl."/".$this->alias."/",$url);

View File

@ -648,9 +648,10 @@ class QuestController extends AbstractController
return false; return false;
} }
public function result($id,Request $request) { public function result($id,Request $request,$access="") {
// Type pdf / css // Type pdf / css
$type=$request->get('type'); $type=$request->get('type');
if($access!="") $type="";
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$quest=$em->getRepository("App:Quest")->find($id); $quest=$em->getRepository("App:Quest")->find($id);
@ -658,7 +659,7 @@ class QuestController extends AbstractController
$questoptions=$em->getRepository("App:Questoption")->findBy(["quest"=>$quest],["roworder"=>"ASC"]); $questoptions=$em->getRepository("App:Questoption")->findBy(["quest"=>$quest],["roworder"=>"ASC"]);
// On s'assure que le quest appartient bien à l'utilisateur // On s'assure que le quest appartient bien à l'utilisateur
if($this->getUser()!=$quest->getUser()) { if($this->getUser()!=$quest->getUser()&&$access=="") {
return $this->redirect($this->generateUrl('app_quest')); return $this->redirect($this->generateUrl('app_quest'));
} }
@ -780,6 +781,7 @@ class QuestController extends AbstractController
'quest' => $quest, 'quest' => $quest,
'questguests' => $questguests, 'questguests' => $questguests,
'graphs' => $graphs, 'graphs' => $graphs,
'access' => $access,
]); ]);
} }
else { else {
@ -799,6 +801,7 @@ class QuestController extends AbstractController
'questguests' => $questguests, 'questguests' => $questguests,
'graphs' => $graphs, 'graphs' => $graphs,
'type' => $type, 'type' => $type,
'access' => $access,
]); ]);
$render=str_replace("/ninesurvey/","https://ninegate.ac-arno.fr/ninesurvey/",$render); $render=str_replace("/ninesurvey/","https://ninegate.ac-arno.fr/ninesurvey/",$render);
@ -806,4 +809,39 @@ class QuestController extends AbstractController
return $this->file($fileloc); return $this->file($fileloc);
} }
} }
public function resultbyguestkey($key,Request $request)
{
$em = $this->getDoctrine()->getManager();
// Recherche de la clé d'invitation
$questguest = $em->getRepository("App:Questguest")->findOneBy(["key"=>$key]);
if(!$questguest) {
return $this->render('Response/nokey.html.twig',[
'useheader' => true,
'usesidebar' => false,
]);
}
//return new Response();
return $this->result($questguest->getQuest()->getId(),$request,"byguestkey");
}
public function resultbyuserkey($key,Request $request)
{
$em = $this->getDoctrine()->getManager();
// Recherche de l'utilisateur dans le sondage
$questguest = $em->getRepository("App:Questguest")->findOneBy(["quest"=>$key,"user"=>$this->getUser()]);
if(!$questguest) {
return $this->render('Response/nokey.html.twig',[
'useheader' => true,
'usesidebar' => false,
]);
}
//return new Response();
return $this->result($questguest->getQuest()->getId(),$request,"byuserkey");
}
} }

View File

@ -20,7 +20,7 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h1 class="text-center">NINESURVEY</h1> <h1 class="text-center">ENQUETES</h1>
<div class="container mt-4"> <div class="container mt-4">
<div class="row"> <div class="row">
@ -42,12 +42,23 @@
</a> </a>
</div> </div>
</div> </div>
<div class="custom-control custom-switch text-right mb-3">
<input type="checkbox" class="custom-control-input" id="switchactive" checked>
<label class="custom-control-label" for="switchactive">Afficher que mes enquêtes</label>
</div>
<div class="grid" style="display:none"> <div class="grid" style="display:none">
<div class="grid-sizer"></div> <div class="grid-sizer"></div>
<div class="gutter-sizer"></div> <div class="gutter-sizer"></div>
{% for guest in questguests %} {% for guest in questguests %}
<div class="grid-item" > {% set class="" %}
{% if app.user!=guest.quest.user %}
{% set class="notmy" %}
{% endif %}
<div class="grid-item {{class}}">
<div class="card mb-3"> <div class="card mb-3">
<div class="card-header"> <div class="card-header">
{{ guest.quest.title }} {{ guest.quest.title }}
@ -59,7 +70,8 @@
<a href="{{ path('app_quest_result',{id:guest.quest.id})}}" class="questaction btn btn-success btn-sm"><i class="fas fa-trophy"></i> Résultat<br></a> <a href="{{ path('app_quest_result',{id:guest.quest.id})}}" class="questaction btn btn-success btn-sm"><i class="fas fa-trophy"></i> Résultat<br></a>
<a href="{{ path('app_quest_delete',{id:guest.quest.id})}}" class="btn btn-danger btn-sm float-right" data-method="delete" data-confirm="Êtes-vous sûr de vouloir supprimer cet enregistrement ?"><i class="fa fa-trash"></i></a> <a href="{{ path('app_quest_delete',{id:guest.quest.id})}}" class="btn btn-danger btn-sm float-right" data-method="delete" data-confirm="Êtes-vous sûr de vouloir supprimer cet enregistrement ?"><i class="fa fa-trash"></i></a>
{% else %}
<a href="{{ path('app_quest_byuserkey_result',{key:guest.quest.id})}}" class="questaction btn btn-success btn-sm"><i class="fas fa-trophy"></i> Résultat<br></a>
{% endif %} {% endif %}
<div class="row mt-2"> <div class="row mt-2">
<div class="col-md-12"> <div class="col-md-12">
@ -130,12 +142,14 @@
{% block localjavascript %} {% block localjavascript %}
$(document).ready(function() { $(document).ready(function() {
$(".notmy").hide();
$('.grid').masonry({ $('.grid').masonry({
itemSelector: '.grid-item', itemSelector: '.grid-item',
columnWidth: '.grid-sizer', columnWidth: '.grid-sizer',
gutter: '.gutter-sizer', gutter: '.gutter-sizer',
percentPosition: true, percentPosition: true,
}); });
}); });
$(".grid").show(); $(".grid").show();
@ -157,4 +171,19 @@
document.execCommand("copy"); document.execCommand("copy");
$temp.remove(); $temp.remove();
} }
$('#switchactive').change(function() {
if($(this).is(":checked"))
$(".notmy").hide();
else
$(".notmy").show();
$('.grid').masonry({
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
gutter: '.gutter-sizer',
percentPosition: true,
});
});
{% endblock %} {% endblock %}

View File

@ -42,11 +42,16 @@
{% block body %} {% block body %}
<div class="container"> <div class="container">
{% if not type is defined or type !="pdf" %} {% if (not type is defined or type !="pdf") and access=="" %}
<a class="btn btn-secondary mb-3 mt-3" href={{ path('app_quest') }}>Retour</a> <a class="btn btn-secondary mb-3 mt-3" href={{ path('app_quest') }}>Retour</a>
<a class="btn btn-secondary mb-3 mt-3 float-right" href={{ path('app_quest') }}><i class="fas fa-file-csv fa-fw fa-2x"></i>Exporter en CSV</a> <a class="btn btn-secondary mb-3 mt-3 float-right" href={{ path('app_quest_result',{id:quest.id,type:'csv'}) }}><i class="fas fa-file-csv fa-fw fa-2x"></i>Exporter en CSV</a>
<a class="btn btn-secondary mb-3 mt-3 float-right mr-3" href={{ path('app_quest_pdf',{id:quest.id,type:'pdf'}) }}><i class="fas fa-file-pdf fa-fw fa-2x"></i>Exporter en PDF</a> <a class="btn btn-secondary mb-3 mt-3 float-right mr-3" href={{ path('app_quest_result',{id:quest.id,type:'pdf'}) }}><i class="fas fa-file-pdf fa-fw fa-2x"></i>Exporter en PDF</a>
{% endif %} {% endif %}
{% if (not type is defined or type !="pdf") and access=="byuserkey" %}
<a class="btn btn-secondary mb-3 mt-3" href={{ path('app_quest') }}>Retour</a>
{% endif %}
<h1>Synthèse</h1> <h1>Synthèse</h1>
<b>Titre de l'enquête =</b> {{ quest.title }}<br> <b>Titre de l'enquête =</b> {{ quest.title }}<br>
<b>Nombre de réponses récoltées =</b> <b>Nombre de réponses récoltées =</b>
@ -96,101 +101,103 @@
{% endfor %} {% endfor %}
</div> </div>
{% for guest in questguests %} {% if access=="" %}
{% if not guest.questvotes is empty %} {% for guest in questguests %}
<hr> {% if not guest.questvotes is empty %}
<h2> <hr>
Réponse n° {{loop.index}} <h2>
</h2> Réponse n° {{loop.index}}
{% if not quest.anonymous %}<small>email = {{ guest.email }}</small>{%endif%} </h2>
{% if not quest.anonymous %}<small>email = {{ guest.email }}</small>{%endif%}
<div class="row"> <div class="row">
{% for vote in guest.questvotes %} {% for vote in guest.questvotes %}
<div class="col-md-4 mb-3" style="zoom:80%"> <div class="col-md-4 mb-3" style="zoom:80%">
<div class="card card-default"> <div class="card card-default">
<div class="card-header"> <div class="card-header">
{{vote.questoption.name}} {{vote.questoption.name}}
</div> </div>
<div class="card-body"> <div class="card-body">
{% if vote.questoption.type == "10" %} {% if vote.questoption.type == "10" %}
<div style="text-align:center;font-size:150%;"> <div style="text-align:center;font-size:150%;">
{% if vote.vote == 0 %}non {% if vote.vote == 0 %}non
{% else %}oui {% else %}oui
{% endif %}
</div>
{% endif %} {% endif %}
</div>
{% endif %}
{% if vote.questoption.type == "20" %} {% if vote.questoption.type == "20" %}
<div style="text-align:center;font-size:150%;"> <div style="text-align:center;font-size:150%;">
{% if vote.vote == 0 %}non {% if vote.vote == 0 %}non
{% elseif vote.vote== 1 %}oui {% elseif vote.vote== 1 %}oui
{% else %}peut-être {% else %}peut-être
{% endif %}
</div>
{% endif %}
{% if vote.questoption.type == "30" %}
<div style="text-align:center;font-size:150%;">
{% if vote.vote == 0 %}non
{% elseif vote.vote== 1 %}oui
{% else %}en partie
{% endif %}
</div>
{% endif %}
{% if vote.questoption.type == "40" %}
<div style="text-align:center;font-size:150%;">
{% if vote.vote == 0 %}Très Satisfait
{% elseif vote.vote== 1 %}Satisfait
{% elseif vote.vote== 2 %}Peu Satisfait
{% else %}Insatisfait
{% endif %}
</div>
{% endif %}
{% if vote.questoption.type == "50" %}
{% endif %}
{% if vote.questoption.type == "60" %}
<div style="text-align:center;font-size:150%;">
{{ vote.vote }} / 5
</div>
{% endif %}
{% if vote.questoption.type == "70" %}
<div style="text-align:center;font-size:150%;">
{{ vote.vote }} / 10
</div>
{% endif %}
{% if vote.questoption.type == "80" %}
<div style="text-align:center;font-size:150%;">
{{ vote.vote }} / 20
</div>
{% endif %}
{% if vote.questoption.type == "90" %}
{{ vote.vote|raw }}
{% endif %} {% endif %}
</div>
{% endif %}
{% if vote.questoption.type == "30" %} {% if vote.questoption.type == "100" %}
<div style="text-align:center;font-size:150%;"> {{ vote.vote|raw }}
{% if vote.vote == 0 %}non
{% elseif vote.vote== 1 %}oui
{% else %}en partie
{% endif %} {% endif %}
</div>
{% endif %}
{% if vote.questoption.type == "40" %} {% if vote.questoption.type == "110" %}
<div style="text-align:center;font-size:150%;"> <div style="text-align:center;font-size:150%;">
{% if vote.vote == 0 %}Très Satisfait {{ vote.vote|raw }}
{% elseif vote.vote== 1 %}Satisfait </div>
{% elseif vote.vote== 2 %}Peu Satisfait {% endif %}
{% else %}Insatisfait
{% endif %}
</div>
{% endif %}
{% if vote.questoption.type == "50" %}
{% endif %}
{% if vote.questoption.type == "60" %}
<div style="text-align:center;font-size:150%;">
{{ vote.vote }} / 5
</div>
{% endif %}
{% if vote.questoption.type == "70" %}
<div style="text-align:center;font-size:150%;">
{{ vote.vote }} / 10
</div>
{% endif %}
{% if vote.questoption.type == "80" %}
<div style="text-align:center;font-size:150%;">
{{ vote.vote }} / 20
</div>
{% endif %}
{% if vote.questoption.type == "90" %}
{{ vote.vote|raw }}
{% endif %}
{% if vote.questoption.type == "100" %}
{{ vote.vote|raw }}
{% endif %}
{% if vote.questoption.type == "110" %}
<div style="text-align:center;font-size:150%;">
{{ vote.vote|raw }}
</div>
{% endif %}
</div>
</div> </div>
</div> </div>
</div> {% endfor %}
{% endfor %} </div>
</div> {% endif %}
{% endif %} {% endfor %}
{% endfor %} {% endif %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -20,7 +20,7 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h1 class="text-center">NINESURVEY</h1> <h1 class="text-center">SONDAGES DE DATES</h1>
<div class="container mt-4"> <div class="container mt-4">
<div class="row"> <div class="row">
@ -42,12 +42,23 @@
</a> </a>
</div> </div>
</div> </div>
<div class="custom-control custom-switch text-right mb-3">
<input type="checkbox" class="custom-control-input" id="switchactive" checked>
<label class="custom-control-label" for="switchactive">Afficher que mes sondages</label>
</div>
<div class="grid" style="display:none"> <div class="grid" style="display:none">
<div class="grid-sizer"></div> <div class="grid-sizer"></div>
<div class="gutter-sizer"></div> <div class="gutter-sizer"></div>
{% for surveyguest in surveyguests %} {% for surveyguest in surveyguests %}
<div class="grid-item" > {% set class="" %}
{% if app.user!=surveyguest.survey.user %}
{% set class="notmy" %}
{% endif %}
<div class="grid-item {{class}}">
<div class="card mb-3"> <div class="card mb-3">
<div class="card-header"> <div class="card-header">
{{ surveyguest.survey.title }} {{ surveyguest.survey.title }}
@ -147,6 +158,7 @@
{% block localjavascript %} {% block localjavascript %}
$(document).ready(function() { $(document).ready(function() {
$(".notmy").hide();
$('.grid').masonry({ $('.grid').masonry({
itemSelector: '.grid-item', itemSelector: '.grid-item',
columnWidth: '.grid-sizer', columnWidth: '.grid-sizer',
@ -174,4 +186,19 @@
document.execCommand("copy"); document.execCommand("copy");
$temp.remove(); $temp.remove();
} }
$('#switchactive').change(function() {
if($(this).is(":checked"))
$(".notmy").hide();
else
$(".notmy").show();
$('.grid').masonry({
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
gutter: '.gutter-sizer',
percentPosition: true,
});
});
{% endblock %} {% endblock %}