From f749fa174c87e75e4f7a392786f9504e2d3d3144 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Wed, 15 Jun 2016 10:05:54 +0100 Subject: [PATCH] - fixed browser unfocus detection. --- BUGS.md | 5 +++-- static/js/admin.js | 4 ++-- static/js/detect_unfocus.js | 36 ++++++++++++++++++++++++++++++++++++ templates/test.html | 6 ++++-- 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 static/js/detect_unfocus.js diff --git a/BUGS.md b/BUGS.md index bb8ad8a..b1d9135 100644 --- a/BUGS.md +++ b/BUGS.md @@ -2,12 +2,12 @@ # BUGS - usar thread.Lock para aceder a variaveis de estado? -- permitir adicionar imagens nas perguntas. -- detect_unfocus.js so funciona se estiver inline no html. porquê??? # TODO +- lidar com focus. aviso em /admin - implementar practice mode. +- permitir adicionar imagens nas perguntas. - abrir o teste numa janela maximizada e que nao permite que o aluno a redimensione/mova. - detectar scroll e enviar posição para servidor (analise de scroll para detectar copianço? ou simplesmente para analisar como os alunos percorrem o teste) - detectar se janela perde focus e alertar o prof (http://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active) @@ -24,6 +24,7 @@ # FIXED +- detect_unfocus.js so funciona se estiver inline no html. porquê??? - inserir novo aluno /admin não fecha. - se aluno desistir, ainda fica marcado como online - give dá None em vez de 0.0 diff --git a/static/js/admin.js b/static/js/admin.js index 4711c41..1a7fd37 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -113,9 +113,9 @@ $(document).ready(function() { rows += '\ \ ' + uid + '\ - ' + d['name'] + '\ + ' + d['name'] + (d['password_defined'] ? ' pw' : '') +'\ ' + - (d['password_defined'] ? 'pw' : '') + + // (d['online'] ? 'online' : '') + (d['start_time']==''?'':'teste') + '\ diff --git a/static/js/detect_unfocus.js b/static/js/detect_unfocus.js new file mode 100644 index 0000000..483487f --- /dev/null +++ b/static/js/detect_unfocus.js @@ -0,0 +1,36 @@ +$(document).ready(function() { + $(window).focus(function(){ + $.ajax({ + type: "POST", + url: "/adminwebservice", + data: { + "cmd": "focus", + "name": $("#number").text() + } + }); + }); + + $(window).blur(function(e){ + $.ajax({ + type: "POST", + url: "/adminwebservice", + data: { + "cmd": "blur", + "name": $("#number").text() + } + }); + }); + + $(window).resize(function(){ + var n = $(window).scrollTop(); + $.ajax({ + type: "POST", + url: "/adminwebservice", + data: { + "cmd": "resize", + "name": $("#number").text(), + "scroll": n + } + }); + }); +}); \ No newline at end of file diff --git a/templates/test.html b/templates/test.html index 804737f..d366ab9 100644 --- a/templates/test.html +++ b/templates/test.html @@ -74,8 +74,10 @@