Commit 3ba69818214c43980a6a36b90a613159a28d8598
1 parent
5338ec53
Exists in
master
and in
1 other branch
fix submit on enter getting json page
Showing
6 changed files
with
22 additions
and
20 deletions
Show diff stats
BUGS.md
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | |
| 32 | 32 | # FIXED |
| 33 | 33 | |
| 34 | +- enter nas respostas mostra json | |
| 34 | 35 | - apos clicar no botao responder, inactivar o input (importante quando o tempo de correcção é grande) |
| 35 | 36 | - double click submits twice. |
| 36 | 37 | - checkbox devia ter correct no intervalo [0,1] tal como radio. em caso de desconto a correccção faz 2*x-1. isto permite a mesma semantica nos dois tipos de perguntas. | ... | ... |
aprendizations/static/js/topic.js
| ... | ... | @@ -25,7 +25,6 @@ function showTriesLeft(tries) { |
| 25 | 25 | function getQuestion() { |
| 26 | 26 | $("#comments").html("").hide(); |
| 27 | 27 | $("#submit").addClass("disabled"); |
| 28 | - | |
| 29 | 28 | $.ajax({ |
| 30 | 29 | type: "GET", |
| 31 | 30 | url: "/question", |
| ... | ... | @@ -37,18 +36,17 @@ function getQuestion() { |
| 37 | 36 | |
| 38 | 37 | // updates question in the page according to the response given by the server |
| 39 | 38 | function updateQuestion(response) { |
| 40 | - var method = response["method"]; | |
| 41 | 39 | var params = response["params"]; |
| 42 | 40 | |
| 43 | 41 | $("#right, #wrong").hide(); |
| 44 | 42 | |
| 45 | - switch (method) { | |
| 43 | + switch (response["method"]) { | |
| 46 | 44 | case "new_question": |
| 47 | 45 | new_question(params["type"], params["question"], params["tries"], params["progress"]); |
| 48 | 46 | break; |
| 49 | 47 | case "finished_topic": |
| 50 | 48 | $('#submit, #comments, #solution').remove(); |
| 51 | - $("#content").html(response["params"]["question"]).animateCSS('tada'); | |
| 49 | + $("#content").html(params["question"]).animateCSS('tada'); | |
| 52 | 50 | $('#topic_progress').css('width', '100%').attr('aria-valuenow', 100); |
| 53 | 51 | setTimeout(function(){window.location.replace('/course/');}, 2000); |
| 54 | 52 | break; |
| ... | ... | @@ -57,6 +55,7 @@ function updateQuestion(response) { |
| 57 | 55 | |
| 58 | 56 | function new_question(type, question, tries, progress) { |
| 59 | 57 | window.scrollTo(0, 0); |
| 58 | + | |
| 60 | 59 | $("#submit").hide(); |
| 61 | 60 | $("#question_div").animateCSS('bounceOutUp', function() { |
| 62 | 61 | $("#question_div").html(question); |
| ... | ... | @@ -64,6 +63,14 @@ function new_question(type, question, tries, progress) { |
| 64 | 63 | $("#question_div").animateCSS('bounceInDown', function() { |
| 65 | 64 | showTriesLeft(tries); |
| 66 | 65 | $("#submit").removeClass("disabled").show(); |
| 66 | + | |
| 67 | + // disable enter in some question types (prevent submission on enter) | |
| 68 | + $("input:text, input:radio, input:checkbox").keydown(function (e) { | |
| 69 | + if (e.keyCode == 13 || e.keyCode == 169) { | |
| 70 | + e.preventDefault(); | |
| 71 | + return false; | |
| 72 | + } | |
| 73 | + }); | |
| 67 | 74 | }); |
| 68 | 75 | }); |
| 69 | 76 | var btntext = (type == "information") ? "Continuar" : "Responder"; |
| ... | ... | @@ -76,14 +83,6 @@ function new_question(type, question, tries, progress) { |
| 76 | 83 | $("div.list-group input:radio").eq(index).prop("checked", true); |
| 77 | 84 | }); |
| 78 | 85 | } |
| 79 | - | |
| 80 | - // disable enter in some question types (prevent submission on enter) | |
| 81 | - $("input:text, input:radio, input:checkbox").keydown(function (e) { | |
| 82 | - if (e.keyCode == 13 || e.keyCode == 169) { | |
| 83 | - e.preventDefault(); | |
| 84 | - return false; | |
| 85 | - } | |
| 86 | - }); | |
| 87 | 86 | } |
| 88 | 87 | |
| 89 | 88 | |
| ... | ... | @@ -108,15 +107,14 @@ function postAnswer() { |
| 108 | 107 | } |
| 109 | 108 | |
| 110 | 109 | function getFeedback(response) { |
| 111 | - var method = response["method"]; | |
| 112 | 110 | var params = response["params"]; |
| 113 | 111 | |
| 114 | - if (params['type'] == "information") { | |
| 112 | + if (params["type"] == "information") { | |
| 115 | 113 | getQuestion(); |
| 116 | 114 | return; |
| 117 | 115 | } |
| 118 | 116 | |
| 119 | - switch (method) { | |
| 117 | + switch (response["method"]) { | |
| 120 | 118 | case "right": |
| 121 | 119 | $('#wrong').hide(); |
| 122 | 120 | $('#comments').html(params['comments']).show(); | ... | ... |
aprendizations/templates/login.html
| 1 | -<!DOCTYPE html> | |
| 2 | -<html lang="en"> | |
| 1 | +<!doctype html> | |
| 2 | +<html lang="pt"> | |
| 3 | 3 | <head> |
| 4 | 4 | <title>{{appname}}</title> |
| 5 | 5 | <link rel="icon" href="/static/favicon.ico"> |
| 6 | 6 | |
| 7 | 7 | <meta charset="utf-8"> |
| 8 | 8 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 9 | + <meta name="author" content="Miguel Barão"> | |
| 9 | 10 | |
| 10 | 11 | <!-- Styles --> |
| 11 | 12 | <link rel="stylesheet" href="/static/mdbootstrap/css/bootstrap.min.css"> | ... | ... |
aprendizations/templates/maintopics-table.html
aprendizations/templates/rankings.html
aprendizations/templates/topic.html
| 1 | -<!DOCTYPE html> | |
| 1 | +<!doctype html> | |
| 2 | 2 | <html> |
| 3 | 3 | |
| 4 | 4 | <head> |
| 5 | 5 | <title>{{appname}}</title> |
| 6 | 6 | <link rel="icon" href="/static/favicon.ico"> |
| 7 | + | |
| 7 | 8 | <meta charset="utf-8"> |
| 8 | 9 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 9 | 10 | <meta name="author" content="Miguel Barão"> |
| 11 | + | |
| 10 | 12 | <!-- MathJax3 --> |
| 11 | 13 | <script> |
| 12 | 14 | MathJax = { | ... | ... |