Commit 3ba69818214c43980a6a36b90a613159a28d8598

Authored by Miguel Barão
1 parent 5338ec53
Exists in master and in 1 other branch dev

fix submit on enter getting json page

@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
31 31
32 # FIXED 32 # FIXED
33 33
  34 +- enter nas respostas mostra json
34 - apos clicar no botao responder, inactivar o input (importante quando o tempo de correcção é grande) 35 - apos clicar no botao responder, inactivar o input (importante quando o tempo de correcção é grande)
35 - double click submits twice. 36 - double click submits twice.
36 - 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. 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,7 +25,6 @@ function showTriesLeft(tries) {
25 function getQuestion() { 25 function getQuestion() {
26 $("#comments").html("").hide(); 26 $("#comments").html("").hide();
27 $("#submit").addClass("disabled"); 27 $("#submit").addClass("disabled");
28 -  
29 $.ajax({ 28 $.ajax({
30 type: "GET", 29 type: "GET",
31 url: "/question", 30 url: "/question",
@@ -37,18 +36,17 @@ function getQuestion() { @@ -37,18 +36,17 @@ function getQuestion() {
37 36
38 // updates question in the page according to the response given by the server 37 // updates question in the page according to the response given by the server
39 function updateQuestion(response) { 38 function updateQuestion(response) {
40 - var method = response["method"];  
41 var params = response["params"]; 39 var params = response["params"];
42 40
43 $("#right, #wrong").hide(); 41 $("#right, #wrong").hide();
44 42
45 - switch (method) { 43 + switch (response["method"]) {
46 case "new_question": 44 case "new_question":
47 new_question(params["type"], params["question"], params["tries"], params["progress"]); 45 new_question(params["type"], params["question"], params["tries"], params["progress"]);
48 break; 46 break;
49 case "finished_topic": 47 case "finished_topic":
50 $('#submit, #comments, #solution').remove(); 48 $('#submit, #comments, #solution').remove();
51 - $("#content").html(response["params"]["question"]).animateCSS('tada'); 49 + $("#content").html(params["question"]).animateCSS('tada');
52 $('#topic_progress').css('width', '100%').attr('aria-valuenow', 100); 50 $('#topic_progress').css('width', '100%').attr('aria-valuenow', 100);
53 setTimeout(function(){window.location.replace('/course/');}, 2000); 51 setTimeout(function(){window.location.replace('/course/');}, 2000);
54 break; 52 break;
@@ -57,6 +55,7 @@ function updateQuestion(response) { @@ -57,6 +55,7 @@ function updateQuestion(response) {
57 55
58 function new_question(type, question, tries, progress) { 56 function new_question(type, question, tries, progress) {
59 window.scrollTo(0, 0); 57 window.scrollTo(0, 0);
  58 +
60 $("#submit").hide(); 59 $("#submit").hide();
61 $("#question_div").animateCSS('bounceOutUp', function() { 60 $("#question_div").animateCSS('bounceOutUp', function() {
62 $("#question_div").html(question); 61 $("#question_div").html(question);
@@ -64,6 +63,14 @@ function new_question(type, question, tries, progress) { @@ -64,6 +63,14 @@ function new_question(type, question, tries, progress) {
64 $("#question_div").animateCSS('bounceInDown', function() { 63 $("#question_div").animateCSS('bounceInDown', function() {
65 showTriesLeft(tries); 64 showTriesLeft(tries);
66 $("#submit").removeClass("disabled").show(); 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 var btntext = (type == "information") ? "Continuar" : "Responder"; 76 var btntext = (type == "information") ? "Continuar" : "Responder";
@@ -76,14 +83,6 @@ function new_question(type, question, tries, progress) { @@ -76,14 +83,6 @@ function new_question(type, question, tries, progress) {
76 $("div.list-group input:radio").eq(index).prop("checked", true); 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,15 +107,14 @@ function postAnswer() {
108 } 107 }
109 108
110 function getFeedback(response) { 109 function getFeedback(response) {
111 - var method = response["method"];  
112 var params = response["params"]; 110 var params = response["params"];
113 111
114 - if (params['type'] == "information") { 112 + if (params["type"] == "information") {
115 getQuestion(); 113 getQuestion();
116 return; 114 return;
117 } 115 }
118 116
119 - switch (method) { 117 + switch (response["method"]) {
120 case "right": 118 case "right":
121 $('#wrong').hide(); 119 $('#wrong').hide();
122 $('#comments').html(params['comments']).show(); 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 <head> 3 <head>
4 <title>{{appname}}</title> 4 <title>{{appname}}</title>
5 <link rel="icon" href="/static/favicon.ico"> 5 <link rel="icon" href="/static/favicon.ico">
6 6
7 <meta charset="utf-8"> 7 <meta charset="utf-8">
8 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 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 <!-- Styles --> 11 <!-- Styles -->
11 <link rel="stylesheet" href="/static/mdbootstrap/css/bootstrap.min.css"> 12 <link rel="stylesheet" href="/static/mdbootstrap/css/bootstrap.min.css">
aprendizations/templates/maintopics-table.html
1 {% autoescape %} 1 {% autoescape %}
2 2
3 <!doctype html> 3 <!doctype html>
4 -<html lang="pt-PT"> 4 +<html lang="pt">
5 <head> 5 <head>
6 <title>{{appname}}</title> 6 <title>{{appname}}</title>
7 <link rel="icon" href="/static/favicon.ico"> 7 <link rel="icon" href="/static/favicon.ico">
aprendizations/templates/rankings.html
1 {% autoescape %} 1 {% autoescape %}
2 2
3 <!doctype html> 3 <!doctype html>
4 -<html lang="pt-PT"> 4 +<html lang="pt">
5 <head> 5 <head>
6 <title>{{appname}}</title> 6 <title>{{appname}}</title>
7 <link rel="icon" href="/static/favicon.ico"> 7 <link rel="icon" href="/static/favicon.ico">
aprendizations/templates/topic.html
1 -<!DOCTYPE html> 1 +<!doctype html>
2 <html> 2 <html>
3 3
4 <head> 4 <head>
5 <title>{{appname}}</title> 5 <title>{{appname}}</title>
6 <link rel="icon" href="/static/favicon.ico"> 6 <link rel="icon" href="/static/favicon.ico">
  7 +
7 <meta charset="utf-8"> 8 <meta charset="utf-8">
8 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 9 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
9 <meta name="author" content="Miguel Barão"> 10 <meta name="author" content="Miguel Barão">
  11 +
10 <!-- MathJax3 --> 12 <!-- MathJax3 -->
11 <script> 13 <script>
12 MathJax = { 14 MathJax = {