From ca1bda3d63bd9816bddba4b45dd7a0047fe61c58 Mon Sep 17 00:00:00 2001 From: Avisha Sodhi <38086281+SodhiA1@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:22:00 -0700 Subject: [PATCH 1/2] Updates to endpoints --- backend/src/components/sdc.js | 23 ++++++------------- backend/src/routes/sdc.js | 5 ++-- .../src/components/common/DuplicateTab.vue | 2 +- .../src/components/common/EditStudent.vue | 5 +++- .../EnrollmentDuplicateResolveViaRemove.vue | 11 ++++----- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/backend/src/components/sdc.js b/backend/src/components/sdc.js index 81790c3a..1d3ab7ef 100644 --- a/backend/src/components/sdc.js +++ b/backend/src/components/sdc.js @@ -363,23 +363,15 @@ async function updateAndValidateSdcSchoolCollectionStudent(req, res) { } -async function deleteSDCSchoolCollectionStudent(req, res) { - try { - log.info('User :: ' + getCreateOrUpdateUserValue(req) + ' is removing SDC student :: ' + req.params.sdcSchoolCollectionStudentID); - const token = getAccessToken(req); - let deletedSdcSchoolCollectionStudentData = await deleteData(token, `${config.get('sdc:schoolCollectionStudentURL')}/${req.params.sdcSchoolCollectionStudentID}`, req.session?.correlationID); - return res.status(HttpStatus.OK).json(deletedSdcSchoolCollectionStudentData); - } catch (e) { - log.error('Error deleting SDC School Collection Student.', e.stack); - return handleExceptionResponse(e, res); - } -} - async function removeSDCSchoolCollectionStudents(req, res) { try { - log.info('EDX User :: ' + getCreateOrUpdateUserValue(req) + ' is removing SDC students :: ' + JSON.stringify(req.body)); const token = getAccessToken(req); - let deletedSdcSchoolCollectionStudentData = await postData(token, req.body, `${config.get('sdc:schoolCollectionStudentURL')}/soft-delete-students`); + let payload = { + softDeleteStudentIDs: req.body, + updateUser: getCreateOrUpdateUserValue(req) + } + log.info('EDX User :: ' + getCreateOrUpdateUserValue(req) + ' is removing SDC students :: ' + JSON.stringify(payload)); + let deletedSdcSchoolCollectionStudentData = await postData(token, payload, `${config.get('sdc:schoolCollectionStudentURL')}/soft-delete-students`); return res.status(HttpStatus.OK).json(deletedSdcSchoolCollectionStudentData); } catch (e) { log.error('Error deleting SDC School Collection Students.', e.stack); @@ -1121,7 +1113,7 @@ async function resolveDuplicates(req, res) { student.sdcSchoolCollectionStudentEnrolledPrograms = null; }); - const data = await postData(token, payload, `${config.get('sdc:sdcDuplicateURL')}/${req.params.sdcDuplicateID}/type/${req.params.type}`, req.session?.correlationID); + const data = await postData(token, payload, `${config.get('sdc:sdcDuplicateURL')}/type/${req.params.type}`, req.session?.correlationID); await redisUtil.unlockSdcDuplicateBeingProcessedInRedis(duplicateLock); return res.status(HttpStatus.OK).json(data); } catch (e) { @@ -1279,7 +1271,6 @@ module.exports = { getSDCSchoolCollectionStudentSummaryCounts, getSDCSchoolCollectionStudentDetail, updateAndValidateSdcSchoolCollectionStudent, - deleteSDCSchoolCollectionStudent, markSdcSchoolCollectionStudentAsDifferent, getStudentHeadcounts, getSdcSchoolCollectionMonitoringBySdcDistrictCollectionId, diff --git a/backend/src/routes/sdc.js b/backend/src/routes/sdc.js index 02e519ca..922205ee 100644 --- a/backend/src/routes/sdc.js +++ b/backend/src/routes/sdc.js @@ -3,7 +3,7 @@ const express = require('express'); const router = express.Router(); const { getCollectionBySchoolId, getCollectionByDistrictId, uploadFile, reportZeroEnrollment, getSdcFileProgress, getDistrictSdcFileProgress, updateSchoolCollection, getSchoolCollectionById, getDistrictCollectionById, getSDCSchoolCollectionStudentPaginated, getSDCSchoolCollectionStudentSummaryCounts, - getSDCSchoolCollectionStudentDetail, updateAndValidateSdcSchoolCollectionStudent, deleteSDCSchoolCollectionStudent, removeSDCSchoolCollectionStudents, + getSDCSchoolCollectionStudentDetail, updateAndValidateSdcSchoolCollectionStudent, removeSDCSchoolCollectionStudents, getStudentHeadcounts, downloadSdcReport, getSchoolStudentDuplicates, getSchoolSdcDuplicates, getProvincialDuplicatesForSchool, getStudentDifferencesByInstituteCollectionId, markSdcSchoolCollectionStudentAsDifferent, getSdcSchoolCollectionMonitoringBySdcDistrictCollectionId, updateDistrictCollection, getDistrictHeadcounts, startFromPriorSeptCollection, getInDistrictDuplicates, unsubmitSdcSchoolCollection, resolveDuplicates, getSdcSchoolCollections, getProvincialDuplicates, getStudentValidationIssueCodes, submitDistrictSignature, getSdcDistrictCollectionPaginated, getSdcSchoolCollectionPaginated} = require('../components/sdc'); @@ -74,7 +74,8 @@ router.post('/sdcSchoolCollectionStudent', passport.authenticate('jwt', {session router.post('/resolve-duplicates/:sdcDuplicateID/:type', passport.authenticate('jwt', {session: false}, undefined), isValidBackendToken, validateAccessToken, checkEdxUserPermission(PERMISSION.SCHOOL_SDC_EDIT), validate(resolveDuplicateSchema), checkSdcDuplicateAccess, findSdcSchoolCollectionsInDuplicate, checkUserAccessToDuplicateSdcSchoolCollections, resolveDuplicates); router.post('/sdcSchoolCollectionStudent/:sdcSchoolCollectionID/markDiff', passport.authenticate('jwt', {session: false}, undefined), isValidBackendToken, validateAccessToken, checkEdxUserPermission(PERMISSION.SCHOOL_SDC_EDIT), validate(markDiffSchema), findSdcSchoolCollectionID_params, loadSdcSchoolCollection, checkSdcSchoolCollectionAccess, markSdcSchoolCollectionStudentAsDifferent); -router.delete('/sdcSchoolCollectionStudent/:sdcSchoolCollectionStudentID', passport.authenticate('jwt', {session: false}, undefined), validateAccessToken, checkEdxUserPermission(PERMISSION.SCHOOL_SDC_EDIT), validate(getBySdcSchoolCollectionStudentSchema), findSdcSchoolCollectionStudentID_params, loadSdcSchoolCollectionStudent, findSdcSchoolCollectionID_fromRequestedSdcSchoolCollectionStudent, loadSdcSchoolCollection, checkSdcSchoolCollectionAccess, deleteSDCSchoolCollectionStudent); + + router.post('/sdcSchoolCollectionStudent/:sdcSchoolCollectionID/students/remove', passport.authenticate('jwt', {session: false}, undefined), isValidBackendToken, validateAccessToken, checkEdxUserPermission(PERMISSION.SCHOOL_SDC_EDIT), validate(removeStudentFromSchoolCollectionSchema), findSdcSchoolCollectionID_params, loadSdcSchoolCollection, checkSdcSchoolCollectionAccess, removeSDCSchoolCollectionStudents); router.get('/sdcSchoolCollectionStudent/getStudentHeadcounts/:sdcSchoolCollectionID', passport.authenticate('jwt', {session: false}, undefined), isValidBackendToken, validateAccessToken, checkEdxUserPermission(PERMISSION.SCHOOL_SDC_VIEW), validate(getBySdcSchoolCollectionSchema), findSdcSchoolCollectionID_params, loadSdcSchoolCollection, checkSdcSchoolCollectionAccess, getStudentHeadcounts); diff --git a/frontend/src/components/common/DuplicateTab.vue b/frontend/src/components/common/DuplicateTab.vue index 09c4ac09..0351158b 100644 --- a/frontend/src/components/common/DuplicateTab.vue +++ b/frontend/src/components/common/DuplicateTab.vue @@ -488,7 +488,7 @@ export default defineComponent({ resolveEnrollmentDuplicateViaRemove(duplicate, sdcSchoolCollectionStudent) { this.selectedDuplicate = duplicate; this.selectedSdcSchoolCollectionStudent = sdcSchoolCollectionStudent; - this.$refs.resolveEnrollmentDuplicateViaRemoveStudent.removeAndResolveStudent(duplicate, sdcSchoolCollectionStudent); + this.$refs.resolveEnrollmentDuplicateViaRemoveStudent.removeAndResolveStudent(sdcSchoolCollectionStudent); }, closeAndRefreshDuplicates() { this.openProgramResolutionView = false; diff --git a/frontend/src/components/common/EditStudent.vue b/frontend/src/components/common/EditStudent.vue index 7980c2c5..39b54c41 100644 --- a/frontend/src/components/common/EditStudent.vue +++ b/frontend/src/components/common/EditStudent.vue @@ -835,7 +835,10 @@ export default { } this.loadingCount += 1; this.hasError = false; - ApiService.apiAxios.delete(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${this.selectedSdcStudentID}`, this.sdcSchoolCollectionStudentDetailCopy) + let studentToRemove = []; + studentToRemove.push(this.selectedSdcStudentID); + + ApiService.apiAxios.post(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${this.sdcSchoolCollectionStudentDetailCopy.sdcSchoolCollectionID}/students/remove`, studentToRemove) .then(() => { this.removeIndex = this.selectedStudents.findIndex(value => value === this.selectedSdcStudentID); this.selectedStudents.splice(this.removeIndex, 1); diff --git a/frontend/src/components/sdcCollection/sdcDistrictCollection/duplicates/EnrollmentDuplicateResolveViaRemove.vue b/frontend/src/components/sdcCollection/sdcDistrictCollection/duplicates/EnrollmentDuplicateResolveViaRemove.vue index bd34b8be..d1094374 100644 --- a/frontend/src/components/sdcCollection/sdcDistrictCollection/duplicates/EnrollmentDuplicateResolveViaRemove.vue +++ b/frontend/src/components/sdcCollection/sdcDistrictCollection/duplicates/EnrollmentDuplicateResolveViaRemove.vue @@ -25,17 +25,16 @@ export default { }, methods: { displayName, - async removeAndResolveStudent(duplicate, sdcSchoolCollectionStudent) { + async removeAndResolveStudent(sdcSchoolCollectionStudent) { this.sdcSchoolCollectionStudent = sdcSchoolCollectionStudent; + let studentToRemove = []; + studentToRemove.push(this.sdcSchoolCollectionStudent.sdcSchoolCollectionStudentID); + const confirmation = await this.$refs.confirmResolveEnrollmentDuplicateViaRemoveStudent.open('Remove Student', null, {color: '#fff', width: 580, closeIcon: false, subtitle: false, dark: false, resolveText: 'Remove', rejectText: 'Cancel'}); if (!confirmation) { return; } - let payload = { - students: [this.sdcSchoolCollectionStudent], - duplicate: duplicate - }; - ApiService.apiAxios.post(ApiRoutes.sdc.SDC_DUPLICATE_RESOLVE + '/'+ duplicate?.sdcDuplicateID + '/DELETE_ENROLLMENT_DUPLICATE', payload) + ApiService.apiAxios.post(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${this.sdcSchoolCollectionStudent.sdcSchoolCollectionID}/students/remove`, studentToRemove) .then(() => { setSuccessAlert('Success! The student has been removed.'); }).catch(error => { From 930505c89152dc7facfd61a586cf281733596063 Mon Sep 17 00:00:00 2001 From: Avisha Sodhi <38086281+SodhiA1@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:22:55 -0700 Subject: [PATCH 2/2] Update sdc.js --- backend/src/components/sdc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/components/sdc.js b/backend/src/components/sdc.js index 1d3ab7ef..ebff2756 100644 --- a/backend/src/components/sdc.js +++ b/backend/src/components/sdc.js @@ -1,5 +1,5 @@ 'use strict'; -const { getAccessToken, handleExceptionResponse, getData, postData, putData, getDataWithParams, deleteData, formatNumberOfCourses, stripNumberFormattingNumberOfCourses, +const { getAccessToken, handleExceptionResponse, getData, postData, putData, getDataWithParams, formatNumberOfCourses, stripNumberFormattingNumberOfCourses, getCreateOrUpdateUserValue} = require('./utils'); const { edxUserHasAccessToInstitute } = require('./permissionUtils'); const HttpStatus = require('http-status-codes');