Commit c1422adeaa8ac1dedf3b7dd5da943bf0b33390c7
1 parent
c2ba4715
Exists in
master
and in
1 other branch
maybe fixed sqlalchemy error on studenttopic insertion
Showing
5 changed files
with
12 additions
and
6 deletions
Show diff stats
BUGS.md
1 | 1 | ||
2 | # BUGS | 2 | # BUGS |
3 | 3 | ||
4 | +- na definicao dos topicos, indicar: | ||
5 | + "file: questions.yaml" (default questions.yaml) | ||
6 | + "shuffle: True/False" (default False) | ||
7 | + "choose: 6" (default tudo) | ||
4 | - SQLAlchemy error (rollback em accao no final de um topico): | 8 | - SQLAlchemy error (rollback em accao no final de um topico): |
5 | Users/mjsb/Library/Python/3.7/lib/python/site-packages/sqlalchemy/sql/crud.py:700: SAWarning: Column 'studenttopic.student_id' is marked as a member of the primary key for table 'studenttopic', but has no Python-side or server-side default generator indicated, nor does it indicate 'autoincrement=True' or 'nullable=True', and no explicit value is passed. Primary key columns typically may not store NULL. Note that as of SQLAlchemy 1.1, 'autoincrement=True' must be indicated explicitly for composite (e.g. multicolumn) primary keys if AUTO_INCREMENT/SERIAL/IDENTITY behavior is expected for one of the columns in the primary key. CREATE TABLE statements are impacted by this change as well on most backends. | 9 | Users/mjsb/Library/Python/3.7/lib/python/site-packages/sqlalchemy/sql/crud.py:700: SAWarning: Column 'studenttopic.student_id' is marked as a member of the primary key for table 'studenttopic', but has no Python-side or server-side default generator indicated, nor does it indicate 'autoincrement=True' or 'nullable=True', and no explicit value is passed. Primary key columns typically may not store NULL. Note that as of SQLAlchemy 1.1, 'autoincrement=True' must be indicated explicitly for composite (e.g. multicolumn) primary keys if AUTO_INCREMENT/SERIAL/IDENTITY behavior is expected for one of the columns in the primary key. CREATE TABLE statements are impacted by this change as well on most backends. |
6 | util.warn(msg) | 10 | util.warn(msg) |
demo/solar_system/questions.yaml
@@ -42,8 +42,8 @@ | @@ -42,8 +42,8 @@ | ||
42 | type: textarea | 42 | type: textarea |
43 | title: Sistema solar | 43 | title: Sistema solar |
44 | text: Escreva o nome dos três planetas mais próximos do Sol. (Exemplo `A, B e C`) | 44 | text: Escreva o nome dos três planetas mais próximos do Sol. (Exemplo `A, B e C`) |
45 | - # correct: correct-first_3_planets.py | ||
46 | - correct: correct-timeout.py | 45 | + correct: correct-first_3_planets.py |
46 | + # correct: correct-timeout.py | ||
47 | # opcional | 47 | # opcional |
48 | answer: Vulcano, Krypton, Plutão | 48 | answer: Vulcano, Krypton, Plutão |
49 | lines: 3 | 49 | lines: 3 |
learnapp.py
@@ -170,12 +170,14 @@ class LearnApp(object): | @@ -170,12 +170,14 @@ class LearnApp(object): | ||
170 | a = s.query(StudentTopic).filter_by(student_id=uid, topic_id=topic).one_or_none() | 170 | a = s.query(StudentTopic).filter_by(student_id=uid, topic_id=topic).one_or_none() |
171 | if a is None: | 171 | if a is None: |
172 | # insert new studenttopic into database | 172 | # insert new studenttopic into database |
173 | + logger.debug('Database insert new studenttopic') | ||
173 | t = s.query(Topic).get(topic) | 174 | t = s.query(Topic).get(topic) |
174 | - a = StudentTopic(level=level, date=date, topic=t) | ||
175 | u = s.query(Student).get(uid) | 175 | u = s.query(Student).get(uid) |
176 | + a = StudentTopic(level=level, date=date, topic=t, student=u) # association object | ||
176 | u.topics.append(a) | 177 | u.topics.append(a) |
177 | else: | 178 | else: |
178 | # update studenttopic in database | 179 | # update studenttopic in database |
180 | + logger.debug('Database update studenttopic') | ||
179 | a.level = level | 181 | a.level = level |
180 | a.date = date | 182 | a.date = date |
181 | 183 |
models.py
1 | +# FIXME see https://stackoverflow.com/questions/38248415/many-to-many-with-association-object-and-all-relationships-defined-crashes-on-de | ||
2 | +# And fix the association StudentTopic etc | ||
3 | + | ||
1 | 4 | ||
2 | 5 | ||
3 | from sqlalchemy import Table, Column, ForeignKey, Integer, Float, String, DateTime | 6 | from sqlalchemy import Table, Column, ForeignKey, Integer, Float, String, DateTime |
serve.py
@@ -276,11 +276,8 @@ class QuestionHandler(BaseHandler): | @@ -276,11 +276,8 @@ class QuestionHandler(BaseHandler): | ||
276 | answer = answer[0] | 276 | answer = answer[0] |
277 | 277 | ||
278 | # check answer in another thread (nonblocking) | 278 | # check answer in another thread (nonblocking) |
279 | - # action = await asyncio.get_event_loop().run_in_executor(None, | ||
280 | - # self.learn.check_answer, user, answer) | ||
281 | action = await self.learn.check_answer(user, answer) | 279 | action = await self.learn.check_answer(user, answer) |
282 | 280 | ||
283 | - | ||
284 | # get next question (same, new or None) | 281 | # get next question (same, new or None) |
285 | question = self.learn.get_current_question(user) | 282 | question = self.learn.get_current_question(user) |
286 | 283 |