Commit d8e3946a13c23b2d1d0e8c64de1cd0e170e63b77

Authored by Miguel Barão
1 parent 9788839f
Exists in master and in 1 other branch dev

fix submit on enter showing json in the browser

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/__init__.py
... ... @@ -30,7 +30,7 @@ are progressively uncovered as the students progress.
30 30 '''
31 31  
32 32 APP_NAME = 'aprendizations'
33   -APP_VERSION = '2019.12.dev1'
  33 +APP_VERSION = '2019.12.dev2'
34 34 APP_DESCRIPTION = __doc__
35 35  
36 36 __author__ = 'Miguel Barão'
... ...
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
1 1 {% autoescape %}
2 2  
3 3 <!doctype html>
4   -<html lang="pt-PT">
  4 +<html lang="pt">
5 5 <head>
6 6 <title>{{appname}}</title>
7 7 <link rel="icon" href="/static/favicon.ico">
... ...
aprendizations/templates/rankings.html
1 1 {% autoescape %}
2 2  
3 3 <!doctype html>
4   -<html lang="pt-PT">
  4 +<html lang="pt">
5 5 <head>
6 6 <title>{{appname}}</title>
7 7 <link rel="icon" href="/static/favicon.ico">
... ...
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 = {
... ...