From: Florent Bruneau Date: Tue, 18 Jan 2011 20:48:11 +0000 (+0100) Subject: Can add answers to a multiple-choices question. X-Git-Tag: xorg/1.1.0~187 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=43f0c0402fc23c2e9dd9814eea20942cce07994d;p=platal.git Can add answers to a multiple-choices question. Signed-off-by: Florent Bruneau --- diff --git a/core b/core index 4836f91..ad884e3 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 4836f918dd6180f92e10722f9a01b9013f42da64 +Subproject commit ad884e358383200846eef6db76c97f67283fdaea diff --git a/htdocs/javascript/survey.js b/htdocs/javascript/survey.js index 884da41..9b3bfee 100644 --- a/htdocs/javascript/survey.js +++ b/htdocs/javascript/survey.js @@ -80,7 +80,6 @@ for (var q in questions) { var q = questions[q]; var child = this.addQuestion(q); - console.log("New question added in " + child.get(0).id); if ($.isArray(q.children)) { child.prepareQuestions(q.children); } @@ -100,6 +99,10 @@ return this.isQuestion() ? this : this.parentQuestion(); }, + questionForm: function() { + return this.question().children('.q_edit_form'); + }, + qid: function() { var question = this.question(); if (question.get(0) == undefined) { @@ -122,7 +125,7 @@ childrenContainer: function() { var question = this.question(); - return question.isRootSection() ? question : question.children('.q_edit_form').children(); + return question.isRootSection() ? question : question.questionForm().children(); }, childrenQuestion: function() { @@ -146,7 +149,11 @@ var type = $(this).val(); var form = question.children('.q_edit_form'); form.empty(); - $("#q_edit_base").tmpl([ { qid: id, type: type } ]).appendTo(form); + if (type != '') { + $("#q_edit_base").tmpl({ qid: id, type: type }) + .bindQuestion(type) + .appendTo(form); + } return true; }); var dest = this.question(); @@ -155,6 +162,14 @@ return question; }, + bindQuestion: function(type) { + var name = type + '_bindQuestion'; + if ($.isFunction(this[name])) { + this[name](); + } + return this; + }, + removeQuestion: function(force) { var question = this.parentQuestion(); if (!force && question.children('.q_edit_form').children().children('.q_edit').length > 0) { @@ -186,6 +201,17 @@ } }); return $this; + }, + + /* Multiple choices questions */ + multiple_bindQuestion: function() { + return this; + }, + + multiple_addAnswer: function() { + var answer = $("#q_edit_multiple_answer").tmpl({ qid: this.qid() }); + this.childrenContainer().children('.add_answer').before(answer); + return answer; } }); })(jQuery); diff --git a/templates/survey/edit.questions.tpl b/templates/survey/edit.questions.tpl index fc8bb97..492a5b4 100644 --- a/templates/survey/edit.questions.tpl +++ b/templates/survey/edit.questions.tpl @@ -59,7 +59,7 @@ + + + {/literal} {* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}