Add colors to grades
This commit is contained in:
parent
59eb0332d7
commit
c4c99e7b96
5 changed files with 30 additions and 16 deletions
|
@ -2,32 +2,32 @@
|
|||
{
|
||||
"Id": 26,
|
||||
"Kod": "Akt",
|
||||
"Nazwa": "Aktywność"
|
||||
"Nazwa": "A - aktywność (czarny, waga 3)"
|
||||
},
|
||||
{
|
||||
"Id": 27,
|
||||
"Kod": "Bież",
|
||||
"Nazwa": "Bieżące"
|
||||
"Nazwa": "B - bieżące (fiol,waga 8)"
|
||||
},
|
||||
{
|
||||
"Id": 28,
|
||||
"Kod": "Kart",
|
||||
"Nazwa": "Kartkówka"
|
||||
"Nazwa": "K - kartkówka (zielony, waga 5)"
|
||||
},
|
||||
{
|
||||
"Id": 29,
|
||||
"Kod": "Spr",
|
||||
"Nazwa": "Sprawdzian"
|
||||
"Nazwa": "S - sprawdzian (czerwony, waga 10)"
|
||||
},
|
||||
{
|
||||
"Id": 30,
|
||||
"Kod": "Z.dom",
|
||||
"Nazwa": "Zadanie domowe"
|
||||
"Nazwa": "Zd - zadanie domowe (czarny, waga 2)"
|
||||
},
|
||||
{
|
||||
"Id": 65,
|
||||
"Kod": "odp",
|
||||
"Nazwa": "Odpowiedź ustna"
|
||||
"Nazwa": "OD - odpowiedź ustna (czarny, waga 5)"
|
||||
},
|
||||
{
|
||||
"Id": 67,
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
"node-sass-middleware": "^0.11.0",
|
||||
"pug": "^2.0.3",
|
||||
"serve-favicon": "~2.5.0",
|
||||
"uuid": "^3.3.2"
|
||||
"uuid": "^3.3.2",
|
||||
"lodash": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jshint": "^2.10.1",
|
||||
|
|
|
@ -2,6 +2,7 @@ const express = require('express');
|
|||
const router = express.Router();
|
||||
const converter = require('../utils/converter');
|
||||
const dictMap = require('../utils/dictMap');
|
||||
const { getGradeColorByCategoryName } = require("../utils/gradeColor");
|
||||
const _ = require('lodash');
|
||||
|
||||
global.opiekunRoot = "/Default/123456";
|
||||
|
@ -65,11 +66,12 @@ router.get("/Oceny(\.mvc|)/Wszystkie", (req, res) => {
|
|||
if (req.query.details === '2') {
|
||||
data = details.map(item => {
|
||||
const teacher = dictMap.getByValue(teachers, "Id", item.IdPracownikD);
|
||||
const category = dictMap.getByValue(subjectCategories, "Id", item.IdKategoria);
|
||||
return {
|
||||
"subject": dictMap.getByValue(subjects, "Id", item.IdPrzedmiot).Nazwa,
|
||||
"value": item.Wpis === "" ? item.Komentarz : item.Wpis,
|
||||
"color": "000000",
|
||||
"symbol": dictMap.getByValue(subjectCategories, "Id", item.IdKategoria).Kod,
|
||||
"color": getGradeColorByCategoryName(category.Nazwa),
|
||||
"symbol": category.Kod,
|
||||
"description": item.Opis,
|
||||
"weight": item.Waga,
|
||||
"date": converter.formatDate(new Date(item.DataUtworzenia * 1000)),
|
||||
|
@ -225,7 +227,7 @@ router.get("/Lekcja(\.mvc|)/PlanZajec", (req, res) => {
|
|||
const daysWithGaps = _.mapValues(days, day => {
|
||||
const dayWithGaps = [];
|
||||
let prevNumber = null;
|
||||
|
||||
|
||||
const beforeGap = day[0].number - firstLesson;
|
||||
|
||||
for (i = 0; i < beforeGap; i++) {
|
||||
|
@ -257,7 +259,7 @@ router.get("/Lekcja(\.mvc|)/PlanZajec", (req, res) => {
|
|||
}
|
||||
|
||||
prevNumber = lesson.number;
|
||||
|
||||
|
||||
dayWithGaps.push(lesson);
|
||||
});
|
||||
|
||||
|
@ -273,12 +275,12 @@ router.get("/Lekcja(\.mvc|)/PlanZajec", (req, res) => {
|
|||
end: times.KoniecTekst,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return dayWithGaps;
|
||||
});
|
||||
|
||||
const data = _.groupBy(_.flatten(_.values(daysWithGaps)), "number");
|
||||
|
||||
|
||||
res.render("opiekun/plan-zajec", {
|
||||
title: "Witryna ucznia i rodzica – Plan lekcji",
|
||||
data,
|
||||
|
@ -346,7 +348,7 @@ router.get("/ZadaniaDomowe.mvc", (req, res) => {
|
|||
date: converter.formatDate(date),
|
||||
dayName: converter.getDayName(date),
|
||||
entryDate: converter.formatDate(new Date(item.DataTekst)),
|
||||
teacher: teacher.Imie + " " + teacher.Nazwisko,
|
||||
teacher: teacher.Imie + " " + teacher.Nazwisko,
|
||||
teacherSymbol: teacher.Kod,
|
||||
subject: dictMap.getByValue(subjects, "Id", item.IdPrzedmiot).Nazwa,
|
||||
content: item.Opis
|
||||
|
|
|
@ -5,6 +5,7 @@ const dictMap = require('../utils/dictMap');
|
|||
const converter = require('../utils/converter');
|
||||
const Tokens = require('csrf');
|
||||
const _ = require('lodash');
|
||||
const { getGradeColorByCategoryName } = require("../utils/gradeColor");
|
||||
const {format, fromUnixTime, getYear, addYears, addMonths, addDays, differenceInDays, parseISO} = require('date-fns');
|
||||
|
||||
router.get("/", (req, res) => {
|
||||
|
@ -408,14 +409,15 @@ router.all("/Oceny.mvc/Get", (req, res) => {
|
|||
"Pozycja": item.Pozycja,
|
||||
"OcenyCzastkowe": require("../../data/api/student/Oceny").filter(grade => grade.IdPrzedmiot === item.Id).map(item => {
|
||||
const teacher = dictMap.getByValue(teachers, "Id", item.IdPracownikD);
|
||||
const category = dictMap.getByValue(subjectCategories, "Id", item.IdKategoria);
|
||||
return {
|
||||
"Nauczyciel": `${teacher.Imie} ${teacher.Nazwisko}`,
|
||||
"Wpis": item.Wpis,
|
||||
"Waga": Math.round(item.WagaOceny),
|
||||
"NazwaKolumny": item.Opis,
|
||||
"KodKolumny": dictMap.getByValue(subjectCategories, "Id", item.IdKategoria).Kod,
|
||||
"KodKolumny": category.Kod,
|
||||
"DataOceny": converter.formatDate(new Date(item.DataUtworzenia * 1000)),
|
||||
"KolorOceny": 0
|
||||
"KolorOceny": parseInt(getGradeColorByCategoryName(category.Nazwa), 16)
|
||||
};
|
||||
}),
|
||||
"ProponowanaOcenaRoczna": dictMap.getByValue(summary.OcenyPrzewidywane, "IdPrzedmiot", item.Id, {"Wpis": ""}).Wpis,
|
||||
|
|
9
src/utils/gradeColor.js
Normal file
9
src/utils/gradeColor.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
exports.getGradeColorByCategoryName = name => {
|
||||
switch (true) {
|
||||
case name.includes("czarny"): return "000000";
|
||||
case name.includes("czerw"): return "ff0000";
|
||||
case name.includes("fiol"): return "800080";
|
||||
case name.includes("nieb"): return "0000ff";
|
||||
case name.includes("zielony"): return "00ff00";
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue