Skip to content
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
7 changes: 5 additions & 2 deletions backend/src/components/cache-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const cacheService = {
if (assessmentTypeCodesResponse && assessmentTypeCodesResponse.length > 0) {
assessmentTypeCodesMap.clear();
assessmentTypeCodesResponse.forEach(entry => {
assessmentTypeCodesMap.set(entry.assessmentTypeCode, entry.label);
assessmentTypeCodesMap.set(entry.assessmentTypeCode, {'label': entry.label, 'displayOrder': entry.displayOrder });
});
}
log.info(`Loaded ${assessmentTypeCodesMap.size} assessmentTypeCodes.`);
Expand Down Expand Up @@ -384,12 +384,15 @@ const cacheService = {
getGradDataCollectionValidationIssueCodes() {
return cachedData[constants.CACHE_KEYS.GDC_VALIDATION_ISSUE_TYPE_CODES].records;
},
getAssessmentTypeLabelByCode(assessmentTypeCode) {
getAssessmentTypeByCode(assessmentTypeCode) {
return assessmentTypeCodesMap.get(assessmentTypeCode);
},
getSpecialCaseTypeLabelByCode(specialCaseTypeCode) {
return assessmentSpecialCaseTypeCodesMap.get(specialCaseTypeCode);
},
getAllAssessmentSpecialCases(){
return assessmentSpecialCaseTypeCodesMap;
},
};

module.exports = cacheService;
98 changes: 79 additions & 19 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, getAccessToken, getData, getDataWithParams, errorResponse, handleExceptionResponse } = require('../utils');
const { logApiError, getAccessToken, getData, putData, getCreateOrUpdateUserValue, getDataWithParams, errorResponse, handleExceptionResponse } = require('../utils');
const HttpStatus = require('http-status-codes');
const config = require('../../config');
const cacheService = require('../cache-service');
Expand Down Expand Up @@ -39,8 +39,12 @@ async function getAssessmentSessionsBySchoolYear(req, res) {
const token = getAccessToken(req);
let data = await getData(token, url);
data.forEach(session => {
session.isOpen = new Date(session.activeFromDate) <= new Date() && new Date(session.activeUntilDate) >= new Date();
session.assessments.forEach(assessment => {
assessment.assessmentTypeName = cacheService.getAssessmentTypeLabelByCode(assessment.assessmentTypeCode)+' ('+assessment.assessmentTypeCode+')';
let assessmentType = cacheService.getAssessmentTypeByCode(assessment.assessmentTypeCode);
assessment.assessmentTypeName = assessmentType.label+' ('+assessment.assessmentTypeCode+')';
assessment.displayOrder = assessmentType.displayOrder;

});
});
return res.status(200).json(data);
Expand Down Expand Up @@ -78,22 +82,7 @@ async function getAssessmentStudentsPaginated(req, res) {
return res.status(HttpStatus.OK).json(result);
}
data?.content.forEach(value => {
let school = cacheService.getSchoolBySchoolID(value.schoolID);
let assessmentCenter = cacheService.getSchoolBySchoolID(value.assessmentCenterID);
let district = cacheService.getDistrictJSONByDistrictID(school.districtID);

value.schoolNumber = school.mincode;
value.schoolName = getSchoolName(school);
value.districtID = school.districtID;
value.districtNumber = district.districtNumber;
value.districtName = getDistrictName(district);
value.assessmentCenterNumber = assessmentCenter.mincode;
value.assessmentCenterName = getSchoolName(assessmentCenter);

value.assessmentTypeName = cacheService.getAssessmentTypeLabelByCode(value.assessmentTypeCode)+' ('+value.assessmentTypeCode+')';
value.provincialSpecialCaseName = value.provincialSpecialCaseName ? cacheService.getSpecialCaseTypeLabelByCode(value.provincialSpecialCaseCode) : '-';
value.sessionName = moment(value.courseMonth, 'MM').format('MMMM') +' '+value.courseYear;

includeAssessmentStudentProps(value);
});
return res.status(200).json(data);
} catch (e) {
Expand All @@ -106,6 +95,64 @@ async function getAssessmentStudentsPaginated(req, res) {
}
}

async function getAssessmentStudentByID(req, res) {
try {
const token = getAccessToken(req);
let data = await getData(token, `${config.get('eas:assessmentStudentsURL')}/${req.params.assessmentStudentID}`);
return res.status(200).json(includeAssessmentStudentProps(data));
} catch (e) {
if (e?.status === 404) {
res.status(HttpStatus.OK).json(null);
} else {
await logApiError(e, 'Error getting eas assessment student');
return errorResponse(res);
}
}
}

function includeAssessmentStudentProps(assessmentStudent) {
if(assessmentStudent) {
let school = cacheService.getSchoolBySchoolID(assessmentStudent.schoolID);
let assessmentCenter = cacheService.getSchoolBySchoolID(assessmentStudent.assessmentCenterID);
let district = cacheService.getDistrictJSONByDistrictID(school.districtID);

if(school && district) {
assessmentStudent.schoolName_desc = getSchoolName(school);
assessmentStudent.districtID = school.districtID;
assessmentStudent.districtName_desc = getDistrictName(district);
}

if(school && district) {
assessmentStudent.assessmentCenterName_desc = getSchoolName(assessmentCenter);
}

assessmentStudent.assessmentTypeName_desc = cacheService.getAssessmentTypeByCode(assessmentStudent.assessmentTypeCode).label+' ('+assessmentStudent.assessmentTypeCode+')';
assessmentStudent.provincialSpecialCaseName_desc = cacheService.getSpecialCaseTypeLabelByCode(assessmentStudent.provincialSpecialCaseCode);
assessmentStudent.sessionName_desc = moment(assessmentStudent.courseMonth, 'MM').format('MMMM') +' '+assessmentStudent.courseYear;
}
return assessmentStudent;
}

async function updateAssessmentStudentByID(req, res) {
if (req.params.assessmentStudentID !== req.body.assessmentStudentID) {
return res.status(HttpStatus.BAD_REQUEST).json({
message: 'The assessmentStudentID in the URL didn\'t match the assessmentStudentID in the request body.'
});
}
try {
const token = getAccessToken(req);
const payload = req.body;
payload.updateUser = getCreateOrUpdateUserValue(req);
payload.updateDate = null;
payload.createDate = null;
const result = await putData(token, payload, `${config.get('eas:assessmentStudentsURL')}/${req.params.assessmentStudentID}`, getCreateOrUpdateUserValue(req));
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);
}
}

function getSchoolName(school) {
return school.mincode + ' - ' + school.schoolName;
}
Expand All @@ -114,9 +161,22 @@ function getDistrictName(district) {
return district.districtNumber + ' - ' + district.name;
}

function getAssessmentSpecialCases(req, res) {
try {
const codes = cacheService.getAllAssessmentSpecialCases();
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);
}
}

module.exports = {
getAssessmentSessions,
getActiveAssessmentSessions,
getAssessmentSessionsBySchoolYear,
getAssessmentStudentsPaginated
getAssessmentStudentsPaginated,
getAssessmentStudentByID,
updateAssessmentStudentByID,
getAssessmentSpecialCases
};
8 changes: 6 additions & 2 deletions backend/src/routes/eas.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions backend/src/validations/eas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { object, string, boolean, number } = require('yup');
const { baseRequestSchema } = require('./base');

const putStudentAssessmentSchema = object({
body: object({
assessmentStudentID: string().nonNullable(),
sessionID:string().nonNullable(),
districtID: string().nonNullable(),
schoolID: string().nonNullable(),
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(),
proficiencyScore: number().nullable().optional(),
provincialSpecialCaseCode: string().max(1).nullable().optional(),
courseStatusCode: string().max(1).nullable().optional(),
numberOfAttempts: number().nullable(),
courseMonth: number().optional(),
courseYear: number().optional(),
}).concat(baseRequestSchema).noUnknown(),
params: object({
studentAssessmentID: string().nonNullable(),
}),
query: object().noUnknown(),
}).noUnknown();

module.exports = {
putStudentAssessmentSchema,
};
4 changes: 4 additions & 0 deletions frontend/src/common/apiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export default {
getAllActiveSchoolFundingCodes:getCodes(`${ApiRoutes.sdc.SDC_SCHOOL_FUNDING_CODES}?active=true`),
getAllActiveSpecialEdCodes:getCodes(`${ApiRoutes.sdc.SDC_SPECIAL_ED_CODES}?active=true`),
getAllCollectionTypeCodes: getCodes(`${ApiRoutes.sdc.COLLECTION_TYPE_CODES_URL}`),

getAllEASSpecialCaseCodes:getCodes(`${ApiRoutes.eas.GET_ASSESSMENT_SPECIALCASE_TYPES}`),


};
function getCodes(url) {
return async function getCodesHandler(query) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import StudentRegistrations from './registrations/StudentRegistrations.vue';
import ApiService from '../../common/apiService';
import { ApiRoutes } from '../../utils/constants';
import { mapState } from 'pinia';
import Spinner from "../common/Spinner.vue";
import {authStore} from "../../store/modules/auth";
import Spinner from '../common/Spinner.vue';
import {authStore} from '../../store/modules/auth';

export default {
name: 'AssessmentSessionDetail',
Expand Down Expand Up @@ -87,8 +87,7 @@ export default {
.get(
`${ApiRoutes.eas.GET_ASSESSMENT_SESSIONS}/school-year/` + this.schoolYear + '/' + this.userInfo.activeInstituteType,
{}
)
.then((response) => {
).then((response) => {
this.schoolYearSessions = response.data;
})
.catch((error) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<template>
<v-card id="viewStudentCard">
<v-card-title id="viewStudentCardTitle" class="sheetHeader pt-1 pb-1">
<v-row no-gutters>
<v-col class="d-flex justify-start"> Edit Student Registration</v-col>
<v-col class="d-flex justify-end">
<v-btn
id="cancel"
color="white"
text="Close"
size="30"
icon="mdi-close"
variant="tonal"
@click="cancel"
/>
</v-col>
</v-row>
</v-card-title>
<v-divider />
<v-card-text>
<EditStudentRegistration
:selected-assessment-student-id="selectedStudentRegistrationId"
:school-year-sessions="schoolYearSessions"
:save-event="saveStudentRegistration"
@form-validity="isValid"
@reset-student-registration-parent="reset()"
@reset-student-registration-pagination="closeAndReload()"
/>
</v-card-text>
</v-card>
</template>

<script>
import EditStudentRegistration from './forms/EditStudentRegistration.vue';

export default {
name: 'StudentRegistrationDetail',
components: {
EditStudentRegistration,
},
props: {
selectedStudentRegistrationId: {
type: String,
required: true,
default: null,
},
schoolYearSessions: {
type: Object,
required: true,
default: null,
}
},
emits: ['close-student-registration', 'reload-student-registrations'],
data() {
return {
studentRegistrationFormValid: true,
saveStudentRegistration: false,
studentRegistrationForEdit: {},
};
},
computed: {
},
created() {
},
mounted() {},
methods: {
setAssessmentStudentContext($event) {
this.studentRegistrationForEdit = $event;
this.selectedStudentRegistrationId = $event.assessmentStudentID;
},
save() {
this.saveStudent = true;
},
cancel() {
this.$emit('close-student-registration');
},
closeAndReload() {
this.$emit('reload-student-registrations');
this.$emit('close-student-registration');
},
isValid($event) {
this.studentRegistrationFormValid = $event;
},
reset() {
this.saveStudentRegistration = false;
this.$emit('reload-student-registrations');
},


},
};
</script>

<style scoped>
.sheetHeader {
background-color: #003366;
color: white;
font-size: medium !important;
font-weight: bolder !important;
}


.headerVal {
color: #7f7f7f;
}
</style>
Loading
Loading