Commit 8005184eaa8150e2041879dc445ff8eae82d75ec
1 parent
0fde1211
Exists in
master
and in
1 other branch
- minor changes
Showing
2 changed files
with
10 additions
and
16 deletions
Show diff stats
BUGS.md
| 1 | 1 | ||
| 2 | # BUGS | 2 | # BUGS |
| 3 | 3 | ||
| 4 | -- servidor nao esta a lidar com eventos scroll/resize | ||
| 5 | - se um teste tiver a mesma pergunta (ref igual) varias vezes, rebenta na correcçao. As respostas são agregadas numa lista para cada ref. Ex: | 4 | - se um teste tiver a mesma pergunta (ref igual) varias vezes, rebenta na correcçao. As respostas são agregadas numa lista para cada ref. Ex: |
| 6 | {'ref1': 'resposta1', 'ref2': ['resposta2a', 'resposta2b']} | 5 | {'ref1': 'resposta1', 'ref2': ['resposta2a', 'resposta2b']} |
| 7 | possivelmente as referencias das perguntas deveriam ser o "testeRef:numPergunta"... é preciso ver como depois estao associadas às correcções. | 6 | possivelmente as referencias das perguntas deveriam ser o "testeRef:numPergunta"... é preciso ver como depois estao associadas às correcções. |
| 8 | - se directorio logs não existir no directorio actual (não perguntations) rebenta. | 7 | - se directorio logs não existir no directorio actual (não perguntations) rebenta. |
| 9 | - usar thread.Lock para aceder a variaveis de estado? | 8 | - usar thread.Lock para aceder a variaveis de estado? |
| 9 | +- servidor nao esta a lidar com eventos scroll/resize | ||
| 10 | 10 | ||
| 11 | # TODO | 11 | # TODO |
| 12 | 12 |
app.py
| @@ -33,7 +33,7 @@ class App(object): | @@ -33,7 +33,7 @@ class App(object): | ||
| 33 | 33 | ||
| 34 | self.testfactory = test.TestFactory(filename, conf=conf) | 34 | self.testfactory = test.TestFactory(filename, conf=conf) |
| 35 | 35 | ||
| 36 | - # database | 36 | + # connect to database and check registered students |
| 37 | engine = create_engine('sqlite:///{}'.format(self.testfactory['database']), echo=False) | 37 | engine = create_engine('sqlite:///{}'.format(self.testfactory['database']), echo=False) |
| 38 | self.Session = scoped_session(sessionmaker(bind=engine)) | 38 | self.Session = scoped_session(sessionmaker(bind=engine)) |
| 39 | 39 | ||
| @@ -46,11 +46,17 @@ class App(object): | @@ -46,11 +46,17 @@ class App(object): | ||
| 46 | else: | 46 | else: |
| 47 | logger.info('Database has {} students registered.'.format(n)) | 47 | logger.info('Database has {} students registered.'.format(n)) |
| 48 | 48 | ||
| 49 | + # command line option --allow-all | ||
| 49 | if conf['allow_all']: | 50 | if conf['allow_all']: |
| 50 | logger.info('Allowing all students') | 51 | logger.info('Allowing all students') |
| 51 | for student in self.get_all_students(): | 52 | for student in self.get_all_students(): |
| 52 | self.allow_student(student[0]) | 53 | self.allow_student(student[0]) |
| 53 | 54 | ||
| 55 | + # ----------------------------------------------------------------------- | ||
| 56 | + def exit(self): | ||
| 57 | + if len(self.online) > 1: | ||
| 58 | + logger.warning('Students still online: {}'.format(', '.join(self.online))) | ||
| 59 | + logger.critical('----------- !!! Server terminated !!! -----------') | ||
| 54 | 60 | ||
| 55 | # ----------------------------------------------------------------------- | 61 | # ----------------------------------------------------------------------- |
| 56 | # helper to manage db sessions using the `with` statement, for example | 62 | # helper to manage db sessions using the `with` statement, for example |
| @@ -63,12 +69,6 @@ class App(object): | @@ -63,12 +69,6 @@ class App(object): | ||
| 63 | self.Session.remove() | 69 | self.Session.remove() |
| 64 | 70 | ||
| 65 | # ----------------------------------------------------------------------- | 71 | # ----------------------------------------------------------------------- |
| 66 | - def exit(self): | ||
| 67 | - if len(self.online) > 1: | ||
| 68 | - logger.warning('Students still online: {}'.format(', '.join(self.online))) | ||
| 69 | - logger.critical('----------- !!! Server terminated !!! -----------') | ||
| 70 | - | ||
| 71 | - # ----------------------------------------------------------------------- | ||
| 72 | def login(self, uid, try_pw): | 72 | def login(self, uid, try_pw): |
| 73 | if uid not in self.allowed and uid != '0': | 73 | if uid not in self.allowed and uid != '0': |
| 74 | # not allowed | 74 | # not allowed |
| @@ -107,14 +107,8 @@ class App(object): | @@ -107,14 +107,8 @@ class App(object): | ||
| 107 | 107 | ||
| 108 | # ----------------------------------------------------------------------- | 108 | # ----------------------------------------------------------------------- |
| 109 | def logout(self, uid): | 109 | def logout(self, uid): |
| 110 | - if uid not in self.online: | ||
| 111 | - # this should never happen | ||
| 112 | - logger.error('Student {}: tried to logout, but is not logged in.'.format(uid)) | ||
| 113 | - return False | ||
| 114 | - else: | ||
| 115 | - logger.info('Student {}: logged out.'.format(uid)) | ||
| 116 | - del self.online[uid] | ||
| 117 | - return True | 110 | + del self.online[uid] |
| 111 | + logger.info('Student {}: logged out.'.format(uid)) | ||
| 118 | 112 | ||
| 119 | # ----------------------------------------------------------------------- | 113 | # ----------------------------------------------------------------------- |
| 120 | def generate_test(self, uid): | 114 | def generate_test(self, uid): |