-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassessment_question.install
More file actions
executable file
·146 lines (133 loc) · 3.5 KB
/
assessment_question.install
File metadata and controls
executable file
·146 lines (133 loc) · 3.5 KB
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
<?php
/**
* Long answer questions.
* @file
*/
/**
* Implements hook_install().
*/
function assessment_question_install() {
// Add body field to assessment question node
quiz_question_add_body_field('assessment_question');
// TODO The drupal_(un)install_schema functions are called automatically in D7.
// drupal_install_schema('assessment_question')
variable_set('node_options_assessment_question', array('status'));
cache_clear_all('autoload:', 'cache');
}
/**
* Implements hook_uninstall().
*/
function assessment_question_uninstall() {
// Delete tables
// TODO The drupal_(un)install_schema functions are called automatically in D7.
// drupal_uninstall_schema('assessment_question')
// Delete data from other tables
// Clear the cache.
cache_clear_all('variables', 'cache');
drupal_set_message(t('The Long Answer module has been uninstalled and related data has been deleted.'));
}
/**
* Implements hook_schema().
*/
function assessment_question_schema() {
// Properties for a question nodes go in here:
$schema['quiz_assessment_question_node_properties'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
/*
'rubric' => array(
'type' => 'text',
),
*/
'required' => array(
'type' => 'int',
'unsigned' => TRUE,
),
),
'primary key' => array('nid', 'vid'),
);
// User answers go in here.
$schema['quiz_assessment_question_user_answers'] = array(
'fields' => array(
'answer_id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'question_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'question_vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'result_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'score' => array(
'type' => 'float',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'is_evaluated' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'default' => 0,
'not null' => TRUE,
),
'answer' => array(
'type' => 'text'
),
'answer_feedback' => array(
'type' => 'text'
),
'answer_feedback_format' => array(
'type' => 'varchar',
'length' => 255,
),
),
'primary key' => array('answer_id'),
'unique keys' => array(
'ids' => array('result_id', 'question_nid', 'question_vid'),
),
);
return $schema;
}
/**
* Adding feedback field to table {quiz_assessment_question_user_answers}
*/
function assessment_question_update_7401() {
$spec = array(
'type' => 'text',
'not null' => FALSE,
);
db_add_field('quiz_assessment_question_user_answers', 'answer_feedback', $spec);
}
/**
* Adding feedback format field to table {quiz_assessment_question_user_answers}
*/
function assessment_question_update_7402() {
if (!db_field_exists('quiz_assessment_question_user_answers', 'answer_feedback_format')) {
$spec = array(
'type' => 'varchar',
'length' => 255,
);
db_add_field('quiz_assessment_question_user_answers', 'answer_feedback_format', $spec);
}
}