/
codepsu.install
executable file
·158 lines (141 loc) · 4.95 KB
/
codepsu.install
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
function codepsu_schema() {
$schema = array();
$schema['codepsu_competitions'] = _codepsu_get_competition_schema();
$schema['codepsu_problems'] = _codepsu_get_problems_schema();
$schema['codepsu_teams'] = _codepsu_get_teams_schema();
return $schema;
}
function _codepsu_get_competition_schema() {
return array(
'description' => 'CodePSU Competitions',
'fields' => array(
'nid' => array(
'description' => 'The node identifier for a competition (also the primary key)',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'foreword' => array(
'description' => 'Text foreword that is displayed on the front page of the competition',
'type' => 'text',
),
'semester' => array(
'description' => 'Year and semester of the competition',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'time_limit' => array(
'description' => 'Time limit for the competition.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'quest_nid' => array(
'description' => 'The node identifier for the questions node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'_path' => array(
'description' => 'Path to the submission directory',
'type' => 'varchar',
'length' => 2048,
'not null' => TRUE,
'default' => '',
),
'start_time' => array(
'description' => 'Time when competition was started.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'running' => array(
'description' => 'Is competition started (1), paused (2), or stopped (0).',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('nid'),
);
}
function _codepsu_get_problems_schema() {
return array(
'description' => 'CodePSU Problems',
'fields' => array(
'pid' => array(
'description' => 'Problem ID; primary key',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nid' => array(
'description' => 'nid of the competition this problem belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'Names of the problem.',
'type' => 'varchar',
'length' => 2048,
'not null' => TRUE,
'default' => '',
),
'points' => array(
'description' => 'Point value of the problem.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('pid'),
);
}
function _codepsu_get_teams_schema() {
return array(
'description' => 'CodePSU Teams',
'fields' => array(
'tid' => array(
'description' => 'Team ID; primary key',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nid' => array(
'description' => 'nid of the competition this team belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'Names of the team.',
'type' => 'varchar',
'length' => 1024,
'not null' => TRUE,
'default' => '',
),
'tier' => array(
'description' => 'The tier the team is in.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('tid'),
);
}
function codepsu_install() {
// Build the native execution program
chdir(drupal_get_path('module', 'codepsu'));
exec('make &');
}
function codepsu_uninstall() {
$nids = db_query('SELECT nid FROM {codepsu_competitions}');
foreach($nids as $nid) {
node_delete($nid);
}
}