Skip to content

Commit

Permalink
EAC-22 & EAC-36.
Browse files Browse the repository at this point in the history
  • Loading branch information
sumathi-thirumani committed Nov 6, 2024
1 parent 1b6dc04 commit e783872
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 168 deletions.
21 changes: 13 additions & 8 deletions backend/src/components/eas/eas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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) {
Expand Down
147 changes: 141 additions & 6 deletions backend/src/components/eas/studentFilters.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
};
72 changes: 37 additions & 35 deletions frontend/src/components/assessments/AssessmentSessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
<div style="display: flex;">
<h2>School Year: {{ schoolYear }}</h2>
<v-btn
variant="text"
@click="goToSchoolYearRegistrations()"
>
<span
class="ml-1 pr-2"
style="color: #003366"
>Continue</span>
<v-icon
color="#003366"
class="ml-n1 mr-1"
right
icon="mdi-arrow-right"
dark
/>
</v-btn>
variant="text"
@click="goToSchoolYearRegistrations()"
>
<span
class="ml-1 pr-2"
style="color: #003366"
>View all Open Sessions in the current school year</span>
<v-icon
color="#003366"
class="ml-n1 mr-1"
right
icon="mdi-arrow-right"
dark
/>
</v-btn>
</div>
</v-col>
</v-row>
Expand Down Expand Up @@ -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"
>
<template #top>
<v-text-field
Expand Down Expand Up @@ -99,7 +99,6 @@ import SessionCard from './sessions/SessionCard.vue';
import EditSession from './sessions/SessionEdit.vue';
import ApiService from '../../common/apiService';
import { Routes } from '../../utils/constants';
import { LocalDate } from '@js-joda/core';
import moment from 'moment';
export default {
Expand All @@ -111,9 +110,8 @@ export default {
data() {
return {
topN: 4,
schoolYear:null,
search: null,
currentYear: LocalDate.now().year(),
schoolYear: null,
search: null,
itemsPerPage: 5,
pageNumber: 1,
allsessions: [],
Expand All @@ -134,15 +132,14 @@ export default {
activeSessions() {
const orderedSessions = [];
const allsessions = this.allsessions
.filter((session, index) => index < this.topN)
.filter((session, index) => index < this.topN)
.map((session) => {
return {
...session,
courseMonth: this.formatMonth(session.courseMonth)
};
});
allsessions.sort((a, b) => new Date(a.activeUntilDate) - new Date(b.activeUntilDate));
this.schoolYear = allsessions[0]?.schoolYear;
});
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));
}
Expand All @@ -151,20 +148,19 @@ export default {
historicalSessions() {
const allsessions = this.allsessions
.filter((session, index) => index >= this.topN)
.map((session) => {
.map((entry) => {
return {
...session,
activeFromDate: this.formattoDate(session.activeFromDate),
activeUntilDate: this.formattoDate(session.activeUntilDate),
courseMonth: this.formatMonth(session.courseMonth),
...entry,
activeFromDate: this.formattoDate(entry.activeFromDate),
activeUntilDate: this.formattoDate(entry.activeUntilDate),
courseMonth: this.formatMonth(entry.courseMonth),
};
});
allsessions.sort((a, b) => new Date(b.activeUntilDate) - new Date(a.activeUntilDate));
return allsessions;
return allsessions;
},
sessionHeaderSlotName() {
return `column.${this.sessionid}`;
},
}
},
created() {
this.getAllAssessmentSessions();
Expand All @@ -175,15 +171,18 @@ export default {
ApiService.apiAxios
.get(`${Routes.eas.GET_ASSESSMENT_SESSIONS}`, {})
.then((response) => {
this.allsessions = response.data;
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) => {
console.error(error);
})
.finally(() => {
this.loading = false;
});
},
},
sessionEditSuccess() {
this.getAllAssessmentSessions();
},
Expand All @@ -198,7 +197,10 @@ export default {
return moment(month, 'MM').format('MMMM');
},
goToSchoolYearRegistrations() {
this.$router.push({name: 'assessment-session-detail', params: {schoolYear: this.schoolYear.replace(/\//g, '-'), sessionID: null}});
this.$router.push({name: 'assessment-session-detail', params: {schoolYear: this.schoolYear?.replace(/\//g, '-'), sessionID: null}});
},
goToSessionRegistrations(e, { item }) {
this.$router.push({name: 'assessment-session-detail', params: {schoolYear: item?.raw?.schoolYear?.replace(/\//g, '-'), sessionID: item?.raw?.sessionID}});
}
},
};
Expand Down
Loading

0 comments on commit e783872

Please sign in to comment.