Commit ab251263 authored by Quentin Pimont's avatar Quentin Pimont
Browse files

add file update

parent 2cf2a50f
......@@ -3,3 +3,4 @@ test.py
gui.py
*.csv
*.ods
.Rproj.user
,quentinp,quentinp-HP-ProBook-650-G1,29.09.2020 16:45,file:///home/quentinp/.config/libreoffice/4;
\ No newline at end of file
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
This diff is collapsed.
library(stringr)
remove_accent <- function(str) {
new_str <- str_replace_all(str, '[ô]', 'o')
new_str <- str_replace_all(new_str, '[éèëËÉÈ]', 'e')
return(new_str)
}
amc <- read.csv('A2020.csv', header <- TRUE)
moodle_users <- read.csv('Utilisateurs.csv')
list_bac <- read.csv('liste_etu.csv')
amc_name <- amc$Nom
unique_tutor <- unique(as.vector(list_bac$Conseiller))
all_tutor_mail <- c()
for(tutor in unique_tutor){
tutor_split <- unlist(strsplit(tutor, split = ' '))
firstname_tutor_split <- tutor_split[!grepl("^[[:upper:]-]+$", tutor_split)]
firstname_tutor <- paste(firstname_tutor_split, collapse = ' ')
lastname_tutor_split <- tutor_split[grepl("^[[:upper:]-]+$", tutor_split)]
lastname_tutor <- paste(lastname_tutor_split, collapse = ' ')
tutor_mail <- as.vector(moodle_users$email[tolower(moodle_users$firstname) == tolower(remove_accent(firstname_tutor)) & tolower(moodle_users$lastname) == tolower(remove_accent(lastname_tutor))])
if(length(tutor_mail) == 0){
all_tutor_mail <- c(all_tutor_mail, '')
}else{
all_tutor_mail <- c(all_tutor_mail, tutor_mail)
}
}
df_tutor <- data.frame(tutor = unique_tutor, mail = all_tutor_mail)
mails_tutor <- c()
mails <- c();
for(user_amc in amc_name){
name_split <- unlist(strsplit(user_amc, split = ' '))
firstname_amc_split <- name_split[!grepl("^[[:upper:]-]+$", name_split)]
firstname_amc <- paste(firstname_amc_split, collapse = ' ')
lastname_amc_split <- name_split[grepl("^[[:upper:]-]+$", name_split)]
lastname_amc <- paste(lastname_amc_split, collapse = ' ')
current_mail <- as.vector(list_bac$Email[tolower(list_bac$Prénom) == tolower(firstname_amc) & tolower(list_bac$Nom) == tolower(lastname_amc)])
tutor_name <- as.vector(list_bac$Conseiller[tolower(list_bac$Prénom) == tolower(firstname_amc) & tolower(list_bac$Nom) == tolower(lastname_amc)])
tutor_mail <- as.vector(df_tutor$mail[df_tutor$tutor == tutor_name])
if(length(tutor_mail) == 0){
mails_tutor <- c(mails_tutor, '')
}else{
mails_tutor <- c(mails_tutor, tutor_mail)
}
if(length(current_mail) == 0){
firstname <- name_split[1]
lastname <- name_split[2]
current_mail <- as.vector(list_bac$Email[tolower(list_bac$Prénom) == tolower(firstname) & tolower(list_bac$Nom) == tolower(lastname)])
mails <- c(mails, current_mail)
}else{
mails <- c(mails, current_mail)
}
}
amc$Email <- mails
amc$tutor <- mails_tutor
write.csv(amc, file <- 'final_amc.csv', row.names <- FALSE)
\ No newline at end of file
# coding=utf-8
from lxml import etree
from tkinter import *
from tkinter import ttk
......@@ -47,6 +48,7 @@ class GuiPubli():
self.label_xml_etudiant.config(text = self.path_xml_student)
# parse le xml
def get_trees(self):
print(self.path_xml_student)
self.tree = etree.parse(self.path_xml_student)
self.list_uvs = self.tree.xpath('/ExtractionInscriptions/ListeEnseignements/Enseignement')
self.semester = self.tree.xpath('/ExtractionInscriptions/Semestre')[0].text
......@@ -76,6 +78,7 @@ class GuiPubli():
'index_surname' : '' if name_merged else row.index('surname'),
'index_email' : row.index('Email'),
'note' : row.index('note'),
'tutor' : row.index('tutor'),
'206' : row.index('206'),
'208' : row.index('208'),
'9714' : row.index('9714'),
......@@ -146,6 +149,9 @@ class GuiPubli():
# préparation des variable pour le nom et le prenom de l'etudiant séparé
first_name_current_stud = ''
last_name_current_stud = ''
# email du tuteur
current_tutor_stud = row[all_index['tutor']]
#current_tutor_stud = ''
# email de l'etudiant
email_current_stud = row[all_index['index_email']]
# pour chaque uv
......@@ -171,12 +177,14 @@ class GuiPubli():
first_name_current_stud = row[all_index['index_surname']]
last_name_current_stud = row[all_index['index_name']]
email_current_stud = row[all_index['index_email']]
current_tutor_stud = row[all_index['tutor']]
#current_tutor_stud = ''
self.student_tested.append(email_current_stud)
# on prépare la ligne à erire pour l'étudiants avec son nom, prénoms, mails, et le calcul des notes pour chaque catégories.
# on prépare la ligne à ecrire pour l'étudiants avec son nom, prénoms, mails, et le calcul des notes pour chaque catégories.
current_row = {
'Prénom' : first_name_current_stud,
'Nom' : last_name_current_stud,
'Tuteur' : '',
'Tuteur' : current_tutor_stud,
'Adresse de courriel' : email_current_stud,
'Analyser un algorithme_info NF01' : (self.convert_int(row[all_index['algo1']]) + self.convert_int(row[all_index['algo2']])) * 100 / 2,
'Analyser le mouvement d\'un corps en chute libre_phys PS21' : self.convert_int(row[all_index['9714']]) * 100 / 1,
......@@ -300,7 +308,7 @@ class GuiPubli():
if(row_index >= max_len):
# on dit qu'il ne reste plus d'étudiant
remaining_student = False
# créer l'interface graphique
def make_gui(self):
# initiation de l'interface graphique
self.window = Tk()
......
......@@ -2,6 +2,8 @@ import csv
import sys
from lxml import etree
xml_path = ''
csv_path = ''
student_not_register = []
xml_student = etree.parse('assets/input/a2019/inscrits_UV_A2019(4).xml')
list_uv = xml_student.xpath('/ExtractionInscriptions/ListeEnseignements/Enseignement')
......
......@@ -2,62 +2,34 @@ import os
import csv
from unidecode import unidecode
all_name_tutor = []
all_email_tutor = []
first_user = True
header_input_amc = ['Conseiller', 'Email Conseiller', 'Nom', 'Prénom', 'Email', 'Identifiant BAC', 'Salle']
student_bac_csv = open('assets/input/a2019/liste_etudiants_TC00_A19.csv')
student_bac_reader = csv.reader(student_bac_csv, delimiter=',')
with open('assets/output/correct/input_for_amc.csv', 'w') as input_amc:
input_amc_writer = csv.DictWriter(input_amc, fieldnames = header_input_amc, quoting = csv.QUOTE_NONNUMERIC)
input_amc_writer.writeheader()
for index_row_bac, row_bac in enumerate(student_bac_reader):
if(index_row_bac == 0):
index_student_bac = {
'tutor' : row_bac.index('Conseiller'),
'lastname' : row_bac.index('Nom'),
'firstname' : row_bac.index('Prénom'),
'email' : row_bac.index('Email'),
'id_bac' : row_bac.index('Identifiant BAC'),
'room' : row_bac.index('Salle')
}
else:
tutor_fullname = unidecode(row_bac[index_student_bac['tutor']].lower())
if (tutor_fullname != '' and tutor_fullname not in all_name_tutor):
current_mail_tutor = ''
with open('assets/input/a2019/Utilisateurs.csv') as moodle_user_csv:
moodle_user_reader = csv.reader(moodle_user_csv, delimiter=',')
for index_row_user, row_user in enumerate(moodle_user_reader):
if(index_row_user == 0):
header_user_moodle = {
'email' : row_user.index('email'),
'firstname' : row_user.index('firstname'),
'lastname' : row_user.index('lastname')
}
first_user = False
path_user_bac_tutor = '/home/quentinp/Documents/projets/publipostage/bac/p2021/input/tuteur.csv'
path_user_moodle = 'assets/input/p2020/Utilisateurs_moodle.csv'
path_tutor_mail = '/home/quentinp/Documents/projets/publipostage/bac/p2021/output/tutor_mail.csv'
tutor_mail_csv = open(path_tutor_mail, 'w')
tutor_mail_writer = csv.writer(tutor_mail_csv, delimiter=",")
with open(path_user_bac_tutor) as tutor_csv:
tutor_reader = csv.reader(tutor_csv, delimiter=",")
for nb_row, tutor in enumerate(tutor_reader):
if(nb_row > 0):
if(len(tutor) == 1):
tutor_fullname = tutor[0]
tutor_mail = ''
with open(path_user_moodle) as moodle_csv:
moodle_reader = csv.reader(moodle_csv , delimiter=",")
for nb_row_moodle, moodle_user in enumerate(moodle_reader):
if(nb_row_moodle == 0):
email_index = moodle_user.index('email')
fisrtname_index = moodle_user.index('firstname')
lastname_index = moodle_user.index('lastname')
else:
lastname_current_user = row_user[header_user_moodle['lastname']].lower()
firstname_current_user = row_user[header_user_moodle['firstname']].lower()
full_name_user = unidecode(lastname_current_user + ' ' + firstname_current_user)
#print(tutor_fullname + ' === ' + full_name_user)
if (tutor_fullname == full_name_user):
current_mail_tutor = row_user[header_user_moodle['email']]
all_name_tutor.append(tutor_fullname)
all_email_tutor.append(current_mail_tutor)
current_fullname = moodle_user[lastname_index] + ' ' + moodle_user[fisrtname_index]
if(tutor_fullname.lower() == current_fullname.lower()):
tutor_mail = moodle_user[email_index]
break
if(tutor_mail == ''):
tutor_mail = tutor_fullname
moodle_csv.close()
tutor_mail_writer.writerow([tutor_mail])
else:
if(tutor_fullname != ''):
index_current_tutor = all_name_tutor.index(tutor_fullname)
current_mail_tutor = all_email_tutor[index_current_tutor]
else:
current_mail_tutor = ''
row_to_write = {
'Conseiller' : row_bac[index_student_bac['tutor']],
'Email Conseiller' : current_mail_tutor,
'Nom' : row_bac[index_student_bac['lastname']],
'Prénom' : row_bac[index_student_bac['firstname']],
'Email' : row_bac[index_student_bac['email']],
'Identifiant BAC' : row_bac[index_student_bac['id_bac']],
'Salle' : row_bac[index_student_bac['room']]
}
input_amc_writer.writerow(row_to_write)
\ No newline at end of file
tutor_mail_writer.writerow([''])
from csvGenerate.generate_publi import GuiPubli
# coding=utf-8
from generate_publi import GuiPubli
mypubli = GuiPubli()
mypubli.make_gui()
\ No newline at end of file
import csv
path_amc_file = 'assets/input/p2020/amc_out.csv'
path_tutor_file = 'assets/input/p2020/mail_tutor.csv'
path_merge_file = 'assets/input/p2020/amc_final.csv'
header_merge_file = ['Nom', 'surname', 'Tuteur', 'Email', 'note','206','208','9714','BA1301','BA1501','BA2101','Bary22','Bary32','FLVH1','Geo3d21','Geo3d41','OG1','OG32','Phvec52',
'Poutres12','Poutres41','VH10','VH6','VHb2','VHbis4','Vitesse31','algo1','algo2','assert1','assert2','ella','fc1','fdp1','lecture11','lecture31','mathbis131','maths115','maths12','maths123','maths126',
'maths17','maths19','maths224','maths225','mathsbis11','mathsbis111','mathsbis119','mathsbis120','mathsbis16','mathsbis215','mathsbis28b','mp22','mp42','phrec21','phrec41','pytha42','pytha43','testlog1',
'thales32','thales42','vec82']
with open(path_merge_file, 'w') as merge_file:
merge_writer = csv.DictWriter(merge_file, fieldnames = header_merge_file, quoting = csv.QUOTE_NONNUMERIC)
merge_writer.writeheader()
with open(path_amc_file) as amc_file:
amc_reader = csv.reader(amc_file, delimiter=',')
for id_row_amc, row_amc in enumerate(amc_reader):
if(id_row_amc == 0):
header_amc_csv = {
'name' : row_amc.index('Nom'),
'note' : row_amc.index('note'),
'206' : row_amc.index('206'),
'208' : row_amc.index('208'),
'9714' : row_amc.index('9714'),
'BA1301' : row_amc.index('BA1301'),
'BA1501' : row_amc.index('BA1501'),
'BA2101' : row_amc.index('BA2101'),
'Bary22' : row_amc.index('Bary22'),
'Bary32' : row_amc.index('Bary32'),
'FLVH1' : row_amc.index('FLVH1'),
'Geo3d21' : row_amc.index('Geo3d21'),
'Geo3d41' : row_amc.index('Geo3d41'),
'OG1' : row_amc.index('OG1'),
'OG32' : row_amc.index('OG32'),
'Phvec52' : row_amc.index('Phvec52'),
'Poutres12' : row_amc.index('Poutres12'),
'Poutres41' : row_amc.index('Poutres41'),
'VH10' : row_amc.index('VH10'),
'VH6' : row_amc.index('VH6'),
'VHb2' : row_amc.index('VHb2'),
'VHbis4' : row_amc.index('VHbis4'),
'Vitesse31' : row_amc.index('Vitesse31'),
'algo1' : row_amc.index('algo1'),
'algo2' : row_amc.index('algo2'),
'assert1' : row_amc.index('assert1'),
'assert2' : row_amc.index('assert2'),
'ella' : row_amc.index('ella'),
'fc1' : row_amc.index('fc1'),
'fdp1' : row_amc.index('fdp1'),
'lecture11' : row_amc.index('lecture11'),
'lecture31' : row_amc.index('lecture31'),
'mathbis131' : row_amc.index('mathbis131'),
'maths115' : row_amc.index('maths115'),
'maths12' : row_amc.index('maths12'),
'maths123' : row_amc.index('maths123'),
'maths126' : row_amc.index('maths126'),
'maths17' : row_amc.index('maths17'),
'maths19' : row_amc.index('maths19'),
'maths224' : row_amc.index('maths224'),
'maths225' : row_amc.index('maths225'),
'mathsbis11' : row_amc.index('mathsbis11'),
'mathsbis111' : row_amc.index('mathsbis111'),
'mathsbis119' : row_amc.index('mathsbis119'),
'mathsbis120' : row_amc.index('mathsbis120'),
'mathsbis16' : row_amc.index('mathsbis16'),
'mathsbis215' : row_amc.index('mathsbis215'),
'mathsbis28b' : row_amc.index('mathsbis28b'),
'mp22' : row_amc.index('mp22'),
'mp42' : row_amc.index('mp42'),
'phrec21' : row_amc.index('phrec21'),
'phrec41' : row_amc.index('phrec41'),
'pytha42' : row_amc.index('pytha42'),
'pytha43' : row_amc.index('pytha43'),
'testlog1' : row_amc.index('testlog1'),
'thales32' : row_amc.index('thales32'),
'thales42' : row_amc.index('thales42'),
'vec82' : row_amc.index('vec82')
}
else:
tutor_file = open(path_tutor_file)
tutor_reader = csv.reader(tutor_file, delimiter=',')
is_match = False
for id_row_tutor, row_tutor in enumerate(tutor_reader):
if(id_row_tutor == 0):
header_tutor_csv = {
'tutor' : row_tutor.index('Conseiller'),
'tutor_mail' : row_tutor.index('Email Conseiller'),
'name' : row_tutor.index('Nom'),
'firstname' : row_tutor.index('Prénom'),
'student_mail' : row_tutor.index('Email')
}
else:
full_name = row_tutor[header_tutor_csv['firstname']].lower() + ' ' + row_tutor[header_tutor_csv['name']].lower()
if(full_name == row_amc[header_amc_csv['name']].lower()):
is_match = True
break
if(is_match):
row_to_write = {
'Nom' : row_tutor[header_tutor_csv['name']],
'surname' : row_tutor[header_tutor_csv['firstname']],
'Tuteur' : row_tutor[header_tutor_csv['tutor_mail']],
'Email' : row_tutor[header_tutor_csv['student_mail']],
'note' : row_amc[header_amc_csv['note']],
'206' : row_amc[header_amc_csv['206']],
'208' : row_amc[header_amc_csv['208']],
'9714' : row_amc[header_amc_csv['9714']],
'BA1301' : row_amc[header_amc_csv['BA1301']],
'BA1501' : row_amc[header_amc_csv['BA1501']],
'BA2101' : row_amc[header_amc_csv['BA2101']],
'Bary22' : row_amc[header_amc_csv['Bary22']],
'Bary32' : row_amc[header_amc_csv['Bary32']],
'FLVH1' : row_amc[header_amc_csv['FLVH1']],
'Geo3d21' : row_amc[header_amc_csv['Geo3d21']],
'Geo3d41' : row_amc[header_amc_csv['Geo3d41']],
'OG1' : row_amc[header_amc_csv['OG1']],
'OG32' : row_amc[header_amc_csv['OG32']],
'Phvec52' : row_amc[header_amc_csv['Phvec52']],
'Poutres12' : row_amc[header_amc_csv['Poutres12']],
'Poutres41' : row_amc[header_amc_csv['Poutres41']],
'VH10' : row_amc[header_amc_csv['VH10']],
'VH6' : row_amc[header_amc_csv['VH6']],
'VHb2' : row_amc[header_amc_csv['VHb2']],
'VHbis4' : row_amc[header_amc_csv['VHbis4']],
'Vitesse31' : row_amc[header_amc_csv['Vitesse31']],
'algo1' : row_amc[header_amc_csv['algo1']],
'algo2' : row_amc[header_amc_csv['algo2']],
'assert1' : row_amc[header_amc_csv['assert1']],
'assert2' : row_amc[header_amc_csv['assert2']],
'ella' : row_amc[header_amc_csv['ella']],
'fc1' : row_amc[header_amc_csv['fc1']],
'fdp1' : row_amc[header_amc_csv['fdp1']],
'lecture11' : row_amc[header_amc_csv['lecture11']],
'lecture31' : row_amc[header_amc_csv['lecture31']],
'mathbis131' : row_amc[header_amc_csv['mathbis131']],
'maths115' : row_amc[header_amc_csv['maths115']],
'maths12' : row_amc[header_amc_csv['maths12']],
'maths123' : row_amc[header_amc_csv['maths123']],
'maths126' : row_amc[header_amc_csv['maths126']],
'maths17' : row_amc[header_amc_csv['maths17']],
'maths19' : row_amc[header_amc_csv['maths19']],
'maths224' : row_amc[header_amc_csv['maths224']],
'maths225' : row_amc[header_amc_csv['maths225']],
'mathsbis11' : row_amc[header_amc_csv['mathsbis11']],
'mathsbis111' : row_amc[header_amc_csv['mathsbis111']],
'mathsbis119' : row_amc[header_amc_csv['mathsbis119']],
'mathsbis120' : row_amc[header_amc_csv['mathsbis120']],
'mathsbis16' : row_amc[header_amc_csv['mathsbis16']],
'mathsbis215' : row_amc[header_amc_csv['mathsbis215']],
'mathsbis28b' : row_amc[header_amc_csv['mathsbis28b']],
'mp22' : row_amc[header_amc_csv['mp22']],
'mp42' : row_amc[header_amc_csv['mp42']],
'phrec21' : row_amc[header_amc_csv['phrec21']],
'phrec41' : row_amc[header_amc_csv['phrec41']],
'pytha42' : row_amc[header_amc_csv['pytha42']],
'pytha43' : row_amc[header_amc_csv['pytha43']],
'testlog1' : row_amc[header_amc_csv['testlog1']],
'thales32' : row_amc[header_amc_csv['thales32']],
'thales42' : row_amc[header_amc_csv['thales42']],
'vec82' : row_amc[header_amc_csv['vec82']]
}
merge_writer.writerow(row_to_write)
"""
'index_email' : row.index('Email'),
'note' : row.index('note'),
'206' : row.index('206'),
'208' : row.index('208'),
'9714' : row.index('9714'),
'BA1301' : row.index('BA1301'),
'BA1501' : row.index('BA1501'),
'BA2101' : row.index('BA2101'),
'Bary22' : row.index('Bary22'),
'Bary32' : row.index('Bary32'),
'FLVH1' : row.index('FLVH1'),
'Geo3d21' : row.index('Geo3d21'),
'Geo3d41' : row.index('Geo3d41'),
'OG1' : row.index('OG1'),
'OG32' : row.index('OG32'),
'Phvec52' : row.index('Phvec52'),
'Poutres12' : row.index('Poutres12'),
'Poutres41' : row.index('Poutres41'),
'VH10' : row.index('VH10'),
'VH6' : row.index('VH6'),
'VHb2' : row.index('VHb2'),
'VHbis4' : row.index('VHbis4'),
'Vitesse31' : row.index('Vitesse31'),
'algo1' : row.index('algo1'),
'algo2' : row.index('algo2'),
'assert1' : row.index('assert1'),
'assert2' : row.index('assert2'),
'ella' : row.index('ella'),
'fc1' : row.index('fc1'),
'fdp1' : row.index('fdp1'),
'lecture11' : row.index('lecture11'),
'lecture31' : row.index('lecture31'),
'mathbis131' : row.index('mathbis131'),
'maths115' : row.index('maths115'),
'maths12' : row.index('maths12'),
'maths123' : row.index('maths123'),
'maths126' : row.index('maths126'),
'maths17' : row.index('maths17'),
'maths19' : row.index('maths19'),
'maths224' : row.index('maths224'),
'maths225' : row.index('maths225'),
'mathsbis11' : row.index('mathsbis11'),
'mathsbis111' : row.index('mathsbis111'),
'mathsbis119' : row.index('mathsbis119'),
'mathsbis120' : row.index('mathsbis120'),
'mathsbis16' : row.index('mathsbis16'),
'mathsbis215' : row.index('mathsbis215'),
'mathsbis28b' : row.index('mathsbis28b'),
'mp22' : row.index('mp22'),
'mp42' : row.index('mp42'),
'phrec21' : row.index('phrec21'),
'phrec41' : row.index('phrec41'),
'pytha42' : row.index('pytha42'),
'pytha43' : row.index('pytha43'),
'testlog1' : row.index('testlog1'),
'thales32' : row.index('thales32'),
'thales42' : row.index('thales42'),
'vec82' : row.index('vec82')
}
"""
\ No newline at end of file
Markdown is supported
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