Commit a0f5b4b0791a21f99c2445092f13a1fa8375b439
1 parent
7d7be851
Exists in
master
and in
1 other branch
- added codemirror to textarea questions.
Showing
5 changed files
with
18 additions
and
21 deletions
Show diff stats
BUGS.md
1 | 1 | ||
2 | # BUGS | 2 | # BUGS |
3 | 3 | ||
4 | -- arranjar os links para static/libs como no perguntations. | ||
5 | -- quando erra uma textarea, o comment fica na nova pergunta que se gera. | ||
6 | - nao esta a guardar as respostas erradas. | 4 | - nao esta a guardar as respostas erradas. |
7 | - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question. | 5 | - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question. |
8 | 6 | ||
@@ -18,13 +16,11 @@ | @@ -18,13 +16,11 @@ | ||
18 | - session management. close after inactive time. | 16 | - session management. close after inactive time. |
19 | - radio e checkboxes, aceitar numeros como seleccao das opcoes. | 17 | - radio e checkboxes, aceitar numeros como seleccao das opcoes. |
20 | - reload das perguntas enquanto online. ver signal em http://stackabuse.com/python-async-await-tutorial/ | 18 | - reload das perguntas enquanto online. ver signal em http://stackabuse.com/python-async-await-tutorial/ |
21 | -- pertuntas tipo tristate: (sim, não, não sei | ||
22 | - tabela de progresso de todos os alunos por topico. | 19 | - tabela de progresso de todos os alunos por topico. |
23 | - tabela com perguntas / quantidade de respostas certas/erradas. | 20 | - tabela com perguntas / quantidade de respostas certas/erradas. |
24 | - tabela com topicos / quantidade de estrelas. | 21 | - tabela com topicos / quantidade de estrelas. |
25 | - pymips: activar/desactivar instruções | 22 | - pymips: activar/desactivar instruções |
26 | - implementar servidor http com redirect para https. | 23 | - implementar servidor http com redirect para https. |
27 | -- usar codemirror no textarea | ||
28 | - ao fim de 3 tentativas com password errada, envia email com nova password. | 24 | - ao fim de 3 tentativas com password errada, envia email com nova password. |
29 | - titulos das perguntas não suportam markdown. | 25 | - titulos das perguntas não suportam markdown. |
30 | - pagina report que permita ver tabela alunos/topicos, estatisticas perguntas mais falhadas, tempo médio por pergunta. | 26 | - pagina report que permita ver tabela alunos/topicos, estatisticas perguntas mais falhadas, tempo médio por pergunta. |
@@ -32,6 +28,9 @@ | @@ -32,6 +28,9 @@ | ||
32 | 28 | ||
33 | # FIXED | 29 | # FIXED |
34 | 30 | ||
31 | +- usar codemirror no textarea | ||
32 | +- quando erra uma textarea, o comment fica na nova pergunta que se gera. | ||
33 | +- arranjar os links para static/libs como no perguntations. | ||
35 | - each topic only loads a sample of K questions (max) in random order. | 34 | - each topic only loads a sample of K questions (max) in random order. |
36 | - change password modal nao aparece no ipad (safari e firefox) | 35 | - change password modal nao aparece no ipad (safari e firefox) |
37 | - detect questions in questions.yaml without ref -> error ou generate default. | 36 | - detect questions in questions.yaml without ref -> error ou generate default. |
static/js/topic.js
@@ -24,23 +24,7 @@ function updateQuestion(response){ | @@ -24,23 +24,7 @@ function updateQuestion(response){ | ||
24 | if (e.shiftKey) postQuestion(); | 24 | if (e.shiftKey) postQuestion(); |
25 | return false; | 25 | return false; |
26 | }}); | 26 | }}); |
27 | - $("textarea").keydown(function (e) { | ||
28 | - if (e.keyCode == 13 && e.shiftKey) { // shift enter | ||
29 | - e.preventDefault(); | ||
30 | - postQuestion(); | ||
31 | - } | ||
32 | - else if (e.keyCode == 9) { // tab | ||
33 | - e.preventDefault(); // prevent loosing focus | ||
34 | - // get caret position/selection | ||
35 | - var start = this.selectionStart; | ||
36 | - var end = this.selectionEnd; | ||
37 | - var value = $(this).val(); | ||
38 | 27 | ||
39 | - // set textarea value to: text before caret + tab + text after caret | ||
40 | - $(this).val(value.substring(0, start) + " " + " " + " " + " " + value.substring(end)); | ||
41 | - // put caret at right position again (add one for the tab) | ||
42 | - this.selectionStart = this.selectionEnd = start + 4; | ||
43 | - }}); | ||
44 | $('#question_div').animateCSS('bounceInDown'); | 28 | $('#question_div').animateCSS('bounceInDown'); |
45 | break; | 29 | break; |
46 | 30 | ||
@@ -75,6 +59,7 @@ function getQuestion() { | @@ -75,6 +59,7 @@ function getQuestion() { | ||
75 | // Send answer and receive a response. | 59 | // Send answer and receive a response. |
76 | // The response can be a new_question or a shake if the answer is wrong. | 60 | // The response can be a new_question or a shake if the answer is wrong. |
77 | function postQuestion() { | 61 | function postQuestion() { |
62 | + editor.save(); | ||
78 | $.ajax({ | 63 | $.ajax({ |
79 | type: "POST", | 64 | type: "POST", |
80 | url: "/question", | 65 | url: "/question", |
templates/question-textarea.html
@@ -2,7 +2,16 @@ | @@ -2,7 +2,16 @@ | ||
2 | 2 | ||
3 | {% block answer %} | 3 | {% block answer %} |
4 | 4 | ||
5 | -<textarea class="form-control" rows="{{ question['lines'] }}" name="answer" autofocus>{{ question['answer'] or '' }}</textarea><br /> | 5 | +<textarea class="form-control" rows="{{ question['lines'] }}" name="answer" id="code" autofocus>{{ question['answer'] or '' }}</textarea><br /> |
6 | <input type="hidden" name="question_ref" value="{{ question['ref'] }}"> | 6 | <input type="hidden" name="question_ref" value="{{ question['ref'] }}"> |
7 | 7 | ||
8 | +<script> | ||
9 | + var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
10 | + lineNumbers: true, | ||
11 | + mode: "clike", | ||
12 | + // matchBrackets: true, | ||
13 | + // theme: "night", | ||
14 | + }); | ||
15 | +</script> | ||
16 | + | ||
8 | {% end %} | 17 | {% end %} |
templates/topic.html
@@ -23,6 +23,7 @@ | @@ -23,6 +23,7 @@ | ||
23 | <link rel="stylesheet" href="/static/MDB/css/mdb.min.css"> | 23 | <link rel="stylesheet" href="/static/MDB/css/mdb.min.css"> |
24 | <link rel="stylesheet" href="/static/css/animate.min.css"> | 24 | <link rel="stylesheet" href="/static/css/animate.min.css"> |
25 | <link rel="stylesheet" href="/static/css/github.css"> | 25 | <link rel="stylesheet" href="/static/css/github.css"> |
26 | + <link rel="stylesheet" href="/static/codemirror/codemirror.css"> | ||
26 | <link rel="stylesheet" href="/static/css/topic.css"> | 27 | <link rel="stylesheet" href="/static/css/topic.css"> |
27 | 28 | ||
28 | <!-- Scripts --> | 29 | <!-- Scripts --> |
@@ -31,6 +32,8 @@ | @@ -31,6 +32,8 @@ | ||
31 | <script defer src="/static/fontawesome/fontawesome-all.min.js"></script> | 32 | <script defer src="/static/fontawesome/fontawesome-all.min.js"></script> |
32 | <script defer src="/static/bootstrap/js/bootstrap.min.js"></script> | 33 | <script defer src="/static/bootstrap/js/bootstrap.min.js"></script> |
33 | <script defer src="/static/MDB/js/mdb.min.js"></script> | 34 | <script defer src="/static/MDB/js/mdb.min.js"></script> |
35 | + <script defer src="/static/codemirror/codemirror.js"></script> | ||
36 | + <script defer src="/static/codemirror/z80.js"></script> | ||
34 | 37 | ||
35 | <script defer src="/static/js/topic.js"></script> | 38 | <script defer src="/static/js/topic.js"></script> |
36 | </head> | 39 | </head> |