-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
650 lines (594 loc) · 30.5 KB
/
Copy pathmain.py
File metadata and controls
650 lines (594 loc) · 30.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
import requests
import json
import urllib
from art import *
import matplotlib.pyplot as plt
from getpass4 import getpass
global s
s = requests.Session()
s.headers.update({'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,da;q=0.6',
'content-length': '0',
'content-type': 'application/x-www-form-urlencoded',
'origin': 'https://www.ecoledirecte.com',
'referer': 'https://www.ecoledirecte.com/',
'sec-ch-ua': '"Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
})
global token
def connect(username,password):
payload = '''data={
"uuid": "",
"identifiant": "username",
"motdepasse": "password",
"isReLogin": false
}
'''
username = urllib.parse.quote(username)
password = urllib.parse.quote(password)
payload = payload.replace('username',username).replace('password',password)
s.headers.update({'content-length':f'{len(payload)}'})
r = s.post('https://api.ecoledirecte.com/v3/login.awp?v=4.26.3',data=payload)
try:
answer = json.loads(r.text)
if answer['code'] == 200:
token = answer['token']
id_user = answer['data']['accounts'][0]['id']
write_in_file('id_user.txt',id_user)
write_in_file('token.txt',token)
s.headers.update({'x-token':f'{token}'})
else :
print(answer['message'])
quit()
except ValueError as e:
print(e)
def notes(whatiwant):
payload = '''data={
"anneeScolaire": ""
}'''
s.headers.update({'content-length':f'{len(payload)}'})
id_user = read_in_file('id_user.txt')
r = s.post(f'https://api.ecoledirecte.com/v3/Eleves/{id_user}/notes.awp?verbe=get&v=4.27.1',data=payload)
answer = json.loads(r.text)
toutelesnotes = answer['data']['notes']
if whatiwant == 'moyenne_annuelle':
somme_coef = 0
somme_notes = 0
for x in range(0,len(toutelesnotes)):
#print(toutelesnotes[x]['valeur']+'/'+toutelesnotes[x]['noteSur']+' coef : '+toutelesnotes[x]['coef']+' en '+toutelesnotes[x]['libelleMatiere'])
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['valeur'] != '':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['valeur'] == '':
pass
print("Votre moyenne annuelle est de :",round(somme_notes/somme_coef,2))
if whatiwant == 'mediane_annuelle':
notes = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['valeur'] != '':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.')))/float(toutelesnotes[x]['noteSur'])
notes.append(note)
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True and toutelesnotes[x]['valeur'] == '':
pass
notes.sort()
if len(notes)%2 == 0:
mediane = float((notes[int(len(notes)/2)]+notes[int((len(notes)/2)+1)]))/2
if len(notes)%2 != 0:
mediane = notes[int((len(notes)+1)/2)]
print("Votre médiane annuelle est de",round(mediane,2))
if whatiwant == 'mediane_A001':
notes = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A001' and toutelesnotes[x]['valeur'] != '':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))
notes.append(note)
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['codePeriode'] == 'A001' and toutelesnotes[x]['valeur'] != '':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A001':
pass
notes.sort()
if len(notes)%2 == 0:
mediane = float((notes[int(len(notes)/2)]+notes[int((len(notes)/2)+1)]))/2
if len(notes)%2 != 0:
mediane = notes[int((len(notes)+1)/2)]
print("Votre médiane du T1 est de",round(mediane,2))
if whatiwant == 'mediane_A002':
notes = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A002' and toutelesnotes[x]['valeur'] != '':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))
notes.append(note)
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['codePeriode'] == 'A002' and toutelesnotes[x]['valeur'] != '':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A002':
pass
notes.sort()
if len(notes)%2 == 0:
mediane = float((notes[int(len(notes)/2)]+notes[int((len(notes)/2)+1)]))/2
if len(notes)%2 != 0:
mediane = notes[int((len(notes)+1)/2)]
print("Votre médiane du T2 est de",round(mediane,2))
if whatiwant == 'mediane_A003':
notes = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A003' and toutelesnotes[x]['valeur'] != '':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))
notes.append(note)
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['codePeriode'] == 'A003' and toutelesnotes[x]['valeur'] != '':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A003':
pass
notes.sort()
if len(notes)%2 == 0:
mediane = float((notes[int(len(notes)/2)]+notes[int((len(notes)/2)+1)]))/2
if len(notes)%2 != 0:
mediane = notes[int((len(notes)+1)/2)]
print("Votre médiane du T3 est de",round(mediane,2))
if whatiwant == 'A001':
somme_coef = 0
somme_notes = 0
for x in range(0,len(toutelesnotes)):
#print(toutelesnotes[x]['valeur']+'/'+toutelesnotes[x]['noteSur']+' coef : '+toutelesnotes[x]['coef']+' en '+toutelesnotes[x]['libelleMatiere'])
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A001' and toutelesnotes[x]['valeur'] != '':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['codePeriode'] == 'A001' and toutelesnotes[x]['valeur'] != '':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A001':
pass
if somme_notes == 0:
print("Vous n'avez pas de notes sur la période A001.")
else:
print("Votre moyenne pour la période A001 est de :",round(somme_notes/somme_coef,2))
if whatiwant == 'A002':
somme_coef = 0
somme_notes = 0
for x in range(0,len(toutelesnotes)):
#print(toutelesnotes[x]['valeur']+'/'+toutelesnotes[x]['noteSur']+' coef : '+toutelesnotes[x]['coef']+' en '+toutelesnotes[x]['libelleMatiere'])
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A002' and toutelesnotes[x]['valeur'] != '':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['codePeriode'] == 'A002' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['valeur'] != '':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A002':
pass
if somme_notes == 0:
print("Vous n'avez pas de notes sur la période A002.")
else:
print("Votre moyenne pour la période A002 est de :",round(somme_notes/somme_coef,2))
if whatiwant == 'A003':
somme_coef = 0
somme_notes = 0
for x in range(0,len(toutelesnotes)):
#print(toutelesnotes[x]['valeur']+'/'+toutelesnotes[x]['noteSur']+' coef : '+toutelesnotes[x]['coef']+' en '+toutelesnotes[x]['libelleMatiere'])
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A003':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['codePeriode'] == 'A003':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A003':
pass
if somme_notes == 0:
print("Vous n'avez pas de notes sur la période A003.")
else:
print("Votre moyenne pour la période A003 est de :",round(somme_notes/somme_coef,2))
if whatiwant == 'tracetoutelesnotes':
notes = []
dates = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False :
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' :
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True:
pass
plt.plot(dates,notes)
plt.xlabel("Date")
plt.ylabel("Note")
ax=plt.gca()
ax.get_xaxis().set_visible(False)
ax.set_ylim(0, 20)
plt.title("Tracé annuel des notes")
plt.show()
if whatiwant == 'tracenotesA001':
notes = []
dates = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A001':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['codePeriode'] == 'A001':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A001':
pass
plt.plot(dates,notes)
plt.xlabel("Date")
plt.ylabel("Note")
plt.title("Tracé des notes du T1")
ax=plt.gca()
ax.get_xaxis().set_visible(False)
ax.set_ylim(0, 20)
plt.show()
if whatiwant == 'tracenotesA002':
notes = []
dates = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A002':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['codePeriode'] == 'A002':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A002':
pass
plt.plot(dates,notes)
plt.xlabel("Date")
plt.ylabel("Note")
plt.title("Tracé des notes du T2")
ax=plt.gca()
ax.get_xaxis().set_visible(False)
ax.set_ylim(0, 20)
plt.show()
if whatiwant == 'tracenotesA003':
notes = []
dates = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['codePeriode'] == 'A003':
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['codePeriode'] == 'A003':
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['codePeriode'] != 'A003':
pass
plt.plot(dates,notes)
plt.xlabel("Date")
plt.ylabel("Note")
plt.title("Tracé des notes du T3")
ax=plt.gca()
ax.get_xaxis().set_visible(False)
ax.set_ylim(0, 20)
plt.show()
def notes_matieres(matiere,periode):
payload = '''data={
"anneeScolaire": ""
}'''
s.headers.update({'content-length':f'{len(payload)}'})
id_user = read_in_file('id_user.txt')
r = s.post(f'https://api.ecoledirecte.com/v3/Eleves/{id_user}/notes.awp?verbe=get&v=4.27.1',data=payload)
answer = json.loads(r.text)
toutelesnotes = answer['data']['notes']
if periode == None:
somme_coef = 0
somme_notes = 0
for x in range(0,len(toutelesnotes)):
#print(toutelesnotes[x]['valeur']+'/'+toutelesnotes[x]['noteSur']+' coef : '+toutelesnotes[x]['coef']+' en '+toutelesnotes[x]['libelleMatiere'])
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['libelleMatiere'] == matiere:
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['libelleMatiere'] == matiere:
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['libelleMatiere'] != matiere:
pass
if somme_notes == 0:
print("Vous n'avez pas de notes pour la matière : ",matiere)
else:
print("Votre moyenne annuelle pour la matière",matiere,"est de :",round(somme_notes/somme_coef,2))
if periode != None:
somme_coef = 0
somme_notes = 0
for x in range(0,len(toutelesnotes)):
#print(toutelesnotes[x]['valeur']+'/'+toutelesnotes[x]['noteSur']+' coef : '+toutelesnotes[x]['coef']+' en '+toutelesnotes[x]['libelleMatiere'])
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['libelleMatiere'] == matiere and toutelesnotes[x]['codePeriode'] == periode:
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.'))/float(toutelesnotes[x]['noteSur']))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['libelleMatiere'] == matiere and toutelesnotes[x]['codePeriode'] == periode:
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))*float(toutelesnotes[x]['coef'])
somme_coef += float(toutelesnotes[x]['coef'])
somme_notes += note
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['libelleMatiere'] != matiere or toutelesnotes[x]['codePeriode'] != periode:
pass
if somme_notes == 0:
print("Vous n'avez pas de notes pour la matière : ",matiere)
else:
print("Votre moyenne pour la période",periode,"pour la matière",matiere,"est de :",round(somme_notes/somme_coef,2))
def trace_matieres(matiere,periode):
payload = '''data={
"anneeScolaire": ""
}'''
s.headers.update({'content-length':f'{len(payload)}'})
id_user = read_in_file('id_user.txt')
r = s.post(f'https://api.ecoledirecte.com/v3/Eleves/{id_user}/notes.awp?verbe=get&v=4.27.1',data=payload)
answer = json.loads(r.text)
toutelesnotes = answer['data']['notes']
if periode == None:
notes = []
dates = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['libelleMatiere'] == matiere:
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.')))/float(toutelesnotes[x]['noteSur'])
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['libelleMatiere'] == matiere:
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['libelleMatiere'] != matiere:
pass
plt.plot(dates,notes)
plt.xlabel("Date")
plt.ylabel("Note")
plt.title("Tracé des notes pour la matière : "+matiere)
ax=plt.gca()
ax.set_ylim(0, 22)
plt.show()
if periode != None:
notes = []
dates = []
for x in range(0,len(toutelesnotes)):
if toutelesnotes[x]['noteSur'] != 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['valeur'] != 'Abs\xa0' and toutelesnotes[x]['nonSignificatif'] == False and toutelesnotes[x]['libelleMatiere'] == matiere and toutelesnotes[x]['codePeriode'] == periode:
note = (20*float(toutelesnotes[x]['valeur'].replace(',', '.')))/float(toutelesnotes[x]['noteSur'])
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['noteSur'] == 20 and toutelesnotes[x]['valeur'] != '' and toutelesnotes[x]['libelleMatiere'] == matiere and toutelesnotes[x]['codePeriode'] == periode:
note = float(toutelesnotes[x]['valeur'].replace(',', '.'))
notes.append(note)
dates.append(toutelesnotes[x]['date'])
if toutelesnotes[x]['valeur'] == 'Abs\xa0' or toutelesnotes[x]['nonSignificatif'] == True or toutelesnotes[x]['libelleMatiere'] != matiere or toutelesnotes[x]['codePeriode'] != periode:
pass
plt.plot(dates,notes)
plt.xlabel("Date")
plt.ylabel("Note")
plt.title("Tracé des notes pour la matière : "+matiere)
ax=plt.gca()
ax.set_ylim(0, 22)
plt.show()
def listes_matieres():
payload = '''data={
"anneeScolaire": ""
}'''
s.headers.update({'content-length':f'{len(payload)}'})
id_user = read_in_file('id_user.txt')
r = s.post(f'https://api.ecoledirecte.com/v3/Eleves/{id_user}/notes.awp?verbe=get&v=4.27.1',data=payload)
answer = json.loads(r.text)
ensemblematieres = answer['data']['periodes'][0]['ensembleMatieres']['disciplines']
listes_matieres = []
for x in range(0,len(ensemblematieres)):
listes_matieres.append(ensemblematieres[x]['discipline'])
return listes_matieres
def write_in_file(name,towrite):
file = open(name,'w')
file.write(str(towrite))
file.close()
def read_in_file(name):
file = open(name,'r')
read = file.read()
file.close()
return read
if __name__ == '__main__':
tprint("ECOLE DIRECTE")
print("Ce logiciel vous permets pour l'instant 4 choses :\n 1. Connaître votre moyenne\n 2. Connaitre votre médiane\n 3. Effectuer le tracé de vos notes\n 4. Les moyennes par matières")
choix = int(input("Entrer un nombre entre 1 et 4 : "))
if choix == 1:
print("Vous avez choisi la moyenne.\nSouhaitez-vous votre :\n 1.Moyenne annuelle\n 2.Moyenne par periode")
type_moyenne = int(input("Entrer un nombre entre 1 et 2: "))
if type_moyenne == 1:
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('moyenne_annuelle')
if type_moyenne == 2:
print("Vous avez choisi la moyenne par periode.\n 1.Trimestre 1\n 2.Trimestre 2\n 3.Trimestre 3")
trimestre = int(input("Entrer un nombre entre 1 et 3 : "))
if trimestre == 1:
print("Vous avez choisi le premier trimestre.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n ( aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('A001')
elif trimestre == 2:
print("Vous avez choisi le second trimestre.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('A002')
elif trimestre == 3:
print("Vous avez choisi le troisième trimestre.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('A003')
if choix == 2:
print("Vous avez choisi la médiane.Souhaitez-vous :\n 1. La médiane annuelle\n 2. La médiane par periode")
type_mediane = int(input("Entrer un nombre entre 1 et 2 : "))
if type_mediane == 1:
print("Vous avez choisi la médiane annuelle.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('mediane_annuelle')
if type_mediane == 2:
print("Vous avez choisi la médiane par période. Souhaitez-vous :\n 1. Le trimestre 1\n 2. Le trimestre 2\n 3. Le trimestre 3")
trimestre_mediane = int(input("Entrer un nombre entre 1 et 3 : "))
if trimestre_mediane == 1:
print("Vous avez choisi la médiane pour le trimestre 1.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('mediane_A001')
if trimestre_mediane == 2:
print("Vous avez choisi la médiane pour le trimestre 2.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('mediane_A002')
if trimestre_mediane == 3:
print("Vous avez choisi la médiane pour le trimestre 3.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('mediane_A003')
if choix == 3:
print("Vous avez choisi le tracé de vos notes. Souhaitez-vous\n 1. Le tracé annuel de toutes vos notes\n 2. Le tracé par periode de toutes vos notes\n 3. Le tracé annuel pour une matière \n 4. Le tracé par période pour une matière")
trace = int(input("Entrer un nombre entre 1 et 4 : "))
if trace == 1:
print("Vous avez choisi le tracé annuel de vos notes.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('tracetoutelesnotes')
if trace == 2:
print("Vous avez choisi le tracé par période de vos notes.Souhaitez-vous\n 1. Le premier trimestre\n 2. Le deuxième trimestre\n 3. Le troisième trimestre")
periode = int(input("Entrer un nombre entre 1 et 3 : "))
if periode == 1:
print("Vous avez choisi le T1.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('tracenotesA001')
if periode == 2:
print("Vous avez choisi le T2.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('tracenotesA002')
if periode == 3:
print("Vous avez choisi le T3.\n Je vais vous demander d'entrer vos identifiants ECOLE DIRECTE\n(aucune information ne sera collectée).")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
notes('tracenotesA003')
if trace == 3:
print("Il est nécessaire que vous vous connectiez pour afficher vos matières")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
l = listes_matieres()
counter = 1
for el in l:
print(str(counter)+'. '+el)
counter += 1
matiere = int(input("Entrer un nombre entre 1 et "+str(counter-1)+' pour sélectionnez la matière : '))
trace_matieres(l[matiere-1],None)
if trace == 4:
print("Il est nécessaire que vous vous connectiez pour afficher vos matières")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
l = listes_matieres()
counter = 1
for el in l:
print(str(counter)+'. '+el)
counter += 1
matiere = int(input("Entrer un nombre entre 1 et "+str(counter-1)+' pour sélectionnez la matière : '))
p = input('Pour quelle période souhaitez-vous le tracé.\n 1. 1er Trimestre\n 2. 2e Trimestre \n 3. 3e Trimestre\nEntrer un nombre entre 1 et 3 : ')
periode = 'A00'+str(p)
trace_matieres(l[matiere-1],periode)
if choix == 4:
print("Vous avez choisi les moyennes par matières.Connectez-vous pour voir la liste de vos matières.")
identifiant = input("Votre identifiant : ")
motdepasse = getpass('Votre mot de passe : ')
try:
connect(identifiant,motdepasse)
except:
"Vos identifiants sont incorrectes !"
l = listes_matieres()
counter = 1
for el in l:
print(str(counter)+'. '+el)
counter += 1
matiere = int(input("Entrer un nombre entre 1 et "+str(counter-1)+' pour sélectionnez la matière : '))
type_stat = int(input("Souhaitez-vous\n 1. La moyenne annuelle\n 2. La moyenne par période\nEntrer un nombre entre 1 et 2 : "))
if type_stat == 1:
notes_matieres(l[matiere-1],None)
if type_stat !=1 :
periode = int(input('Vous avez choisi la moyenne par periode.\n 1. 1er trimestre\n 2. 2e trimestre\n 3. 3e trimestre\nEntrer un nombre entre 1 et 3 : '))
if periode == 1:
notes_matieres(l[matiere-1],'A001')
if periode == 2:
notes_matieres(l[matiere-1],'A002')
if periode == 3:
notes_matieres(l[matiere-1],'A003')