-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quiz sondage #6486
base: dev
Are you sure you want to change the base?
Quiz sondage #6486
Conversation
Co-authored-by: Situphen <[email protected]>
Co-authored-by: Situphen <[email protected]>
Co-authored-by: Situphen <[email protected]>
(et qui sait? plus digeste)
modify test : test_opinion_link_is_not_related_to_the_author in file : zds/tutorialv2/tests/tests_views/tests_published.py to accept the Fix zestedesavoir#5793
templates/misc/quizz.graph.part.html
Outdated
function deleteQuizz(quizzName, question) { | ||
const csrfmiddlewaretoken = document.querySelector('input[name=\'csrfmiddlewaretoken\']').value | ||
const xhttp = new XMLHttpRequest() | ||
const url = 'http://0.0.0.0:8000/contenus/delete_quizz/' | ||
const data = question ? JSON.stringify({ 'quizzName': quizzName, 'question': question }) : JSON.stringify({ 'quizzName': quizzName }) | ||
xhttp.open('POST', url) | ||
xhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest') | ||
xhttp.setRequestHeader('Content-Type', 'application/json') | ||
xhttp.setRequestHeader('X-CSRFToken', csrfmiddlewaretoken) | ||
xhttp.onload = function () { | ||
location.reload() | ||
} | ||
xhttp.send(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non, on ne fait pas comme ça, notamment l'URL codée en dur, ça ne va pas (on fait comment quand on passera en prod ?). Inspire-toi ce qui est fait pour la liste des contenus à mettre en avant : http://0.0.0.0:8080/mise-en-avant/unes/requetes/ (connecté en tant qu'admin). Ça se passe là et là ou encore ici.
templates/misc/quizz.graph.part.html
Outdated
</script> | ||
|
||
<style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tout ce qui suit devrait aller quelque part dans assets/scss/
.
zds/tutorialv2/views/statistics.py
Outdated
@@ -1,24 +1,29 @@ | |||
import itertools | |||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On importe loads
juste en-dessous, donc cette ligne est inutile, et tu peux directement appeler loads
au lieu de json.loads
.
zds/tutorialv2/views/statistics.py
Outdated
import uuid | ||
from collections import OrderedDict, Counter | ||
import logging | ||
import urllib.parse | ||
from datetime import timedelta, datetime, date | ||
from json import loads, dumps | ||
|
||
from django.shortcuts import get_object_or_404, redirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essai de garder les imports liés à Django ensemble, donc déplace cette ligne plus bas.
import uuid | ||
from collections import OrderedDict, Counter | ||
import logging | ||
import urllib.parse | ||
from datetime import timedelta, datetime, date | ||
from json import loads, dumps | ||
|
||
from django.shortcuts import get_object_or_404, redirect | ||
from django.views import View |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu te sers de View
, pour créer une vue de suppression, donc cette vue devrait plutôt hériter de DeleteView
, et cet import devient inutile.
zds/tutorialv2/views/statistics.py
Outdated
import requests | ||
from django.conf import settings | ||
from django.contrib import messages | ||
from django.core.exceptions import PermissionDenied | ||
from django.db.models import Count | ||
from django.forms.utils import ErrorDict | ||
from django.http import StreamingHttpResponse | ||
from django.http import HttpResponse, HttpResponseBadRequest, JsonResponse, StreamingHttpResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu importes HttpResponse
et JsonResponse
, mais tu ne t'en sers pas...
zds/tutorialv2/views/statistics.py
Outdated
from django.utils.translation import gettext_lazy as _ | ||
from django.views.generic import FormView | ||
from django.views.generic import FormView, DeleteView | ||
from zds.member.decorator import LoggedWithReadWriteHability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem, cet import n'est pas utilisé.
zds/tutorialv2/views/statistics.py
Outdated
|
||
from zds.tutorialv2.forms import ContentCompareStatsURLForm, QuizzStatsForm | ||
from zds.tutorialv2.mixins import ( | ||
SingleContentDetailViewMixin, | ||
SingleContentViewMixin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem, pas utilisé.
zds/tutorialv2/views/statistics.py
Outdated
end_date = date.today() | ||
except ValueError: | ||
end_date = date.today() | ||
messages.error(self.request, _("La date de fin fournie est invalide.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Euh, on veut afficher le message pour les deux exceptions TypeError
et ValueError
, non ? Et je ne sais plus si Python permet d'écrire des choses du genre except TypeError, ValueError:
, ça permettrait de factoriser du code.
Et idem pour la date de début juste en-dessous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
en python le double catch c'est except (ValueError, TypeError) as e
si tu as besoin de la variable, sinon c'est simplement except TypeError, ValueError
en effet.
zds/tutorialv2/views/statistics.py
Outdated
except Exception as e: | ||
return HttpResponseBadRequest(f"An error occurred while deleting the quiz: {str(e)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il ne devrait pas y avoir d'erreur à ce niveau-là. S'il y a des erreurs, c'est qu'il faut les éviter en amont.
…ondage squelette que dans les forums
…/ last commit :)
Contrôle de qualité :
Quiz:
Valider le tutoriel et publier le par user staff
Assurer que l'utilisateur doit se connecter pour répondre au quiz
Se connecter et assurer qu'un quiz non complètement répondu n'est pas accepté.
Répondre au quiz, et assurer que la réaction après la réponse est cohérente.
Assurer que l'explication s'affiche pour chaque question de quiz après la réponse au quiz.
Assurer que les statistiques dans la page des statistiques (pour l'auteur de quiz ou staff) sont bonnes
Essayer le générateur de code Markdown d'un quiz avec " créer un quiz " dans la barre transversale à gauche lors de la création d'une section pour un tutoriel