From d5341208d8c17b080a100c971bcb2f3b9fcd8aac Mon Sep 17 00:00:00 2001 From: "QSL\\SumathiT" Date: Wed, 27 Nov 2024 14:06:09 -0800 Subject: [PATCH] Remove registration from the active session. --- backend/src/components/eas/eas.js | 22 ++++++++++--- backend/src/routes/eas.js | 3 +- .../forms/EditStudentRegistration.vue | 32 +++++++++++++++---- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/backend/src/components/eas/eas.js b/backend/src/components/eas/eas.js index b3109428..bc630391 100644 --- a/backend/src/components/eas/eas.js +++ b/backend/src/components/eas/eas.js @@ -58,7 +58,7 @@ async function updateAssessmentSession(req, res) { return res.status(HttpStatus.OK).json(result); } catch (e) { logApiError(e, 'updateAssessmentSession', 'Error occurred while attempting to save the changes to the assessment session.'); - return errorResponse(res); + return handleExceptionResponse(e, res); } } @@ -93,7 +93,7 @@ async function getAssessmentStudentsPaginated(req, res) { res.status(HttpStatus.OK).json(null); } else { await logApiError(e, 'Error getting eas assessment student paginated list'); - return errorResponse(res); + return handleExceptionResponse(e, res); } } } @@ -108,7 +108,7 @@ async function getAssessmentStudentByID(req, res) { res.status(HttpStatus.OK).json(null); } else { await logApiError(e, 'Error getting eas assessment student'); - return errorResponse(res); + return handleExceptionResponse(e, res); } } } @@ -131,10 +131,21 @@ async function updateAssessmentStudentByID(req, res) { return res.status(HttpStatus.OK).json(result); } catch (e) { logApiError(e, 'updateAssessmentStudent', 'Error occurred while attempting to save the changes to the assessment student registration.'); - return errorResponse(res); + return handleExceptionResponse(e, res); } } +async function deleteAssessmentStudentByID(req, res) { + try { + const result = await utils.deleteData(`${config.get('server:eas:assessmentStudentsURL')}/${req.params.assessmentStudentID}`); + return res.status(HttpStatus.OK).json(result); + } catch (e) { + logApiError(e, 'deleteAssessmentStudentByID', 'Error occurred while attempting to delete the assessment student registration.'); + return handleExceptionResponse(e, res); + } +} + + function includeAssessmentStudentProps(assessmentStudent) { if(assessmentStudent) { let school = cacheService.getSchoolBySchoolID(assessmentStudent.schoolID); @@ -172,7 +183,7 @@ function getAssessmentSpecialCases(req, res) { return res.status(HttpStatus.OK).json(Object.fromEntries(codes)); } catch (e) { logApiError(e, 'getAssessmentSpecialCases', 'Error occurred while attempting to get specialcase types.'); - return errorResponse(res); + return handleExceptionResponse(e, res); } } @@ -184,5 +195,6 @@ module.exports = { getAssessmentStudentsPaginated, getAssessmentStudentByID, updateAssessmentStudentByID, + deleteAssessmentStudentByID, getAssessmentSpecialCases }; diff --git a/backend/src/routes/eas.js b/backend/src/routes/eas.js index 42750b0d..d44f45a3 100644 --- a/backend/src/routes/eas.js +++ b/backend/src/routes/eas.js @@ -1,7 +1,7 @@ const passport = require('passport'); const express = require('express'); const router = express.Router(); -const { getAssessmentSessions, getAssessmentSessionsBySchoolYear, updateAssessmentSession, getAssessmentStudentsPaginated, getAssessmentStudentByID, updateAssessmentStudentByID, getAssessmentSpecialCases } = require('../components/eas/eas'); +const { getAssessmentSessions, getAssessmentSessionsBySchoolYear, updateAssessmentSession, getAssessmentStudentsPaginated, getAssessmentStudentByID, updateAssessmentStudentByID, getAssessmentSpecialCases, deleteAssessmentStudentByID } = require('../components/eas/eas'); const utils = require('../components/utils'); const extendSession = utils.extendSession(); const permUtils = require('../components/permissionUtils'); @@ -19,6 +19,7 @@ router.put('/assessment-sessions/:sessionID', passport.authenticate('jwt', {sess router.get('/assessment-registrations/student/:assessmentStudentID', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.VIEW_EAS_STUDENT_PERMISSION), extendSession, getAssessmentStudentByID); router.put('/assessment-registrations/student/:assessmentStudentID', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.EDIT_EAS_STUDENT_PERMISSION), extendSession, validate(putStudentAssessmentSchema), updateAssessmentStudentByID); router.get('/assessment-registrations/paginated', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.VIEW_EAS_STUDENT_PERMISSION), extendSession, getAssessmentStudentsPaginated); +router.delete('/assessment-registrations/student/:assessmentStudentID', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.EDIT_EAS_STUDENT_PERMISSION), extendSession, deleteAssessmentStudentByID); router.get('/assessment-specialcase-types', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.MANAGE_EAS_SESSIONS_PERMISSION), extendSession, getAssessmentSpecialCases); diff --git a/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue b/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue index c44a34c8..6b2e4e97 100644 --- a/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue +++ b/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue @@ -220,7 +220,7 @@ > 0; + return this.assessmentStudentDetail.proficiencyScore; }, getAssessmentStudentDetail(assessmentStudentID) { this.loadingCount += 1; @@ -475,6 +475,7 @@ export default { ApiService.apiAxios.get(`${Routes.eas.ASSESSMENT_STUDENTS}/${assessmentStudentID}`) .then(response => { this.assessmentStudentDetail = response.data; + this.assessmentStudentDetailCopy = cloneDeep(this.assessmentStudentDetail); this.refreshAssessmentTypes(this.assessmentStudentDetail.sessionID); this.setupActiveFlag(); this.setupSpecialCaseCodes(); @@ -524,9 +525,26 @@ export default { }, deleteStudentRegistration() { const confirmation = this.$refs.confirmRemoveStudentRegistration.open('Confirm Removal of Student Registration', null, {color: '#fff', width: 580, closeIcon: false, subtitle: false, dark: false, resolveText: 'Remove', rejectText: 'Cancel'}); - if (!confirmation) { - return; - } + confirmation.then((result) => { + if (result) { + this.loadingCount += 1; + ApiService.apiAxios.delete(`${Routes.eas.ASSESSMENT_STUDENTS}/`+this.selectedAssessmentStudentID) + .then(() => { + setSuccessAlert('Success! The student registration details have been deleted.'); + this.$emit('reset-student-registration-pagination'); + }).catch((error) => { + console.error(error); + setFailureAlert( + error?.response?.data?.message + ? error?.response?.data?.message + : 'An error occurred while trying to delete student registration details. Please try again later.' + ); + }).finally(() => { + this.loadingCount -= 1; + this.$emit('reset-student-registration-parent'); + }); + } + }); }, validateForm() { this.$refs?.registrationDetailsForm?.validate();