2024-10-17 10:47:01 +00:00
|
|
|
// Definicja kategorii i ich kryteriów
|
|
|
|
const categories = {
|
|
|
|
frekwencja: [
|
|
|
|
{ name: "Frekwencja 95-100%", id: "frekwencja" },
|
|
|
|
{ name: "Brak godzin nieusprawiedliwionych", id: "brak_godzin" },
|
|
|
|
{ name: "Minimum 85% frekwencja", id: "min_85" }
|
|
|
|
],
|
|
|
|
olimpiady: [
|
|
|
|
{ name: "Etap szkolny", id: "etap_szkolny" },
|
|
|
|
{ name: "Etap rejonowy", id: "etap_rejonowy" },
|
|
|
|
{ name: "Etap wojewódzki", id: "etap_wojewodzki" },
|
|
|
|
{ name: "Etap ogólnopolski", id: "etap_ogolnopolski" }
|
|
|
|
],
|
|
|
|
konkursy: [
|
|
|
|
{ name: "Udział w konkursach", id: "udzial_konkurs" },
|
|
|
|
{ name: "Wyróżnienie w konkursie", id: "wyroznienie_konkurs" }
|
|
|
|
],
|
|
|
|
reprezentacja: [
|
|
|
|
{ name: "Reprezentacja indywidualna", id: "reprezentacja_indywidualna" },
|
|
|
|
{ name: "Reprezentacja zespołowa", id: "reprezentacja_zespolowa" },
|
|
|
|
{ name: "Udział w zawodach", id: "udzial_zawody" }
|
|
|
|
],
|
|
|
|
aktywnosc: [
|
|
|
|
{ name: "Organizacja imprez", id: "organizacja_imprez" },
|
|
|
|
{ name: "Funkcje w klasie", id: "funkcja_klasa" },
|
|
|
|
{ name: "Uroczystości okolicznościowe", id: "uroczystosci" },
|
|
|
|
{ name: "Udział w poczcie sztandarowej", id: "poczta_sztandar" },
|
|
|
|
{ name: "Pomoc nauczycielowi", id: "pomoc_nauczyciel" },
|
|
|
|
{ name: "Wolontariat", id: "wolontariat" }
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
// Zmienna przechowująca aktualną kategorię
|
|
|
|
let currentCategory = 'frekwencja';
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
|
|
}
|
|
|
|
return await response.json();
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Error fetching JSON file:", error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Funkcja do wczytania pliku class.json
|
|
|
|
async function loadClasses() {
|
|
|
|
const classFilePath = '/data/class.json';
|
|
|
|
const classes = await fetchJSONFile(classFilePath);
|
|
|
|
|
|
|
|
if (classes) {
|
|
|
|
console.log('Classes loaded:', classes);
|
|
|
|
|
2024-10-17 12:14:38 +00:00
|
|
|
const selectClass = document.getElementById("select-class-select");
|
|
|
|
selectClass.innerHTML = ""; // Clear existing options
|
|
|
|
|
|
|
|
classes.forEach(classInfo => {
|
|
|
|
const option = document.createElement('option');
|
|
|
|
option.value = classInfo.class;
|
|
|
|
option.textContent = `Klasa: ${classInfo.class}`;
|
|
|
|
selectClass.appendChild(option);
|
|
|
|
console.log("DODANO KLASE ", classInfo.class, " DO SELECT");
|
|
|
|
});
|
2024-10-16 10:42:08 +00:00
|
|
|
|
2024-10-17 12:14:38 +00:00
|
|
|
// Add event listener for class selection
|
|
|
|
selectClass.addEventListener('change', function() {
|
|
|
|
const selectedClass = this.value;
|
|
|
|
console.log(`Wybrano klasę: ${selectedClass}`);
|
|
|
|
// Wczytaj dane uczniów dla wybranej klasy
|
|
|
|
// To implement based on how you store student data per class
|
|
|
|
// For example:
|
|
|
|
// loadStudents(selectedClass);
|
|
|
|
// But for now, assuming studentsData is global
|
|
|
|
});
|
|
|
|
|
|
|
|
// Optionally, set a default selected class
|
|
|
|
if (classes.length > 0) {
|
|
|
|
selectClass.value = classes[0].class;
|
|
|
|
// Load students for the first class
|
|
|
|
// loadStudents(classes[0].class);
|
2024-10-16 10:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 10:47:01 +00:00
|
|
|
console.log("Criteria loaded:", criteria);
|
|
|
|
// Implementacja dalszego przetwarzania kryteriów, jeśli jest potrzebna
|
2024-10-16 10:18:43 +00:00
|
|
|
}
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Dane uczniów (przykładowe, powinny być ładowane z plików JSON)
|
2024-10-17 12:14:38 +00:00
|
|
|
let studentsData = [
|
2024-10-16 09:24:57 +00:00
|
|
|
{ name: "Jan Kowalski", behavior: {} },
|
|
|
|
{ name: "Anna Nowak", behavior: {} },
|
|
|
|
{ name: "Piotr Wiśniewski", behavior: {} },
|
|
|
|
{ name: "Katarzyna Zielińska", behavior: {} }
|
|
|
|
];
|
|
|
|
|
2024-10-17 12:14:38 +00:00
|
|
|
// To store student data per class, you might need a data structure like:
|
|
|
|
// let allStudentsData = {
|
|
|
|
// "1A": [...],
|
|
|
|
// "2B": [...],
|
|
|
|
// ...
|
|
|
|
// };
|
|
|
|
|
|
|
|
// let allStudentsData = {};
|
|
|
|
|
|
|
|
// function loadStudents(className) {
|
|
|
|
// // Load students data for the class from allStudentsData[className]
|
|
|
|
// // And set studentsData accordingly
|
|
|
|
// }
|
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
let currentDay = 0;
|
|
|
|
const baseDate = new Date();
|
|
|
|
|
|
|
|
// 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 10:18:43 +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'
|
|
|
|
showInnerTab('frekwencja');
|
2024-10-16 10:18:43 +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-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() {
|
2024-10-17 12:14:38 +00:00
|
|
|
studentsData.forEach(student => {
|
|
|
|
const studentId = student.name.replace(/ /g, '-');
|
|
|
|
const behavior = student.behavior[`day${currentDay}`] || {};
|
|
|
|
|
|
|
|
// Get criteria for the current category
|
|
|
|
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 10:47:01 +00:00
|
|
|
const studentId = student.name.replace(/ /g, '-');
|
|
|
|
const behavior = student.behavior[`day${currentDay}`] || {};
|
|
|
|
|
|
|
|
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,
|
|
|
|
brak_godzin: parseInt(document.getElementById('brak-godzin-punkty').value) || 0,
|
|
|
|
min_85: parseInt(document.getElementById('min-85-punkty').value) || 0,
|
|
|
|
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 12:14:38 +00:00
|
|
|
let dayPoints = 0;
|
|
|
|
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;
|
|
|
|
});
|
|
|
|
|
|
|
|
stats += `${student.name}: ${totalPoints} punktów (${getGrade(totalPoints)})\n`;
|
|
|
|
});
|
|
|
|
|
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
|
|
|
|
function generateTable(category) {
|
|
|
|
const table = document.getElementById('student-table');
|
|
|
|
const thead = table.querySelector('thead tr');
|
|
|
|
const tbody = table.querySelector('tbody');
|
|
|
|
|
|
|
|
// Clear existing headers and body
|
|
|
|
thead.innerHTML = '';
|
|
|
|
tbody.innerHTML = '';
|
|
|
|
|
|
|
|
// Add 'Imię i Nazwisko' header
|
|
|
|
const thName = document.createElement('th');
|
|
|
|
thName.textContent = "Imię i Nazwisko";
|
|
|
|
thead.appendChild(thName);
|
|
|
|
|
|
|
|
// Get columns for the category
|
|
|
|
const categoryColumns = categories[category];
|
|
|
|
|
|
|
|
// Add headers for category
|
|
|
|
categoryColumns.forEach(column => {
|
|
|
|
const th = document.createElement('th');
|
|
|
|
th.textContent = column.name;
|
|
|
|
thead.appendChild(th);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Generate rows
|
|
|
|
studentsData.forEach(student => {
|
|
|
|
const row = document.createElement('tr');
|
2024-10-16 09:24:57 +00:00
|
|
|
|
2024-10-17 10:47:01 +00:00
|
|
|
// Name cell
|
|
|
|
const tdName = document.createElement('td');
|
|
|
|
tdName.textContent = student.name;
|
|
|
|
row.appendChild(tdName);
|
|
|
|
|
|
|
|
// Checkbox cells
|
|
|
|
categoryColumns.forEach(column => {
|
|
|
|
const td = document.createElement('td');
|
|
|
|
const checkbox = document.createElement('input');
|
|
|
|
checkbox.type = 'checkbox';
|
|
|
|
checkbox.id = `${column.id}-${student.name.replace(/ /g, '-')}`;
|
|
|
|
checkbox.onchange = calculateStats;
|
|
|
|
|
|
|
|
// Ustawienie stanu checkboxa na podstawie zapisanych danych
|
|
|
|
if (student.behavior[`day${currentDay}`] && student.behavior[`day${currentDay}`][column.id]) {
|
|
|
|
checkbox.checked = student.behavior[`day${currentDay}`][column.id];
|
|
|
|
}
|
|
|
|
|
|
|
|
td.appendChild(checkbox);
|
|
|
|
row.appendChild(td);
|
|
|
|
});
|
|
|
|
|
|
|
|
tbody.appendChild(row);
|
|
|
|
});
|
|
|
|
}
|