@@ -8,14 +8,14 @@ import AttendanceController from './attendance.controller'
8
8
const Router = express . Router ( { mergeParams : true } )
9
9
10
10
/**
11
- //
11
+ * @swagger
12
12
* tags:
13
- * name: Attendance
14
- * description: Attendance session management and submission
13
+ * name: Attendance
14
+ * description: Attendance session management and submission
15
15
*/
16
16
17
17
/**
18
- // //
18
+ * @swagger
19
19
* components:
20
20
* schemas:
21
21
* AttendanceSessionResponse:
@@ -50,12 +50,9 @@ const Router = express.Router({ mergeParams: true })
50
50
* AttendanceRequest:
51
51
* type: object
52
52
* required:
53
- * - courseId
54
53
* - timeLimitSeconds
55
54
* - maxTries
56
55
* properties:
57
- * courseId:
58
- * type: integer
59
56
* timeLimitSeconds:
60
57
* type: integer
61
58
* maxTries:
@@ -68,6 +65,7 @@ const Router = express.Router({ mergeParams: true })
68
65
* attendanceCode:
69
66
* type: string
70
67
* description: The code submitted by the student.
68
+ *
71
69
* AttendanceSubmissionResponse:
72
70
* type: object
73
71
* properties:
@@ -77,13 +75,46 @@ const Router = express.Router({ mergeParams: true })
77
75
* triesLeft:
78
76
* type: integer
79
77
* description: Number of attempts made (including this one). Placeholder - logic might differ.
78
+ *
79
+ * AttendanceSubmission:
80
+ * type: object
81
+ * properties:
82
+ * id:
83
+ * type: integer
84
+ * description: Unique identifier for this submission record.
85
+ * example: 543
86
+ * sessionId:
87
+ * type: integer
88
+ * description: The ID of the attendance session this submission belongs to.
89
+ * example: 101
90
+ * success:
91
+ * type: boolean
92
+ * description: Whether this specific submission attempt was successful (code matched the session's code at the time).
93
+ * example: true
94
+ * submittedAt:
95
+ * type: string
96
+ * format: date-time
97
+ * description: The exact time the submission was recorded by the system.
98
+ * example: "2025-04-21T11:20:05.123Z" # Example timestamp
99
+ * submission:
100
+ * type: string
101
+ * description: The actual code string submitted by the user.
102
+ * example: "ABCD12"
103
+ * required:
104
+ * - id
105
+ * - sessionId
106
+ * - success
107
+ * - submittedAt
108
+ * - submission
80
109
*/
81
110
82
111
/**
83
- //
112
+ * @swagger
84
113
* /attendance/course/{courseId}:
85
114
* get:
86
- * summary: Retrieve all active attendance sessions for a specific course (Requires course editing privileges)
115
+ * summary: Retrieve all active attendance sessions for a specific course
116
+ * tags:
117
+ * - Attendance
87
118
* parameters:
88
119
* - name: courseId
89
120
* in: path
@@ -113,41 +144,75 @@ Router.get(
113
144
AttendanceController . getSessionsByCourse ,
114
145
)
115
146
116
- Router . get (
117
- '/:id/results' ,
118
- isAuthorized ( 'courseEdit' ) ,
119
- asInt ( 'id' ) ,
120
- AttendanceController . getAllSubmissions ,
121
- )
122
-
123
-
124
147
/**
125
- //
126
- * /attendance/{id}:
148
+ * @swagger
149
+ * /attendance/{id}/results :
127
150
* get:
128
- * summary: Retrieve a specific attendance session by its ID (Requires course editing privileges)
151
+ * summary: Retrieve all submissions for a specific attendance session
152
+ * tags:
153
+ * - Attendance
129
154
* parameters:
130
155
* - name: id
131
156
* in: path
132
157
* required: true
133
- * description: Unique ID of the attendance session
158
+ * description: ID of the attendance session to retrieve results for
134
159
* schema:
135
160
* type: integer
136
161
* responses:
137
162
* '200':
138
- * description: Details of the attendance session.
163
+ * description: A list of all submission records for the specified attendance session.
139
164
* content:
140
165
* application/json:
141
166
* schema:
142
- * $ref: '#/components/schemas/AttendanceSessionResponse' # Use a serialized response schema
167
+ * type: array
168
+ * items:
169
+ * $ref: '#/components/schemas/AttendanceSubmission'
143
170
* '400':
144
- * description: Invalid ID supplied.
171
+ * description: Invalid session ID supplied (e.g., not an integer) .
145
172
* '401':
146
- * description: Unauthorized.
173
+ * description: Unauthorized (User is not logged in) .
147
174
* '403':
148
175
* description: Forbidden (User lacks 'courseEdit' permission).
149
176
* '404':
150
- * description: Attendance session not found.
177
+ * description: Attendance session with the specified ID not found.
178
+ * */
179
+ Router . get (
180
+ '/:id/results' ,
181
+ isAuthorized ( 'courseEdit' ) ,
182
+ asInt ( 'id' ) ,
183
+ AttendanceController . getAllSubmissions ,
184
+ )
185
+
186
+
187
+ /**
188
+ @swagger
189
+ * /attendance/{id}:
190
+ * get:
191
+ * summary: Retrieve a specific attendance session by its ID
192
+ * tags:
193
+ * - Attendance
194
+ * parameters:
195
+ * - name: id
196
+ * in: path
197
+ * required: true
198
+ * description: Unique ID of the attendance session
199
+ * schema:
200
+ * type: integer
201
+ * responses:
202
+ * '200':
203
+ * description: Details of the attendance session.
204
+ * content:
205
+ * application/json:
206
+ * schema:
207
+ * $ref: '#/components/schemas/AttendanceSessionResponse' # Use a serialized response schema
208
+ * '400':
209
+ * description: Invalid ID supplied.
210
+ * '401':
211
+ * description: Unauthorized.
212
+ * '403':
213
+ * description: Forbidden (User lacks 'courseEdit' permission).
214
+ * '404':
215
+ * description: Attendance session not found.
151
216
*/
152
217
Router . get (
153
218
'/:id' ,
@@ -156,31 +221,33 @@ Router.get(
156
221
AttendanceController . getSessionById ,
157
222
)
158
223
/**
159
- //
224
+ @swagger
160
225
* /attendance:
161
- * post:
162
- * summary: Create a new attendance session (Requires course editing privileges)
163
- * requestBody:
164
- * required: true
165
- * content:
166
- * application/json:
167
- * schema:
168
- * $ref: '#/components/schemas/AttendanceRequest'
169
- * responses:
170
- * '201':
171
- * description: Attendance session created successfully.
172
- * content:
173
- * application/json:
174
- * schema:
175
- * $ref: '#/components/schemas/AttendanceSessionResponse'
176
- * '400':
177
- * description: Invalid request body or input data.
178
- * '401':
179
- * description: Unauthorized (Not logged in).
180
- * '403':
181
- * description: Forbidden (User lacks 'courseEdit' permission).
182
- * '500':
183
- * description: Server error during session creation.
226
+ * post:
227
+ * summary: Create a new attendance session
228
+ * tags:
229
+ * - Attendance
230
+ * requestBody:
231
+ * required: true
232
+ * content:
233
+ * application/json:
234
+ * schema:
235
+ * $ref: '#/components/schemas/AttendanceRequest'
236
+ * responses:
237
+ * '201':
238
+ * description: Attendance session created successfully.
239
+ * content:
240
+ * application/json:
241
+ * schema:
242
+ * $ref: '#/components/schemas/AttendanceSessionResponse'
243
+ * '400':
244
+ * description: Invalid request body or input data.
245
+ * '401':
246
+ * description: Unauthorized (Not logged in).
247
+ * '403':
248
+ * description: Forbidden (User lacks 'courseEdit' permission).
249
+ * '500':
250
+ * description: Server error during session creation.
184
251
*/
185
252
186
253
Router . post (
@@ -191,10 +258,12 @@ Router.post(
191
258
)
192
259
193
260
/**
194
- //
261
+ * @swagger
195
262
* /attendance/{sessionId}/submit:
196
263
* post:
197
- * summary: Submit an attendance code for a student (Requires permission to create self-submissions)
264
+ * summary: Submit an attendance code for a student
265
+ * tags:
266
+ * - Attendance
198
267
* parameters:
199
268
* - name: sessionId
200
269
* in: path
@@ -226,35 +295,37 @@ Router.post(
226
295
* */
227
296
Router . post (
228
297
'/:sessionId/submit' ,
229
- isAuthorized ( 'submissionCreateAll ' ) ,
298
+ isAuthorized ( 'submissionCreateSelf ' ) ,
230
299
asInt ( 'sessionId' ) ,
231
300
validateAttendanceSubmission ,
232
301
AttendanceController . submitAttendance ,
233
302
)
234
303
235
304
/**
236
- //
305
+ @swagger
237
306
* /attendance/{id}:
238
- * delete:
239
- * summary: Delete (soft delete) an attendance session (Requires course editing privileges)
240
- * parameters:
241
- * - name: id
242
- * in: path
243
- * required: true
244
- * description: ID of the attendance session to delete
245
- * schema:
246
- * type: integer
247
- * responses:
248
- * '204':
249
- * description: Session deleted successfully (No Content).
250
- * '400':
251
- * description: Invalid ID supplied.
252
- * '401':
253
- * description: Unauthorized.
254
- * '403':
255
- * description: Forbidden (User lacks 'courseEdit' permission).
256
- * '404':
257
- * description: Attendance session not found.
307
+ * delete:
308
+ * summary: Delete (soft delete) an attendance session
309
+ * tags:
310
+ * - Attendance
311
+ * parameters:
312
+ * - name: id
313
+ * in: path
314
+ * required: true
315
+ * description: ID of the attendance session to delete
316
+ * schema:
317
+ * type: integer
318
+ * responses:
319
+ * '204':
320
+ * description: Session deleted successfully (No Content).
321
+ * '400':
322
+ * description: Invalid ID supplied.
323
+ * '401':
324
+ * description: Unauthorized.
325
+ * '403':
326
+ * description: Forbidden (User lacks 'courseEdit' permission).
327
+ * '404':
328
+ * description: Attendance session not found.
258
329
*/
259
330
Router . delete (
260
331
'/:id' ,
0 commit comments