17
17
DROP TABLE problem_tag;
18
18
DROP TABLE problem_test_case;
19
19
DROP TABLE problem_prerequisite;
20
DROP TABLE problem_save;
21
DROP TABLE problem_attempt;
22
DROP TABLE worksheet_problem;
26
CREATE TABLE exercise (
27
identifier TEXT PRIMARY KEY,
36
CREATE TABLE worksheet (
37
worksheetid SERIAL PRIMARY KEY,
38
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
39
identifier TEXT NOT NULL,
42
assessable BOOLEAN NOT NULL,
45
UNIQUE (offeringid, identifier)
48
CREATE TABLE worksheet_exercise (
49
ws_ex_id SERIAL PRIMARY KEY,
50
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
51
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL,
53
active BOOLEAN NOT NULL DEFAULT true,
54
optional BOOLEAN NOT NULL,
55
UNIQUE (worksheetid, exerciseid)
58
CREATE TABLE exercise_attempt (
59
loginid INT4 REFERENCES login (loginid) NOT NULL,
60
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL,
61
date TIMESTAMP NOT NULL,
62
attempt TEXT NOT NULL,
63
complete BOOLEAN NOT NULL,
64
active BOOLEAN NOT NULL DEFAULT true,
65
PRIMARY KEY (loginid, ws_ex_id, date)
68
CREATE TABLE exercise_save (
69
loginid INT4 REFERENCES login (loginid) NOT NULL,
70
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL,
71
date TIMESTAMP NOT NULL,
73
PRIMARY KEY (loginid, ws_ex_id)
20
TRUNCATE worksheet_problem, worksheet;
22
-- Remove References to problemid
23
ALTER TABLE problem_attempt DROP CONSTRAINT problem_attempt_problemid_fkey;
24
ALTER TABLE problem_save DROP CONSTRAINT problem_save_problemid_fkey;
25
ALTER TABLE worksheet_problem DROP CONSTRAINT worksheet_problem_problemid_fkey;
27
-- Add fields to problem necessary to store all exercise information in non-xml
28
ALTER TABLE problem ADD COLUMN name TEXT;
29
ALTER TABLE problem ADD COLUMN description TEXT;
30
ALTER TABLE problem ADD COLUMN partial TEXT;
31
ALTER TABLE problem ADD COLUMN solution TEXT;
32
ALTER TABLE problem ADD COLUMN include TEXT;
33
ALTER TABLE problem ADD COLUMN num_rows INT4;
34
-- Drop (now) unused columns spec and problemid
35
ALTER TABLE problem DROP COLUMN spec;
36
ALTER TABLE problem DROP COLUMN problemid;
38
-- Set problems and worksheets to reference exercises by identifier
39
ALTER TABLE problem_attempt ADD COLUMN worksheetid INT4 REFERENCES worksheet (worksheetid);
40
ALTER TABLE problem_attempt DROP COLUMN problemid;
41
ALTER TABLE problem_attempt ADD COLUMN problemid TEXT REFERENCES problem (identifier);
43
ALTER TABLE problem_save ADD COLUMN worksheetid INT4 REFERENCES worksheet (worksheetid);
44
ALTER TABLE problem_save DROP COLUMN problemid;
45
ALTER TABLE problem_save ADD COLUMN problemid TEXT references problem (identifier);
47
ALTER TABLE worksheet_problem DROP COLUMN problemid;
48
ALTER TABLE worksheet_problem ADD COLUMN problemid TEXT REFERENCES problem (identifier);
76
50
CREATE TABLE test_suite (
77
suiteid SERIAL PRIMARY KEY,
78
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL,
51
suiteid SERIAL UNIQUE NOT NULL,
52
problemid TEXT REFERENCES problem (identifier) NOT NULL,
55
PRIMARY KEY (problemid, suiteid)
85
58
CREATE TABLE test_case (
86
testid SERIAL PRIMARY KEY,
87
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
94
CREATE TABLE suite_variable (
95
varid SERIAL PRIMARY KEY,
59
testid SERIAL UNIQUE NOT NULL,
96
60
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
99
var_type TEXT NOT NULL,
103
CREATE TABLE test_case_part (
104
partid SERIAL PRIMARY KEY,
105
testid INT4 REFERENCES test_case (testid) NOT NULL,
106
part_type TEXT NOT NULL,
68
PRIMARY KEY (testid, suiteid)
71
-- Link worksheets to offerings
72
ALTER TABLE worksheet ADD COLUMN offeringid INT4 REFERENCES offering (offeringid) NOT NULL;