-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabelle.py
58 lines (54 loc) · 3.13 KB
/
tabelle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
db.define_table('domanda',
Field('testo', type='string', length=512, default=None,
required=True,
ondelete='CASCADE', notnull=True, unique=False,
widget=None, label='Question', comment='Type the text of the question',
writable=True, readable=True, update=None, authorize=None),
Field('scelte', type='list:string', length=128, default=None,
required=True,
ondelete='CASCADE', notnull=True, unique=False,
widget=None, label='Response', comment='Type the text of response',
writable=True, readable=True, update=None, authorize=None),
Field('risposta', type='integer', default=None,
required=True,
ondelete='CASCADE', notnull=True, unique=False,
widget=None, label='Answer', comment='Number of the correct answer [1,2,3,...]',
writable=True, readable=True, update=None, authorize=None),
Field('illustra', type='upload',
label='Illustration', comment='Optional image associated with the question'),
format='%(testo)s')
# tebella con tutte le sessioni create
db.define_table('sessione',
Field('codice', type='string', length=10, default=None,
required=True, notnull=True, unique=True,
label='Session Code', comment='Enter the unique code identifying this session or lecture',
writable=True, readable=True),
Field('giorno', type='date', comment='Type the date of the session'),
Field('descrizione', type='string', comment='Type a description of the session to help identify it'),
format='%(codice)s')
# tabella con domande in ciascuna sessione, per many2many relations
db.define_table('OdG',
Field('ses_id', 'reference sessione'),
Field('dom_id', 'reference domanda'),
Field('is_active', type='boolean', default=False, unique=False, comment='Is this session+question active now?'),
Field('n_respond', type='integer', unique=False, comment='Number of respondents who answered this question in this session',
writable=False, readable=False),
Field('n_correct', type='integer', unique=False, comment='Number of respondents who answered this question correctly',
writable=False, readable=False),
format='%(ses_id)s %(dom_id)s')
#db.OdG.drop()
# tabella con le risposte inviate dal pubblico. In alternativa ai primi due campi si potrebbe fare
# riferimento alla tabella OdG. Con campi separati è possibile avere un record con combinazione
# sessione-domanda che non è nell'OdG.
# This is the only table that is entirely generated by the controller, never edited by admin
db.define_table('risposte',
Field('ses_id', 'reference sessione'),
Field('dom_id', 'reference domanda'),
Field('respondent_id', type='string', length=128, default='nessuno',
required=True, unique=False,
comment='https session ID of the user who responded as in record'),
Field('ris_id', type='integer', default='0', unique=False))
# if there's a problem with the table, it might be best to drop it. But it can't be done before it is
# created. But if it already existed, some fields may remain, ergo the need to drop it.
#db.risposte.drop()