Skip to content

Commit

Permalink
Merge pull request #2096 from bcgov/fix/collectionDate
Browse files Browse the repository at this point in the history
Number of courses fix
  • Loading branch information
arcshiftsolutions authored Dec 18, 2024
2 parents d1c8b3e + e715fd2 commit bc8f340
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 61 deletions.
36 changes: 2 additions & 34 deletions backend/src/components/sdc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const { getAccessToken, handleExceptionResponse, getData, postData, putData, getDataWithParams, formatNumberOfCourses, stripNumberFormattingNumberOfCourses,
const { getAccessToken, handleExceptionResponse, getData, postData, putData, getDataWithParams,
getCreateOrUpdateUserValue} = require('./utils');
const { edxUserHasAccessToInstitute } = require('./permissionUtils');
const HttpStatus = require('http-status-codes');
Expand Down Expand Up @@ -275,10 +275,6 @@ async function getSDCSchoolCollectionStudentDetail(req, res) {
sdcSchoolCollectionStudentData.enrolledProgramCodes = sdcSchoolCollectionStudentData?.enrolledProgramCodes.match(/.{1,2}/g);
}

if (sdcSchoolCollectionStudentData?.numberOfCourses) {
sdcSchoolCollectionStudentData.numberOfCourses = formatNumberOfCourses(sdcSchoolCollectionStudentData?.numberOfCourses);
}

return res.status(HttpStatus.OK).json(sdcSchoolCollectionStudentData);
} catch (e) {
log.error('Error getting sdc school collection student detail', e.stack);
Expand All @@ -298,10 +294,6 @@ async function markSdcSchoolCollectionStudentAsDifferent(req, res) {
payload.assignedStudentId = null;
payload.penMatchResult = null;

if (payload?.numberOfCourses) {
payload.numberOfCourses = stripNumberFormattingNumberOfCourses(payload.numberOfCourses);
}

if (payload?.enrolledProgramCodes) {
payload.enrolledProgramCodes = payload.enrolledProgramCodes.join('');
}
Expand Down Expand Up @@ -338,10 +330,6 @@ async function updateAndValidateSdcSchoolCollectionStudent(req, res) {
payload.enrolledProgramCodes = payload.enrolledProgramCodes.join('');
}

if (payload?.numberOfCourses) {
payload.numberOfCourses = stripNumberFormattingNumberOfCourses(payload.numberOfCourses);
}

payload.sdcSchoolCollectionStudentValidationIssues = null;
payload.sdcSchoolCollectionStudentEnrolledPrograms = null;

Expand All @@ -352,10 +340,6 @@ async function updateAndValidateSdcSchoolCollectionStudent(req, res) {
if (data?.enrolledProgramCodes) {
data.enrolledProgramCodes = data?.enrolledProgramCodes.match(/.{1,2}/g);
}

if (data?.numberOfCourses) {
data.numberOfCourses = formatNumberOfCourses(data?.numberOfCourses);
}
return res.status(HttpStatus.OK).json(data);
} catch (e) {
if (e.message === '409' || e.status === '409' || e.status === 409) {
Expand Down Expand Up @@ -424,10 +408,6 @@ async function getSchoolStudentDuplicates(req, res) {
if (student?.enrolledProgramCodes) {
student.enrolledProgramCodes = student?.enrolledProgramCodes.match(/.{1,2}/g);
}

if (student?.numberOfCourses) {
student.numberOfCourses = formatNumberOfCourses(student?.numberOfCourses);
}
return student;
}

Expand Down Expand Up @@ -467,7 +447,7 @@ function toTableRow(student, collectionType = null) {
student.ellProgramEligible = getProgramEligibleValue('ELL', student.ellNonEligReasonCode, collectionType, student.schoolID);
student.careerProgramEligible = getProgramEligibleValue('CAREER', student.careerProgramNonEligReasonCode, collectionType, student.schoolID);
student.spedProgramEligible = getProgramEligibleValue('SPED',student.specialEducationNonEligReasonCode, collectionType, student.schoolID);
student.mappedNoOfCourses = student.numberOfCoursesDec ? student.numberOfCoursesDec.toFixed(2) : '0';
student.mappedNoOfCourses = student.numberOfCoursesDec;
student.mappedHomelanguageCode = student.homeLanguageSpokenCode !== '' && homeLanguageSpokenCodesMap.get(student.homeLanguageSpokenCode) !== undefined ? `${homeLanguageSpokenCodesMap.get(student.homeLanguageSpokenCode)?.description} (${homeLanguageSpokenCodesMap.get(student.homeLanguageSpokenCode)?.homeLanguageSpokenCode})` : null;

return student;
Expand Down Expand Up @@ -896,18 +876,10 @@ function setDuplicateResponsePayload(req, sdcDuplicates, isProvincialDuplicate,
sdcDuplicate.sdcSchoolCollectionStudent2Entity.enrolledProgramCodes = sdcDuplicate?.sdcSchoolCollectionStudent2Entity?.enrolledProgramCodes.match(/.{1,2}/g);
}

if (sdcDuplicate.sdcSchoolCollectionStudent2Entity?.numberOfCourses) {
sdcDuplicate.sdcSchoolCollectionStudent2Entity.numberOfCourses = formatNumberOfCourses(sdcDuplicate.sdcSchoolCollectionStudent2Entity?.numberOfCourses);
}

if (sdcDuplicate.sdcSchoolCollectionStudent1Entity?.enrolledProgramCodes) {
sdcDuplicate.sdcSchoolCollectionStudent1Entity.enrolledProgramCodes = sdcDuplicate.sdcSchoolCollectionStudent1Entity?.enrolledProgramCodes.match(/.{1,2}/g);
}

if (sdcDuplicate.sdcSchoolCollectionStudent1Entity?.numberOfCourses) {
sdcDuplicate.sdcSchoolCollectionStudent1Entity.numberOfCourses = formatNumberOfCourses(sdcDuplicate.sdcSchoolCollectionStudent1Entity?.numberOfCourses);
}

if (sdcDuplicate?.duplicateTypeCode === DUPLICATE_TYPE_CODES.ENROLLMENT) {
setIfOnlineStudentAndCanChangeGrade(sdcDuplicate, school1, school2);
setCanMoveToCrossEnrollment(sdcDuplicate);
Expand Down Expand Up @@ -1136,10 +1108,6 @@ async function resolveDuplicates(req, res) {
student.enrolledProgramCodes = student.enrolledProgramCodes.join('');
}

if (student?.numberOfCourses) {
student.numberOfCourses = stripNumberFormattingNumberOfCourses(student.numberOfCourses);
}

student.sdcSchoolCollectionStudentValidationIssues = null;
student.sdcSchoolCollectionStudentEnrolledPrograms = null;
});
Expand Down
25 changes: 0 additions & 25 deletions backend/src/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,30 +308,6 @@ function getCreateOrUpdateUserValue(req){
return 'EDX/' + req.session.edxUserData.edxUserID;
}
}

function formatNumberOfCourses(value) {
if (!value) return '00.00';

let formatted = '';
switch (value.length) {
case 1:
formatted = `0${value}.00`;
break;
case 2:
formatted = `${value}.00`;
break;
case 3:
formatted = `0${value.slice(0, 1)}.${value.slice(1)}`;
break;
case 4:
formatted = `${value.slice(0, 2)}.${value.slice(2)}`;
break;
default:
formatted = '00.00';
}
return formatted;
}

function formatDate(date) {
if (date && (date.length === 8)) {
const year = date.substring(0, 4);
Expand Down Expand Up @@ -371,7 +347,6 @@ const utils = {
logApiError,
isPdf,
isImage,
formatNumberOfCourses,
stripNumberFormattingNumberOfCourses
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/common/EditStudent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
<v-col>
<v-autocomplete
id="numberOfCourses"
v-model="sdcSchoolCollectionStudentDetailCopy.numberOfCourses"
v-model="sdcSchoolCollectionStudentDetailCopy.numberOfCoursesDec"
:items="courseOptions"
label="Number of Courses"
variant="underlined"
Expand Down Expand Up @@ -471,7 +471,7 @@
<v-autocomplete
v-else-if="sdcFieldMappings[field]?.key === 'numberOfCourses'"
:id="`${sdcFieldMappings[field].key}ValidationDropdown`"
v-model="sdcSchoolCollectionStudentDetailCopy[sdcFieldMappings[field].key]"
v-model="sdcSchoolCollectionStudentDetailCopy['numberOfCoursesDec']"
:rules="sdcFieldMappings[field].options.rules"
:items="courseOptions"
item-title="dropdownText"
Expand Down

0 comments on commit bc8f340

Please sign in to comment.