From c3e0209787c7fbbfa278721544d82e6bb422aa68 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Tue, 4 Dec 2018 23:24:31 +0000 Subject: [PATCH] - fixed default correct for checkbox questions. - fixed debug messages alignment. - updated codemirror and fontawesome links to latest versions --- BUGS.md | 4 +++- app.py | 3 +-- config/logger-debug.yaml | 2 +- questions.py | 9 +++++---- serve.py | 6 ++++-- static/codemirror | 2 +- static/fontawesome.min.js | 2 +- test.py | 2 +- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/BUGS.md b/BUGS.md index 1d92387..9bae78e 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,6 +1,7 @@ # BUGS +- se aluno entrar com l12345 rebenta. numa funcao get_... ver imagem no ipad - a revisao do teste não mostra as imagens. - melhorar o botao de autorizar (desliga-se), usar antes um botao? e.g. retornar None quando nao ha alteracoes relativamente à última vez. @@ -19,7 +20,7 @@ ou usar push (websockets?) - adicionar opcao para eliminar um teste em curso. - gerar teste qd o prof autoriza? melhor nao, pode apagar o teste em curso. gerar previamente e manter uma pool de testes gerados? - enviar resposta de cada pergunta individualmente. -- experimentar gerador de svg que inclua no markdown da pergunta e ver se funciona. +- experimentar gerador de svg que inclua no markdown da pergunta e ver se funciona. - suportar cotacao to teste diferente de 20 (e.g. para juntar perguntas em papel). opcao "points: 18" que normaliza total para 18 em vez de 20. - quando ha varias perguntas para escolher, escolher sucessivamente em vez de aleatoriamente. - como refrescar a tabela de admin sem fazer reload da pagina? @@ -61,6 +62,7 @@ ou usar push (websockets?) # FIXED +- default correct in checkbox must be 1.0, so that the pairs (right,wrong) still work with `correct` left undefined. - textarea com codemirror - decorador para user 0, evita o "if uid==0" em muitas funcoes. - numeric interval deve converter respostas que usam virgulas para pontos decimais diff --git a/app.py b/app.py index 5cc74a6..7c3de51 100644 --- a/app.py +++ b/app.py @@ -74,7 +74,6 @@ class App(object): dbfile = path.expanduser(self.testfactory['database']) engine = create_engine(f'sqlite:///{dbfile}', echo=False) self.Session = sessionmaker(bind=engine) - try: with self.db_session() as s: n = s.query(Student).filter(Student.id != '0').count() @@ -117,7 +116,7 @@ class App(object): else: # check password pw_ok = await check_password(try_pw, password) # async bcrypt - if pw_ok: # success + if pw_ok: # success self.allowed.discard(uid) # remove from set of allowed students if uid in self.online: logger.warning(f'Student {uid}: already logged in.') diff --git a/config/logger-debug.yaml b/config/logger-debug.yaml index 3bccb78..5ca30ea 100644 --- a/config/logger-debug.yaml +++ b/config/logger-debug.yaml @@ -5,7 +5,7 @@ formatters: void: format: '' standard: - format: '%(asctime)s | %(levelname)-8s | %(name)-14s | %(message)s' + format: '%(asctime)s | %(levelname)-8s | %(name)-15s | %(message)s' handlers: default: diff --git a/questions.py b/questions.py index c2107d2..3f02ce9 100644 --- a/questions.py +++ b/questions.py @@ -154,7 +154,7 @@ class QuestionCheckbox(Question): # set defaults if missing self.set_defaults({ 'text': '', - 'correct': [0.0] * n, # useful for questionaries + 'correct': [1.0] * n, # Using 0.0 breaks the (right, wrong) options 'shuffle': True, 'discount': True, 'choose': n, # number of options @@ -167,7 +167,7 @@ class QuestionCheckbox(Question): # FIXME it's possible that all options are chosen wrong options = [] correct = [] - for o,c in zip(self['options'], self['correct']): + for o, c in zip(self['options'], self['correct']): if isinstance(o, list): r = random.randint(0,1) o = o[r] @@ -190,7 +190,7 @@ class QuestionCheckbox(Question): if self['answer'] is not None: sum_abs = sum(abs(p) for p in self['correct']) if sum_abs < 1e-6: # case correct [0,...,0] avoid div-by-zero - self['grade'] = 0.0 + self['grade'] = 1.0 else: x = 0.0 @@ -332,7 +332,8 @@ class QuestionTextArea(Question): 'correct': '' # trying to execute this will fail => grade 0.0 }) - self['correct'] = path.abspath(path.normpath(path.join(self['path'], self['correct']))) # abspath will prepend cwd, which is plain wrong... + # self['correct'] = path.join(self['path'], self['correct']) + self['correct'] = path.abspath(path.normpath(path.join(self['path'], self['correct']))) #------------------------------------------------------------------------ # can return negative values for wrong answers diff --git a/serve.py b/serve.py index a60089d..2d8edea 100755 --- a/serve.py +++ b/serve.py @@ -10,14 +10,15 @@ import argparse import mimetypes import signal import asyncio -import json import functools +import json # user installed libraries import tornado.ioloop import tornado.web import tornado.httpserver from tornado import template, gen +import yaml # this project from app import App, AppException @@ -293,7 +294,7 @@ class TestHandler(BaseHandler): # --- REVIEW ------------------------------------------------------------- class ReviewHandler(BaseHandler): SUPPORTED_METHODS = ['GET'] - + _templates = { 'radio': 'review-question-radio.html', 'checkbox': 'review-question-checkbox.html', @@ -327,6 +328,7 @@ class ReviewHandler(BaseHandler): else: with f: t = json.load(f) + # print(yaml.dump(t, default_flow_style=False)) self.render('review.html', t=t, md=md_to_html, templ=self._templates) diff --git a/static/codemirror b/static/codemirror index cd50a8c..6eafd2c 120000 --- a/static/codemirror +++ b/static/codemirror @@ -1 +1 @@ -libs/codemirror-5.40.2/ \ No newline at end of file +libs/codemirror-5.42.0/ \ No newline at end of file diff --git a/static/fontawesome.min.js b/static/fontawesome.min.js index 6cbab90..e950aff 120000 --- a/static/fontawesome.min.js +++ b/static/fontawesome.min.js @@ -1 +1 @@ -libs/fontawesome-free-5.3.1-web/js/all.js \ No newline at end of file +libs/fontawesome-free-5.5.0-web/js/all.js \ No newline at end of file diff --git a/test.py b/test.py index a259f36..08930ab 100644 --- a/test.py +++ b/test.py @@ -191,7 +191,7 @@ class TestFactory(dict): 'debug': self['debug'], # required by template test.html 'database': self['database'], 'questions_dir': self['questions_dir'], - 'files': self['files'], + # 'files': self['files'], }) # ----------------------------------------------------------------------- -- libgit2 0.21.2