mirror of
https://git.schule.click/GymSedan/IServ2LMS.git
synced 2024-12-22 07:55:14 +01:00
Kursliste hinzugefügt
This commit is contained in:
parent
7a13310703
commit
2a45988156
1 changed files with 44 additions and 10 deletions
54
convert.py
54
convert.py
|
@ -11,10 +11,12 @@ import csv
|
|||
|
||||
# Schuljahr
|
||||
schuljahr='22'
|
||||
categoryid='17'
|
||||
|
||||
# Ergebnisspeicher
|
||||
members = []
|
||||
maxgroups = 0
|
||||
maxkurse = 0
|
||||
allekurse = []
|
||||
|
||||
# Kollegium einlesen
|
||||
with open('Export_Kollegium.csv', 'r', encoding='utf-8-sig') as f:
|
||||
|
@ -38,14 +40,20 @@ with open('Export_Kollegium.csv', 'r', encoding='utf-8-sig') as f:
|
|||
gt = row['Alle Gruppen'].split(',')
|
||||
|
||||
# Gruppen filtern
|
||||
gruppen = list(filter(lambda g: g.startswith('Kurs') or g.startswith('Klasse'), gt))
|
||||
gruppen = list(filter(lambda g: g.startswith('Kurs_') or g.startswith('Klasse_'), gt))
|
||||
|
||||
# Gruppen ins Format von Moodle bringen
|
||||
# Gruppen ins Format von Moodle bringen und Gruppen sammeln
|
||||
for i, g in enumerate(gruppen):
|
||||
p['course' + str(i+1)] = schuljahr + '_' + g
|
||||
p['role' + str(i+1)] = 'editingteacher'
|
||||
|
||||
maxgroups = max(maxgroups, len(gruppen))
|
||||
# Kurse sammeln
|
||||
if g not in allekurse:
|
||||
allekurse.append(g)
|
||||
|
||||
# Anzahl der maximalen Gruppen pro Person merken
|
||||
maxkurse = max(maxkurse, len(gruppen))
|
||||
|
||||
# Person zur Liste hinzfügen
|
||||
members.append(p)
|
||||
|
||||
|
@ -71,19 +79,24 @@ with open('Export_SuS.csv', 'r', encoding='utf-8-sig') as f:
|
|||
gt = row['Alle Gruppen'].split(',')
|
||||
|
||||
# Gruppen filtern
|
||||
gruppen = list(filter(lambda g: g.startswith('Kurs') or g.startswith('Klasse'), gt))
|
||||
gruppen = list(filter(lambda g: g.startswith('Kurs_') or g.startswith('Klasse_'), gt))
|
||||
|
||||
# Gruppen ins Format von Moodle bringen
|
||||
# Gruppen ins Format von Moodle bringen und Gruppen sammeln
|
||||
for i, g in enumerate(gruppen):
|
||||
p['course' + str(i+1)] = schuljahr + '_' + g
|
||||
p['role' + str(i+1)] = 'student'
|
||||
|
||||
maxgroups = max(maxgroups, len(gruppen))
|
||||
# Kurse sammeln
|
||||
if g not in allekurse:
|
||||
allekurse.append(g)
|
||||
|
||||
maxkurse = max(maxkurse, len(gruppen))
|
||||
|
||||
# Person zur Liste hinzfügen
|
||||
members.append(p)
|
||||
|
||||
# Moodle-Importdatei schreiben
|
||||
with open('import.csv', 'w', encoding='utf-8-sig') as f:
|
||||
# Moodle-Importdatei für User schreiben
|
||||
with open('Import_Users.csv', 'w', encoding='utf-8-sig') as f:
|
||||
# CSV DictWriter anlegen
|
||||
fieldnames = [
|
||||
'username',
|
||||
|
@ -95,7 +108,7 @@ with open('import.csv', 'w', encoding='utf-8-sig') as f:
|
|||
'idnumber',
|
||||
'password']
|
||||
|
||||
for i in range(1,maxgroups+1):
|
||||
for i in range(1,maxkurse+1):
|
||||
fieldnames.append("course" + str(i))
|
||||
fieldnames.append("role" + str(i))
|
||||
|
||||
|
@ -105,3 +118,24 @@ with open('import.csv', 'w', encoding='utf-8-sig') as f:
|
|||
cw.writeheader()
|
||||
for p in members:
|
||||
cw.writerow(p)
|
||||
|
||||
# Moodle-Importdatei für Kurse schreiben
|
||||
with open('Import_Courses.csv', 'w', encoding='utf-8-sig') as f:
|
||||
# CSV DictWriter anlegen
|
||||
fieldnames = [
|
||||
'shortname',
|
||||
'fullname',
|
||||
'category',
|
||||
'visible']
|
||||
|
||||
cw = csv.DictWriter(f, delimiter=';', fieldnames=fieldnames)
|
||||
|
||||
# Datei schreiben
|
||||
cw.writeheader()
|
||||
for c in allekurse:
|
||||
cw.writerow({
|
||||
'shortname' : schuljahr + '_' + c,
|
||||
'fullname' : schuljahr + '_' + c,
|
||||
'category' : categoryid,
|
||||
'visible' : '1'
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue