Skip to content
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

Open
wants to merge 88 commits into
base: dev
Choose a base branch
from
Open

Quiz sondage #6486

wants to merge 88 commits into from

Conversation

atman0eirb
Copy link
Contributor

@atman0eirb atman0eirb commented Apr 7, 2023

Contrôle de qualité :

Quiz:

  • Lancez une instance locale de zds. (de préférence sur un autre navigateur que Firefox, sinon il faut à chaque fois rouvrir le tutoriel pour voir le bon comportement : problème de variable local answers après l'actualisation de la page )
  • Créer un tutoriel qui comporte des quizs
  • Pour créer un quiz dans le tutoriel, utiliser :
[[quizz | la question1]]
| - [ ] réponse 1
| - [x] bonne réponse
| - [ ] réponse 2
| - réponse 2 est correcte car c'est correct

[[quizz | la question2]]
| - [x] réponse 1
| - [x] bonne réponse
| - [ ] réponse 2
| - réponse 1 et 2 sont correcte car c'est correct

exemple de quizz à deux questions

  • 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

artragis and others added 30 commits October 30, 2022 20:11
Co-authored-by: Situphen <Situphen@users.noreply.github.com>
Co-authored-by: Situphen <Situphen@users.noreply.github.com>
Co-authored-by: Situphen <Situphen@users.noreply.github.com>
(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
Comment on lines 36 to 48
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)
Copy link
Member

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 et ou encore ici.

</script>

<style>
Copy link
Member

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/.

@@ -1,24 +1,29 @@
import itertools
import json
Copy link
Member

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.

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
Copy link
Member

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
Copy link
Member

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.

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
Copy link
Member

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...

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
Copy link
Member

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é.


from zds.tutorialv2.forms import ContentCompareStatsURLForm, QuizzStatsForm
from zds.tutorialv2.mixins import (
SingleContentDetailViewMixin,
SingleContentViewMixin,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem, pas utilisé.

end_date = date.today()
except ValueError:
end_date = date.today()
messages.error(self.request, _("La date de fin fournie est invalide."))
Copy link
Member

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.

Copy link
Member

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.

Comment on lines 431 to 432
except Exception as e:
return HttpResponseBadRequest(f"An error occurred while deleting the quiz: {str(e)}")
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Suivi des PR
  
Modification demandée
Development

Successfully merging this pull request may close these issues.

None yet

3 participants