Skip to content

Commit

Permalink
fix grades > 10
Browse files Browse the repository at this point in the history
  • Loading branch information
QkeleQ10 committed Jun 14, 2024
1 parent fdd6454 commit a4753e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/magister/scripts/grades.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/magister/scripts/today.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a4753e7

Please sign in to comment.