Browse Source

Eine bereits recht vollstaendige Version, auch wenn sie optisch noch nicht sehr ansprechend ist.

Vinzent Reiß 7 years ago
parent
commit
2476b640e1
1 changed files with 67 additions and 6 deletions
  1. 67 6
      ToolV00.py

+ 67 - 6
ToolV00.py

@@ -1,6 +1,7 @@
1 1
 # genutzte Module
2 2
 from Tkinter import *
3 3
 import sys
4
+import os
4 5
 
5 6
 # Globale Variablen
6 7
 name = ""
@@ -211,15 +212,56 @@ def NotenspiegelAusgabe():
211 212
 		Label(root, width =  int(float(Notenverteilung[i])/float(len(Studenten))*128), background = "red").grid(row = i, column = 1, sticky = W, pady = 4)
212 213
 	Button(root, text = "Beenden", command = root.destroy).grid(row = 0, column = 2)
213 214
 	root.mainloop()
214
-
215
+def DatenAnpassen():
216
+	for i in range(len(Studenten)):
217
+		if Studenten[i][0] >= 10**15:
218
+			Studenten[i][0] = Studenten[i][0] - (Studenten[i][0] / 10**15) * 10**15
219
+		if len(Studenten[i][1]) >= 16:
220
+			Studenten[i][1] = Studenten[i][1][0:15]
215 221
 def TextdateiErstellen():
216 222
 	Datei = open(name, "w")
217 223
 	Datei.write("Name der Klausur:\t%s\n" % (name))
218 224
 	Datei.write("Datum der Klausur:\t%s\n" % (date))
219 225
 	Datei.write("|\tMatr.-Nr.\t|\t\tName\t\t|\tNote\t|\n\n")
220 226
 	for i in range(len(Studenten)):
221
-		Datei.write("|\t%8d\t|\t%16s\t|\t%.1f\t|\n" % (Studenten[i][0], Studenten[i][1], Studenten[i][2]))
227
+		Datei.write("|\t%8d\t|\t%16s\t|\t%4.1f\t|\n" % (Studenten[i][0], Studenten[i][1], Studenten[i][2]))
228
+	Datei.close()
229
+def ExistenzPruefung():
230
+	global name
231
+	foldercontent = os.listdir(".")
232
+	if name in foldercontent:
233
+		return True
234
+	else:
235
+		return False
236
+def DatenAuslesen():
237
+	Datei = open(name,"r")
238
+	Datei.readline()
239
+	Datei.readline()
240
+	Datei.readline()
241
+	Datei.readline()
242
+	while True:
243
+		line = Datei.readline()
244
+		if not line: break
245
+		tmp = line.split("|")
246
+		tmp = "".join(tmp)
247
+		tmp = tmp.split("\t")
248
+		tmp = "".join(tmp)
249
+		tmp = tmp.split()
250
+		Student = []
251
+		Student.append(int(tmp[0]))
252
+		Student.append(tmp[1])
253
+		Student.append(float(tmp[2]))
254
+		Studenten.append(Student)
255
+	Datei.close()
256
+def NichtExistenzVerkuenden():
257
+	root = Tk()
258
+	root.title("Keine Datei gefunden")
259
+	Label(root, text = "Die Datei existiert noch gar nicht!").grid()
260
+	Button(root, text = "Weiter", command = root.destroy).grid()
261
+	root.mainloop()
222 262
 def NeueKlausur():
263
+	button1.config(text = "", command = mainroot.destroy)
264
+	button2.config(text = "", command = mainroot.destroy)
223 265
 	SchluesselDatenAbfragen()
224 266
 	AufgabenPunkteAbfragen()
225 267
 	MindestPunktzahlAbfragen()
@@ -228,10 +270,29 @@ def NeueKlausur():
228 270
 	GesamtNoteBerechnen()
229 271
 	Notenspiegel()
230 272
 	NotenspiegelAusgabe()
273
+	DatenAnpassen()
231 274
 	TextdateiErstellen()
275
+def AlteKlausur():
276
+	button1.config(text = "", command = mainroot.destroy)
277
+	button2.config(text = "", command = mainroot.destroy)
278
+	SchluesselDatenAbfragen()
279
+	if ExistenzPruefung():
280
+		AufgabenPunkteAbfragen()
281
+		MindestPunktzahlAbfragen()
282
+		BewertungsSpiegelBerechnen()
283
+		StudentenMaskeGenerieren()
284
+		GesamtNoteBerechnen()
285
+		DatenAuslesen()
286
+		Notenspiegel()
287
+		NotenspiegelAusgabe()
288
+		DatenAnpassen()
289
+		TextdateiErstellen()
290
+	else:
291
+		NichtExistenzVerkuenden()
232 292
 mainroot = Tk()
233
-mainroot.title("Hauptmenü")
234
-Button(mainroot, text = "Neue Klausur", command = NeueKlausur).grid()
235
-Button(mainroot, text = "Alte Klausur bearbeiten", command = AlteKlausur).grid()
236
-Button(mainroot, text = "Beenden", command = mainroot.destroy).grid()
293
+mainroot.title("Hauptmenue")
294
+button1 = Button(mainroot, text = "Neue Klausur", command = NeueKlausur)
295
+button2 = Button(mainroot, text = "Alte Klausur bearbeiten", command = AlteKlausur)
296
+button1.grid()
297
+button2.grid()
237 298
 mainroot.mainloop()