2024-10-16 10:18:43 +00:00
|
|
|
// Funkcja do wczytania pliku JSON
|
|
|
|
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-16 10:42:08 +00:00
|
|
|
var section_HTML = ""
|
|
|
|
|
2024-10-16 10:18:43 +00:00
|
|
|
// Iterowanie po wszystkich klasach i wczytywanie plików z danymi uczniów
|
|
|
|
for (const classInfo of classes) {
|
|
|
|
const studentsFilePath = '/data/'+ classInfo.file_path;
|
|
|
|
const studentsData = await fetchJSONFile(studentsFilePath);
|
|
|
|
|
2024-10-16 10:42:08 +00:00
|
|
|
// Wczytywanie klas do elementu select w html
|
|
|
|
|
|
|
|
const section_by_id = document.getElementById("select-class")
|
|
|
|
|
|
|
|
if (!section_HTML.includes(classInfo.class)) {
|
|
|
|
const section_option = "<option>" + "Klasa: " + classInfo.class + "</option>"
|
|
|
|
section_HTML += section_option;
|
|
|
|
console.log("DODANO KLASE ", classInfo.class, " DO SELECT")
|
|
|
|
section_by_id.innerHTML = section_HTML
|
|
|
|
}
|
|
|
|
|
2024-10-16 11:51:22 +00:00
|
|
|
//Literowanie studentow i dodawanie do tabeli
|
|
|
|
|
2024-10-16 10:18:43 +00:00
|
|
|
if (studentsData) {
|
|
|
|
console.log(`Students loaded for class ${classInfo.class}:`, studentsData);
|
|
|
|
// Tutaj możesz przechowywać dane lub je przetwarzać według potrzeb
|
|
|
|
processClassData(classInfo, studentsData);
|
2024-10-16 10:42:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-16 10:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const classData = []
|
|
|
|
|
|
|
|
// Funkcja do przetwarzania danych o klasach i uczniach
|
|
|
|
function processClassData(classInfo, studentsData) {
|
|
|
|
console.log(`Class: ${classInfo.class}, Group: ${classInfo.group}, Students Count: ${classInfo.student_count}`);
|
|
|
|
console.log('Student Data:', studentsData);
|
|
|
|
classData.push(studentsData)
|
|
|
|
// Możesz tutaj np. wyświetlić dane w interfejsie lub przeprowadzić dodatkowe operacje
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uruchomienie wczytywania klas
|
|
|
|
loadClasses();
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
2024-10-16 09:24:57 +00:00
|
|
|
let currentDay = 0;
|
|
|
|
const baseDate = new Date();
|
2024-10-16 11:51:22 +00:00
|
|
|
|
|
|
|
//Pobieranie studentow na podstawie aktualnie wybranej klasy
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
document.getElementById('select-class').addEventListener('change', function() {
|
|
|
|
var selectedClass = this.value;
|
|
|
|
var lastCharacter = selectedClass.slice(-1); // Pobiera ostatni znak
|
|
|
|
console.log("Aktualnie wybrana klasa: ", lastCharacter, " Liczba studentow: ");
|
|
|
|
|
|
|
|
if (studentsData && studentsData.students) {
|
|
|
|
// Literowanie po studentach i wyświetlanie ich danych
|
|
|
|
|
|
|
|
studentsData.students.forEach(student => {
|
|
|
|
if(studentsData.header.class == classInfo.class){
|
|
|
|
console.log('Imię: ', student.first_name)
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
console.log('Nie udało się pobrać danych studentów.');
|
|
|
|
}
|
|
|
|
|
|
|
|
//Pobranie uczniow klasy
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-10-16 09:24:57 +00:00
|
|
|
const studentsData = [
|
|
|
|
{ name: "Jan Kowalski", behavior: {} },
|
|
|
|
{ name: "Anna Nowak", behavior: {} },
|
|
|
|
{ name: "Piotr Wiśniewski", behavior: {} },
|
|
|
|
{ name: "Katarzyna Zielińska", behavior: {} }
|
|
|
|
];
|
|
|
|
|
|
|
|
function showTab(tabName) {
|
|
|
|
const tabs = document.querySelectorAll('.tab');
|
|
|
|
tabs.forEach(tab => tab.classList.remove('active'));
|
|
|
|
document.getElementById(tabName).classList.add('active');
|
|
|
|
|
|
|
|
if (tabName === 'criteria') {
|
|
|
|
loadDayData();
|
|
|
|
} else if (tabName === 'points') {
|
|
|
|
calculateStats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-16 10:18:43 +00:00
|
|
|
async function changeClass() {
|
|
|
|
await loadClasses()
|
|
|
|
let classesNames = []
|
|
|
|
for (const classInfo of classData) {
|
|
|
|
console.log(classInfo)
|
|
|
|
classesNames.push(classInfo.header.class + "-" + classInfo.header.group)
|
|
|
|
}
|
|
|
|
console.log("lol")
|
|
|
|
console.log(classesNames)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-16 09:24:57 +00:00
|
|
|
function generateTable() {
|
2024-10-16 10:18:43 +00:00
|
|
|
changeClass()
|
2024-10-16 09:24:57 +00:00
|
|
|
const table = document.getElementById('student-table');
|
|
|
|
table.innerHTML = '';
|
|
|
|
|
2024-10-16 10:42:08 +00:00
|
|
|
//xd
|
|
|
|
|
2024-10-16 09:24:57 +00:00
|
|
|
studentsData.forEach(student => {
|
|
|
|
const row = document.createElement('tr');
|
|
|
|
row.innerHTML = `
|
2024-10-16 10:42:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-16 09:24:57 +00:00
|
|
|
<td>${student.name}</td>
|
|
|
|
<td><input type="checkbox" id="frekwencja-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="brak-godzin-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="min-85-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="etap-szkolny-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="etap-rejonowy-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="etap-wojewodzki-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="etap-ogolnopolski-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="udzial-konkurs-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="wyroznienie-konkurs-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="reprezentacja-indywidualna-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="reprezentacja-zespolowa-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="udzial-zawody-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="organizacja-imprez-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="funkcja-klasa-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="uroczystosci-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="poczta-sztandar-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="pomoc-nauczyciel-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
<td><input type="checkbox" id="wolontariat-${student.name.replace(' ', '-')}" onchange="calculateStats()"></td>
|
|
|
|
`;
|
|
|
|
table.appendChild(row);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeDay(direction) {
|
|
|
|
saveDayData();
|
|
|
|
currentDay += direction;
|
|
|
|
const newDate = new Date(baseDate);
|
|
|
|
newDate.setDate(baseDate.getDate() + currentDay);
|
|
|
|
document.getElementById('current-date').innerText = newDate.toLocaleDateString();
|
|
|
|
loadDayData();
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadDayData() {
|
|
|
|
studentsData.forEach(student => {
|
|
|
|
const studentId = student.name.replace(' ', '-');
|
|
|
|
const behavior = student.behavior[`day${currentDay}`] || {};
|
|
|
|
|
|
|
|
document.getElementById(`frekwencja-${studentId}`).checked = behavior.frekwencja || false;
|
|
|
|
document.getElementById(`brak-godzin-${studentId}`).checked = behavior.brak_godzin || false;
|
|
|
|
document.getElementById(`min-85-${studentId}`).checked = behavior.min_85 || false;
|
|
|
|
document.getElementById(`etap-szkolny-${studentId}`).checked = behavior.etap_szkolny || false;
|
|
|
|
document.getElementById(`etap-rejonowy-${studentId}`).checked = behavior.etap_rejonowy || false;
|
|
|
|
document.getElementById(`etap-wojewodzki-${studentId}`).checked = behavior.etap_wojewodzki || false;
|
|
|
|
document.getElementById(`etap-ogolnopolski-${studentId}`).checked = behavior.etap_ogolnopolski || false;
|
|
|
|
document.getElementById(`udzial-konkurs-${studentId}`).checked = behavior.udzial_konkurs || false;
|
|
|
|
document.getElementById(`wyroznienie-konkurs-${studentId}`).checked = behavior.wyroznienie_konkurs || false;
|
|
|
|
document.getElementById(`reprezentacja-indywidualna-${studentId}`).checked = behavior.reprezentacja_indywidualna || false;
|
|
|
|
document.getElementById(`reprezentacja-zespolowa-${studentId}`).checked = behavior.reprezentacja_zespolowa || false;
|
|
|
|
document.getElementById(`udzial-zawody-${studentId}`).checked = behavior.udzial_zawody || false;
|
|
|
|
document.getElementById(`organizacja-imprez-${studentId}`).checked = behavior.organizacja_imprez || false;
|
|
|
|
document.getElementById(`funkcja-klasa-${studentId}`).checked = behavior.funkcja_klasa || false;
|
|
|
|
document.getElementById(`uroczystosci-${studentId}`).checked = behavior.uroczystosci || false;
|
|
|
|
document.getElementById(`poczta-sztandar-${studentId}`).checked = behavior.poczta_sztandar || false;
|
|
|
|
document.getElementById(`pomoc-nauczyciel-${studentId}`).checked = behavior.pomoc_nauczyciel || false;
|
|
|
|
document.getElementById(`wolontariat-${studentId}`).checked = behavior.wolontariat || false;
|
|
|
|
});
|
|
|
|
|
|
|
|
calculateStats();
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveDayData() {
|
|
|
|
studentsData.forEach(student => {
|
|
|
|
const studentId = student.name.replace(' ', '-');
|
|
|
|
const behavior = {
|
|
|
|
frekwencja: document.getElementById(`frekwencja-${studentId}`).checked,
|
|
|
|
brak_godzin: document.getElementById(`brak-godzin-${studentId}`).checked,
|
|
|
|
min_85: document.getElementById(`min-85-${studentId}`).checked,
|
|
|
|
etap_szkolny: document.getElementById(`etap-szkolny-${studentId}`).checked,
|
|
|
|
etap_rejonowy: document.getElementById(`etap-rejonowy-${studentId}`).checked,
|
|
|
|
etap_wojewodzki: document.getElementById(`etap-wojewodzki-${studentId}`).checked,
|
|
|
|
etap_ogolnopolski: document.getElementById(`etap-ogolnopolski-${studentId}`).checked,
|
|
|
|
udzial_konkurs: document.getElementById(`udzial-konkurs-${studentId}`).checked,
|
|
|
|
wyroznienie_konkurs: document.getElementById(`wyroznienie-konkurs-${studentId}`).checked,
|
|
|
|
reprezentacja_indywidualna: document.getElementById(`reprezentacja-indywidualna-${studentId}`).checked,
|
|
|
|
reprezentacja_zespolowa: document.getElementById(`reprezentacja-zespolowa-${studentId}`).checked,
|
|
|
|
udzial_zawody: document.getElementById(`udzial-zawody-${studentId}`).checked,
|
|
|
|
organizacja_imprez: document.getElementById(`organizacja-imprez-${studentId}`).checked,
|
|
|
|
funkcja_klasa: document.getElementById(`funkcja-klasa-${studentId}`).checked,
|
|
|
|
uroczystosci: document.getElementById(`uroczystosci-${studentId}`).checked,
|
|
|
|
poczta_sztandar: document.getElementById(`poczta-sztandar-${studentId}`).checked,
|
|
|
|
pomoc_nauciciel: document.getElementById(`pomoc-nauczyciel-${studentId}`).checked,
|
|
|
|
wolontariat: document.getElementById(`wolontariat-${studentId}`).checked
|
|
|
|
};
|
|
|
|
|
|
|
|
student.behavior[`day${currentDay}`] = behavior;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function calculateStats() {
|
|
|
|
const frekwencjaPoints = parseInt(document.getElementById('frekwencja-punkty').value);
|
|
|
|
const brakGodzinPoints = parseInt(document.getElementById('brak-godzin-punkty').value);
|
|
|
|
const min85Points = parseInt(document.getElementById('min-85-punkty').value);
|
|
|
|
const etapSzkolnyPoints = parseInt(document.getElementById('etap-szkolny-punkty').value);
|
|
|
|
const etapRejonowyPoints = parseInt(document.getElementById('etap-rejonowy-punkty').value);
|
|
|
|
const etapWojewodzkiPoints = parseInt(document.getElementById('etap-wojewodzki-punkty').value);
|
|
|
|
const etapOgolnopolskiPoints = parseInt(document.getElementById('etap-ogolnopolski-punkty').value);
|
|
|
|
const udzialKonkursPoints = 5; // stała wartość
|
|
|
|
const wyroznienieKonkursPoints = 10; // stała wartość
|
|
|
|
const reprezentacjaIndPoints = 5; // stała wartość
|
|
|
|
const reprezentacjaZesPoints = 10; // stała wartość
|
|
|
|
const udzialZawodyPoints = 15; // stała wartość
|
|
|
|
const organizacjaImprezPoints = 10; // stała wartość
|
|
|
|
const funkcjaKlasyPoints = 10; // stała wartość
|
|
|
|
const uroczystosciPoints = 10; // stała wartość
|
|
|
|
const pocztaSztandarPoints = 20; // stała wartość
|
|
|
|
const pomocNauczycielaPoints = 10; // stała wartość
|
|
|
|
const wolontariatPoints = 10; // stała wartość
|
|
|
|
|
|
|
|
let stats = '';
|
|
|
|
|
|
|
|
studentsData.forEach(student => {
|
|
|
|
let totalPoints = 0;
|
|
|
|
|
|
|
|
Object.keys(student.behavior).forEach(day => {
|
|
|
|
const behavior = student.behavior[day];
|
|
|
|
|
|
|
|
let dayPoints = 0; // Startowa liczba punktów
|
|
|
|
if (behavior.frekwencja) dayPoints += frekwencjaPoints;
|
|
|
|
if (behavior.brak_godzin) dayPoints += brakGodzinPoints;
|
|
|
|
if (behavior.min_85) dayPoints += min85Points;
|
|
|
|
if (behavior.etap_szkolny) dayPoints += etapSzkolnyPoints;
|
|
|
|
if (behavior.etap_rejonowy) dayPoints += etapRejonowyPoints;
|
|
|
|
if (behavior.etap_wojewodzki) dayPoints += etapWojewodzkiPoints;
|
|
|
|
if (behavior.etap_ogolnopolski) dayPoints += etapOgolnopolskiPoints;
|
|
|
|
if (behavior.udzial_konkurs) dayPoints += udzialKonkursPoints;
|
|
|
|
if (behavior.wyroznienie_konkurs) dayPoints += wyroznienieKonkursPoints;
|
|
|
|
if (behavior.reprezentacja_indywidualna) dayPoints += reprezentacjaIndPoints;
|
|
|
|
if (behavior.reprezentacja_zespolowa) dayPoints += reprezentacjaZesPoints;
|
|
|
|
if (behavior.udzial_zawody) dayPoints += udzialZawodyPoints;
|
|
|
|
if (behavior.organizacja_imprez) dayPoints += organizacjaImprezPoints;
|
|
|
|
if (behavior.funkcja_klasa) dayPoints += funkcjaKlasyPoints;
|
|
|
|
if (behavior.uroczystosci) dayPoints += uroczystosciPoints;
|
|
|
|
if (behavior.poczta_sztandar) dayPoints += pocztaSztandarPoints;
|
|
|
|
if (behavior.pomoc_nauciciel) dayPoints += pomocNauczycielaPoints;
|
|
|
|
if (behavior.wolontariat) dayPoints += wolontariatPoints;
|
|
|
|
|
|
|
|
totalPoints += dayPoints;
|
|
|
|
});
|
|
|
|
|
|
|
|
stats += `${student.name}: ${totalPoints} punktów (${getGrade(totalPoints)})\n`;
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById('stats').innerText = stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ustawienie daty na dziś
|
|
|
|
document.getElementById('current-date').innerText = baseDate.toLocaleDateString();
|
|
|
|
|
|
|
|
// Generowanie tabeli przy starcie
|
|
|
|
generateTable();
|