From a4753e797313604b049747008124b276dc5325ac Mon Sep 17 00:00:00 2001 From: QkeleQ10 Date: Fri, 14 Jun 2024 17:40:39 +0200 Subject: [PATCH] fix grades > 10 --- src/magister/scripts/grades.js | 9 +++++++++ src/magister/scripts/today.js | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/magister/scripts/grades.js b/src/magister/scripts/grades.js index 3dacde4..5fca8f9 100644 --- a/src/magister/scripts/grades.js +++ b/src/magister/scripts/grades.js @@ -872,6 +872,15 @@ async function gradeStatistics() { if (i === a.length - 1) { input.checked = true let yearGrades = (await MagisterApi.grades.forYear(year)) + .filter(grade => grade.CijferKolom.KolomSoort == 1 && !isNaN(Number(grade.CijferStr.replace(',', '.'))) && (Number(grade.CijferStr.replace(',', '.')) <= 10) && (Number(grade.CijferStr.replace(',', '.')) >= 1)) + .filter((grade, index, self) => + index === self.findIndex((g) => + g.CijferKolom.KolomKop === grade.CijferKolom.KolomKop && + g.CijferKolom.KolomNaam === grade.CijferKolom.KolomNaam && + g.CijferStr === grade.CijferStr + ) + ) + .sort((a, b) => new Date(a.DatumIngevoerd) - new Date(b.DatumIngevoerd)) statsGrades.push(...yearGrades.filter(grade => grade.CijferKolom.KolomSoort == 1 && !isNaN(Number(grade.CijferStr.replace(',', '.')))).map(e => ({ ...e, result: Number(e.CijferStr.replace(',', '.')), year: year.id }))) let yearSubjects = statsGrades.filter(e => e.year === year.id).map(e => e.Vak.Omschrijving) diff --git a/src/magister/scripts/today.js b/src/magister/scripts/today.js index 9673736..c851c11 100644 --- a/src/magister/scripts/today.js +++ b/src/magister/scripts/today.js @@ -848,14 +848,12 @@ async function today() { if (type === 'Lijst') widgetTitle.dataset.amount = recentGrades.filter(item => item.unread).length recentGrades.forEach((item, i) => { + console.log(item) const gradeElement = element('div', `st-start-widget-grades-${i}`, widgetItemsContainer, { class: 'st-start-widget-grades-item', 'data-unread': item.unread, 'data-hidden': item.hidden, 'data-assignment': item.assignment }) children.push(gradeElement) if (i === 0) widgetElement.dataset.unread = item.unread - let formattedResult = item.waarde - if (!isNaN(Number(item.waarde.replace(',', '.')))) formattedResult = Number(item.waarde.replace(',', '.')).toLocaleString(locale, { maximumFractionDigits: 1, minimumFractionDigits: 1 }) - - let itemRslt = element('span', `st-start-widget-grades-${i}-rslt`, gradeElement, { class: 'st-start-widget-grades-item-rslt', innerText: formattedResult, 'data-great': autoRotate == 'true' && Number(item.waarde.replace(',', '.')) > 8.9, 'data-insuf': syncedStorage['insuf-red'] === true && Number(item.waarde.replace(',', '.')) < 5.5 }) + let itemRslt = element('span', `st-start-widget-grades-${i}-rslt`, gradeElement, { class: 'st-start-widget-grades-item-rslt', innerText: item.waarde, 'data-great': autoRotate == 'true' && Number(item.waarde.replace(',', '.')) > 8.9 && Number(item.waarde.replace(',', '.')) <= 10, 'data-insuf': syncedStorage['insuf-red'] === true && Number(item.waarde.replace(',', '.')) >= 1 && Number(item.waarde.replace(',', '.')) < 5.5 }) let itemSubj = element('span', `st-start-widget-grades-${i}-subj`, gradeElement, { class: 'st-start-widget-grades-item-subj', innerText: item.vak.omschrijving.charAt(0).toUpperCase() + item.vak.omschrijving.slice(1) }) let itemInfo = element('span', `st-start-widget-grades-${i}-info`, gradeElement, { class: 'st-start-widget-grades-item-info', innerText: item.assignment ? item.omschrijving : `${item.omschrijving} (${item.weegfactor || 0}×)` }) let itemDate = element('span', `st-start-widget-grades-${i}-date`, gradeElement, { class: 'st-start-widget-grades-item-date', 'data-temporal-type': 'timestamp', 'data-temporal-start': item.date }) @@ -934,6 +932,8 @@ async function today() { widgetElement.dataset.unread = children[targetIndex]?.dataset.unread || false visibleChildIndex = targetIndex + if (!document.querySelector(`#st-start-widget-grades-scroll-pagn>div:nth-child(${targetIndex + 1})`) || !document.querySelector('#st-start-widget-grades-scroll-pagn>div')) return + document.querySelectorAll('#st-start-widget-grades-scroll-pagn>div').forEach(d => d.dataset.current = false) document.querySelector(`#st-start-widget-grades-scroll-pagn>div:nth-child(${targetIndex + 1})`).dataset.current = true }