basic notenrechner
This commit is contained in:
parent
c875b45c44
commit
d8eaa98e36
7 changed files with 223 additions and 21 deletions
|
@ -20,30 +20,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
<html>
|
||||
<head>
|
||||
<title>iFSR Notenrechner</title>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<script src="rechner.js"></script>
|
||||
<h1>Notenberechnungen</h1>
|
||||
<p>Hier könnt ihr Vordiploms- und Abschlussnoten ausgewählter Studiengänge der Fakultät Informatik der TU Dresden berechnen.</p>
|
||||
|
||||
<h2>Informatik</h2>
|
||||
<ul>
|
||||
<li><a href="?note=a_ba_inf">Berechnung Abschlussnote Bachelor Informatik (PO 2009)</a></li>
|
||||
<li><a href="?note=a_ma_inf">Berechnung Abschlussnote Master Informatik (PO 2010)</a></li>
|
||||
<li><a href="?note=vordip_inf">Berechnung Vordiplom Informatik (PO 2010)</a></li>
|
||||
<li><a href="?note=a_dip_inf">Berechnung Abschlussnote Diplom Informatik (PO 2010)</a></li>
|
||||
<li><a href="?note=a_dip_inf">Berechnung Abschlussnote Diplom Informatik (PO 2004)</a></li>
|
||||
</ul>
|
||||
<label for="options">Wähle eine Berechnung aus</label>
|
||||
<select id="options">
|
||||
<option disabled selected value> -- -- </option>
|
||||
</select>
|
||||
|
||||
<h2>Medieninformatik</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="?note=">Berechnung Abschlussnote Bachelor Medieninformatik</a></li>
|
||||
<li><a href="?note=">Berechnung Abschlussnote Master Medieninformatik</a></li>
|
||||
<li><a href="?note=">Berechnung Vordiplom bzw. Grundstudium Bakkalaureat Medieninformatik PO 2004</a></li>
|
||||
<li><a href="?note=">Berechnung Abschlussnote Diplom Medieninformatik (PO 2004)</a></li>
|
||||
<li><a href="?note=">Berechnung Abschlussnote Bakkalaureat Medieninformatik (PO 2004)</a></li>
|
||||
</ul>
|
||||
<div>
|
||||
<form id="noten"></form>
|
||||
</div>
|
||||
|
||||
<script src="rechner.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -16,3 +16,85 @@
|
|||
|
||||
import gewichtungen from '../build/gewichtungen.json'
|
||||
|
||||
var select = document.getElementById("options") as HTMLSelectElement;
|
||||
|
||||
for (let key in gewichtungen) {
|
||||
let option = document.createElement('option');
|
||||
option.value = key;
|
||||
option.text = String(gewichtungen[key as keyof typeof gewichtungen].display_name);
|
||||
select.add(option);
|
||||
}
|
||||
select.selectedIndex = 0;
|
||||
|
||||
var noten = document.getElementById("noten") as HTMLFormElement;
|
||||
|
||||
select.onchange = function changed() {
|
||||
noten.innerHTML = "";
|
||||
let gewichtung_index = select.selectedOptions[0].value as keyof typeof gewichtungen;
|
||||
let gewichtung = gewichtungen[gewichtung_index];
|
||||
|
||||
let table = document.createElement('table');
|
||||
for (let modulIndex in gewichtung.module) {
|
||||
let modul = gewichtung.module[modulIndex];
|
||||
let label = document.createElement('label');
|
||||
let input = document.createElement('input');
|
||||
let row = table.insertRow();
|
||||
|
||||
|
||||
input.id = modul.short + "input";
|
||||
input.type = "number";
|
||||
input.required = true;
|
||||
input.min = "1";
|
||||
input.max = "5";
|
||||
input.style.width = "70px";
|
||||
input.step = "0.1";
|
||||
input.addEventListener("input", () => {
|
||||
// Validate with the built-in constraints
|
||||
input.setCustomValidity("");
|
||||
if (!input.validity.valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
let note = parseFloat(input.value.replace(",", "."));
|
||||
if (note > 4) {
|
||||
input.setCustomValidity("Keine Berechnung möglich bei nicht bestandenen Prüfungen (mit > 4.0)")
|
||||
}
|
||||
});
|
||||
|
||||
label.htmlFor = input.id;
|
||||
label.textContent = modul.name;
|
||||
|
||||
row.insertCell().appendChild(label);
|
||||
row.insertCell().appendChild(input);
|
||||
}
|
||||
noten.appendChild(table);
|
||||
|
||||
let submit = document.createElement('button');
|
||||
submit.type = "submit";
|
||||
submit.innerText = "Berechnen";
|
||||
|
||||
let result = document.createElement('p');
|
||||
|
||||
noten.appendChild(result);
|
||||
noten.appendChild(submit);
|
||||
|
||||
noten.onsubmit = function calculate(event) {
|
||||
event.preventDefault();
|
||||
let sum = 0;
|
||||
let credits = 0;
|
||||
|
||||
for (let modulIndex in gewichtung.module) {
|
||||
let modul = gewichtung.module[modulIndex];
|
||||
let noteInput = document.getElementById(modul.short + "input") as HTMLInputElement;
|
||||
let noteString = noteInput.value;
|
||||
let note = parseFloat(noteString.replace(",", "."));
|
||||
|
||||
sum += modul.lp * note;
|
||||
credits += modul.lp;
|
||||
}
|
||||
|
||||
let endnote = Math.floor((sum / credits) * 10) / 10;
|
||||
|
||||
result.innerText = "Deine Note: " + String(endnote);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue