learn.js
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// function newquestion(q) {
// $('#title').html(q["title"]);
// $('#text').html(q["text"]);
// switch (q["type"]) {
// case "information":
// case "warning":
// case "alert":
// $('#answer').html("");
// break;
// case "text":
// case "text_regex":
// $('#answer').html(`
// <fieldset data-role="controlgroup">
// <input type="text" name="FIXME" class="form-control">
// </fieldset>
// `);
// // <input type="text" name="${i}" class="form-control" value="${q['answer'] if q['answer'] is not None else ''}">
// break;
// case "radio":
// case "checkbox":
// // $('#answer').html(nunjucks.renderString('<h1>{{title}}</h1><strong>{{type}}</strong>', data)); // FIXME should not be public
// // $('#answer').html(render('question-radio.html', data));
// $('#answer').html(nunjucks.renderString(`
// <fieldset data-role="controlgroup">
// <div class="list-group">
// {% for opt in options %}
// <a class="list-group-item">
// <input type="{{ type }}" name="a" id="b" value="c">
// {{ opt }}
// </a>
// {% else %}
// No options????? FIXME
// {% endfor %}
// </div>
// </fieldset>
// <button class="btn btn-primary" id="submit">
// Submeter resposta
// </button>
// `, q));
// $("submit").click(function (e) {
// e.preventDefault();
// });
// break;
// default:
// $('#answer').html("Tipo de pergunta desconhecido: " + data["type"]);
// }
// $("#actions").html(`
// `);
// }
// function get_question() {
// }
// $(document).ready(function() {
// // nunjucks.configure("/static/tmpl", {"autoescape": false}); // FIXME
// // get question
// $.ajax({
// url: "/question",
// context: document.body;
// // dataType: "json",
// success: function(response){
// $("#question").html(response);
// },
// error: function() {alert("Servidor não responde.");}
// });
// });