5
5
login VARCHAR UNIQUE NOT NULL,
7
7
state VARCHAR NOT NULL CHECK (state in ('no_agreement', 'pending',
8
'enabled', 'disabled'))
9
DEFAULT 'no_agreement',
8
'enabled', 'disabled')),
10
9
rolenm VARCHAR NOT NULL CHECK (rolenm in ('anyone', 'student',
12
11
'lecturer', 'admin')),
192
--TODO: Add in a field for the user-friendly identifier
193
192
CREATE TABLE problem (
194
identifier VARCHAR PRIMARY KEY NOT NULL,
193
problemid SERIAL PRIMARY KEY NOT NULL,
194
identifier VARCHAR UNIQUE NOT NULL,
203
--TODO: Link worksheets to offerings
204
198
CREATE TABLE worksheet (
205
199
worksheetid SERIAL PRIMARY KEY NOT NULL,
206
200
subject VARCHAR NOT NULL,
207
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
208
201
identifier VARCHAR NOT NULL,
209
202
assessable BOOLEAN,
214
207
CREATE TABLE worksheet_problem (
215
208
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
216
problemid TEXT REFERENCES problem (identifier) NOT NULL,
209
problemid INT4 REFERENCES problem (problemid) NOT NULL,
217
210
optional BOOLEAN,
218
211
PRIMARY KEY (worksheetid, problemid)
214
CREATE TABLE problem_tag (
215
problemid INT4 REFERENCES problem (problemid),
216
tag VARCHAR NOT NULL,
218
standard BOOLEAN NOT NULL,
219
added_by INT4 REFERENCES login (loginid) NOT NULL,
220
date TIMESTAMP NOT NULL,
221
PRIMARY KEY (problemid,added_by,tag)
224
CREATE TABLE problem_test_case (
225
problemid INT4 REFERENCES problem (problemid) NOT NULL,
226
testcaseid SERIAL UNIQUE NOT NULL,
229
visibility VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
232
CREATE TABLE problem_test_case_tag (
233
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
234
tag VARCHAR NOT NULL,
236
standard BOOLEAN NOT NULL,
237
added_by INT4 REFERENCES login (loginid) NOT NULL,
238
date TIMESTAMP NOT NULL,
239
PRIMARY KEY (testcaseid,added_by,tag)
221
242
CREATE TABLE problem_attempt (
222
problemid VARCHAR REFERENCES problem (identifier) NOT NULL,
243
problemid INT4 REFERENCES problem (problemid) NOT NULL,
223
244
loginid INT4 REFERENCES login (loginid) NOT NULL,
224
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
225
245
date TIMESTAMP NOT NULL,
226
246
attempt VARCHAR NOT NULL,
227
247
complete BOOLEAN NOT NULL,
232
252
CREATE TABLE problem_save (
233
253
problemid INT4 REFERENCES problem (problemid) NOT NULL,
234
254
loginid INT4 REFERENCES login (loginid) NOT NULL,
235
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
236
255
date TIMESTAMP NOT NULL,
237
256
text VARCHAR NOT NULL,
238
257
PRIMARY KEY (problemid,loginid)
241
260
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
243
CREATE TABLE test_suite (
244
suiteid SERIAL NOT NULL,
245
problemid TEXT REFERENCES problem (identifier) NOT NULL,
248
PRIMARY KEY (problemid, suiteid)
251
CREATE TABLE test_case (
252
testid SERIAL NOT NULL,
253
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
261
PRIMARY KEY (testid, suiteid)
262
CREATE TABLE problem_attempt_breakdown (
263
problemid INT4 REFERENCES problem (problemid) NOT NULL,
264
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
265
loginid INT4 REFERENCES login (loginid) NOT NULL,
266
date TIMESTAMP NOT NULL,
270
CREATE TABLE problem_prerequisite (
271
parent INT4 REFERENCES problem (problemid) NOT NULL,
272
child INT4 REFERENCES problem (problemid) NOT NULL,
273
PRIMARY KEY (parent,child)