203
--TODO: Link worksheets to offerings
204
203
CREATE TABLE worksheet (
205
worksheetid SERIAL PRIMARY KEY NOT NULL,
206
subject VARCHAR NOT NULL,
207
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
208
identifier VARCHAR NOT NULL,
211
UNIQUE (subject, identifier)
214
CREATE TABLE worksheet_problem (
215
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
216
problemid TEXT REFERENCES problem (identifier) NOT NULL,
218
PRIMARY KEY (worksheetid, problemid)
221
CREATE TABLE problem_attempt (
222
problemid VARCHAR REFERENCES problem (identifier) NOT NULL,
204
worksheetid SERIAL PRIMARY KEY,
205
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
206
identifier TEXT NOT NULL,
209
assessable BOOLEAN NOT NULL,
210
seq_no INT4 NOT NULL,
211
format TEXT NOT NUll,
212
UNIQUE (offeringid, identifier)
215
CREATE TABLE worksheet_exercise (
216
ws_ex_id SERIAL PRIMARY KEY,
217
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
218
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL,
219
seq_no INT4 NOT NULL,
220
active BOOLEAN NOT NULL DEFAULT true,
221
optional BOOLEAN NOT NULL,
222
UNIQUE (worksheetid, exerciseid)
225
CREATE TABLE exercise_attempt (
223
226
loginid INT4 REFERENCES login (loginid) NOT NULL,
224
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
227
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL,
225
228
date TIMESTAMP NOT NULL,
226
attempt VARCHAR NOT NULL,
229
attempt TEXT NOT NULL,
227
230
complete BOOLEAN NOT NULL,
228
231
active BOOLEAN NOT NULL DEFAULT true,
229
PRIMARY KEY (problemid,loginid,date)
232
PRIMARY KEY (loginid, ws_ex_id, date)
232
CREATE TABLE problem_save (
233
problemid INT4 REFERENCES problem (problemid) NOT NULL,
235
CREATE TABLE exercise_save (
234
236
loginid INT4 REFERENCES login (loginid) NOT NULL,
235
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
237
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL,
236
238
date TIMESTAMP NOT NULL,
237
text VARCHAR NOT NULL,
238
PRIMARY KEY (problemid,loginid)
240
PRIMARY KEY (loginid, ws_ex_id)
241
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
243
243
CREATE TABLE test_suite (
244
suiteid SERIAL NOT NULL,
245
problemid TEXT REFERENCES problem (identifier) NOT NULL,
244
suiteid SERIAL PRIMARY KEY,
245
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL,
246
246
description TEXT,
248
PRIMARY KEY (problemid, suiteid)
251
252
CREATE TABLE test_case (
252
testid SERIAL NOT NULL,
253
testid SERIAL PRIMARY KEY,
254
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
261
CREATE TABLE suite_variable (
262
varid SERIAL PRIMARY KEY,
253
263
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
261
PRIMARY KEY (testid, suiteid)
266
var_type TEXT NOT NULL,
270
CREATE TABLE test_case_part (
271
partid SERIAL PRIMARY KEY,
272
testid INT4 REFERENCES test_case (testid) NOT NULL,
273
part_type TEXT NOT NULL,