From a0f5b4b0791a21f99c2445092f13a1fa8375b439 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Sat, 21 Apr 2018 23:50:31 +0100 Subject: [PATCH] - added codemirror to textarea questions. --- BUGS.md | 7 +++---- static/codemirror | 1 + static/js/topic.js | 17 +---------------- templates/question-textarea.html | 11 ++++++++++- templates/topic.html | 3 +++ 5 files changed, 18 insertions(+), 21 deletions(-) create mode 120000 static/codemirror diff --git a/BUGS.md b/BUGS.md index 4ad4af1..012655c 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,8 +1,6 @@ # BUGS -- arranjar os links para static/libs como no perguntations. -- quando erra uma textarea, o comment fica na nova pergunta que se gera. - nao esta a guardar as respostas erradas. - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question. @@ -18,13 +16,11 @@ - session management. close after inactive time. - radio e checkboxes, aceitar numeros como seleccao das opcoes. - reload das perguntas enquanto online. ver signal em http://stackabuse.com/python-async-await-tutorial/ -- pertuntas tipo tristate: (sim, não, não sei - tabela de progresso de todos os alunos por topico. - tabela com perguntas / quantidade de respostas certas/erradas. - tabela com topicos / quantidade de estrelas. - pymips: activar/desactivar instruções - implementar servidor http com redirect para https. -- usar codemirror no textarea - ao fim de 3 tentativas com password errada, envia email com nova password. - titulos das perguntas não suportam markdown. - pagina report que permita ver tabela alunos/topicos, estatisticas perguntas mais falhadas, tempo médio por pergunta. @@ -32,6 +28,9 @@ # FIXED +- usar codemirror no textarea +- quando erra uma textarea, o comment fica na nova pergunta que se gera. +- arranjar os links para static/libs como no perguntations. - each topic only loads a sample of K questions (max) in random order. - change password modal nao aparece no ipad (safari e firefox) - detect questions in questions.yaml without ref -> error ou generate default. diff --git a/static/codemirror b/static/codemirror new file mode 120000 index 0000000..fab5be1 --- /dev/null +++ b/static/codemirror @@ -0,0 +1 @@ +libs/codemirror-5.37.0/ \ No newline at end of file diff --git a/static/js/topic.js b/static/js/topic.js index bbfd1b7..3fcdaeb 100644 --- a/static/js/topic.js +++ b/static/js/topic.js @@ -24,23 +24,7 @@ function updateQuestion(response){ if (e.shiftKey) postQuestion(); return false; }}); - $("textarea").keydown(function (e) { - if (e.keyCode == 13 && e.shiftKey) { // shift enter - e.preventDefault(); - postQuestion(); - } - else if (e.keyCode == 9) { // tab - e.preventDefault(); // prevent loosing focus - // get caret position/selection - var start = this.selectionStart; - var end = this.selectionEnd; - var value = $(this).val(); - // set textarea value to: text before caret + tab + text after caret - $(this).val(value.substring(0, start) + " " + " " + " " + " " + value.substring(end)); - // put caret at right position again (add one for the tab) - this.selectionStart = this.selectionEnd = start + 4; - }}); $('#question_div').animateCSS('bounceInDown'); break; @@ -75,6 +59,7 @@ function getQuestion() { // Send answer and receive a response. // The response can be a new_question or a shake if the answer is wrong. function postQuestion() { + editor.save(); $.ajax({ type: "POST", url: "/question", diff --git a/templates/question-textarea.html b/templates/question-textarea.html index 9678015..8a9c435 100644 --- a/templates/question-textarea.html +++ b/templates/question-textarea.html @@ -2,7 +2,16 @@ {% block answer %} -
+
+ + {% end %} diff --git a/templates/topic.html b/templates/topic.html index 27e8f39..0258b90 100644 --- a/templates/topic.html +++ b/templates/topic.html @@ -23,6 +23,7 @@ + @@ -31,6 +32,8 @@ + + -- libgit2 0.21.2