diff --git a/BUGS.md b/BUGS.md index c9c9ed8..c60145b 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,7 +1,6 @@ # BUGS -- /review não mostra imagens porque precisa que teste esteja a decorrer... - usar thread.Lock para aceder a variaveis de estado? # TODO @@ -23,6 +22,7 @@ # FIXED +- /review não mostra imagens porque precisa que teste esteja a decorrer... - visualizar um teste ja realizado na página de administração - Depois da correcção, mostra testes realizados que não foram realizados pelo próprio - 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) diff --git a/app.py b/app.py index 3cb4f20..4018614 100644 --- a/app.py +++ b/app.py @@ -175,6 +175,8 @@ class App(object): return self.online[uid]['student']['name'] def get_test(self, uid, default=None): return self.online[uid].get('test', default) + def get_questions_path(self): + return self.testfactory['questions_dir'] def get_test_qtypes(self, uid): return {q['ref']:q['type'] for q in self.online[uid]['test']['questions']} def get_student_grades_from_all_tests(self, uid): diff --git a/serve.py b/serve.py index 63530b5..26fe2dd 100755 --- a/serve.py +++ b/serve.py @@ -256,6 +256,7 @@ class Root(object): @require() def file(self, ref, name): # serve a static file: userid, question ref, file name + # only works for users running a test uid = cherrypy.session.get(SESSION_KEY) filename = self.app.get_file(uid, ref, name) return cherrypy.lib.static.serve_file(filename) @@ -275,6 +276,12 @@ class Root(object): t = json.load(f) return self.template['review'].render(t=t) + @cherrypy.expose + @require(name_is('0')) + def absfile(self, name): + filename = path.abspath(path.join(self.app.get_questions_path(), name)) + return cherrypy.lib.static.serve_file(filename) + # ============================================================================ def parse_arguments(): argparser = argparse.ArgumentParser(description='Server for online tests. Enrolled students and tests have to be previously configured. Please read the documentation included with this software before running the server.') diff --git a/templates/review.html b/templates/review.html index c6e00b9..e0b22f1 100644 --- a/templates/review.html +++ b/templates/review.html @@ -89,7 +89,7 @@ <%! - from tools import md_to_html + from tools import md_to_html_review %> <% total_points = sum(q['points'] for q in t['questions']) @@ -105,7 +105,7 @@ ${q['title']}
- ${md_to_html(q['text'], q['ref'], q['files'])} + ${md_to_html_review(q['text'], q)}
% elif q['type'] == 'warning': @@ -115,7 +115,7 @@ ${q['title']}- ${md_to_html(q['text'], q['ref'], q['files'])} + ${md_to_html_review(q['text'], q)}
% elif q['type'] == 'alert': @@ -125,7 +125,7 @@ ${q['title']}- ${md_to_html(q['text'], q['ref'], q['files'])} + ${md_to_html_review(q['text'], q)}
@@ -146,15 +146,15 @@