Skip to content

Commit 2a2ca27

Browse files
committed
major add
1 parent ca353ec commit 2a2ca27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1327
-31
lines changed

.env

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
55
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
66

7-
DATABASE_URL="mysql://root:12345678@34.128.67.12:3306/asco"
7+
DATABASE_URL="mysql://admin:12345678@localhost:3306/asco"
88
PORT=7892
99
TESTING_PORT=8889
1010
HOST=127.0.0.1
@@ -13,4 +13,10 @@ ISSUER=api.jj
1313
GCP_PUB_SUB_PROJECTID="asco-app"
1414
GCP_PUB_SUB_TOPICID="publish-card-sync-meeting"
1515
GCP_PUB_SUB_SUBSCRIPTIONID="pull-card-meeting"
16-
NODE_ENV=sandbox
16+
KAFKA_HOST=localhost:9092
17+
DATABASE_HOST=localhost
18+
DATABASE_PORT=3306
19+
DATABASE_USER=admin
20+
DATABASE_PASSWORD=12345678
21+
DATABASE_NAME=asco
22+
NODE_ENV=development

media/1720360929634

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
be-task : waktu luang
2+
mas fauzan : deployment
3+
drone.xetia.dev : ci/cd
4+
dokumentasi buat report

src/api/classroom/router/ClassroomRouterImpl.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export class ClassroomRouter extends BaseRouter {
4242
this.router
4343
.route(this.path + "/:classroomId/meetings")
4444
.get(
45-
this.authorizationMiddlware.authorize([USER_ROLE.STUDENT]),
45+
this.authorizationMiddlware.authorize([
46+
USER_ROLE.STUDENT,
47+
USER_ROLE.ASSISTANT,
48+
]),
4649
this.handler.getClassroomMeetings
4750
);
4851

src/api/meeting/handler/MeetingHandler.ts

+14
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,22 @@ export abstract class MeetingHandler {
1010
this.postMeetingAttendances = this.postMeetingAttendances.bind(this);
1111
this.postMeetingScore = this.postMeetingScore.bind(this);
1212
this.getMeetingControlCards = this.getMeetingControlCards.bind(this);
13+
this.getStudentMeetingScores = this.getStudentMeetingScores.bind(this);
14+
this.putMeetingAttendance = this.putMeetingAttendance.bind(this);
1315
}
1416

17+
abstract putMeetingAttendance(
18+
req: Request,
19+
res: Response,
20+
next: NextFunction
21+
): Promise<any>;
22+
23+
abstract getStudentMeetingScores(
24+
req: Request,
25+
res: Response,
26+
next: NextFunction
27+
): Promise<any>;
28+
1529
abstract getMeetingControlCards(
1630
req: Request,
1731
res: Response,

src/api/meeting/handler/MeetingHandlerImpl.ts

+63-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ import { MeetingDTO } from "../../../utils/dto/meeting/IMeetingDTO";
1313
import { IPutClassroomMeetingPayload } from "../../../utils/interfaces/request/IPutClassroomMeetingPayload";
1414
import { PracticumMeetingPutPayloadSchema } from "../../../utils/validator/meeting/Joi/PracticumMeetingPutPayloadSchema";
1515
import { IPostMeetingAttendancePayload } from "../../../utils/interfaces/request/IPostMeetingAttendancePayload";
16-
import { MeetingAttendancePostPayloadSchema } from "../../../utils/validator/attendance/Joi/MeetingAttendancePostPayloadSchema";
16+
import {
17+
MeetingAttendancePostPayloadSchema,
18+
MeetingAttendancePutPayloadSchema,
19+
} from "../../../utils/validator/attendance/Joi/MeetingAttendancePostPayloadSchema";
1720
import { AttendanceService } from "../../../services/attendance/AttendanceService";
1821
import { ListStudentAttendanceDTO } from "../../../utils/dto/attendances/IListStudentAttendanceDTO";
1922
import { IPostMeetingScore } from "../../../utils/interfaces/request/IPostMeetingResponseScore";
2023
import { MeetingScorePostPayloadSchema } from "../../../utils/validator/score/MeetingResponseScorePostPayloadSchema";
2124
import { ScoreService } from "../../../services/score/ScoreService";
2225
import { ControlCardService } from "../../../services/controlCard/ControlCardService";
2326
import { MeetingControlCardDTO } from "../../../utils/dto/controlCard/IMeetingControlCardDTO";
27+
import { IPutMeetingAttendancePayload } from "../../../utils/interfaces/request/IPutMeetingAttendancePayload";
2428

2529
export class MeetingHandlerImpl extends MeetingHandler {
2630
private meetingService: MeetingService;
@@ -46,6 +50,63 @@ export class MeetingHandlerImpl extends MeetingHandler {
4650
this.schemaValidator = schemaValidator;
4751
}
4852

53+
async putMeetingAttendance(
54+
req: Request,
55+
res: Response,
56+
next: NextFunction
57+
): Promise<any> {
58+
const { id } = req.params;
59+
const payload: IPutMeetingAttendancePayload = req.body;
60+
const { profileId } = getTokenPayload(res);
61+
62+
try {
63+
this.schemaValidator.validate({
64+
schema: MeetingAttendancePutPayloadSchema,
65+
payload,
66+
});
67+
68+
await this.attendanceService.updateAttendaceByMeetingIdAndProfileId(
69+
id,
70+
payload,
71+
profileId
72+
);
73+
74+
return res
75+
.status(200)
76+
.json(
77+
createResponse(
78+
RESPONSE_MESSAGE.SUCCESS,
79+
"successfully update attendance"
80+
)
81+
);
82+
} catch (error) {
83+
return next(error);
84+
}
85+
}
86+
87+
async getStudentMeetingScores(
88+
req: Request,
89+
res: Response,
90+
next: NextFunction
91+
): Promise<any> {
92+
const { id } = req.params;
93+
const { classroom, type } = req.query;
94+
95+
try {
96+
const scores = await this.meetingService.getMeetingStudentMeetingScores(
97+
id,
98+
type,
99+
classroom
100+
);
101+
102+
return res
103+
.status(200)
104+
.json(createResponse(RESPONSE_MESSAGE.SUCCESS, scores));
105+
} catch (error) {
106+
return next(error);
107+
}
108+
}
109+
49110
async getMeetingControlCards(
50111
req: Request,
51112
res: Response,
@@ -62,7 +123,7 @@ export class MeetingHandlerImpl extends MeetingHandler {
62123
);
63124

64125
return res
65-
.status(201)
126+
.status(200)
66127
.json(
67128
createResponse(
68129
RESPONSE_MESSAGE.SUCCESS,

src/api/meeting/router/MeetingRouterImpl.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ export class MeetingRouter extends BaseRouter {
3333
this.authorizationMiddlware.authorize([
3434
USER_ROLE.ADMIN,
3535
USER_ROLE.STUDENT,
36+
USER_ROLE.ASSISTANT,
3637
]),
3738
this.getMeetingMiddleware.checkAuthorizedRole,
3839
this.handler.getMeeting
3940
)
4041
.put(
41-
this.authorizationMiddlware.authorize([USER_ROLE.ADMIN]),
42+
this.authorizationMiddlware.authorize([
43+
USER_ROLE.ADMIN,
44+
USER_ROLE.ASSISTANT,
45+
]),
4246
this.handler.putMeeting
4347
);
4448

@@ -56,6 +60,9 @@ export class MeetingRouter extends BaseRouter {
5660
USER_ROLE.ADMIN,
5761
]),
5862
this.handler.getMeetingAttendances
63+
).put(
64+
this.authorizationMiddlware.authorize([USER_ROLE.ASSISTANT]),
65+
this.handler.putMeetingAttendance
5966
);
6067

6168
// * input response scores
@@ -64,6 +71,10 @@ export class MeetingRouter extends BaseRouter {
6471
.post(
6572
this.authorizationMiddlware.authorize([USER_ROLE.ASSISTANT]),
6673
this.handler.postMeetingScore
74+
)
75+
.get(
76+
this.authorizationMiddlware.authorize([USER_ROLE.ASSISTANT]),
77+
this.handler.getStudentMeetingScores
6778
);
6879

6980
// * get students control card by meeting

src/api/practicum/handler/PracticumHandler.ts

+29
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,37 @@ export abstract class PracticumHandler {
2626
this.getPracticumMeetingAttendances =
2727
this.getPracticumMeetingAttendances.bind(this);
2828
this.postPracticumExamScore = this.postPracticumExamScore.bind(this);
29+
this.getScoreRecaps = this.getScoreRecaps.bind(this);
30+
this.getStudentScoreDetail = this.getStudentScoreDetail.bind(this);
31+
this.getStudentScoreDetailStudent =
32+
this.getStudentScoreDetailStudent.bind(this);
33+
this.getExamScore = this.getExamScore.bind(this);
2934
}
3035

36+
abstract getExamScore(
37+
req: Request,
38+
res: Response,
39+
next: NextFunction
40+
): Promise<any>;
41+
42+
abstract getStudentScoreDetailStudent(
43+
req: Request,
44+
res: Response,
45+
next: NextFunction
46+
): Promise<any>;
47+
48+
abstract getStudentScoreDetail(
49+
req: Request,
50+
res: Response,
51+
next: NextFunction
52+
): Promise<any>;
53+
54+
abstract getScoreRecaps(
55+
req: Request,
56+
res: Response,
57+
next: NextFunction
58+
): Promise<any>;
59+
3160
abstract postPracticumExamScore(
3261
req: Request,
3362
res: Response,

src/api/practicum/handler/PracticumHandlerImpl.ts

+93-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { ListMeetingAttendanceDTO } from "../../../utils/dto/meeting/IListMeetin
3434
import { ScoreService } from "../../../services/score/ScoreService";
3535
import { IPostPracticumExamScore } from "../../../utils/interfaces/request/IPostPracticumExamScore";
3636
import { PracticumExamScorePostPayloadSchema } from "../../../utils/validator/practicum/Joi/PracticumExamScorePostPayloadSchema";
37+
import { ListScoreRecapDTO } from "../../../utils/dto/score/IListScoreRecapDTO";
3738

3839
export class PracticumHandlerImpl extends PracticumHandler {
3940
private practicumService: PracticumService;
@@ -69,6 +70,93 @@ export class PracticumHandlerImpl extends PracticumHandler {
6970
this.schemaValidator = schemaValidator;
7071
}
7172

73+
async getExamScore(
74+
req: Request,
75+
res: Response,
76+
next: NextFunction
77+
): Promise<any> {
78+
const { practicumId } = req.params;
79+
80+
try {
81+
const scores = await this.practicumService.getLabExamScoreByPracticumId(practicumId);
82+
83+
return res
84+
.status(200)
85+
.json(
86+
createResponse(RESPONSE_MESSAGE.SUCCESS, scores)
87+
);
88+
} catch (error) {
89+
return next(error);
90+
}
91+
}
92+
93+
async getStudentScoreDetailStudent(
94+
req: Request,
95+
res: Response,
96+
next: NextFunction
97+
): Promise<any> {
98+
const { practicumId } = req.params;
99+
const { username } = getTokenPayload(res);
100+
101+
try {
102+
const scores =
103+
await this.scoreService.getScoreRecapByPracticumIdAndStudentId(
104+
practicumId,
105+
username
106+
);
107+
108+
return res
109+
.status(200)
110+
.json(
111+
createResponse(RESPONSE_MESSAGE.SUCCESS, ListScoreRecapDTO(scores))
112+
);
113+
} catch (error) {
114+
return next(error);
115+
}
116+
}
117+
118+
async getStudentScoreDetail(
119+
req: Request,
120+
res: Response,
121+
next: NextFunction
122+
): Promise<any> {
123+
const { practicumId, id } = req.params;
124+
125+
try {
126+
const scores =
127+
await this.scoreService.getScoreRecapByPracticumIdAndStudentId(
128+
practicumId,
129+
id
130+
);
131+
132+
return res
133+
.status(200)
134+
.json(
135+
createResponse(RESPONSE_MESSAGE.SUCCESS, ListScoreRecapDTO(scores))
136+
);
137+
} catch (error) {
138+
return next(error);
139+
}
140+
}
141+
142+
async getScoreRecaps(
143+
req: Request,
144+
res: Response,
145+
next: NextFunction
146+
): Promise<any> {
147+
const { practicumId } = req.params;
148+
149+
const scores = await this.scoreService.getScoreRecapByPracticumId(
150+
practicumId
151+
);
152+
153+
return res
154+
.status(200)
155+
.json(
156+
createResponse(RESPONSE_MESSAGE.SUCCESS, scores.map(ListScoreRecapDTO))
157+
);
158+
}
159+
72160
async postPracticumExamScore(
73161
req: Request,
74162
res: Response,
@@ -84,7 +172,11 @@ export class PracticumHandlerImpl extends PracticumHandler {
84172
payload,
85173
});
86174

87-
await this.scoreService.addPracticumExamScore(practicumId, payload, profileId);
175+
await this.scoreService.addPracticumExamScore(
176+
practicumId,
177+
payload,
178+
profileId
179+
);
88180

89181
return res
90182
.status(201)

0 commit comments

Comments
 (0)