-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacm_course.view.list.inc
289 lines (282 loc) · 11.4 KB
/
acm_course.view.list.inc
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<?php
function course_list(){
$content = '<div class="block" >'.drupal_get_form('acm_course_search_form').'</div>';
$content .= '<div style="clear:both" ></div>';
$header = array(
array('data' => t('Id'), 'field' => 'id', 'sort' => 'asc'),
array('data' => t('Title'),'field' => 'title', 'sort' => 'asc'),
array('data' => t('Code'),'field' => 'Code', ),
array('data' => t('Test Score'),'field' => 'test_score', ),
//array('data' => t('Submitted by'),'field' => 'submittedby', ),
array('data' => t('View')),
array('data' => t('Update')),
);
$id = $_GET['ono'];
if(!empty($_GET['ono'])){
$Sql="SELECT c.id,c.title,c.code,c.test_score FROM acm_course c where c.id =".$id;
}
else{
$Sql="SELECT c.id,c.title,c.code,c.test_score FROM acm_course c";
}
$count = "SELECT count(*) FROM acm_course";
$query = pager_query($Sql,5,0,$count);
while($row = db_fetch_object($query)){
$data[] = array( $row->id, $row->title,$row->code,$row->test_score, l('View', 'student/course/'.$row->id.'/view'), l('Edit','student/course/update/', array('query'=>array('acmID'=>$row->id))));
}
$content .= theme('table', $header, $data);
$content .= theme('pager', 5);
return $content;
}
function acm_course_search_form($form_id){
$form['#method'] = 'get';
$form['#token'] = FALSE;
$form['#form_build_id'] = FALSE;
$form['#form_id'] = FALSE;
$form['ono'] = array(
'#type' => 'textfield',
'#title' => t('View order number'),
'#attributes' => array( 'maxlength' => '128', 'size'=> '30'),
'#prefix' => '<div class="form-inline views-exposed-form"> <div class="views-exposed-widget">',
'#suffix' => '</div>',
'#default_value' => isset($_GET['ono'])?$_GET['ono']:'',
);
$form['submit'] = array(
'#type' => 'submit',
'#attributes' => array( 'name' => ''),
'#prefix' => '<div class="views-exposed-widget">',
'#suffix' => '</div></div>',
'#value' => 'Apply',
);
return $form;
}
function acm_course_update(){
return drupal_get_form('acm_course_update_form');
}
function acm_course_update_form($form_id){
$acm_id = $_GET['acmID'];
$query = db_query("SELECT c.id,c.exam_score,c.test_score,c.academic_departmentid,c.title,c.code,c.description,c.creditpoint,c.prerequisitecodes,c.prerequisites,c.level,c.semester,c.session,c.lecturerincharge,c.numberofcas,c.caapprovalmethod,c.maxtestmark,c.maxexammark,c.programme,c.type,c.created,c.updated FROM acm_course c where c.id=".$acm_id);
$row = db_fetch_object($query);
$form['title'] = array(
'#title' => t('Title'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => isset($row->title)? $row->title:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['exam_score'] = array(
'#title' => t('Exam Score'),
'#type' => 'textfield',
'#default_value' => isset($row->exam_score)? $row->exam_score:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['test_score'] = array(
'#title' => t('Test Score'),
'#type' => 'textfield',
'#default_value' => isset($row->test_score)? $row->test_score:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>' ,
);
$form['academic_departmentid'] = array(
'#title' => t('Academic Department Id'),
'#type' => 'textfield',
'#default_value' => isset($row->academic_departmentid)? $row->academic_departmentid:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['code'] = array(
'#title' => t('Code'),
'#type' => 'textfield',
'#default_value' => isset($row->code)? $row->code:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['description'] = array(
'#title' => t('Description'),
'#type' => 'textarea',
'#default_value' => isset($row->description)? $row->description:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['creditpoint'] = array(
'#title' => t('Credit Point'),
'#type' => 'textfield',
'#default_value' => isset($row->creditpoint)? $row->creditpoint:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['prerequisitecodes'] = array(
'#title' => t('Prerequisite Codes'),
'#type' => 'textfield',
'#default_value' => isset($row->prerequisitecodes)? $row->prerequisitecodes:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['prerequisites'] = array(
'#title' => t('Prerequisite Course'),
'#type' => 'textfield',
'#default_value' => isset($row->prerequisites)? $row->prerequisites:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['level'] = array(
'#title' => t('Level'),
'#type' => 'textfield',
'#default_value' => isset($row->level)? $row->level:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['semester'] = array(
'#title' => t('Semester'),
'#type' => 'textfield',
'#default_value' => isset($row->semester)? $row->semester:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['session'] = array(
'#title' => t('Session'),
'#type' => 'textfield',
'#default_value' => isset($row->session)? $row->session:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['lecturerincharge'] = array(
'#title' => t('Lecturer in Charge'),
'#type' => 'textfield',
'#default_value' => isset($row->lecturerincharge)? $row->lecturerincharge:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['numberofcas'] = array(
'#title' => t('Number of CAS'),
'#type' => 'textfield',
'#default_value' => isset($row->numberofcas)? $row->numberofcas:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['caapprovalmethod'] = array(
'#title' => t('CA Approval Method'),
'#type' => 'textfield',
'#default_value' => isset($row->caapprovalmethod)? $row->caapprovalmethod:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['maxtestmark'] = array(
'#title' => t('Max Test Mark'),
'#type' => 'textfield',
'#default_value' => isset($row->maxtestmark)? $row->maxtestmark:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['maxexammark'] = array(
'#title' => t('Max Exam Mark'),
'#type' => 'textfield',
'#default_value' => isset($row->maxexammark)? $row->maxexammark:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['programme'] = array(
'#title' => t('Programme'),
'#type' => 'textfield',
'#default_value' => isset($row->programme)? $row->programme:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$options = array('Core'=>'Core','Elective'=>'Elective','Required'=>'Required');
$form['type'] = array(
'#title' => t('Type'),
'#type' => 'select',
'#options' => $options,
'#default_value' => isset($row->type)? $row->type:'',
'#prefix' => '<div class="require-data">',
'#suffix' => '</div>',
);
$form['updated'] = array(
'#title' => t('Updated'),
'#type' => 'hidden',
'#default_value' => date("Y-m-d H:i:s"),
);
$form['submit'] = array(
'#value' => 'Update',
'#type' => 'submit',
'#submit' => array('acm_course_update_form_submit'),
'#prefix' => '<div class="member_submit" >',
'#suffix' => '</div>',
);
return $form;
}
function acm_course_update_form_submit($form, &$form_state){
$values = $form_state['values']; $update="title='$values[title]',exam_score='$values[exam_score]',test_score='$values[test_score]',academic_departmentid='$values[academic_departmentid]',code='$values[code]',description='$values[description]',creditpoint='$values[creditpoint]',prerequisitecodes='$values[prerequisitecodes]',prerequisites='$values[prerequisites]',level='$values[level]',semester='$values[semester]',session='$values[session]',lecturerincharge='$values[lecturerincharge]',numberofcas='$values[numberofcas]',caapprovalmethod='$values[caapprovalmethod]',maxtestmark='$values[maxtestmark]',maxexammark='$values[maxexammark]',programme='$values[programme]',type='$values[type]',updated='$values[updated]'";
$acm_id = $_GET['acmID'];
$res=update_sql("UPDATE {acm_course} SET $update WHERE id =".$acm_id);
if($res){
drupal_goto('student/course/list');
}
}
function view_courselist($id){
$output ="<div></div>" ;
$output .="<div class='title'><h3>Course Details</h3></div>" ;
$output .= "<table class='course_details' cellpadding='4' width='100%'>" ;
$query = db_query("SELECT c.id,c.exam_score,c.test_score,c.academic_departmentid,c.title,c.code,c.description,c.creditpoint,c.prerequisitecodes,c.prerequisites,c.level,c.semester,c.session,c.lecturerincharge,c.numberofcas,c.caapprovalmethod,c.maxtestmark,c.maxexammark,c.programme,c.type,c.created,c.updated FROM acm_course c where c.id=".$id);
$row = db_fetch_object($query);
if($row->title){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Course Title:</td><td>".$row->title."</td></tr>";
}
if($row->exam_score){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Exam Score:</td><td>".$row->exam_score."</td></tr>";
}
if($row->test_score){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Test Score:</td><td>".$row->test_score."</td></tr>";
}
if($row->academic_departmentid){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Academic Department Id:</td><td>".$row->academic_departmentid."</td></tr>";
}
if($row->code){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Code:</td><td>".$row->code."</td></tr>";
}
if($row->description){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Description:</td><td>".$row->description."</td></tr>";
}
if($row->creditpoint){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Credit Point:</td><td>".$row->creditpoint."</td></tr>";
}
if($row->prerequisitecodes){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Prerequisite Codes:</td><td>".$row->prerequisitecodes."</td></tr>";
}
if($row->prerequisites){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Prerequisites:</td><td>".$row->prerequisites."</td></tr>";
}
if($row->level){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Level:</td><td>".$row->level."</td></tr>";
}
if($row->semester){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Semester:</td><td>".$row->semester."</td></tr>";
}
if($row->lecturerincharge){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Lecturer in Charge:</td><td>".$row->lecturerincharge."</td></tr>";
}
if($row->numberofcas){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Number of CAS:</td><td>".$row->numberofcas."</td></tr>";
}
if($row->caapprovalmethod){
$output.="<tr><td colspan='3'style='font-weight:bold;'>CA Approval Method:</td><td>".$row->caapprovalmethod."</td></tr>";
}
if($row->maxtestmark){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Max Test Mark:</td><td>".$row->maxtestmark."</td></tr>";
}
if($row->maxexammark){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Max Exam Mark:</td><td>".$row->maxexammark."</td></tr>";
}
if($row->programme){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Programme:</td><td>".$row->programme."</td></tr>";
}
if($row->type){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Type:</td><td>".$row->type."</td></tr>";
}
if($row->created){
$output.="<tr><td colspan='3'style='font-weight:bold;'>Created:</td><td>".$row->created."</td></tr>";
}
$output.= '</table>';
return $output;
}