diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
commit | 23563c7188e089929b60f9e10721c6fc43a220ff (patch) | |
tree | edfe2b009c82900d4ac27db02222d2f68dcad846 /includes/external/school/node_modules/pronote-api/src/fetch/marks.js | |
parent | 7a7a49332df7c852abbaa33c7e8e87f93d064d61 (diff) | |
download | pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.gz pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.bz2 pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.zip |
Updated 15 files, added includes/maintenance/deleteUnusedAssets.php and deleted 4944 files (automated)
Diffstat (limited to 'includes/external/school/node_modules/pronote-api/src/fetch/marks.js')
-rw-r--r-- | includes/external/school/node_modules/pronote-api/src/fetch/marks.js | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/marks.js b/includes/external/school/node_modules/pronote-api/src/fetch/marks.js deleted file mode 100644 index 1e57e85..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/marks.js +++ /dev/null @@ -1,73 +0,0 @@ -const { getPeriodBy } = require('../data/periods'); -const { withId, checkDuplicates } = require('../data/id'); - -const getMarks = require('./pronote/marks'); - -async function marks(session, user, period = null, type = null) -{ - const marks = await getMarks(session, user, getPeriodBy(session, period, type)); - if (!marks) { - return null; - } - - const result = { - subjects: [], - averages: {} - }; - - if (marks.studentAverage) { - result.averages.student = Number((marks.studentAverage / marks.studentAverageScale * 20).toFixed(2)); - } - if (marks.studentClassAverage) { - result.averages.studentClass = Number(marks.studentClassAverage.toFixed(2)); - } - - for (const subject of marks.subjects.sort((a, b) => a.order - b.order)) { - result.subjects.push({ - name: subject.name, - averages: { - student: subject.studentAverage / subject.studentAverageScale * 20, - studentClass: subject.studentClassAverage, - max: subject.maxAverage, - min: subject.minAverage - }, - color: subject.color, - marks: [] - }); - } - - for (const mark of marks.marks) { - const subject = result.subjects.find(s => s.name === mark.subject.name); - if (!subject) { - continue; - } - - const res = { - isAway: mark.value < 0 - }; - - if (!res.isAway) { - res.value = mark.value; - } - - if (mark.average >= 0) { - res.min = mark.min; - res.max = mark.max; - res.average = mark.average; - } - - subject.marks.push(withId({ - title: mark.title, - ...res, - scale: mark.scale, - coefficient: mark.coefficient, - date: mark.date - }, ['title', 'date'], subject.name)); - } - - result.subjects.forEach(s => checkDuplicates(s.marks)); - - return result; -} - -module.exports = marks; |