diff --git a/data.json b/data.json
new file mode 100644
index 0000000..e69de29
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..6e56fce
--- /dev/null
+++ b/index.html
@@ -0,0 +1,57 @@
+
+
+
+
+
+ PunctualityTracker
+
+
+
+
+
+
+
+ Elev |
+ Forseelser |
+ Minuter forsent |
+ Dage mødt |
+ % af dage forsent |
+ Gnm møde tidspunkt |
+
+
+
+
+
+
+
+
+
diff --git a/main.py b/main.py
index 263c8e7..8865ea7 100644
--- a/main.py
+++ b/main.py
@@ -1,22 +1,39 @@
import bs4 as bs
import requests
+import json
import urllib3
-from datetime import datetime
+from datetime import datetime, timedelta, time
urllib3.disable_warnings()
class Student:
- def __init__(self, name, total_times, total_minutes, total_days):
+ def __init__(self, name, total_times, total_minutes, total_days, average_time):
self.name = name
self.total_times = total_times
self.total_minutes = total_minutes
self.total_days = total_days
+ self.average_time = average_time
+
+class StudentEncoder(json.JSONEncoder):
+ def default(self, obj):
+ if isinstance(obj, Student):
+ return {
+ "name": obj.name,
+ "total_times": obj.total_times,
+ "total_minutes": obj.total_minutes,
+ "total_days": obj.total_days,
+ "average_time": str(obj.average_time)
+ }
+ return super().default(obj)
def get_all_student_data():
student_ids = get_all_student_ids()
students = []
for student_id in student_ids:
- students.append(get_student_data(student_id))
+ student = get_student_data(student_id)
+ if student.name == "Null":
+ continue
+ students.append(student)
return students
@@ -71,23 +88,44 @@ def get_student_data(student_string):
if too_late:
total_times += 1
minutes_total += minutes_difference
+
+ if len(times) == 0:
+ return Student("Null", 0, 0, 0, 0)
+
+ # Convert time objects to time durations in seconds
+ durations = [t.hour * 3600 + t.minute * 60 + t.second for t in times]
+
+ # Calculate the average time duration
+ average_duration = sum(durations) / len(durations)
+
+ # Convert the average time duration back to the time format
+ average_time = time(
+ int(average_duration // 3600),
+ int((average_duration % 3600) // 60),
+ int(average_duration % 60)
+ )
- return Student(student_name, total_times, minutes_total, total_days)
+ return Student(student_name, total_times, minutes_total, total_days, average_time)
students = get_all_student_data()
+file_content = json.dumps(students, cls=StudentEncoder)
-# Sort the array based on total_minutes in descending order
-sorted_array = sorted(students, key=lambda x: x.total_times / x.total_days if x.total_days != 0 else 0, reverse=True)
-# sorted_array = sorted(students, key=lambda x: x.total_minutes, reverse=True)
+f = open("data.json", "w")
+f.write(file_content)
+f.close()
-i = 0
-# Print the sorted array
-for item in sorted_array:
- if item.total_times == 0:
- continue
- i += 1
- hours = round(item.total_minutes / 50, 2)
- percent_late = round((item.total_times / item.total_days) * 100, 2)
- print(f"{str(i)}) Name: {item.name}, Total Times: {item.total_times} / {item.total_days} = {percent_late}%, Total Minutes: {item.total_minutes}, Total Hours: {hours}")
\ No newline at end of file
+# # Sort the array based on total_minutes in descending order
+# sorted_array = sorted(students, key=lambda x: x.total_times / x.total_days if x.total_days != 0 else 0, reverse=True)
+# # sorted_array = sorted(students, key=lambda x: x.total_minutes, reverse=True)
+
+# i = 0
+# # Print the sorted array
+# for item in sorted_array:
+# if item.total_times == 0:
+# continue
+# i += 1
+# hours = round(item.total_minutes / 50, 2)
+# percent_late = round((item.total_times / item.total_days) * 100, 2)
+# print(f"{str(i)}) Name: {item.name}, Total Times: {item.total_times} / {item.total_days} = {percent_late}%, Total Minutes: {item.total_minutes}, Total Hours: {hours}, Average time: {item.average_time}")
\ No newline at end of file
diff --git a/sortable.min.css b/sortable.min.css
new file mode 100644
index 0000000..0f7b25a
--- /dev/null
+++ b/sortable.min.css
@@ -0,0 +1 @@
+.sortable th{cursor:pointer}.sortable th.no-sort{pointer-events:none}.sortable th::after,.sortable th::before{transition:color .1s ease-in-out;font-size:1.2em;color:rgba(0,0,0,0)}.sortable th::after{margin-left:3px;content:"▸"}.sortable th:hover::after{color:inherit}.sortable th.dir-d::after{color:inherit;content:"▾"}.sortable th.dir-u::after{color:inherit;content:"▴"}.sortable th.indicator-left::after{content:""}.sortable th.indicator-left::before{margin-right:3px;content:"▸"}.sortable th.indicator-left:hover::before{color:inherit}.sortable th.indicator-left.dir-d::before{color:inherit;content:"▾"}.sortable th.indicator-left.dir-u::before{color:inherit;content:"▴"}.sortable{--stripe-color: #272b2c;--th-color: #d8d4cf;--th-bg: #181a1b;--td-color: #d8d4cf;--td-on-stripe-color: #000;border-spacing:0}.sortable tbody tr:nth-child(odd){background-color:var(--stripe-color);color:var(--td-on-stripe-color)}.sortable th{background:var(--th-bg);color:var(--th-color);font-weight:normal;text-align:left;text-transform:capitalize;vertical-align:baseline;white-space:nowrap}.sortable td{color:var(--td-color)}.sortable td,.sortable th{padding:10px}.sortable td:first-child,.sortable th:first-child{border-top-left-radius:4px}.sortable td:last-child,.sortable th:last-child{border-top-right-radius:4px}/*# sourceMappingURL=sortable.min.css.map */
diff --git a/sortable.min.js b/sortable.min.js
new file mode 100644
index 0000000..de6e93f
--- /dev/null
+++ b/sortable.min.js
@@ -0,0 +1,2 @@
+document.addEventListener("click",function(c){try{function f(a,b){return a.nodeName===b?a:f(a.parentNode,b)}var x=c.shiftKey||c.altKey,d=f(c.target,"TH"),m=f(d,"TR"),g=f(m,"TABLE");function n(a,b){a.classList.remove("dir-d");a.classList.remove("dir-u");b&&a.classList.add(b)}function p(a){return x&&a.dataset.sortAlt||a.dataset.sort||a.textContent}if(g.classList.contains("sortable")){var q,e=m.cells,r=parseInt(d.dataset.sortTbr);for(c=0;c