diff --git a/backend/src/components/eas/eas.js b/backend/src/components/eas/eas.js index 75c9d513..bd3b49c8 100644 --- a/backend/src/components/eas/eas.js +++ b/backend/src/components/eas/eas.js @@ -21,10 +21,15 @@ async function getAssessmentSessions(req, res) { async function getAssessmentSessionsBySchoolYear(req, res) { try { const url = `${config.get('server:eas:assessmentSessionsURL')}/school-year/${req.params.schoolYear}`; - const data = await getData(url); + let data = await getData(url); + data.forEach(session => { + session.assessments.forEach(assessment => { + assessment.assessmentTypeName = cacheService.getAssessmentTypeLabelByCode(assessment.assessmentTypeCode)+' ('+assessment.assessmentTypeCode+')'; + }); + }); return res.status(200).json(data); } catch (e) { - logApiError(e, 'getSessions', 'Error occurred while attempting to GET sessions.'); + logApiError(e, 'getSessions', 'Error occurred while attempting to GET sessions by school year.'); return handleExceptionResponse(e, res); } } @@ -71,29 +76,29 @@ async function getAssessmentStudentsPaginated(req, res) { } }; - let data = await getData(`${config.get('server:eas:assessmentStudentsURL')}/paginated`, params); if (req?.query?.returnKey) { let result = data?.content.map((student) => student[req?.query?.returnKey]); return res.status(HttpStatus.OK).json(result); } - data?.content.forEach(value => { let school = cacheService.getSchoolBySchoolID(value.schoolID); - let assessmentCenter = cacheService.getSchoolBySchoolID(value.assessmentCenter); + let assessmentCenter = cacheService.getSchoolBySchoolID(value.assessmentCenterID); let district = cacheService.getDistrictJSONByDistrictId(school.districtID); + value.schoolNumber = school.mincode; value.schoolName = getSchoolName(school); - value.districtName = getDistrictName(district); - value.districtNumber = district.districtNumber; value.districtID = school.districtID; - value.mincode = cacheService.getSchoolBySchoolID(value.schoolID)?.mincode; + 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 = cacheService.getSpecialCaseTypeLabelByCode(value.provincialSpecialCaseCode); value.sessionName = moment(value.courseMonth, 'MM').format('MMMM') +' '+value.courseYear; + }); return res.status(200).json(data); } catch (e) { diff --git a/backend/src/components/eas/studentFilters.js b/backend/src/components/eas/studentFilters.js index 863e7325..7d583a82 100644 --- a/backend/src/components/eas/studentFilters.js +++ b/backend/src/components/eas/studentFilters.js @@ -1,23 +1,105 @@ 'use strict'; const { FILTER_OPERATION, VALUE_TYPE, CONDITION} = require('../../util/constants'); - function createMoreFiltersSearchCriteria(searchFilter = []) { let searchCriteriaList = []; + + let districtNameNumberFilter = []; + let schoolNameNumberFilter = []; + let assessmentCenterNameNumberFilter = []; + let scoreRangeList = []; + for (const [key, filter] of Object.entries(searchFilter)) { let pValue = filter ? filter.map(filter => filter.value) : null; - if (key === 'specialCaseCode' && pValue) { - searchCriteriaList.push({ key: 'provincialSpecialCaseCode', value: pValue.toString(), operation: FILTER_OPERATION.IN, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND }); + + //Default Filter Begin + if (key === 'schoolYear' && pValue) { + searchCriteriaList.push({ key: 'assessmentEntity.sessionEntity.schoolYear', value: pValue[0].replace('-', '/'), operation: FILTER_OPERATION.EQUAL, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND }); } + if (key === 'sessionID' && pValue) { searchCriteriaList.push({ key: 'assessmentEntity.sessionEntity.sessionID', value: pValue[0], operation: FILTER_OPERATION.IN, valueType: VALUE_TYPE.UUID, condition: CONDITION.AND }); } - if (key === 'schoolYear' && pValue) { - searchCriteriaList.push({ key: 'assessmentEntity.sessionEntity.schoolYear', value: pValue[0].replace('-', '/'), operation: FILTER_OPERATION.EQUAL, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND }); + //Default Filter End + + if (key === 'surName' && pValue) { + searchCriteriaList.push({ key: 'surName', 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 }); + } + + if (key === 'localID' && pValue) { + 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 === 'schoolNameNumber' && pValue) { + let schoolNameNumberCriteria = createSchoolNameNumberSearchCriteria(pValue.toString()); + schoolNameNumberFilter = [...schoolNameNumberCriteria]; + } + + if (key === 'assessmentCenterNameNumber' && pValue) { + let schoolNameNumberCriteria = createAssessmentCenterNameNumberSearchCriteria(pValue.toString()); + assessmentCenterNameNumberFilter = [...schoolNameNumberCriteria]; + } + + if (key === 'sessions' && pValue) { + searchCriteriaList.push({ key: 'assessmentEntity.sessionEntity.sessionID', value: pValue.toString(), operation: FILTER_OPERATION.IN, valueType: VALUE_TYPE.UUID, condition: CONDITION.AND }); + } + + if (key === 'assessmentTypeCode' && pValue) { + searchCriteriaList.push({ key: 'assessmentEntity.assessmentTypeCode', value: pValue.toString(), operation: FILTER_OPERATION.IN, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND }); + } + + if (key === 'specialCaseCode' && pValue) { + searchCriteriaList.push({ key: 'provincialSpecialCaseCode', value: pValue.toString(), operation: FILTER_OPERATION.IN, valueType: VALUE_TYPE.STRING, condition: CONDITION.AND }); + } + + if (key === 'proficienyScore' && pValue) { + if(JSON.parse(pValue) === true) { + searchCriteriaList.push({ key: 'proficiencyScore', value: 0, operation: FILTER_OPERATION.GREATER_THAN, valueType: VALUE_TYPE.INTEGER, condition: CONDITION.AND }); + } else { + searchCriteriaList.push({ key: 'proficiencyScore', value:0, operation: FILTER_OPERATION.LESS_THAN_OR_EQUAL_TO, valueType: VALUE_TYPE.INTEGER, condition: CONDITION.AND }); + } + } + + if (key === 'proficienyScoreRange' && pValue) { + scoreRangeList = createScoreRangeFilter(pValue); } + + } + const search = []; + if (districtNameNumberFilter.length > 0) { + search.push({ + condition: CONDITION.AND, + searchCriteriaList: districtNameNumberFilter + }); + } + if (schoolNameNumberFilter.length > 0) { + search.push({ + condition: CONDITION.AND, + searchCriteriaList: schoolNameNumberFilter + }); + } + if (assessmentCenterNameNumberFilter.length > 0) { + search.push({ + condition: CONDITION.AND, + searchCriteriaList: assessmentCenterNameNumberFilter + }); + } + if(scoreRangeList.length > 0) { + search.push({ + condition: CONDITION.AND, + searchCriteriaList: scoreRangeList + }); } - const search = []; if (searchCriteriaList.length > 0) { search.push({ condition: CONDITION.AND, @@ -27,6 +109,59 @@ 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 = []; + + searchSchoolCriteriaList.push({ + key: 'schoolID', + operation: FILTER_OPERATION.EQUAL, + value: value, + valueType: VALUE_TYPE.UUID, + condition: CONDITION.AND + }); + + return searchSchoolCriteriaList; +} + +function createAssessmentCenterNameNumberSearchCriteria(value) { + const searchAssessmentCenterCriteriaList = []; + + searchAssessmentCenterCriteriaList.push({ + key: 'assessmentCenterID', + operation: FILTER_OPERATION.EQUAL, + value: value, + valueType: VALUE_TYPE.UUID, + condition: CONDITION.AND + }); + + return searchAssessmentCenterCriteriaList; +} + +function createScoreRangeFilter(pValue) { + let scoreRangeList = []; + + scoreRangeList.push({key:'proficiencyScore', value: pValue[0][1], operation: FILTER_OPERATION.LESS_THAN_OR_EQUAL_TO, valueType: VALUE_TYPE.INTEGER, condition: CONDITION.AND}); + scoreRangeList.push({key:'proficiencyScore', value: pValue[0][0], operation: FILTER_OPERATION.GREATER_THAN_OR_EQUAL_TO, valueType: VALUE_TYPE.INTEGER, condition: CONDITION.AND}); + if(pValue[0][0] === '0'){ + scoreRangeList.push({key:'proficiencyScore', value: null, operation: FILTER_OPERATION.EQUAL, valueType: VALUE_TYPE.STRING, condition: CONDITION.OR}); + } + return scoreRangeList; +} + module.exports = { createMoreFiltersSearchCriteria }; diff --git a/frontend/src/components/assessments/AssessmentSessions.vue b/frontend/src/components/assessments/AssessmentSessions.vue index b5fc801e..7779ae2c 100644 --- a/frontend/src/components/assessments/AssessmentSessions.vue +++ b/frontend/src/components/assessments/AssessmentSessions.vue @@ -5,21 +5,21 @@

School Year: {{ schoolYear }}

- Continue - - + variant="text" + @click="goToSchoolYearRegistrations()" + > + View all Open Sessions in the current school year + +
@@ -58,11 +58,11 @@ { value: 25, title: '25' }, { value: 50, title: '50' }, { value: 100, title: '100' }, - { value: -1, title: 'All' } ]" :hover="true" class="fill-height" style="border-radius: 0" + @click:row="goToSessionRegistrations" >