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

Adds validation issues to edit #2160

Merged
merged 1 commit into from
Jan 2, 2025
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
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 @@ -61,9 +61,9 @@
location="right"
:temporary="true"
width="700"
:persistent="true"

Check warning on line 64 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@editSelectedRow' must be hyphenated

Check warning on line 64 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@editSelectedRow' must be hyphenated
scrim="transparent"

Check warning on line 65 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@loadNext' must be hyphenated

Check warning on line 65 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@loadNext' must be hyphenated
:border="true"

Check warning on line 66 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@loadPrevious' must be hyphenated

Check warning on line 66 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@loadPrevious' must be hyphenated
style="top: 0; height: 100%"
rounded="true"
>
Expand Down Expand Up @@ -101,7 +101,7 @@
>
<StudentRegistrationDetail
:selected-student-registration-id="studentRegistrationForEdit?.assessmentStudentID"
:school-year-sessions="schoolYearSessions"

Check warning on line 104 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@update:sessionID' must be hyphenated

Check warning on line 104 in frontend/src/components/assessments/registrations/StudentRegistrations.vue

View workflow job for this annotation

GitHub Actions / test

v-on event '@update:sessionID' must be hyphenated
@reload-student-registrations="reloadStudentRegistrationsFlag = true"
@close-student-registration="closeEditAndLoadStudentRegistrations"
/>
Expand Down Expand Up @@ -172,7 +172,7 @@
},
},
created() {
this.applydefaultFilers();
this.applyDefaultFilters();
this.getAssessmentStudents();
},
methods: {
Expand All @@ -194,7 +194,7 @@
}
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 @@
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
Loading