Skip to content

Commit

Permalink
Adds validation issues to edit
Browse files Browse the repository at this point in the history
  • Loading branch information
eckermania committed Jan 2, 2025
1 parent 28418e9 commit ad96cee
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 279 deletions.
1 change: 0 additions & 1 deletion backend/src/components/eas/eas.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ async function deleteAssessmentStudentByID(req, res) {
}
}


function includeAssessmentStudentProps(assessmentStudent) {
if(assessmentStudent) {
let school = cacheService.getSchoolBySchoolID(assessmentStudent.schoolID);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/eas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
45 changes: 41 additions & 4 deletions backend/src/validations/eas.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ 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(),
pen: string().max(9).nonNullable(),
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(),
Expand All @@ -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({
Expand All @@ -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
};
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default {
},
},
created() {
this.applydefaultFilers();
this.applyDefaultFilters();
this.getAssessmentStudents();
},
methods: {
Expand All @@ -194,7 +194,7 @@ export default {
}
this.reloadStudentRegistrationsFlag = false;
},
applydefaultFilers() {
applyDefaultFilters() {
if (this.sessionID) {
const activeSession = this.schoolYearSessions.find(
(session) => session.sessionID === this.sessionID
Expand Down Expand Up @@ -253,9 +253,6 @@ export default {
openCreateStudentRegDialog() {
this.newStudentRegistrationSheet = !this.newStudentRegistrationSheet;
},
closeNewStudentRegModal() {
this.newStudentRegistrationSheet = false;
},
loadNext() {
if (this.canLoadNext) {
this.pageNumber += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</v-row>
<div v-else ref="topDiv">
<v-row class="d-flex">
<v-col :cols = "this.newStudentDetail.assessmentStudentValidationIssues.length > 0 ? 6 : 12">
<v-col :cols = "hasError ? 6 : 12">
<v-form ref="addRegistrationForm" v-model="addStudentRegistrationFormValid">
<v-row>
<v-col>
Expand Down Expand Up @@ -75,6 +75,15 @@
density="compact"
:rules="[rules.required(), rules.penIsValid()]"
/>
<v-text-field
id="LocalID"
v-model="newStudentDetail.localID"
label="Local ID"
variant="underlined"
:maxlength="25"
density="compact"
:rules="[rules.required(), rules.number()]"
/>
<v-text-field
id="SurName"
v-model="newStudentDetail.surName"
Expand Down Expand Up @@ -344,19 +353,19 @@ export default {
},
saveStudentRegistration() {
this.loadingCount += 1;
const postAssessmentStudentDetail = Object.fromEntries(
Object.entries(this.newStudentDetail).filter(([key]) => !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');
Expand Down
Loading

0 comments on commit ad96cee

Please sign in to comment.