Skip to content

Commit a3f5222

Browse files
committed
feat: Expand dashboard enrollment activities to all users and grant quiz access to admins.
1 parent 0f3cfed commit a3f5222

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

apps/api/src/dashboard/dashboard.service.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -249,27 +249,25 @@ export class DashboardService {
249249
// FIX: Explicitly type the array here
250250
const activities: ActivityItem[] = [];
251251

252-
// 1. Enrollment Activities
253-
if (user.role === UserRole.STUDENT || !user.role) {
254-
const recentEnrollments = await this.enrollmentRepository.find({
255-
where: { userId: user.id },
256-
relations: ['course'],
257-
order: { enrolledAt: 'DESC' },
258-
take: 5,
259-
});
252+
// 1. Enrollment Activities (For ALL users)
253+
const recentEnrollments = await this.enrollmentRepository.find({
254+
where: { userId: user.id },
255+
relations: ['course'],
256+
order: { enrolledAt: 'DESC' },
257+
take: 5,
258+
});
260259

261-
recentEnrollments.forEach((enrollment) => {
262-
activities.push({
263-
id: enrollment.id,
264-
type: 'enrollment',
265-
title: `Enrolled in "${enrollment.course.title}"`,
266-
course: enrollment.course.title,
267-
timestamp: enrollment.enrolledAt.toISOString(),
268-
});
260+
recentEnrollments.forEach((enrollment) => {
261+
activities.push({
262+
id: enrollment.id,
263+
type: 'enrollment',
264+
title: `Enrolled in "${enrollment.course.title}"`,
265+
course: enrollment.course.title,
266+
timestamp: enrollment.enrolledAt.toISOString(),
269267
});
270-
}
268+
});
271269

272-
// 2. Course Creation Activities
270+
// 2. Course Creation Activities (For INSTRUCTORS)
273271
if (user.role === UserRole.INSTRUCTOR) {
274272
const recentCourses = await this.courseRepository.find({
275273
where: { instructor: { id: user.id } },
@@ -287,7 +285,7 @@ export class DashboardService {
287285
});
288286
}
289287

290-
// 3. User Registration Activity
288+
// 3. User Registration Activity (For ADMINS)
291289
if (user.role === UserRole.ADMIN) {
292290
const recentUsers = await this.userRepository.find({
293291
order: { createdAt: 'DESC' },

apps/api/src/quizzes/quizzes.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class QuizzesController {
125125
}
126126

127127
@Post(':id/save-progress')
128-
@Roles(UserRole.STUDENT, UserRole.INSTRUCTOR)
128+
@Roles(UserRole.STUDENT, UserRole.INSTRUCTOR, UserRole.ADMIN)
129129
async saveProgress(
130130
@Param('id') id: string,
131131
@Body() submitDto: SubmitQuizDto,
@@ -138,7 +138,7 @@ export class QuizzesController {
138138
);
139139
}
140140
@Post(':id/submit')
141-
@Roles(UserRole.STUDENT, UserRole.INSTRUCTOR)
141+
@Roles(UserRole.STUDENT, UserRole.INSTRUCTOR, UserRole.ADMIN)
142142
async submitQuiz(
143143
@Param('id') id: string,
144144
@Body() submitDto: SubmitQuizDto,
@@ -148,7 +148,7 @@ export class QuizzesController {
148148
}
149149

150150
@Get(':id/submission')
151-
@Roles(UserRole.STUDENT, UserRole.INSTRUCTOR)
151+
@Roles(UserRole.STUDENT, UserRole.INSTRUCTOR, UserRole.ADMIN)
152152
async getSubmission(
153153
@Param('id') id: string,
154154
@CurrentUser() user: User,

0 commit comments

Comments
 (0)