Commit 3d24dd0fb7fc8416ff0a151889991c16819112a1
1 parent
73e9fbcb
Exists in
master
and in
1 other branch
- configuration of logger system to support --debug
Showing
3 changed files
with
20 additions
and
51 deletions
Show diff stats
BUGS.md
| 1 | 1 | |
| 2 | 2 | # BUGS |
| 3 | 3 | |
| 4 | -- total do teste aparece negativo. | |
| 5 | -- espaco no final das tabelas. | |
| 6 | 4 | - qual a diferenca entre md_to_html e md_to_html_review, parece desnecessario haver dois. |
| 7 | 5 | - servir imagens das perguntas |
| 8 | -- como alterar configuracao para mostrar logs de debug? | |
| 9 | 6 | - hints nao funciona |
| 10 | 7 | - uniformizar question.py com a de aprendizations... |
| 11 | -- permitir eliminar teste a decorrer de modo a que o aluno possa recomeçar (e.g. noutro browser) | |
| 8 | +- permitir eliminar teste a decorrer | |
| 12 | 9 | - servidor nao esta a lidar com eventos scroll/resize. ignorar? |
| 13 | 10 | |
| 14 | 11 | # TODO |
| ... | ... | @@ -20,6 +17,8 @@ |
| 20 | 17 | npm install mathjax-node mathjax-node-cli # pacotes em ~/node_modules |
| 21 | 18 | node_modules/mathjax-node-cli/bin/tex2svg '\sqrt{x}' |
| 22 | 19 | usar isto para gerar svg que passa a fazer parte do texto da pergunta (markdown suporta tags svg?) |
| 20 | + fazer funçao tex() que recebe formula e converte para svg. exemplo: | |
| 21 | + fr'''A formula é {tex(\sqrt{x]})}''' | |
| 23 | 22 | |
| 24 | 23 | - Gerar pdf's com todos os testes no final (pdfkit). |
| 25 | 24 | - manter registo dos unfocus durante o teste e de qual a pergunta visivel nesse momento |
| ... | ... | @@ -37,6 +36,9 @@ |
| 37 | 36 | |
| 38 | 37 | # FIXED |
| 39 | 38 | |
| 39 | +- como alterar configuracao para mostrar logs de debug? | |
| 40 | +- espaco no final das tabelas. | |
| 41 | +- total do teste aparece negativo. | |
| 40 | 42 | - reset password nao funciona no admin |
| 41 | 43 | - reload a intervalos não funciona. |
| 42 | 44 | - allow/deny nao funciona no /admin. | ... | ... |
config/server.conf
| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | -# -*- coding: utf-8 -*- | |
| 2 | - | |
| 3 | -[global] | |
| 4 | -environment= 'production' | |
| 5 | - | |
| 6 | -; number of threads running | |
| 7 | -server.thread_pool= 10 | |
| 8 | - | |
| 9 | -; Host address and port | |
| 10 | -; set socket_port = 443 if SSL is enabled below, 8080 otherwise | |
| 11 | -; if port is 443 then the server should be run as root. SSL also works on 8080. | |
| 12 | -server.socket_host = '0.0.0.0' | |
| 13 | -server.socket_port = 8080 | |
| 14 | - | |
| 15 | -; Uncomment to enable SSL (ssl_module = 'builtin' or 'pyopenssl') | |
| 16 | -; server.ssl_module = 'builtin' | |
| 17 | -; server.ssl_certificate = 'certs/webserver.crt' | |
| 18 | -; server.ssl_private_key = 'certs/webserver.key' | |
| 19 | - | |
| 20 | -; not required for snakeoil: | |
| 21 | -; server.ssl_certificate_chain = 'ca_certs.crt' |
serve.py
| ... | ... | @@ -59,6 +59,7 @@ class BaseHandler(tornado.web.RequestHandler): |
| 59 | 59 | if cookie: |
| 60 | 60 | return cookie.decode('utf-8') |
| 61 | 61 | |
| 62 | + | |
| 62 | 63 | # ------------------------------------------------------------------------- |
| 63 | 64 | # /login and /logout |
| 64 | 65 | # ------------------------------------------------------------------------- |
| ... | ... | @@ -75,7 +76,9 @@ class LoginHandler(BaseHandler): |
| 75 | 76 | self.set_secure_cookie("user", str(uid), expires_days=30) |
| 76 | 77 | self.redirect(self.get_argument("next", "/")) |
| 77 | 78 | else: |
| 78 | - self.render("login.html", error='Não autorizado ou número/senha inválido') | |
| 79 | + self.render("login.html", | |
| 80 | + error='Não autorizado ou número/senha inválido') | |
| 81 | + | |
| 79 | 82 | |
| 80 | 83 | # ------------------------------------------------------------------------- |
| 81 | 84 | class LogoutHandler(BaseHandler): |
| ... | ... | @@ -85,6 +88,7 @@ class LogoutHandler(BaseHandler): |
| 85 | 88 | self.clear_cookie('user') |
| 86 | 89 | self.redirect('/') |
| 87 | 90 | |
| 91 | + | |
| 88 | 92 | # ------------------------------------------------------------------------- |
| 89 | 93 | # FIXME checkit |
| 90 | 94 | class FileHandler(BaseHandler): |
| ... | ... | @@ -101,6 +105,7 @@ class FileHandler(BaseHandler): |
| 101 | 105 | self.write(f.read()) |
| 102 | 106 | f.close() |
| 103 | 107 | |
| 108 | + | |
| 104 | 109 | # ------------------------------------------------------------------------- |
| 105 | 110 | # FIXME images missing, needs testing |
| 106 | 111 | # ------------------------------------------------------------------------- |
| ... | ... | @@ -128,7 +133,6 @@ class TestHandler(BaseHandler): |
| 128 | 133 | t = self.testapp.get_test(uid) or self.testapp.generate_test(uid) |
| 129 | 134 | self.render('test.html', t=t, md=md_to_html, templ=self.templates) |
| 130 | 135 | |
| 131 | - | |
| 132 | 136 | # POST |
| 133 | 137 | @tornado.web.authenticated |
| 134 | 138 | def post(self): |
| ... | ... | @@ -150,7 +154,8 @@ class TestHandler(BaseHandler): |
| 150 | 154 | ans[i] = None |
| 151 | 155 | else: |
| 152 | 156 | ans[i] = ans[i][0] |
| 153 | - elif q['type'] in ('text', 'text-regex', 'textarea', 'numeric-interval'): | |
| 157 | + elif q['type'] in ('text', 'text-regex', 'textarea', | |
| 158 | + 'numeric-interval'): | |
| 154 | 159 | ans[i] = ans[i][0] |
| 155 | 160 | |
| 156 | 161 | self.testapp.correct_test(uid, ans) |
| ... | ... | @@ -235,9 +240,8 @@ class RootHandler(BaseHandler): |
| 235 | 240 | self.redirect('/test') |
| 236 | 241 | |
| 237 | 242 | |
| 238 | -# ---------------------------------------------------------------------------- | |
| 243 | +# ------------------------------------------------------------------------- | |
| 239 | 244 | class AdminHandler(BaseHandler): |
| 240 | - | |
| 241 | 245 | @tornado.web.authenticated |
| 242 | 246 | def get(self): |
| 243 | 247 | if self.current_user != '0': |
| ... | ... | @@ -264,7 +268,6 @@ class AdminHandler(BaseHandler): |
| 264 | 268 | else: |
| 265 | 269 | self.render('admin.html') |
| 266 | 270 | |
| 267 | - | |
| 268 | 271 | @tornado.web.authenticated |
| 269 | 272 | def post(self): |
| 270 | 273 | if self.current_user != '0': |
| ... | ... | @@ -290,28 +293,10 @@ class AdminHandler(BaseHandler): |
| 290 | 293 | logging.error(f'Unknown command in post: "{cmd}"') |
| 291 | 294 | |
| 292 | 295 | |
| 293 | - | |
| 294 | -# # ============================================================================ | |
| 295 | -# # Student webservice | |
| 296 | -# # ============================================================================ | |
| 297 | -# class StudentWebService(object): | |
| 298 | - | |
| 299 | -# @cherrypy.tools.accept(media='application/json') # FIXME | |
| 300 | -# def POST(self, **args): | |
| 301 | -# # uid = cherrypy.session.get(SESSION_KEY) | |
| 302 | -# if args['cmd'] == 'focus': | |
| 303 | -# v = json.loads(args['value']) | |
| 304 | -# self.app.set_student_focus(uid=args['number'], value=v) | |
| 305 | - | |
| 306 | - | |
| 307 | - | |
| 308 | 296 | # ------------------------------------------------------------------------- |
| 309 | 297 | # Tornado web server |
| 310 | 298 | # ------------------------------------------------------------------------- |
| 311 | 299 | def main(): |
| 312 | - SERVER_PATH = path.dirname(path.realpath(__file__)) | |
| 313 | - LOGGER_CONF = path.join(SERVER_PATH, 'config/logger.yaml') | |
| 314 | - | |
| 315 | 300 | # --- Commandline argument parsing |
| 316 | 301 | 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.') |
| 317 | 302 | argparser.add_argument('--debug', action='store_true', |
| ... | ... | @@ -321,6 +306,10 @@ def main(): |
| 321 | 306 | arg = argparser.parse_args() |
| 322 | 307 | |
| 323 | 308 | # --- Setup logging |
| 309 | + logger_file = 'logger-debug.yaml' if arg.debug else 'logger.yaml' | |
| 310 | + SERVER_PATH = path.dirname(path.realpath(__file__)) | |
| 311 | + LOGGER_CONF = path.join(SERVER_PATH, f'config/{logger_file}') | |
| 312 | + | |
| 324 | 313 | try: |
| 325 | 314 | logging.config.dictConfig(load_yaml(LOGGER_CONF)) |
| 326 | 315 | except: |
| ... | ... | @@ -349,7 +338,7 @@ def main(): |
| 349 | 338 | ssl_options={ |
| 350 | 339 | "certfile": "certs/cert.crt", |
| 351 | 340 | "keyfile": "certs/cert.key" |
| 352 | - }) | |
| 341 | + }) | |
| 353 | 342 | http_server.listen(8443) |
| 354 | 343 | |
| 355 | 344 | # --- run webserver |
| ... | ... | @@ -365,4 +354,3 @@ def main(): |
| 365 | 354 | # ------------------------------------------------------------------------- |
| 366 | 355 | if __name__ == "__main__": |
| 367 | 356 | main() |
| 368 | - | ... | ... |