1
1
$ ( document ) . ready ( function ( ) {
2
2
3
- $ ( document ) . on ( 'submit' , '#cse_attend_form ' , function ( event ) {
3
+ $ ( document ) . on ( 'submit' , '#attend_form ' , function ( event ) {
4
4
event . preventDefault ( ) ;
5
-
5
+ var element = $ ( '#course_id .active' ) ;
6
+ var course_code = element . data ( 'course' ) ;
6
7
$ . ajax ( {
7
8
url : 'attendance' ,
8
9
type : 'POST' ,
9
10
data : {
10
11
student_id : $ ( '#student_id' ) . val ( ) ,
11
- course_id : $ ( '#course_id' ) . val ( ) ,
12
+ course_id : course_code ,
12
13
present_attend : $ ( '#present_attend' ) . val ( ) ,
13
14
total_attend : $ ( '#total_attend' ) . val ( ) ,
14
15
csrfmiddlewaretoken : $ ( 'input[name=csrfmiddlewaretoken]' ) . val ( )
15
16
} ,
16
17
success : function ( response ) {
17
18
if ( response . result === 'Success' ) {
18
- $ ( '#cse_attend_form' ) . each ( function ( ) {
19
- this . reset ( ) ;
20
- } ) ;
21
- }
22
- else {
23
- alert ( response . message ) ;
24
- }
25
-
26
- }
27
- } ) ;
28
- } ) ;
29
-
30
- $ ( document ) . on ( 'submit' , '#ece_attend_form' , function ( event ) {
31
- event . preventDefault ( ) ;
32
-
33
- $ . ajax ( {
34
- url : 'attendance' ,
35
- type : 'POST' ,
36
- data : {
37
- student_id : $ ( '#student_id_ece' ) . val ( ) ,
38
- course_id : $ ( '#course_id_ece' ) . val ( ) ,
39
- present_attend : $ ( '#present_attend_ece' ) . val ( ) ,
40
- total_attend : $ ( '#total_attend_ece' ) . val ( ) ,
41
- csrfmiddlewaretoken : $ ( 'input[name=csrfmiddlewaretoken]' ) . val ( )
42
- } ,
43
- success : function ( response ) {
44
- if ( response . result === 'Success' ) {
45
- $ ( '#ece_attend_form' ) . each ( function ( ) {
46
- this . reset ( ) ;
47
- } ) ;
48
- }
49
- else {
50
- alert ( response . message ) ;
51
- }
52
-
53
- }
54
- } ) ;
55
- } ) ;
56
-
57
- $ ( document ) . on ( 'submit' , '#mech_attend_form' , function ( event ) {
58
- event . preventDefault ( ) ;
59
-
60
- $ . ajax ( {
61
- url : 'attendance' ,
62
- type : 'POST' ,
63
- data : {
64
- student_id : $ ( '#student_id_mech' ) . val ( ) ,
65
- course_id : $ ( '#course_id_mech' ) . val ( ) ,
66
- present_attend : $ ( '#present_attend_mech' ) . val ( ) ,
67
- total_attend : $ ( '#total_attend_mech' ) . val ( ) ,
68
- csrfmiddlewaretoken : $ ( 'input[name=csrfmiddlewaretoken]' ) . val ( )
69
- } ,
70
- success : function ( response ) {
71
- if ( response . result === 'Success' ) {
72
- $ ( '#mech_attend_form' ) . each ( function ( ) {
19
+ $ ( '#attend_form' ) . each ( function ( ) {
73
20
this . reset ( ) ;
74
21
} ) ;
75
22
}
76
23
else {
77
24
alert ( response . message ) ;
25
+ alert ( element ) ;
78
26
}
79
27
80
28
}
81
29
} ) ;
82
30
} ) ;
83
31
84
-
85
- $ ( document ) . on ( 'submit' , '#design_attend_form' , function ( event ) {
32
+ $ ( '#course_id' ) . on ( 'click' , '.item' , function ( event ) {
86
33
event . preventDefault ( ) ;
87
-
88
- $ . ajax ( {
89
- url : 'attendance' ,
90
- type : 'POST' ,
91
- data : {
92
- student_id : $ ( '#student_id_design' ) . val ( ) ,
93
- course_id : $ ( '#course_id_design' ) . val ( ) ,
94
- present_attend : $ ( '#present_attend_design' ) . val ( ) ,
95
- total_attend : $ ( '#total_attend_design' ) . val ( ) ,
96
- csrfmiddlewaretoken : $ ( 'input[name=csrfmiddlewaretoken]' ) . val ( )
97
- } ,
98
- success : function ( response ) {
99
- if ( response . result === 'Success' ) {
100
- $ ( '#design_attend_form' ) . each ( function ( ) {
101
- this . reset ( ) ;
102
- } ) ;
103
- }
104
- else {
105
- alert ( response . message ) ;
106
- }
107
-
108
- }
109
- } ) ;
34
+ // alert($(this).data('course'));
35
+ $ ( this ) . addClass ( 'active' ) ;
110
36
} ) ;
111
37
112
38
113
- $ ( '#cse_courses' ) . on ( 'click' , 'button ' , function ( event ) {
39
+ $ ( '#cse_courses' ) . on ( 'click' , '.item ' , function ( event ) {
114
40
115
41
event . preventDefault ( ) ;
116
42
var course_code = $ ( this ) . data ( 'course' ) ;
43
+ alert ( course_code ) ;
117
44
$ ( '#cse_table tbody' ) . find ( "tr:gt(0)" ) . remove ( ) ;
118
45
119
46
element = $ ( '#cse_table tbody tr' ) . last ( ) ;
@@ -162,152 +89,6 @@ $(document).ready(function () {
162
89
} ) ;
163
90
} ) ;
164
91
165
- $ ( '#ece_courses' ) . on ( 'click' , 'button' , function ( event ) {
166
-
167
- event . preventDefault ( ) ;
168
- var course_code = $ ( this ) . data ( 'course' ) ;
169
- $ ( '#ece_table tbody' ) . find ( "tr:gt(0)" ) . remove ( ) ;
170
-
171
- element = $ ( '#ece_table tbody tr' ) . last ( ) ;
172
- $ . ajax ( {
173
- url : 'get_attendance' ,
174
- type : 'GET' ,
175
- data : { 'course_id' : course_code } ,
176
- success : function ( response ) {
177
-
178
-
179
- for ( var j = 0 ; j < response . tuples . length ; j ++ ) {
180
- var name = response . stud_data . name [ j ] ;
181
- var programme = response . stud_data . programme [ j ] ;
182
- var batch = response . stud_data . batch [ j ] ;
183
- var roll = response . tuples [ j ] [ 1 ] ;
184
- var course = course_code ;
185
- var present_attend = response . tuples [ j ] [ 2 ] ;
186
- var total_attend = response . tuples [ j ] [ 3 ] ;
187
- var attend_percent = ( ( present_attend / total_attend ) * 100 ) . toFixed ( 2 ) ;
188
- txt = "<tr>" ;
189
- txt += '<td> </td>' +
190
- '<td>' + name + '</td>' +
191
- '<td>' + roll + '</td>' +
192
- '<td>' + batch + '</td>' +
193
- '<td>' + programme + '</td>' +
194
- '<td>' + course + '</td>' +
195
- '<td>' + attend_percent + '</td>' +
196
- '<td> <i class="refresh icon" style="font-size:1.3vw"></i>' +
197
- '<button type="submit" id="' + roll + '"> <i class="trash outline icon" style="font-size:1.3vw"></i> </button></td>' ;
198
-
199
- txt += '</tr>' ;
200
- element . after ( txt ) ;
201
- }
202
-
203
- console . log ( response . stud_data . name . length ) ;
204
- console . log ( response . tuples . length ) ;
205
-
206
92
207
93
208
-
209
-
210
- } ,
211
- error : function ( response ) {
212
-
213
- }
214
- } ) ;
215
- } ) ;
216
-
217
- $ ( '#mech_courses' ) . on ( 'click' , 'button' , function ( event ) {
218
-
219
- event . preventDefault ( ) ;
220
- var course_code = $ ( this ) . data ( 'course' ) ;
221
- $ ( '#mech_table tbody' ) . find ( "tr:gt(0)" ) . remove ( ) ;
222
-
223
- element = $ ( '#mech_table tbody tr' ) . last ( ) ;
224
- $ . ajax ( {
225
- url : 'get_attendance' ,
226
- type : 'GET' ,
227
- data : { 'course_id' : course_code } ,
228
- success : function ( response ) {
229
-
230
-
231
- for ( var j = 0 ; j < response . tuples . length ; j ++ ) {
232
- var name = response . stud_data . name [ j ] ;
233
- var programme = response . stud_data . programme [ j ] ;
234
- var batch = response . stud_data . batch [ j ] ;
235
- var roll = response . tuples [ j ] [ 1 ] ;
236
- var course = course_code ;
237
- var present_attend = response . tuples [ j ] [ 2 ] ;
238
- var total_attend = response . tuples [ j ] [ 3 ] ;
239
- var attend_percent = ( ( present_attend / total_attend ) * 100 ) . toFixed ( 2 ) ;
240
- txt = "<tr>" ;
241
- txt += '<td> </td>' +
242
- '<td>' + name + '</td>' +
243
- '<td>' + roll + '</td>' +
244
- '<td>' + batch + '</td>' +
245
- '<td>' + programme + '</td>' +
246
- '<td>' + course + '</td>' +
247
- '<td>' + attend_percent + '</td>' +
248
- '<td> <i class="refresh icon" style="font-size:1.3vw"></i>' +
249
- '<button type="submit" id="' + roll + '"> <i class="trash outline icon" style="font-size:1.3vw"></i> </button></td>' ;
250
-
251
- txt += '</tr>' ;
252
- element . after ( txt ) ;
253
- }
254
-
255
- console . log ( response . stud_data . name . length ) ;
256
- console . log ( response . tuples . length ) ;
257
-
258
- } ,
259
- error : function ( response ) {
260
-
261
- }
262
- } ) ;
263
- } ) ;
264
-
265
- $ ( '#design_courses' ) . on ( 'click' , 'button' , function ( event ) {
266
-
267
- event . preventDefault ( ) ;
268
- var course_code = $ ( this ) . data ( 'course' ) ;
269
- $ ( '#design_table tbody' ) . find ( "tr:gt(0)" ) . remove ( ) ;
270
-
271
- element = $ ( '#design_table tbody tr' ) . last ( ) ;
272
- $ . ajax ( {
273
- url : 'get_attendance' ,
274
- type : 'GET' ,
275
- data : { 'course_id' : course_code } ,
276
- success : function ( response ) {
277
-
278
-
279
- for ( var j = 0 ; j < response . tuples . length ; j ++ ) {
280
- var name = response . stud_data . name [ j ] ;
281
- var programme = response . stud_data . programme [ j ] ;
282
- var batch = response . stud_data . batch [ j ] ;
283
- var roll = response . tuples [ j ] [ 1 ] ;
284
- var course = course_code ;
285
- var present_attend = response . tuples [ j ] [ 2 ] ;
286
- var total_attend = response . tuples [ j ] [ 3 ] ;
287
- var attend_percent = ( ( present_attend / total_attend ) * 100 ) . toFixed ( 2 ) ;
288
- txt = "<tr>" ;
289
- txt += '<td> </td>' +
290
- '<td>' + name + '</td>' +
291
- '<td>' + roll + '</td>' +
292
- '<td>' + batch + '</td>' +
293
- '<td>' + programme + '</td>' +
294
- '<td>' + course + '</td>' +
295
- '<td>' + attend_percent + '</td>' +
296
- '<td> <i class="refresh icon" style="font-size:1.3vw"></i>' +
297
- '<button type="submit" id="' + roll + '"> <i class="trash outline icon" style="font-size:1.3vw"></i> </button></td>' ;
298
-
299
- txt += '</tr>' ;
300
- element . after ( txt ) ;
301
- }
302
-
303
- console . log ( response . stud_data . name . length ) ;
304
- console . log ( response . tuples . length ) ;
305
-
306
- } ,
307
- error : function ( response ) {
308
-
309
- }
310
- } ) ;
311
- } ) ;
312
-
313
94
} ) ;
0 commit comments