[IMP] Correct prefill for MCQ and matrices
bzr revid: rim@openerp.com-20131224132309-rgv75yye7q7zabu6
This commit is contained in:
@@ -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/<model("survey.survey"):survey>'],
|
||||
# type='http', auth='public', multilang=True)
|
||||
|
||||
@@ -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(){
|
||||
|
||||
Reference in New Issue
Block a user