Files
odoo_source/addons/website_slides/tests/test_slide_question.py
T
Lopes Marc (loma) bb4755f979 [IMP] website_slides: allow multiple correct answers
Purpose
=======
Currently the user interface let you specify several correct answers
per quiz question. But when you save the course, you get a notification
error. As those are simple quizzes, it might be interesting to simply
allow multiple answers.

Specifications
==============
Allow questions with multiple correct answers.
Back-end views: improve feedback when user forget to set at least one correct
answer and one incorrect answer per question.

Task-3366803

closes odoo/odoo#127065

Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
2023-08-23 14:43:06 +02:00

39 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import Command
from odoo.addons.website_slides.tests import common as slides_common
from odoo.tests.common import users
class TestSlideQuestionManagement(slides_common.SlidesCase):
@users('user_officer')
def test_compute_answers_validation_error(self):
channel = self.env['slide.channel'].create({
'name': 'Test compute answers channel',
'slide_ids': [Command.create({
'name': "Test compute answers validation error slide",
'slide_category': 'quiz',
'question_ids': [Command.create({
'question': 'Will test compute answers validation error pass?',
'answer_ids': [
Command.create({
'text_value': 'An incorrect answer',
}),
Command.create({
'is_correct': True,
'text_value': 'A correct answer',
})
]
})]
})]
})
question = channel.slide_ids[0].question_ids[0]
self.assertFalse(question.answers_validation_error)
for val in (False, True):
question.answer_ids[0].is_correct = val
question.answer_ids[1].is_correct = val
self.assertTrue(question.answers_validation_error)