Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Frontend: PersonPage: limit the exam num of chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
saitewasreset committed Dec 5, 2023
1 parent 063ed99 commit 0cac77d
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions frontend/js/person.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,31 @@ class PersonPage {
}
}

getBeginValidExamIdLst(examId, count) {
let tempLst = this.validExamList;
tempLst.reverse();
if (tempLst.length > 0) {
let flag = 0;
let current = 0;
let resultLst = [];
for (const id of tempLst) {
if (id === examId) {
flag = 1;
}
if (current >= count) {
break;
}
if (flag) {
resultLst.push(id);
current ++;
}
}
return resultLst.reverse();
} else {
return -1;
}
}

async doGetExamDetailByPerson(studentId) {
let response = await fetch(`${protocolPrefix}${host}/api/scores/data/by_person/${studentId}/exam_detail`);
let data = await response.json();
Expand All @@ -429,7 +454,6 @@ class PersonPage {
while (chartDiv.firstChild) {
chartDiv.removeChild(chartDiv.firstChild);
}
let subjectName = subjectIdToName[subjectId];

let show = 0;
const thisDiv = document.createElement("div");
Expand All @@ -452,7 +476,10 @@ class PersonPage {
let gradeMaxScores = [];
let gradeAvgScores = [];
let gradeRanks = [];
for (const [examId, examDetail] of Object.entries(this.examDetailByPerson)) {
const examSelection = document.querySelector("#exam-selection");
let showLst = this.getBeginValidExamIdLst(Number(examSelection.value), 10);
for (const examId of showLst) {
const examDetail = this.examDetailByPerson[examId];
if (subjectId in examDetail) {
show = 1;
labels.push(this.examIdToName[examId]);
Expand Down

0 comments on commit 0cac77d

Please sign in to comment.