Skip to content

Commit

Permalink
displays student registrations for sch/dis
Browse files Browse the repository at this point in the history
  • Loading branch information
eckermania committed Nov 20, 2024
1 parent 4f492ac commit f1f91c0
Show file tree
Hide file tree
Showing 13 changed files with 427 additions and 275 deletions.
42 changes: 41 additions & 1 deletion backend/src/components/cache-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ let specialEducationCodesMap = new Map();
let homeLanguageSpokenCodesMap = new Map();
let rolePermissionsMap = new Map();
let documentTypeCodesMap = new Map();
let assessmentTypeCodesMap = new Map();
let assessmentSpecialCaseTypeCodesMap = new Map();
let documentTypeCodes = [];
const cachedData = {};

Expand Down Expand Up @@ -102,6 +104,38 @@ const cacheService = {
});

},
async loadAllAssessmentTypeCodesToMap() {
log.debug('Loading all assessment Type Codes during start up');
await retry(async () => {
const data = await getApiCredentials();
const assessmentTypeCodesResponse = await getData(data.accessToken, `${config.get('eas:assessmentTypeCodeURL')}`);
if (assessmentTypeCodesResponse && assessmentTypeCodesResponse.length > 0) {
assessmentTypeCodesMap.clear();
assessmentTypeCodesResponse.forEach(entry => {
assessmentTypeCodesMap.set(entry.assessmentTypeCode, entry.label);
});
}
log.info(`Loaded ${assessmentTypeCodesMap.size} assessmentTypeCodes.`);
}, {
retries: 50
});
},
async loadAllSpecialCaseTypeCodesToMap() {
log.debug('Loading all specialcase Type Codes during start up');
await retry(async () => {
const data = await getApiCredentials();
const provincialSpecialCaseTypeCodesResponse = await getData(data.accessToken, `${config.get('eas:assessmentSpecialCaseTypeCodeURL')}`);
if (provincialSpecialCaseTypeCodesResponse && provincialSpecialCaseTypeCodesResponse.length > 0) {
assessmentSpecialCaseTypeCodesMap.clear();
provincialSpecialCaseTypeCodesResponse.forEach(entry => {
assessmentSpecialCaseTypeCodesMap.set(entry.provincialSpecialCaseCode, entry.label);
});
}
log.info(`Loaded ${assessmentSpecialCaseTypeCodesMap.size} assessmentSpecialCaseTypeCodes.`);
}, {
retries: 50
});
},
getAllActiveAuthoritiesJSON(){
return activeAuthorities;
},
Expand Down Expand Up @@ -346,7 +380,13 @@ const cacheService = {
},
getAllStudentValidationIssueCodes() {
return cachedData[constants.CACHE_KEYS.SDC_VALIDATION_ISSUE_TYPE_CODES].records;
}
},
getAssessmentTypeLabelByCode(assessmentTypeCode) {
return assessmentTypeCodesMap.get(assessmentTypeCode);
},
getSpecialCaseTypeLabelByCode(specialCaseTypeCode) {
return assessmentSpecialCaseTypeCodesMap.get(specialCaseTypeCode);
},
};

module.exports = cacheService;
13 changes: 7 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, getAccessToken, getData, errorResponse, handleExceptionResponse } = require('../utils');
const { logApiError, getAccessToken, getData, getDataWithParams, errorResponse, handleExceptionResponse } = require('../utils');
const HttpStatus = require('http-status-codes');
const config = require('../../config');
const cacheService = require('../cache-service');
Expand Down Expand Up @@ -36,7 +36,8 @@ async function getActiveAssessmentSessions(req, res) {
async function getAssessmentSessionsBySchoolYear(req, res) {
try {
const url = `${config.get('eas:assessmentSessionsURL')}/school-year/${req.params.schoolYear}`;
let data = await getData(url);
const token = getAccessToken(req);
let data = await getData(token, url);
data.forEach(session => {
session.assessments.forEach(assessment => {
assessment.assessmentTypeName = cacheService.getAssessmentTypeLabelByCode(assessment.assessmentTypeCode)+' ('+assessment.assessmentTypeCode+')';
Expand All @@ -49,7 +50,6 @@ async function getAssessmentSessionsBySchoolYear(req, res) {
}
}


async function getAssessmentStudentsPaginated(req, res) {
try {
const search = [];
Expand All @@ -70,7 +70,8 @@ async function getAssessmentStudentsPaginated(req, res) {
}
};

let data = await getData(`${config.get('eas:assessmentStudentsURL')}/paginated`, params);
const token = getAccessToken(req);
let data = await getDataWithParams(token,`${config.get('eas:assessmentStudentsURL')}/paginated`, params);

if (req?.query?.returnKey) {
let result = data?.content.map((student) => student[req?.query?.returnKey]);
Expand All @@ -79,7 +80,7 @@ async function getAssessmentStudentsPaginated(req, res) {
data?.content.forEach(value => {
let school = cacheService.getSchoolBySchoolID(value.schoolID);
let assessmentCenter = cacheService.getSchoolBySchoolID(value.assessmentCenterID);
let district = cacheService.getDistrictJSONByDistrictId(school.districtID);
let district = cacheService.getDistrictJSONByDistrictID(school.districtID);

value.schoolNumber = school.mincode;
value.schoolName = getSchoolName(school);
Expand All @@ -90,7 +91,7 @@ async function getAssessmentStudentsPaginated(req, res) {
value.assessmentCenterName = getSchoolName(assessmentCenter);

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

});
Expand Down
36 changes: 11 additions & 25 deletions backend/src/components/eas/studentFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { FILTER_OPERATION, VALUE_TYPE, CONDITION} = require('../../util/constants
function createMoreFiltersSearchCriteria(searchFilter = []) {
let searchCriteriaList = [];

let districtNameNumberFilter = [];
let schoolNameNumberFilter = [];
let assessmentCenterNameNumberFilter = [];

Expand All @@ -21,6 +20,10 @@ function createMoreFiltersSearchCriteria(searchFilter = []) {
searchCriteriaList.push({ key: 'surName', value: pValue.toString(), operation: FILTER_OPERATION.CONTAINS_IGNORE_CASE, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND });
}

if (key === 'givenName' && pValue) {
searchCriteriaList.push({ key: 'givenName', value: pValue.toString(), operation: FILTER_OPERATION.CONTAINS_IGNORE_CASE, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND });
}

if (key === 'pen' && pValue) {
searchCriteriaList.push({ key: 'pen', value: pValue.toString(), operation: FILTER_OPERATION.EQUAL, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND });
}
Expand All @@ -29,9 +32,12 @@ function createMoreFiltersSearchCriteria(searchFilter = []) {
searchCriteriaList.push({ key: 'localID', value: pValue.toString(), operation: FILTER_OPERATION.EQUAL, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND });
}

if (key === 'districtNameNumber' && pValue) {
let districtNameNumberCriteria = createDistrictNameNumberSearchCriteria(pValue.toString());
districtNameNumberFilter = [...districtNameNumberCriteria];
if (key === 'districtID' && pValue) {
searchCriteriaList.push({key: 'districtID', value: pValue[0], operation: FILTER_OPERATION.EQUAL, valueType: VALUE_TYPE.UUID, condition: CONDITION.AND})
}

if (key === 'schoolID' && pValue) {
searchCriteriaList.push({key: 'schoolID', value: pValue[0], operation: FILTER_OPERATION.EQUAL, valueType: VALUE_TYPE.UUID, condition: CONDITION.AND})
}

if (key === 'schoolNameNumber' && pValue) {
Expand Down Expand Up @@ -69,13 +75,7 @@ function createMoreFiltersSearchCriteria(searchFilter = []) {
}

}
const search = [];
if (districtNameNumberFilter.length > 0) {
search.push({
condition: CONDITION.AND,
searchCriteriaList: districtNameNumberFilter
});
}
const search = [];
if (schoolNameNumberFilter.length > 0) {
search.push({
condition: CONDITION.AND,
Expand All @@ -97,20 +97,6 @@ function createMoreFiltersSearchCriteria(searchFilter = []) {
return search;
}

function createDistrictNameNumberSearchCriteria(value) {
const searchDistrictCriteriaList = [];

searchDistrictCriteriaList.push({
key: 'districtID',
operation: FILTER_OPERATION.EQUAL,
value: value,
valueType: VALUE_TYPE.UUID,
condition: CONDITION.AND
});

return searchDistrictCriteriaList;
}

function createSchoolNameNumberSearchCriteria(value) {
const searchSchoolCriteriaList = [];

Expand Down
15 changes: 15 additions & 0 deletions backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const NATS = require('./messaging/message-pub-sub');
if(process.env.NODE_ENV !== 'test'){ //do not cache for test environment to stop GitHub Actions test from hanging.
const cacheService = require('./components/cache-service');
const sdcDisabled = config.get('frontendConfig').disableSdcFunctionality;
const easDisabled = config.get('frontendConfig').disableEASFunctionality;
cacheService.loadAllSchoolsToMap().then(() => {
log.info('Loaded school data to memory');
}).catch((e) => {
Expand Down Expand Up @@ -106,6 +107,20 @@ if(process.env.NODE_ENV !== 'test'){ //do not cache for test environment to sto
log.error('Error loading DISTRICT_CONTACT_TYPES data during boot .', e);
require('./schedulers/cache-service-scheduler');
});

if(!easDisabled) {
cacheService.loadAllAssessmentTypeCodesToMap().then(() => {
log.info('Loaded AssessmentTypeCodes data to memory');
}).catch((e) => {
log.error('Error loading AssessmentTypeCodes during boot .', e);
});
cacheService.loadAllSpecialCaseTypeCodesToMap().then(() => {
log.info('Loaded SpecialCaseTypeCodes data to memory');
}).catch((e) => {
log.error('Error loading SpecialCaseTypeCodes during boot .', e);
});
}

if(!sdcDisabled) {
cacheService.loadDataToCache(constants.CACHE_KEYS.SDC_BAND_CODES, 'sdc:bandCodesURL').then(() => {
log.info('Loaded SDC_BAND_CODES data to memory');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
<script>
import alertMixin from '../../mixins/alertMixin';
import StudentRegistrations from './registrations/StudentRegistrations.vue';
import Spinner from '@/components/common/Spinner.vue';
import ApiService from '../../common/apiService';
import { Routes } from '../../utils/constants';
import { authStore } from '../store/modules/auth';
import { ApiRoutes } from '../../utils/constants';
import { mapState } from 'pinia';
import Spinner from "../common/Spinner.vue";
import {authStore} from "../../store/modules/auth";
export default {
name: 'AssessmentSessionDetail',
Expand Down Expand Up @@ -85,8 +85,7 @@ export default {
this.loading = true;
ApiService.apiAxios
.get(
`${Routes.eas.GET_ASSESSMENT_SESSIONS}/school-year/` +
this.schoolYear,
`${ApiRoutes.eas.GET_ASSESSMENT_SESSIONS}/school-year/` + this.schoolYear + '/' + this.userInfo.activeInstituteType,
{}
)
.then((response) => {
Expand All @@ -100,7 +99,11 @@ export default {
});
},
backToAssesmentSessions() {
this.$router.push({ name: 'assessment-sessions' });
if(this.userInfo.activeInstituteType === 'DISTRICT'){
this.$router.push({name: 'district-assessment-sessions', params: {institutionID: this.userInfo.activeInstituteIdentifier}});
} else {
this.$router.push({name: 'school-assessment-sessions', params: {institutionID: this.userInfo.activeInstituteIdentifier}});
}
},
},
};
Expand Down
45 changes: 27 additions & 18 deletions frontend/src/components/assessments/AssessmentSessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<h2>School Year: {{ schoolYear }}</h2>
<v-btn
variant="text"
@click="goToSchoolYearRegistrations()"
>
<span
class="ml-1 pr-2"
Expand Down Expand Up @@ -48,6 +49,7 @@
>
<SessionCard
:session="session"
:school-year = "schoolYear"
/>
</v-col>
</v-row>
Expand All @@ -58,6 +60,7 @@
</v-row>
<v-row>
<v-data-table
v-if="!loading"
id="session-history-dataTable"
v-model:items-per-page="itemsPerPage"
:page="pageNumber"
Expand All @@ -74,7 +77,8 @@
]"
:hover="true"
class="fill-height"
style="border-radius: 0"
style="border-radius: 0"
@click:row="goToHistoricalSessionRegistrations"
>
<template #top>
<v-text-field
Expand Down Expand Up @@ -107,7 +111,6 @@ import ApiService from '../../common/apiService';
import { ApiRoutes } from '../../utils/constants';
import { authStore } from '../../store/modules/auth';
import { mapState } from 'pinia';
import moment from 'moment';
export default {
Expand All @@ -128,7 +131,7 @@ export default {
search: null,
itemsPerPage: 5,
pageNumber: 1,
allsessions: [],
allSessions: [],
headers: [
{ title: 'School Year', key: 'schoolYear' },
{ title: 'Course Month', key: 'courseMonth' },
Expand All @@ -140,28 +143,29 @@ export default {
editSession: null,
headerSearchParams: {},
headerSortParams: {},
loading: true
};
},
computed: {
...mapState(authStore, ['userInfo']),
activeSessions() {
const orderedSessions = [];
const allsessions = this.allsessions
const allSessions = this.allSessions
.filter(session => session.isOpen)
.map((session) => {
return {
...session,
courseMonth: this.formatMonth(session.courseMonth)
};
});
allsessions.sort((a, b) => new Date(a.activeUntilDate) - new Date(b.activeUntilDate));
for (let i = 0; i < allsessions.length; i += 2) {
orderedSessions.push(allsessions.slice(i, i + 2));
allSessions.sort((a, b) => new Date(a.activeUntilDate) - new Date(b.activeUntilDate));
for (let i = 0; i < allSessions.length; i += 2) {
orderedSessions.push(allSessions.slice(i, i + 2));
}
return orderedSessions;
},
historicalSessions() {
const allsessions = this.allsessions
const allSessions = this.allSessions
.filter(session => !session.isOpen)
.map((entry) => {
return {
Expand All @@ -171,11 +175,8 @@ export default {
courseMonth: this.formatMonth(entry.courseMonth),
};
});
return allsessions;
return allSessions;
},
sessionHeaderSlotName() {
return `column.${this.sessionid}`;
}
},
created() {
this.getAllAssessmentSessions();
Expand All @@ -186,9 +187,9 @@ export default {
ApiService.apiAxios
.get(`${ApiRoutes.eas.GET_ASSESSMENT_SESSIONS}` + '/' + this.userInfo.activeInstituteType, {})
.then((response) => {
this.allsessions = response.data.sort((a, b) => new Date(b.activeUntilDate) - new Date(a.activeUntilDate));
if(this.allsessions.length >0) {
this.schoolYear = this.allsessions[0].schoolYear;
this.allSessions = response.data.sort((a, b) => new Date(b.activeUntilDate) - new Date(a.activeUntilDate));
if(this.allSessions.length >0) {
this.schoolYear = this.allSessions[0].schoolYear;
}
})
.catch((error) => {
Expand All @@ -205,10 +206,18 @@ export default {
return moment(month, 'MM').format('MMMM');
},
goToSchoolYearRegistrations() {
this.$router.push({name: 'assessment-session-detail', params: {schoolYear: this.schoolYear?.replace(/\//g, '-'), sessionID: null}});
if(this.userInfo.activeInstituteType === 'DISTRICT'){
this.$router.push({name: 'district-assessment-session-detail', params: {schoolYear: this.schoolYear?.replace(/\//g, '-'), sessionID: null, sessionMonth: null}});
} else {
this.$router.push({name: 'school-assessment-session-detail', params: {schoolYear: this.schoolYear?.replace(/\//g, '-'), sessionID: null, sessionMonth: null}});
}
},
goToSessionRegistrations(e, { item }) {
this.$router.push({name: 'assessment-session-detail', params: {schoolYear: item?.raw?.schoolYear?.replace(/\//g, '-'), sessionID: item?.raw?.sessionID}});
goToHistoricalSessionRegistrations(e, { item }) {
if(this.userInfo.activeInstituteType === 'DISTRICT'){
this.$router.push({name: 'district-assessment-session-detail', params: {schoolYear: item?.schoolYear?.replace(/\//g, '-'), sessionID: item?.sessionID}});
} else {
this.$router.push({name: 'school-assessment-session-detail', params: {schoolYear: item?.schoolYear?.replace(/\//g, '-'), sessionID: item?.sessionID}});
}
},
backButtonClick() {
this.$router.push({name: 'home'});
Expand Down
Loading

0 comments on commit f1f91c0

Please sign in to comment.