From 372d2eb09c47e38aa4dc33251c59c078fbd5988f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Hennecart?= Date: Fri, 24 Jan 2020 08:19:21 +0000 Subject: [PATCH] [IMP] survey: illustrate your questions and answers with media - Purpose: Allow the addition of media on a question and/or answers in order to describe or illustrate them. - Specifications: During the creation of a question, you have now the possibility to set a description of a question by filling an html field under the tab "Description". This field can be used to enter text or to illustrate the question with an image or video. There is also an option to add pictures on answers for simple and multiple choice questions. Those are displayed as clickable images. Task ID 2083823 PR #42228 --- addons/survey/models/survey_question.py | 6 +++++- addons/survey/views/survey_question_views.xml | 6 ++++++ addons/survey/views/survey_templates.xml | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/addons/survey/models/survey_question.py b/addons/survey/models/survey_question.py index 24f55e00133..30c31676230 100644 --- a/addons/survey/models/survey_question.py +++ b/addons/survey/models/survey_question.py @@ -54,7 +54,9 @@ class SurveyQuestion(models.Model): # question generic data title = fields.Char('Title', required=True, translate=True) - description = fields.Html('Description', help="Use this field to add additional explanations about your question", translate=True) + description = fields.Html( + 'Description', translate=True, sanitize=False, # TDE TODO: sanitize but find a way to keep youtube iframe media stuff + help="Use this field to add additional explanations about your question or to illustrate it with pictures or a video") survey_id = fields.Many2one('survey.survey', string='Survey', ondelete='cascade') scoring_type = fields.Selection(related='survey_id.scoring_type', string='Scoring Type', readonly=True) sequence = fields.Integer('Sequence', default=10) @@ -86,6 +88,7 @@ class SurveyQuestion(models.Model): suggested_answer_ids = fields.One2many( 'survey.question.answer', 'question_id', string='Types of answers', copy=True, help='Labels used for proposed choices: simple choice, multiple choice and columns of matrix') + allow_value_image = fields.Boolean('Images on answers', help='Display images in addition to answer label. Valid only for simple / multiple choice questions.') # -- matrix matrix_subtype = fields.Selection([ ('simple', 'One choice per row'), @@ -447,6 +450,7 @@ class SurveyQuestionAnswer(models.Model): matrix_question_id = fields.Many2one('survey.question', string='Question (as matrix row)', ondelete='cascade') sequence = fields.Integer('Label Sequence order', default=10) value = fields.Char('Suggested value', translate=True, required=True) + value_image = fields.Image('Image', max_width=256, max_height=256) is_correct = fields.Boolean('Is a correct answer') answer_score = fields.Float('Score for this choice', help="A positive score indicates a correct choice; a negative or null score indicates a wrong answer") diff --git a/addons/survey/views/survey_question_views.xml b/addons/survey/views/survey_question_views.xml index 3d8426a3bc3..efab66e039a 100644 --- a/addons/survey/views/survey_question_views.xml +++ b/addons/survey/views/survey_question_views.xml @@ -109,6 +109,8 @@ + @@ -122,6 +124,9 @@ + + + @@ -150,6 +155,7 @@ + diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index f8d1c136fb3..423754adee5 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -300,6 +300,13 @@ + +