-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonize_data.php
More file actions
56 lines (47 loc) · 1.29 KB
/
pythonize_data.php
File metadata and controls
56 lines (47 loc) · 1.29 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
<?php
header("Content-Type: text/plain; charset=utf-8");
# Opening local DB
$connexion=new mysqli("localhost","root","--somepwd--","repart");
if($connexion->connect_errno) {
printf("Connexion failed:\n%s",$connexion->connect_error);
exit();
}
$connexion->query("SET NAMES utf8");
$query = "SELECT DISTINCT heures_prof FROM ClassesCombi ORDER BY heures_prof DESC";
$answer_hp = $connexion->query($query);
$indent=" ";
$convert = array(
"8.067"=>"6.6+4/3*1.1",
"5.133"=>"4.4+2/3*1.1",
"4.767"=>"4.4+1/3*1.1"
);
printf("lecturesDataRaw = [\n");
$stringToWrite = "";
while($data_hp=$answer_hp->fetch_array()) {
$heures = $data_hp[0];
if($stringToWrite) {
$stringToWrite .= $indent."}, {\n";
} else {
$stringToWrite = $indent."{\n";
}
$query = "SELECT classe FROM ClassesCombi WHERE heures_prof LIKE ".$heures;
$answer_cl = $connexion->query($query);
$classes = "";
while($data_cl=$answer_cl->fetch_array()) {
if($classes) {
$classes .= "\", \"";
}
$classes .= $data_cl[0];
}
if(array_key_exists($heures,$convert)) {
$heures = $convert[$heures];
}
$stringToWrite .=
$indent.$indent."\"duration\": \"".$heures."\",\n".
$indent.$indent."\"sections\": [\"".$classes."\"]\n";
}
printf($stringToWrite.$indent."}\n]\n\n");
printf("Done.");
# Closing local DB
$connexion->close();
?>