(function($) {
$.fn.extend({
- surveyQuestions: function(questions) {
+ showQuestions: function(questions) {
var data = $('#question_base').tmpl(questions);
this.children().remove();
data.appendTo(this);
return this;
+ },
+
+ addQuestion: function(id) {
+ var question = $("#q_edit_new").tmpl([{ qid: id } ]);
+ question
+ .children('select')
+ .change(function () {
+ var type = $(this).val();
+ var form = question.children('.q_edit_form');
+ form.empty();
+ $("#q_edit_base").tmpl([ { qid: id, type: type } ]).appendTo(form);
+ return true;
+ });
+ question.appendTo(this);
+ return this;
}
});
})(jQuery);
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+{literal}
+<script id="q_edit_new" type="text/x-jquery-tmpl">
+ <div>
+ <div><strong>Question ${qid + 1}</strong></div>
+ Type de question : <select name="q_edit[${qid}][type]">
+ <option value=""></option>
+ <option value="text">Texte</option>
+ <option value="section">Section</option>
+ </select>
+ <div class="q_edit_form"></div>
+ </div>
+</script>
+
+<script id="q_edit_base" type="text/x-jquery-tmpl">
+ {{if type}}
+ {{tmpl "#q_edit_" + type}}
+ {{/if}}
+</script>
+
+<script id="q_edit_text" type="text/x-jquery-tmpl">
+ Question : <input type="text" name="q_edit[${qid}][label]" /><br />
+</script>
+
+<script id="q_edit_section" type="text/x-jquery-tmpl">
+ <div id="section_${qid}" style="padding-left: 4ex; border-left: 1px solid white">
+ <div class="center">
+ <a href="javascript:$('#section_${qid}').addQuestion(next_qid++)">
+ {/literal}{icon name="add"}{literal} Ajouter une question
+ </a>
+ </div>
+ <div>
+</script>
+{/literal}
+
+{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
</fieldset>
<fieldset>
- <legend>Déroulement du sondage</legend>
+ <legend>Paramètre du sondage</legend>
Premier jour : <input type="text" class="datepicker" name="begin" /><br />
Dernier jour : <input type="text" class="datepicker" name="end" /><br />
+ Sondage anonyme : Oui <input type="radio" name="anonymous" value="1" checked="checked" />
+ <input type="radio" name="anonymous" value="0" /> Non
</fieldset>
+
+ <h2>Questions</h2>
+
+ <div id="questions">
+ <div class="center">
+ <a href="javascript:$('#questions').addQuestion(next_qid++)">
+ {icon name="add"} Ajouter une question
+ </a>
+ </div>
+ </div>
+
+ <div class="center">
+ <input type="submit" name="valid" value="Soumettre" />
+ </div>
</form>
+<script type="text/javascript">
+ //<![CDATA[
+ var next_qid = 0;
+ //]]>
+</script>
+
+{include file="survey/vote.questions.tpl"}
+{include file="survey/edit.questions.tpl"}
+
{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}