Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EAC-38: Remove registration from the active session. #2131

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions backend/src/components/eas/eas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const { logApiError, getData, errorResponse, handleExceptionResponse } = require('../utils');
const { logApiError, getData, handleExceptionResponse } = require('../utils');
const HttpStatus = require('http-status-codes');
const utils = require('../utils');
const config = require('../../config');
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -184,5 +195,6 @@ module.exports = {
getAssessmentStudentsPaginated,
getAssessmentStudentByID,
updateAssessmentStudentByID,
deleteAssessmentStudentByID,
getAssessmentSpecialCases
};
3 changes: 2 additions & 1 deletion backend/src/routes/eas.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
>
<v-col class="d-flex justify-end mr-3 mt-3">
<v-btn
v-if="isSessionEditable && !hasProficiencyScore()"
v-if="isSessionEditable && !assessmentStudentDetailCopy.provincialSpecialCaseCode && !hasProficiencyScore()"
id="removeRecord"
color="#003366"
large-icon
Expand Down Expand Up @@ -261,14 +261,13 @@ import {
setFailureAlert,
setSuccessAlert,
} from '../../../composable/alertComposable';
import { sortBy } from 'lodash';
import { sortBy, cloneDeep } from 'lodash';
import { appStore } from '@/store/modules/app';
import { authStore } from '@/store/modules/auth';
import { mapState } from 'pinia';
import {easStore} from '@/store/modules/eas';
import { PROFICIENCY_SCORE_RANGE_FILTER } from '@/utils/eas/StudentRegistrationTableConfiguration.js';
import { PERMISSION, hasRequiredPermission } from '@/utils/constants/Permission';

import moment from 'moment';

export default {
Expand Down Expand Up @@ -315,6 +314,7 @@ export default {
proficiencyScoreSearchNames: [],
selectedAssessmentStudentID: null,
studentRegistrationDetailsFormValid: false,
assessmentStudentDetailCopy: {},
assessmentStudentDetail: {},
loadingCount: 0,
isActive: false,
Expand Down Expand Up @@ -467,14 +467,15 @@ export default {
return [];
},
hasProficiencyScore() {
return this.assessmentStudentDetail.proficiencyScore && Number(this.assessmentStudentDetail.proficiencyScore) > 0;
return this.assessmentStudentDetail.proficiencyScore;
},
getAssessmentStudentDetail(assessmentStudentID) {
this.loadingCount += 1;
this.selectedAssessmentStudentID=assessmentStudentID;
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();
Expand Down Expand Up @@ -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();
Expand Down
Loading