2024-10-17 12:15:45 +00:00
|
|
|
// Zmienne globalne
|
2024-10-17 10:47:01 +00:00
|
|
|
let currentCategory = 'frekwencja';
|
2024-10-17 12:15:45 +00:00
|
|
|
let currentClass = '';
|
|
|
|
let studentsData = [];
|
|
|
|
let currentDay = 0;
|
2024-10-18 11:05:39 +00:00
|
|
|
let currentRole = "teacher"
|
|
|
|
let currentRoleCriterias = []
|
2024-10-17 12:15:45 +00:00
|
|
|
const baseDate = new Date();
|
2024-10-17 10:47:01 +00:00
|
|
|
|
|
|
|
// Funkcja do wczytywania pliku JSON
|
2024-10-16 10:18:43 +00:00
|
|
|
async function fetchJSONFile(filePath) {
|
|
|
|
try {
|
|
|
|
const response = await fetch(filePath);
|
|
|
|
if (!response.ok) {
|
2024-10-17 12:15:45 +00:00
|
|
|
throw new Error(`Błąd HTTP! Status: ${response.status}`);
|
2024-10-16 10:18:43 +00:00
|
|
|
}
|
|
|
|
return await response.json();
|
|
|
|
} catch (error) {
|
2024-10-17 12:15:45 +00:00
|
|
|
console.error("Błąd podczas pobierania pliku JSON:", error);
|
|
|
|
return null;
|
2024-10-16 10:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-17 08:46:48 +00:00
|
|
|
// Obiekt do przechowywania danych klas i uczniów
|
|
|
|
const classData = {};
|
|
|
|
|
|
|
|
// Funkcja do wczytania pliku class.json i danych uczniów
|
2024-10-16 10:18:43 +00:00
|
|
|
async function loadClasses() {
|
|
|
|
const classFilePath = '/data/class.json';
|
|
|
|
const classes = await fetchJSONFile(classFilePath);
|
|
|
|
|
|
|
|
if (classes) {
|
2024-10-17 12:15:45 +00:00
|
|
|
console.log('Załadowane klasy:', classes);
|
2024-10-16 10:42:08 +00:00
|
|
|
|
2024-10-17 12:14:38 +00:00
|
|
|
const selectClass = document.getElementById("select-class-select");
|
2024-10-17 12:15:45 +00:00
|
|
|
selectClass.innerHTML = ""; // Wyczyść istniejące opcje
|
2024-10-16 11:51:22 +00:00
|
|
|
|
2024-10-17 12:14:38 +00:00
|
|
|
classes.forEach(classInfo => {
|
|
|
|
const option = document.createElement('option');
|
2024-10-17 12:15:45 +00:00
|
|
|
option.value = classInfo.file_path;
|
2024-10-17 12:14:38 +00:00
|
|
|
option.textContent = `Klasa: ${classInfo.class}`;
|
|
|
|
selectClass.appendChild(option);
|
2024-10-17 12:15:45 +00:00
|
|
|
console.log("Dodano klasę ", classInfo.class, " do SELECT");
|
2024-10-17 12:14:38 +00:00
|
|
|
});
|
2024-10-16 10:42:08 +00:00
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Dodaj nasłuchiwacz zdarzeń na zmianę wyboru klasy
|
2024-10-17 12:14:38 +00:00
|
|
|
selectClass.addEventListener('change', function() {
|
2024-10-17 12:15:45 +00:00
|
|
|
const selectedClassFile = this.value;
|
|
|
|
console.log(`Wybrano klasę: ${selectedClassFile}`);
|
|
|
|
loadStudents(selectedClassFile);
|
2024-10-17 12:14:38 +00:00
|
|
|
});
|
2024-10-16 10:42:08 +00:00
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Opcjonalnie, ustaw domyślnie pierwszą klasę i załaduj jej uczniów
|
2024-10-17 12:14:38 +00:00
|
|
|
if (classes.length > 0) {
|
2024-10-17 12:15:45 +00:00
|
|
|
selectClass.selectedIndex = 0;
|
|
|
|
const defaultClassFile = classes[0].file_path;
|
|
|
|
loadStudents(defaultClassFile);
|
2024-10-16 10:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Funkcja do wczytania danych uczniów dla wybranej klasy
|
|
|
|
async function loadStudents(classFilePath) {
|
|
|
|
if (!classFilePath) {
|
|
|
|
console.warn("Nie wybrano żadnej klasy.");
|
|
|
|
return;
|
|
|
|
}
|
2024-10-16 10:18:43 +00:00
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
const studentsFilePath = `/data/${classFilePath}`;
|
|
|
|
const data = await fetchJSONFile(studentsFilePath);
|
2024-10-16 11:51:22 +00:00
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
if (data && Array.isArray(data.students)) {
|
|
|
|
console.log(`Uczniowie załadowani z pliku ${classFilePath}:`, data);
|
|
|
|
studentsData = data.students; // Aktualizuj globalną tablicę uczniów
|
|
|
|
|
|
|
|
// Inicjalizacja 'behavior' dla każdego ucznia, jeśli jest niezdefiniowany
|
|
|
|
studentsData.forEach(student => {
|
|
|
|
if (!student.behavior) {
|
|
|
|
student.behavior = {};
|
2024-10-17 08:46:48 +00:00
|
|
|
}
|
|
|
|
});
|
2024-10-16 11:51:22 +00:00
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
currentClass = classFilePath; // Ustaw aktualną klasę
|
|
|
|
generateTable(currentCategory); // Regeneruj tabelę z aktualną kategorią
|
|
|
|
} else {
|
|
|
|
console.error("Błąd: Nie udało się załadować danych uczniów lub dane są niepoprawne.");
|
|
|
|
studentsData = []; // Jeśli nie udało się załadować danych, wyczyść tablicę uczniów
|
|
|
|
currentClass = '';
|
|
|
|
generateTable(currentCategory); // Regeneruj pustą tabelę
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-18 10:01:25 +00:00
|
|
|
async function getCategoriesWithCriteria() {
|
|
|
|
const criteriaFilePath = '/data/criteria.json';
|
|
|
|
const criteria = await fetchJSONFile(criteriaFilePath);
|
|
|
|
let categoriesWithCriteria = {}
|
|
|
|
|
|
|
|
criteria.categories.forEach(category => {
|
|
|
|
let criteriaForCategory = []
|
|
|
|
criteria.criteria.forEach(criteria => {
|
|
|
|
if(category.criteria_ids.includes(criteria.id)) {
|
2024-10-18 11:05:39 +00:00
|
|
|
//console.log(`!!! ${category.name} posiada ${criteria.name}`)
|
2024-10-18 10:01:25 +00:00
|
|
|
criteriaForCategory.push({name: criteria.name, id: criteria.id})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
categoriesWithCriteria[category.id] = criteriaForCategory
|
|
|
|
})
|
|
|
|
|
|
|
|
return categoriesWithCriteria
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do wczytania pliku criteria.json
|
|
|
|
async function loadCriteria() {
|
2024-10-16 12:53:18 +00:00
|
|
|
const criteriaFilePath = '/data/criteria.json';
|
2024-10-16 12:56:56 +00:00
|
|
|
const criteria = await fetchJSONFile(criteriaFilePath);
|
2024-10-16 12:53:18 +00:00
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
console.log("Załadowane kryteria:", criteria);
|
2024-10-18 08:30:42 +00:00
|
|
|
|
2024-10-18 10:01:25 +00:00
|
|
|
//
|
|
|
|
// LADOWANIE ROL
|
|
|
|
//
|
2024-10-18 08:30:42 +00:00
|
|
|
const roles = criteria.roles;
|
2024-10-18 10:01:25 +00:00
|
|
|
|
2024-10-18 08:30:42 +00:00
|
|
|
const selectroleByid = document.getElementById("select-role");
|
|
|
|
let selectroleHTML = ""; // Zainicjalizuj pusty string na HTML
|
2024-10-18 11:05:39 +00:00
|
|
|
currentRole = "teacher"
|
2024-10-18 08:30:42 +00:00
|
|
|
// Iteracja przez klucze obiektu roles
|
|
|
|
for (const [key, value] of Object.entries(roles)) {
|
2024-10-18 11:05:39 +00:00
|
|
|
if(key == "teacher") {
|
|
|
|
currentRoleCriterias = value.criteria_ids
|
|
|
|
}
|
2024-10-18 08:30:42 +00:00
|
|
|
selectroleHTML += `<option value="${key}">${value.name}</option>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wstawienie HTML do elementu select
|
|
|
|
selectroleByid.innerHTML = selectroleHTML;
|
2024-10-18 10:01:25 +00:00
|
|
|
|
|
|
|
// category-buttons-box
|
|
|
|
const categoriesCriteria = criteria.categories;
|
|
|
|
const categoryButtonsBox = document.getElementById("category-buttons-box");
|
|
|
|
let categoryButtonHTML = ""
|
|
|
|
categoriesCriteria.forEach(category => {
|
2024-10-18 11:05:39 +00:00
|
|
|
const hasCriteria = category.criteria_ids.some(criteriaId => currentRoleCriterias.includes(criteriaId));
|
|
|
|
|
|
|
|
// Jeśli kategoria ma kryteria, dodajemy przycisk
|
|
|
|
if (hasCriteria) {
|
|
|
|
categoryButtonHTML += `<button data-category="${category.id}" onclick="showInnerTab('${category.id}')">${category.name}</button>`;
|
|
|
|
}
|
|
|
|
});
|
2024-10-18 10:01:25 +00:00
|
|
|
|
|
|
|
categoryButtonsBox.innerHTML = categoryButtonHTML;
|
2024-10-16 10:18:43 +00:00
|
|
|
}
|
2024-10-16 11:51:22 +00:00
|
|
|
|
2024-10-18 11:05:39 +00:00
|
|
|
async function changeRole(role) {
|
|
|
|
const select = document.getElementById('select-role');
|
|
|
|
const selectedValue = select.value;
|
|
|
|
|
|
|
|
const criteriaFilePath = '/data/criteria.json';
|
|
|
|
const criteria = await fetchJSONFile(criteriaFilePath);
|
|
|
|
|
|
|
|
currentRole = selectedValue
|
|
|
|
currentRoleCriterias = criteria.roles[currentRole].criteria_ids
|
|
|
|
console.log("currentRole:", currentRole)
|
|
|
|
console.log("currentRoleCriterias:", currentRoleCriterias)
|
|
|
|
|
|
|
|
// category-buttons-box
|
|
|
|
const categoriesCriteria = criteria.categories;
|
|
|
|
const categoryButtonsBox = document.getElementById("category-buttons-box");
|
|
|
|
let categoryButtonHTML = ""
|
|
|
|
categoriesCriteria.forEach(category => {
|
|
|
|
const hasCriteria = category.criteria_ids.some(criteriaId => currentRoleCriterias.includes(criteriaId));
|
|
|
|
|
|
|
|
|
|
|
|
// Jeśli kategoria ma kryteria, dodajemy przycisk
|
|
|
|
if (hasCriteria) {
|
|
|
|
categoryButtonHTML += `<button data-category="${category.id}" onclick="showInnerTab('${category.id}')">${category.name}</button>`;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
categoryButtonsBox.innerHTML = categoryButtonHTML;
|
|
|
|
|
|
|
|
generateTable(currentCategory)
|
|
|
|
}
|
2024-10-18 08:30:42 +00:00
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do przełączania głównych zakładek
|
2024-10-16 09:24:57 +00:00
|
|
|
function showTab(tabName) {
|
2024-10-17 10:47:01 +00:00
|
|
|
// Ukryj wszystkie główne taby
|
2024-10-16 09:24:57 +00:00
|
|
|
const tabs = document.querySelectorAll('.tab');
|
|
|
|
tabs.forEach(tab => tab.classList.remove('active'));
|
2024-10-17 10:47:01 +00:00
|
|
|
|
|
|
|
// Pokaż wybrany tab
|
|
|
|
const selectedTab = document.getElementById(tabName);
|
|
|
|
if (selectedTab) {
|
|
|
|
selectedTab.classList.add('active');
|
|
|
|
}
|
2024-10-16 09:24:57 +00:00
|
|
|
|
|
|
|
if (tabName === 'criteria') {
|
|
|
|
loadDayData();
|
|
|
|
} else if (tabName === 'points') {
|
|
|
|
calculateStats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do przełączania kategorii w tabeli uczniów
|
|
|
|
function showInnerTab(category) {
|
|
|
|
currentCategory = category;
|
|
|
|
// Generowanie tabeli na podstawie wybranej kategorii
|
|
|
|
generateTable(category);
|
|
|
|
|
|
|
|
// Podkreślenie aktywnego przycisku
|
|
|
|
const buttons = document.querySelectorAll('.category-buttons button');
|
|
|
|
buttons.forEach(button => button.classList.remove('active'));
|
|
|
|
const activeButton = document.querySelector(`.category-buttons button[data-category="${category}"]`);
|
|
|
|
if (activeButton) {
|
|
|
|
activeButton.classList.add('active');
|
|
|
|
}
|
2024-10-16 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja, aby ustawić domyślną kategorię i zakładkę
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
2024-10-17 12:14:38 +00:00
|
|
|
// Domyślnie pokazujemy kategorię 'frekwencja'
|
2024-10-18 11:05:39 +00:00
|
|
|
|
2024-10-17 08:46:48 +00:00
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Ustawienie daty na dziś
|
|
|
|
document.getElementById('current-date').innerText = baseDate.toLocaleDateString();
|
2024-10-16 10:18:43 +00:00
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Uruchomienie wczytywania klas i kryteriów
|
|
|
|
loadClasses();
|
|
|
|
loadCriteria();
|
2024-10-18 11:05:39 +00:00
|
|
|
|
|
|
|
showInnerTab('frekwencja');
|
2024-10-17 10:47:01 +00:00
|
|
|
});
|
2024-10-16 09:24:57 +00:00
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do zmiany dnia
|
2024-10-16 09:24:57 +00:00
|
|
|
function changeDay(direction) {
|
|
|
|
saveDayData();
|
|
|
|
currentDay += direction;
|
|
|
|
const newDate = new Date(baseDate);
|
|
|
|
newDate.setDate(baseDate.getDate() + currentDay);
|
|
|
|
document.getElementById('current-date').innerText = newDate.toLocaleDateString();
|
|
|
|
loadDayData();
|
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do ładowania danych dnia
|
2024-10-16 09:24:57 +00:00
|
|
|
function loadDayData() {
|
|
|
|
studentsData.forEach(student => {
|
2024-10-17 12:24:08 +00:00
|
|
|
const studentId = `${student.first_name}-${student.last_name}`.replace(/ /g, '-');
|
2024-10-16 09:24:57 +00:00
|
|
|
const behavior = student.behavior[`day${currentDay}`] || {};
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Pobierz kryteria dla aktualnej kategorii
|
2024-10-17 12:14:38 +00:00
|
|
|
const categoryColumns = categories[currentCategory];
|
|
|
|
categoryColumns.forEach(column => {
|
|
|
|
const checkbox = document.getElementById(`${column.id}-${studentId}`);
|
|
|
|
if (checkbox) {
|
|
|
|
checkbox.checked = behavior[column.id] || false;
|
|
|
|
}
|
|
|
|
});
|
2024-10-16 09:24:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
calculateStats();
|
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do zapisywania danych dnia
|
2024-10-16 09:24:57 +00:00
|
|
|
function saveDayData() {
|
|
|
|
studentsData.forEach(student => {
|
2024-10-17 12:24:08 +00:00
|
|
|
const studentId = `${student.first_name}-${student.last_name}`.replace(/ /g, '-');
|
|
|
|
|
|
|
|
// Upewnij się, że 'behavior' jest zdefiniowany
|
|
|
|
if (!student.behavior) {
|
|
|
|
student.behavior = {};
|
|
|
|
}
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
let behavior = student.behavior[`day${currentDay}`] || {};
|
2024-10-17 10:47:01 +00:00
|
|
|
|
|
|
|
const categoryColumns = categories[currentCategory];
|
|
|
|
|
|
|
|
categoryColumns.forEach(column => {
|
2024-10-17 12:14:38 +00:00
|
|
|
const checkbox = document.getElementById(`${column.id}-${studentId}`);
|
|
|
|
if (checkbox) {
|
|
|
|
behavior[column.id] = checkbox.checked;
|
|
|
|
}
|
2024-10-17 10:47:01 +00:00
|
|
|
});
|
2024-10-16 09:24:57 +00:00
|
|
|
|
|
|
|
student.behavior[`day${currentDay}`] = behavior;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do obliczania statystyk
|
2024-10-16 09:24:57 +00:00
|
|
|
function calculateStats() {
|
2024-10-17 12:14:38 +00:00
|
|
|
// Pobieranie punktów z zakładki "Ustal punkty"
|
|
|
|
const points = {
|
|
|
|
frekwencja: parseInt(document.getElementById('frekwencja-punkty').value) || 0,
|
2024-10-17 12:24:08 +00:00
|
|
|
brak_godzin: parseInt(document.getElementById('brak_godzin-punkty').value) || 0,
|
|
|
|
min_85: parseInt(document.getElementById('min_85-punkty').value) || 0,
|
2024-10-17 12:14:38 +00:00
|
|
|
etap_szkolny: parseInt(document.getElementById('etap_szkolny-punkty').value) || 5,
|
|
|
|
etap_rejonowy: parseInt(document.getElementById('etap_rejonowy-punkty').value) || 10,
|
|
|
|
etap_wojewodzki: parseInt(document.getElementById('etap_wojewodzki-punkty').value) || 15,
|
|
|
|
etap_ogolnopolski: parseInt(document.getElementById('etap_ogolnopolski-punkty').value) || 20,
|
|
|
|
udzial_konkurs: parseInt(document.getElementById('udzial_konkurs-punkty').value) || 5,
|
|
|
|
wyroznienie_konkurs: parseInt(document.getElementById('wyroznienie_konkurs-punkty').value) || 10,
|
|
|
|
reprezentacja_indywidualna: parseInt(document.getElementById('reprezentacja_indywidualna-punkty').value) || 5,
|
|
|
|
reprezentacja_zespolowa: parseInt(document.getElementById('reprezentacja_zespolowa-punkty').value) || 10,
|
|
|
|
udzial_zawody: parseInt(document.getElementById('udzial_zawody-punkty').value) || 15,
|
|
|
|
organizacja_imprez: parseInt(document.getElementById('organizacja_imprez-punkty').value) || 10,
|
|
|
|
funkcja_klasa: parseInt(document.getElementById('funkcja_klasa-punkty').value) || 10,
|
|
|
|
uroczystosci: parseInt(document.getElementById('uroczystosci-punkty').value) || 10,
|
|
|
|
poczta_sztandar: parseInt(document.getElementById('poczta_sztandar-punkty').value) || 20,
|
|
|
|
pomoc_nauczyciel: parseInt(document.getElementById('pomoc_nauczyciel-punkty').value) || 10,
|
|
|
|
wolontariat: parseInt(document.getElementById('wolontariat-punkty').value) || 10
|
|
|
|
};
|
2024-10-16 09:24:57 +00:00
|
|
|
|
|
|
|
let stats = '';
|
|
|
|
|
|
|
|
studentsData.forEach(student => {
|
|
|
|
let totalPoints = 0;
|
|
|
|
|
|
|
|
Object.keys(student.behavior).forEach(day => {
|
|
|
|
const behavior = student.behavior[day];
|
|
|
|
|
2024-10-17 08:46:48 +00:00
|
|
|
let dayPoints = 0;
|
2024-10-17 12:14:38 +00:00
|
|
|
for (const [criterion, value] of Object.entries(behavior)) {
|
|
|
|
if (value && points[criterion]) {
|
|
|
|
dayPoints += points[criterion];
|
|
|
|
}
|
|
|
|
}
|
2024-10-16 09:24:57 +00:00
|
|
|
|
|
|
|
totalPoints += dayPoints;
|
|
|
|
});
|
|
|
|
|
2024-10-17 12:24:08 +00:00
|
|
|
stats += `${student.first_name} ${student.last_name}: ${totalPoints} punktów (${getGrade(totalPoints)})\n`;
|
2024-10-16 09:24:57 +00:00
|
|
|
});
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
document.getElementById('stats-output').innerText = stats;
|
2024-10-16 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do przypisywania ocen na podstawie punktów
|
2024-10-16 09:24:57 +00:00
|
|
|
function getGrade(points) {
|
|
|
|
if (points >= 250) return "Wzorowe";
|
|
|
|
if (points >= 180) return "Bardzo dobre";
|
|
|
|
if (points >= 100) return "Dobre";
|
|
|
|
if (points >= 50) return "Poprawne";
|
|
|
|
if (points >= 0) return "Nieodpowiednie";
|
|
|
|
return "Naganne";
|
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Funkcja do generowania tabeli uczniów na podstawie wybranej kategorii
|
2024-10-18 10:01:25 +00:00
|
|
|
async function generateTable(category) {
|
2024-10-17 10:47:01 +00:00
|
|
|
const table = document.getElementById('student-table');
|
|
|
|
const thead = table.querySelector('thead tr');
|
|
|
|
const tbody = table.querySelector('tbody');
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Wyczyść istniejące nagłówki i wiersze
|
2024-10-17 10:47:01 +00:00
|
|
|
thead.innerHTML = '';
|
|
|
|
tbody.innerHTML = '';
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Dodaj nagłówek 'Imię i Nazwisko'
|
2024-10-17 10:47:01 +00:00
|
|
|
const thName = document.createElement('th');
|
|
|
|
thName.textContent = "Imię i Nazwisko";
|
|
|
|
thead.appendChild(thName);
|
|
|
|
|
2024-10-18 11:05:39 +00:00
|
|
|
// get role
|
|
|
|
console.log("currentRole", currentRole)
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Pobierz kolumny dla wybranej kategorii
|
2024-10-18 10:01:25 +00:00
|
|
|
const categories = await getCategoriesWithCriteria()
|
|
|
|
console.log("łot:", categories)
|
2024-10-17 10:47:01 +00:00
|
|
|
const categoryColumns = categories[category];
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Dodaj nagłówki dla kryteriów w kategorii
|
2024-10-17 10:47:01 +00:00
|
|
|
categoryColumns.forEach(column => {
|
|
|
|
const th = document.createElement('th');
|
2024-10-18 11:05:39 +00:00
|
|
|
if(currentRoleCriterias.includes(column.id)) {
|
|
|
|
th.textContent = column.name;
|
|
|
|
thead.appendChild(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
});
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Generuj wiersze dla uczniów
|
2024-10-17 10:47:01 +00:00
|
|
|
studentsData.forEach(student => {
|
|
|
|
const row = document.createElement('tr');
|
2024-10-16 09:24:57 +00:00
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Komórka z imieniem i nazwiskiem
|
2024-10-17 10:47:01 +00:00
|
|
|
const tdName = document.createElement('td');
|
2024-10-17 12:24:08 +00:00
|
|
|
tdName.textContent = `${student.first_name} ${student.last_name}`;
|
2024-10-17 10:47:01 +00:00
|
|
|
row.appendChild(tdName);
|
|
|
|
|
2024-10-17 12:24:08 +00:00
|
|
|
// Upewnij się, że 'behavior' jest zdefiniowany
|
|
|
|
if (!student.behavior) {
|
|
|
|
student.behavior = {};
|
|
|
|
}
|
|
|
|
|
2024-10-17 12:15:45 +00:00
|
|
|
// Komórki z checkboxami dla kryteriów
|
2024-10-17 10:47:01 +00:00
|
|
|
categoryColumns.forEach(column => {
|
2024-10-18 11:05:39 +00:00
|
|
|
if(currentRoleCriterias.includes(column.id)) {
|
|
|
|
const td = document.createElement('td');
|
|
|
|
const checkbox = document.createElement('input');
|
|
|
|
checkbox.type = 'checkbox';
|
|
|
|
const studentId = `${student.first_name}-${student.last_name}`.replace(/ /g, '-');
|
|
|
|
checkbox.id = `${column.id}-${studentId}`;
|
|
|
|
checkbox.onchange = calculateStats;
|
|
|
|
|
|
|
|
// Ustawienie stanu checkboxa na podstawie zapisanych danych
|
|
|
|
checkbox.checked = student.behavior[`day${currentDay}`]?.[column.id] || false;
|
|
|
|
|
|
|
|
td.appendChild(checkbox);
|
|
|
|
row.appendChild(td);
|
|
|
|
}
|
2024-10-17 10:47:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tbody.appendChild(row);
|
|
|
|
});
|
|
|
|
}
|
2024-10-18 10:15:36 +00:00
|
|
|
|
|
|
|
//window.onscroll = function() {
|
|
|
|
// const stickyElements = document.querySelectorAll('.sticky');
|
|
|
|
//stickyElements.forEach(element => {
|
|
|
|
// if (window.pageYOffset > element.offsetTop) {
|
|
|
|
// element.classList.add('active');
|
|
|
|
// } else {
|
|
|
|
// element.classList.remove('active');
|
|
|
|
//}
|
|
|
|
//});
|
|
|
|
//};
|