diff --git a/backend/src/components/eas/eas.js b/backend/src/components/eas/eas.js index 471c3425..1eb4fae0 100644 --- a/backend/src/components/eas/eas.js +++ b/backend/src/components/eas/eas.js @@ -177,7 +177,6 @@ async function deleteAssessmentStudentByID(req, res) { } } - function includeAssessmentStudentProps(assessmentStudent) { if(assessmentStudent) { let school = cacheService.getSchoolBySchoolID(assessmentStudent.schoolID); diff --git a/backend/src/routes/eas.js b/backend/src/routes/eas.js index b7f41387..9d797e09 100644 --- a/backend/src/routes/eas.js +++ b/backend/src/routes/eas.js @@ -7,7 +7,7 @@ const extendSession = utils.extendSession(); const permUtils = require('../components/permissionUtils'); const perm = require('../util/Permission'); const validate = require('../components/validator'); -const {putStudentAssessmentSchema} = require('../validations/eas'); +const {putStudentAssessmentSchema, postStudentAssessmentSchema} = require('../validations/eas'); const PERMISSION = perm.PERMISSION; @@ -16,7 +16,7 @@ router.get('/assessment-sessions', passport.authenticate('jwt', {session: false} router.get('/assessment-sessions/school-year/:schoolYear', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.MANAGE_EAS_SESSIONS_PERMISSION), extendSession, getAssessmentSessionsBySchoolYear); router.put('/assessment-sessions/:sessionID', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.MANAGE_EAS_SESSIONS_PERMISSION), extendSession, updateAssessmentSession); -router.post('/assessment-registrations/student', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.EDIT_EAS_STUDENT_PERMISSION), extendSession, postAssessmentStudent); +router.post('/assessment-registrations/student', passport.authenticate('jwt', {session: false}, undefined), permUtils.checkUserHasPermission(PERMISSION.EDIT_EAS_STUDENT_PERMISSION), extendSession, validate(postStudentAssessmentSchema), postAssessmentStudent); 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); diff --git a/backend/src/validations/eas.js b/backend/src/validations/eas.js index 88f79cf8..47cada38 100644 --- a/backend/src/validations/eas.js +++ b/backend/src/validations/eas.js @@ -5,9 +5,9 @@ const putStudentAssessmentSchema = object({ body: object({ assessmentStudentID: string().nonNullable(), sessionID:string().nonNullable(), - districtID: string().nonNullable(), + districtID: string().nullable().optional(), schoolID: string().nonNullable(), - assessmentCenterID: string().nullable().optional(), + assessmentCenterID: string().nonNullable(), assessmentID:string().nonNullable(), assessmentTypeCode: string().nonNullable(), studentID: string().nonNullable(), @@ -15,7 +15,7 @@ const putStudentAssessmentSchema = object({ localID: string().max(12).nonNullable(), givenName: string().max(25).nonNullable(), surName: string().max(25).nonNullable(), - isElectronicExam: boolean().nonNullable(), + isElectronicExam: boolean().nullable().optional(), proficiencyScore: number().nullable().optional(), provincialSpecialCaseCode: string().max(1).nullable().optional(), courseStatusCode: string().max(1).nullable().optional(), @@ -27,7 +27,9 @@ const putStudentAssessmentSchema = object({ assessmentStudentID:string().nullable().optional(), validationIssueSeverityCode:string().nullable().optional(), validationIssueCode:string().nullable().optional(), - validationIssueFieldCode:string().nullable().optional() + validationIssueFieldCode:string().nullable().optional(), + validationLabel:string().nullable().optional(), + validationMessage:string().nullable().optional(), }).concat(baseRequestSchema)).nullable().optional() }).concat(baseRequestSchema).noUnknown(), params: object({ @@ -36,6 +38,41 @@ const putStudentAssessmentSchema = object({ query: object().noUnknown(), }).noUnknown(); +const postStudentAssessmentSchema = object({ + body: object({ + sessionID:string().nonNullable(), + districtID: string().nonNullable(), + schoolID: string().nonNullable(), + assessmentCenterID: string().nonNullable(), + assessmentID:string().nonNullable(), + assessmentTypeCode: string().nonNullable(), + studentID: string().nullable().optional(), + assessmentStudentID: string().nullable().optional(), + courseStatusCode: string().nullable().optional(), + numberOfAttempts: string().nullable().optional(), + pen: string().max(9).nonNullable(), + localID: string().max(12).nonNullable(), + givenName: string().max(25).nonNullable(), + surName: string().max(25).nonNullable(), + isElectronicExam: boolean().nullable().optional(), + proficiencyScore: number().nullable().optional(), + provincialSpecialCaseCode: string().max(1).nullable().optional(), + assessmentStudentValidationIssues: array().of(object({ + assessmentStudentID:string().nullable().optional(), + validationIssueSeverityCode:string().nullable().optional(), + validationIssueCode:string().nullable().optional(), + validationIssueFieldCode: string().nullable().optional(), + validationLabel:string().nullable().optional(), + validationMessage:string().nullable().optional(), + }).concat(baseRequestSchema)).nullable().optional() + }).concat(baseRequestSchema).noUnknown(), + query: object().noUnknown(), + params: object({ + instituteType: string().nonNullable(), + }).noUnknown(), +}).noUnknown(); + module.exports = { putStudentAssessmentSchema, + postStudentAssessmentSchema }; diff --git a/frontend/src/components/assessments/registrations/StudentRegistrations.vue b/frontend/src/components/assessments/registrations/StudentRegistrations.vue index a04b9997..292e570d 100644 --- a/frontend/src/components/assessments/registrations/StudentRegistrations.vue +++ b/frontend/src/components/assessments/registrations/StudentRegistrations.vue @@ -172,7 +172,7 @@ export default { }, }, created() { - this.applydefaultFilers(); + this.applyDefaultFilters(); this.getAssessmentStudents(); }, methods: { @@ -194,7 +194,7 @@ export default { } this.reloadStudentRegistrationsFlag = false; }, - applydefaultFilers() { + applyDefaultFilters() { if (this.sessionID) { const activeSession = this.schoolYearSessions.find( (session) => session.sessionID === this.sessionID @@ -253,9 +253,6 @@ export default { openCreateStudentRegDialog() { this.newStudentRegistrationSheet = !this.newStudentRegistrationSheet; }, - closeNewStudentRegModal() { - this.newStudentRegistrationSheet = false; - }, loadNext() { if (this.canLoadNext) { this.pageNumber += 1; diff --git a/frontend/src/components/assessments/registrations/forms/AddStudentRegistration.vue b/frontend/src/components/assessments/registrations/forms/AddStudentRegistration.vue index 94c1fa0b..28f2d539 100644 --- a/frontend/src/components/assessments/registrations/forms/AddStudentRegistration.vue +++ b/frontend/src/components/assessments/registrations/forms/AddStudentRegistration.vue @@ -25,7 +25,7 @@
- + @@ -75,6 +75,15 @@ density="compact" :rules="[rules.required(), rules.penIsValid()]" /> + !key.endsWith('_desc')) + ); ApiService.apiAxios .post( `${Routes.eas.ASSESSMENT_STUDENTS}`, - this.newStudentDetail + postAssessmentStudentDetail ) .then((res) => { this.newStudentDetail = res.data; - console.log(this.newStudentDetail.assessmentStudentValidationIssues) if(this.newStudentDetail.assessmentStudentValidationIssues){ this.hasError = true; } else if(!this.newStudentDetail.assessmentStudentValidationIssues) { - console.log("found success"); this.hasError = false; setSuccessAlert('Success! The new student registration has been created.'); this.$emit('close-new-student-registration'); diff --git a/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue b/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue index db0c0300..32f55ed2 100644 --- a/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue +++ b/frontend/src/components/assessments/registrations/forms/EditStudentRegistration.vue @@ -4,241 +4,234 @@ -
- - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ - - - - - - - - - - - - - - - - - - - + style="margin-left: 1em" + align="start" + truncate-line="start" + > + + + +

+ {{ issue.validationLabel }} +

+
+
+ + + {{issue.validationMessage}} + + +
+
+
-
-
+ +
- - - @@ -317,12 +310,12 @@ export default { assessmentStudentDetailCopy: {}, assessmentStudentDetail: {}, loadingCount: 0, - isActive: false, - isSessionEditable: false + editPermitted: false, + hasError: false }; }, computed: { - ...mapState(appStore, [ 'activeSchools', 'activeSchools']), + ...mapState(appStore, [ 'activeSchools']), ...mapState(easStore, ['specialCaseCodes']), ...mapState(authStore, ['userInfo']), @@ -346,7 +339,7 @@ export default { removeEvent: { handler(value) { if (value) { - this.deleteRegistration(); + this.deleteStudentRegistration(); } }, }, @@ -372,7 +365,8 @@ export default { this.loading = false; }); }); - this.setupProficienctScore(); + this.setupProficiencyScore(); + this.checkEditPermission(); }, methods: { isLoading(){ @@ -401,12 +395,12 @@ export default { this.sessionSearchNames = sortBy(this.sessionSearchNames, ['sessionCourseYear','sessionCourseMonth']); }, setupSpecialCaseCodes($event) { + this.specialCaseSearchNames = []; if($event && Number($event) >0 && this.assessmentStudentDetail.provincialSpecialCaseCode === 'A') { return; } - this.specialCaseSearchNames = []; Object.keys(this.specialCaseCodes).forEach(key => { - if(!(this.hasProficiencyScore() && key === 'A')) { + if(!(this.assessmentStudentDetail.proficiencyScore && key === 'A')) { this.specialCaseSearchNames.push({ specialCaseCodeName: this.specialCaseCodes[key], specialCaseCodeValue: key @@ -415,8 +409,7 @@ export default { }); this.specialCaseSearchNames = sortBy(this.specialCaseSearchNames, ['specialCaseCodeName']); }, - setupProficienctScore() { - this.proficiencyScoreSearchNames = []; + setupProficiencyScore() { PROFICIENCY_SCORE_RANGE_FILTER.filterOptions.forEach(entry => { this.proficiencyScoreSearchNames.push({ proficiencyScoreCodeName: entry.id, @@ -456,18 +449,7 @@ export default { this.assessmentStudentDetail.assessmentID = null; this.assessmentStudentDetail.assessmentTypeName_desc = null; } - }, - validateProficiencyScore() { - if (this.assessmentStudentDetail) { - if (this.assessmentStudentDetail.provincialSpecialCaseCode === 'A' && this.hasProficiencyScore()) { - return ['Proficieny Score is not allowed']; - } - } - return []; - }, - hasProficiencyScore() { - return this.assessmentStudentDetail.proficiencyScore; - }, + }, getAssessmentStudentDetail(assessmentStudentID) { this.loadingCount += 1; this.selectedAssessmentStudentID=assessmentStudentID; @@ -476,7 +458,6 @@ export default { this.assessmentStudentDetail = response.data; this.assessmentStudentDetailCopy = cloneDeep(this.assessmentStudentDetail); this.refreshAssessmentTypes(this.assessmentStudentDetail.sessionID); - this.setupActiveFlag(); this.setupSpecialCaseCodes(); }).catch(error => { console.error(error); @@ -488,12 +469,8 @@ export default { } }); }, - setupActiveFlag() { - this.isActive = this.schoolYearSessions.find(session => session.sessionID === this.assessmentStudentDetail.sessionID)?.isOpen; - this.isSessionEditable = this.isActive; - }, - hasEditHistoryPermission() { - return !this.isActive && this.hasRequiredPermission(this.userInfo, PERMISSION.EDIT_EAS_HISTORY_PERMISSION); + checkEditPermission() { + this.editPermitted = this.hasRequiredPermission(this.userInfo, PERMISSION.EDIT_EAS_STUDENT_PERMISSION); }, saveStudentRegistration() { this.loadingCount += 1; @@ -505,9 +482,17 @@ export default { `${Routes.eas.ASSESSMENT_STUDENTS}/`+this.selectedAssessmentStudentID, putAssessmentStudentDetail ) - .then(() => { - setSuccessAlert('Success! The student registration details have been updated.'); - this.$emit('reset-student-registration-pagination'); + .then((res) => { + this.assessmentStudentDetail.assessmentStudentValidationIssues = res.data.assessmentStudentValidationIssues; + if(this.assessmentStudentDetail.assessmentStudentValidationIssues){ + this.hasError = true; + } else if(!this.assessmentStudentDetail.assessmentStudentValidationIssues) { + this.hasError = false; + setSuccessAlert('Success! The student registration details have been updated.'); + this.$emit('reset-student-registration-pagination'); + this.$emit('reset-student-registration-parent'); + } + this.loadingCount -= 1; }) .catch((error) => { console.error(error); @@ -517,10 +502,6 @@ export default { : 'An error occurred while trying to update student registration details. Please try again later.' ); }) - .finally(() => { - this.loadingCount -= 1; - this.$emit('reset-student-registration-parent'); - }); }, 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'}); @@ -551,8 +532,8 @@ export default { formatMonth(month) { return moment(month, 'MM').format('MMMM'); }, - getFieldColor(active) { - return active ? '#003366' : '#7f7f7f' ; + getFieldColor(editPermitted) { + return editPermitted ? '#003366' : '#7f7f7f' ; }, hasRequiredPermission }, diff --git a/frontend/src/utils/constants/Permission.js b/frontend/src/utils/constants/Permission.js index 63b7b402..c7027d08 100644 --- a/frontend/src/utils/constants/Permission.js +++ b/frontend/src/utils/constants/Permission.js @@ -42,7 +42,7 @@ export const PERMISSION = Object.freeze( MANAGE_EAS_SESSIONS_PERMISSION: 'MANAGE_EAS_SESSIONS_PERMISSION', - EDIT_EAS_HISTORY_PERMISSION: 'EDIT_EAS_HISTORY_PERMISSION' + EDIT_EAS_STUDENT_PERMISSION: 'EDIT_EAS_STUDENT_PERMISSION' } ); diff --git a/frontend/src/utils/institute/formRules.js b/frontend/src/utils/institute/formRules.js index 64ff4105..31ecdadf 100644 --- a/frontend/src/utils/institute/formRules.js +++ b/frontend/src/utils/institute/formRules.js @@ -247,5 +247,5 @@ export { requiredWithOtherFieldValues, requiredIf, website, - penIsValid + penIsValid, };