From 867f4ec9defc7fa4ad0903d04222f044c95a2528 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Tue, 24 Dec 2013 14:23:09 +0100 Subject: [PATCH] [IMP] Correct prefill for MCQ and matrices bzr revid: rim@openerp.com-20131224132309-rgv75yye7q7zabu6 --- addons/survey/controllers/main.py | 12 +++--------- addons/survey/static/src/js/survey.js | 5 +++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 40410755c2e..d4435bbcfd6 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -208,20 +208,14 @@ class WebsiteSurvey(http.Controller): elif answer.answer_type == 'suggestion' and not answer.value_suggested_row: answer_value = answer.value_suggested.id elif answer.answer_type == 'suggestion' and answer.value_suggested_row: - answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id) + answer_tag = "%s_%s" % (answer_tag, answer.value_suggested_row.id) answer_value = answer.value_suggested.id - # TODO vérifier QCM et matrices if answer_value: - ret.update({answer_tag: answer_value}) + dict_soft_update(ret, answer_tag, answer_value) else: - _logger.warning("[survey] Fetching None answer for question %s" % answer_tag) - + _logger.warning("[survey] No answer has been found for question %s marked as non skipped" % answer_tag) return json.dumps(ret) - # load all the user input lines corresponding to token & page (or survey) - # format them into a json dict - # return them to JS - # AJAX validation of some questions # @website.route(['/survey/validate/'], # type='http', auth='public', multilang=True) diff --git a/addons/survey/static/src/js/survey.js b/addons/survey/static/src/js/survey.js index dc338c8a5d3..4bccc3af3ef 100644 --- a/addons/survey/static/src/js/survey.js +++ b/addons/survey/static/src/js/survey.js @@ -64,10 +64,11 @@ $(document).ready(function () { function prefill(){ var prefill_def = $.ajax(prefill_controller, {dataType: "json"}) .done(function(json_data){ - console.log(json_data); _.each(json_data, function(value, key){ the_form.find(".form-control[name=" + key + "]").val(value); - the_form.find("input[name=" + key + "]").val([value]); + the_form.find("input[name^=" + key + "]").each(function(){ + $(this).val(value); + }); }); }) .fail(function(){