Skip to content

Commit 4ed0328

Browse files
ISR limit update
1 parent a4ad257 commit 4ed0328

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

backend/src/components/assessments/assessments.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const config = require('../../config');
1414
const cacheService = require('../cache-service');
1515
const {createMoreFiltersSearchCriteria} = require('./studentFilters');
1616
const moment = require('moment');
17+
const {doesSchoolBelongToDistrict} = require('../institute-cache');
1718
const {DateTimeFormatter, LocalDate, LocalDateTime} = require('@js-joda/core');
1819
const {FILTER_OPERATION, VALUE_TYPE, CONDITION, ASSESSMENTS_REPORT_TYPE_CODE_MAP,
1920
ASSESSMENTS_STUDENT_REPORT_TYPE_CODE_MAP
@@ -291,6 +292,33 @@ async function downloadAssessmentStudentReport(req, res) {
291292

292293
const token = getAccessToken(req);
293294

295+
if(reportType === 'ISR') {
296+
let student = await getData(token, `${config.get('gradCurrentStudents:rootURL')}/stdid/${req.params.studentID}`);
297+
298+
if(student.studentStatus === 'MER'){
299+
return res.status(HttpStatus.CONFLICT).json({
300+
status: HttpStatus.CONFLICT,
301+
message: 'Student was merged to another student. You must specify an active student PEN.'
302+
});
303+
}
304+
305+
if(req.session.activeInstituteType === 'DISTRICT'){
306+
if(!doesSchoolBelongToDistrict(student.schoolOfRecordId, req.session.activeInstituteIdentifier)){
307+
return res.status(HttpStatus.CONFLICT).json({
308+
status: HttpStatus.CONFLICT,
309+
message: 'The student\'s current School of Record is not within your district. The student’s reports cannot be accessed.'
310+
});
311+
}
312+
}else if(req.session.activeInstituteType === 'SCHOOL'){
313+
if(student.schoolOfRecordId !== req.session.activeInstituteIdentifier){
314+
return res.status(HttpStatus.CONFLICT).json({
315+
status: HttpStatus.CONFLICT,
316+
message: 'Your school is not currently the student\'s School of Record. The student’s reports cannot be accessed.'
317+
});
318+
}
319+
}
320+
}
321+
294322
let url = `${config.get('assessments:rootURL')}/report/student/${req.params.studentID}/${reportType}/download`;
295323

296324
const resData = await getData(token, url);

backend/src/components/permissionUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function checkEDXUserAccessToRequestedInstitute(req, res, next) {
3232
function checkEdxUserPermission(permission) {
3333
return function(req, res, next) {
3434
if (!req.session.activeInstitutePermissions.includes(permission)) {
35+
console.log('Marco' + req.session.activeInstitutePermissions);
3536
return res.status(HttpStatus.FORBIDDEN).json({
3637
message: 'User doesn\'t have permission.'
3738
});

frontend/src/components/assessments/reports/AssessmentReports.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ export default {
485485
this.isLoading = true;
486486
try {
487487
const url = `${ApiRoutes.assessments.BASE_REPORTS_URL}/student/${this.studentForSearch.studentID}/ISR/download`;
488+
await ApiService.apiAxios.get(url);
488489
window.open(url);
489490
} catch (error) {
490491
console.error(error);

0 commit comments

Comments
 (0)