Coder Social home page Coder Social logo

Comments (5)

tomwalker avatar tomwalker commented on August 16, 2024

I havent done anything to allow multiple correct questions but that does sound like a useful feature!

from django_quiz.

mayersre avatar mayersre commented on August 16, 2024

Am 13.11.2015 um 20:00 schrieb Tom Walker:

I havent done anything to allow multiple correct questions but that
does sound like a useful feature!


Reply to this email directly or view it on GitHub
#49 (comment).

May I request it as a feature then?

kind regards

from django_quiz.

mayersre avatar mayersre commented on August 16, 2024

I can offer a german translation in return. I want to make a trainig website for my kids, there I will need multiple correct answers.

from django_quiz.

mykljohn avatar mykljohn commented on August 16, 2024

@tomwalker @mayersre Hi, nice quiz app. Has anything been done with multiple correct answers? We have the same issue. It would be nice to allow both using radioselects for one correct and CheckboxSelectMultiple for multiple choices. cheers, Mykl

from django_quiz.

mayersre avatar mayersre commented on August 16, 2024

With a few code changes multiple answers will work,

in quiz.forms.QuestionForm change the field and the widget

from django.forms.widgets import CheckboxSelectMultiple
        self.fields["answers"] = forms.MultipleChoiceField(choices=choice_list,
                                                  widget=CheckboxSelectMultiple)

in quiz.multichoice.models change the check_if_correct method to process a list and build a Q filter for it

    def check_if_correct(self, guesses):
        #
        filterqs=models.Q()
        # add a filter for each answer
        for guess in guesses :
            filterqs = filterqs | models.Q(id=guess)
        answers = Answer.objects.filter(filterqs)
        # One wrong answer makes the question fail
        retval=False
        for answer in answers :
            if answer.correct is True:
                retval=True
            else:
                return False
        return retval

from django_quiz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.