Commit ea29a0a4 authored by Damien Mondou's avatar Damien Mondou
Browse files

Prise en compte du TEA

parent 0095093a
# Projet "Calendrier"
Outil d'extraction du service annuel à partir du calendrier public de l'Université de La Rochelle.
## Récupération du code source
```
git clone https://gitlab.univ-lr.fr/dmondo01/calendrier.git
```
### Prérequis
Python 2.7 ou plus
Module xslxWriter
####Installation de xslxWriter via PIP
```
pip install XlsxWriter
```
#### Ou:
```
pip install --user XlsxWriter
```
### Utilisation
Dans le fichier main.py, indiquez votre login ULR, la date de début d'année ainsi que le nombre d'heures que vous devez
effectuer dans votre service.
```
timeTable = TimeTable("dmondo01", datetime(2018, 9, 1), 176)
```
Dans cet exemple:
login= "dmondo01"
dateDeDebut = 01/09/2018
nombre d'heures=176
## Author
* **Damien Mondou**
\ No newline at end of file
......@@ -33,3 +33,6 @@ class Course(object):
def getType(self):
return self.m_type
def __lt__(self, other):
return self.m_beginHour <= other.getBeginHour()
......@@ -12,6 +12,7 @@ class Module(object):
self.m_courses = []
self.m_CMHour = 0
self.m_TDHour = 0
self.m_TEAHour = 0
self.m_TPHour = 0
def addCourse(self, course):
......@@ -24,6 +25,9 @@ class Module(object):
else:
if course.getType() == "TP":
self.m_TPHour += course.getDuration()
else:
if course.getType() == "TEA":
self.m_TEAHour += course.getDuration();
def getCMHour(self):
return self.m_CMHour
......@@ -37,6 +41,9 @@ class Module(object):
def getTDHour(self):
return self.m_TDHour
def getTEAHour(self):
return self.m_TEAHour;
def getTPHour(self):
return self.m_TPHour
......@@ -37,14 +37,20 @@ class TimeTable(object):
for component in gcal.events:
description = component.description.replace(u"è", "e").replace(u"é", "e")
type = ""
if "Tp : " in component.description:
type = "TP"
if "examen" in component.description.lower():
type = "Examen"
else:
if "Td : " in component.description:
type = "TD"
if "tp : " in component.description.lower():
type = "TP"
else:
if "Cm : " in component.description:
type = "CM"
if "td : " in component.description.lower():
type = "TD"
else:
if "cm : " in component.description.lower():
type = "CM"
else:
if "tea : " in component.description.lower():
type = "TEA"
if type != "":
index = description.find(":")
......@@ -54,7 +60,7 @@ class TimeTable(object):
temp = temp[:endIndex - 7].replace(u"è", "e").replace(u"é", "e").replace(u"ê", "e")
parentheseIndex = temp.find("(")
date = str(component.begin)[:10].split("-")
date = str(component.begin)[:10].replace(" ","").split("-")
d = datetime(int(date[0]), int(date[1]), int(date[2]))
......@@ -148,63 +154,69 @@ class TimeTable(object):
worksheet.write(0, 11, "CM", cell_format)
worksheet.write(0, 12, "TD", cell_format)
worksheet.write(0, 13, "TP", cell_format)
worksheet.write(0, 14, "Total", cell_format)
worksheet.write(0, 15, "HETD", cell_format)
worksheet.write(0, 14, "TEA", cell_format)
worksheet.write(0, 15, "Total", cell_format)
worksheet.write(0, 16, "HETD", cell_format)
totalDuration = 0
totalDurationHETD = 0
lastWeek = int(sorted(self.m_courses.keys())[0].strftime("%V"))
nbCoursesByDay = 0
merge_format = workbook.add_format({
'align': 'left',
'valign': 'vcenter'})
# Iterate over the module.
for d in sorted(self.m_courses.keys()):
week = int(d.strftime("%V"))
if week != lastWeek:
if nbCoursesByDay > 1:
worksheet.merge_range(row-nbCoursesByDay, col, row-1, col,lastWeek, merge_format)
if self.m_courses.__len__() != 0:
lastWeek = int(sorted(self.m_courses.keys())[0].strftime("%V"))
nbCoursesByDay = 0
merge_format = workbook.add_format({
'align': 'left',
'valign': 'vcenter'})
# Iterate over the module.
for d in sorted(self.m_courses.keys()):
week = int(d.strftime("%V"))
if week != lastWeek:
if nbCoursesByDay > 1:
worksheet.merge_range(row-nbCoursesByDay, col, row-1, col,lastWeek, merge_format)
else:
worksheet.write_number(row, col, lastWeek)
lastWeek = week
nbCoursesByDay = len(self.m_courses[d])
else:
worksheet.write_number(row, col, lastWeek)
lastWeek = week
nbCoursesByDay = len(self.m_courses[d])
else:
nbCoursesByDay += len(self.m_courses[d])
nbCoursesByDay += len(self.m_courses[d])
date = str(d)[:10].split("-")
if(len(self.m_courses[d]) > 1):
worksheet.merge_range(row, col+1, row+len(self.m_courses[d])-1, col+1,
date[2]+"/"+date[1]+"/"+date[0], merge_format)
else:
worksheet.write(row, col+1, date[2]+"/"+date[1]+"/"+date[0])
for course in self.m_courses[d]:
worksheet.write(row, col + 2, course.getBeginHour()[:-3].replace(":","h") + " - " + course.getEndHour()[:-3].replace(":","h"))
worksheet.write(row, col + 3, "")
worksheet.write(row, col + 4, course.getModule().getName())
worksheet.write(row, col + 5, course.getType())
worksheet.write_number(row, col + 6, course.getDuration())
if course.getType() == "CM":
worksheet.write_number(row, col + 7, course.getDuration() * 1.5)
totalDurationHETD += course.getDuration() * 1.5
date = str(d)[:10].split("-")
if(len(self.m_courses[d]) > 1):
worksheet.merge_range(row, col+1, row+len(self.m_courses[d])-1, col+1,
date[2]+"/"+date[1]+"/"+date[0], merge_format)
else:
if course.getType() == "TD":
worksheet.write_number(row, col + 7, course.getDuration())
totalDurationHETD += course.getDuration()
worksheet.write(row, col+1, date[2]+"/"+date[1]+"/"+date[0])
for course in sorted(self.m_courses[d]):
worksheet.write(row, col + 2, course.getBeginHour()[:-3].replace(":","h") + " - " + course.getEndHour()[:-3].replace(":","h"))
worksheet.write(row, col + 3, "")
worksheet.write(row, col + 4, course.getModule().getName())
worksheet.write(row, col + 5, course.getType())
worksheet.write_number(row, col + 6, course.getDuration())
if course.getType() == "CM":
worksheet.write_number(row, col + 7, course.getDuration() * 1.5)
totalDurationHETD += course.getDuration() * 1.5
else:
if course.getType() == "TP":
worksheet.write_number(row, col + 7, course.getDuration() * 2 / 3)
totalDurationHETD += course.getDuration() * 2 / 3
row += 1
totalDuration += course.getDuration()
if nbCoursesByDay > 1:
worksheet.merge_range(row - nbCoursesByDay, col, row - 1, col, lastWeek, merge_format)
else:
worksheet.write_number(row-1, col, lastWeek)
if course.getType() == "TD":
worksheet.write_number(row, col + 7, course.getDuration())
totalDurationHETD += course.getDuration()
else:
if course.getType() == "TP":
worksheet.write_number(row, col + 7, course.getDuration() * 2 / 3)
totalDurationHETD += course.getDuration() * 2 / 3
else:
if course.getType() == "TEA":
worksheet.write_number(row, col + 7, course.getDuration() * 0.015 * 15)
totalDurationHETD += course.getDuration() * 0.015
row += 1
totalDuration += course.getDuration()
if nbCoursesByDay > 1:
worksheet.merge_range(row - nbCoursesByDay, col, row - 1, col, lastWeek, merge_format)
else:
worksheet.write_number(row-1, col, lastWeek)
worksheet.write(row+1, 6, "Total")
worksheet.write_number(row+1, 7, totalDuration)
......@@ -217,23 +229,27 @@ class TimeTable(object):
CM = 0
TD = 0
TP = 0
TEA = 0
for module in self.m_modules:
worksheet.write(row, 10, module.getName())
worksheet.write_number(row, 11, module.getCMHour())
worksheet.write_number(row, 12, module.getTDHour())
worksheet.write_number(row, 13, module.getTPHour())
worksheet.write_number(row, 14, module.getCMHour()+module.getTDHour()+module.getTPHour())
worksheet.write_number(row, 15, module.getCMHour()*1.5+module.getTDHour()+module.getTPHour()*2/3)
worksheet.write_number(row, 14, module.getTEAHour())
worksheet.write_number(row, 15, module.getCMHour()+module.getTDHour()+module.getTPHour()+module.getTEAHour())
worksheet.write_number(row, 16, module.getCMHour()*1.5+module.getTDHour()+module.getTPHour()*2/3+module.getTEAHour()*0.015*15)
row += 1
CM += module.getCMHour()
TD += module.getTDHour()
TP += module.getTPHour()
TEA += module.getTEAHour()
worksheet.write(row+1, 10, "Total", cell_format)
worksheet.write_number(row+1, 11, CM, cell_format)
worksheet.write_number(row+1, 12, TD, cell_format)
worksheet.write_number(row+1, 13, TP, cell_format)
worksheet.write_number(row+1, 14, CM+TD+TP, cell_format)
worksheet.write_number(row+1, 15, CM*1.5+TD+TP*2/3, cell_format)
worksheet.write_number(row+1, 14, TEA, cell_format)
worksheet.write_number(row+1, 15, CM+TD+TP+TEA, cell_format)
worksheet.write_number(row+1, 16, CM*1.5+TD+TP*2/3+TEA*0.015*15, cell_format)
workbook.close()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment