Skip to content

Commit 64c7227

Browse files
Merge pull request #5 from mathanamathav/Bunker-functionality-algorithm-updation
Bunker functionality algorithm updation
2 parents 2ddd7d7 + f4f75f7 commit 64c7227

File tree

6 files changed

+136
-67
lines changed

6 files changed

+136
-67
lines changed
352 Bytes
Binary file not shown.

__pycache__/index.cpython-310.pyc

0 Bytes
Binary file not shown.

bunker_mod.py

+28-22
Original file line numberDiff line numberDiff line change
@@ -81,38 +81,44 @@ def data_json(data):
8181
"""
8282
here we convert the data to json format calculate the amount days we have to take leave.
8383
"""
84-
index_required = [0,1,2,4,7,8,9]
8584
response_data = []
86-
threshold = 0.75
85+
threshold = [0.75, 0.65]
8786

8887
for item in range(1,len(data)):
8988
item = data[item]
9089
temp = {}
9190

92-
temp['name'] = item[index_required[0]]
91+
# Extract data
92+
temp['name'] = item[0]
9393

94-
95-
j = 1
96-
temp['total_hours'] = int(item[index_required[j]]) #1
97-
j += 1
98-
temp['exception_hour'] = int(item[index_required[j]]) #2
99-
j += 1
100-
temp['total_present'] = int(item[index_required[j]]) #4
101-
temp['total_present'] += temp['exception_hour']
102-
j += 1
103-
temp['percentage_of_attendance'] = int(item[index_required[j]])
104-
105-
if temp['percentage_of_attendance'] <= 75:
106-
temp['class_to_attend'] = math.ceil((threshold*temp['total_hours'] - temp['total_present'])/(1-threshold))
107-
94+
temp['total_hours'] = int(item[1])
95+
temp['exception_hour'] = int(item[2])
96+
97+
temp['total_present'] = int(item[4])
98+
99+
temp['percentage_of_attendance'] = int(item[5])
100+
temp['percentage_of_attendance_with_exemp'] = int(item[6])
101+
temp['percentage_of_attendance_with_med_exemp'] = int(item[7])
102+
103+
temp['attendance_from'] = item[8]
104+
temp['attendance_to'] = item[9]
105+
106+
temp['med_exception_hour'] = math.floor(( ( temp['percentage_of_attendance_with_med_exemp'] / 100 ) * temp['total_hours']) - temp['total_present'])
107+
temp['total_present_with_exemp'] = temp['total_present'] + temp['exception_hour'] + temp['med_exception_hour']
108+
109+
# Calculate bunker functionality
110+
if temp['percentage_of_attendance'] > 75 :
111+
temp['class_to_bunk'] = math.floor((temp['total_present']-(threshold[0]*temp['total_hours']))/(threshold[0]))
108112
else:
109-
temp['class_to_bunk'] = math.floor((temp['total_present']-(threshold*temp['total_hours']))/(threshold))
113+
if temp['percentage_of_attendance'] > 65 and (temp['percentage_of_attendance_with_exemp'] > 75 or temp['percentage_of_attendance_with_med_exemp'] > 75 ):
114+
temp['class_to_bunk'] = math.floor((temp['total_present']-(threshold[1]*temp['total_hours']))/(threshold[1]))
110115

116+
elif temp['percentage_of_attendance'] == temp['percentage_of_attendance_with_exemp'] == temp['percentage_of_attendance_with_med_exemp']:
117+
temp['class_to_attend'] = math.ceil((threshold[0]*temp['total_hours'] - temp['total_present'])/(1-threshold[0]))
111118

112-
j += 1
113-
temp['attendance_from'] = (item[index_required[j]])
114-
j += 1
115-
temp['attendance_to'] = (item[index_required[j]])
119+
else:
120+
temp['class_to_attend'] = max(math.ceil((threshold[1]*temp['total_hours'] - temp['total_present'])/(1-threshold[1])) ,
121+
math.ceil((threshold[0]*temp['total_hours'] - temp['total_present_with_exemp'])/(1-threshold[0])) )
116122

117123
response_data.append(temp)
118124

static/home.css

+44-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
body {
33

4-
background-color: #8BC6EC;
5-
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
4+
background-color: #222831;
5+
background-image: linear-gradient(135deg, #222831 0%, #393E46 100%);
66
background-attachment: fixed;
77

88
}
@@ -17,6 +17,8 @@ body {
1717
font-size:3em;
1818
font-family: 'Press Start 2P', cursive;font-size: 40px;
1919
font-weight:bold;
20+
text-shadow:3px 3px 4px #000000;
21+
color: #00ADB5;
2022
opacity:0;
2123
}
2224

@@ -49,11 +51,51 @@ body {
4951
}
5052
}
5153

54+
.button {
55+
font-family: 'Inter', sans-serif;
56+
color: #00ADB5;
57+
background-color: #393E46;
58+
border: 2px solid #EEEEEE;
59+
border-radius: 12px;
60+
padding: 10px;
61+
text-align: center;
62+
}
5263

64+
.button2:hover {
65+
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
66+
}
5367

68+
.card {
69+
/* Add shadows to create the "card" effect */
70+
margin: 0px auto;
71+
background-color: #222831;
72+
padding: 10px;
73+
box-shadow: 0 8px 8px 0 rgba(0,0,0,0.2);
74+
transition: 0.3s;
75+
width: 50%;
5476

77+
}
5578

79+
@media screen and (max-width: 992px) {
80+
.card {
81+
width: 75%;
82+
}
83+
}
5684

85+
@media screen and (max-width: 600px) {
86+
.card {
87+
width: 95%;
88+
}
89+
90+
.card h4{
91+
font-size: large;
92+
}
93+
}
94+
95+
/* On mouse-over, add a deeper shadow */
96+
.card:hover {
97+
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
98+
}
5799

58100

59101

templates/home.html

+9-7
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232

3333

3434
<link href="https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=Bangers&family=Bebas+Neue&family=Bungee&family=Press+Start+2P&family=Rubik+Glitch&family=Square+Peg&family=Ubuntu:wght@300&display=swap" rel="stylesheet">
35-
36-
</head>
35+
<link href="https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,700;1,400&display=swap" rel="stylesheet">
36+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@500&display=swap" rel="stylesheet">
37+
<link href="https://fonts.googleapis.com/css2?family=Anton&display=swap" rel="stylesheet">
38+
</head>
3739
<body>
3840
<!-- Google Tag Manager (noscript) -->
3941
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W8FZCWK"
@@ -49,16 +51,16 @@
4951
<div class="container mt-3">
5052
<form action="{{ url_for("gfg")}}" method="post">
5153
<div class="form-group">
52-
<label for="firstname" style="font-family: 'Rubik Glitch', cursive;">Roll Number</label>
54+
<label for="firstname" style="font-family: 'Courier Prime', monospace;color: #EEEEEE;text-shadow:2px 2px 4px #000000;">Roll Number</label>
5355
<input class="form-control" id="firstname" name="usr" placeholder="Roll Number" style="font-family: 'Bungee', cursive;" >
54-
<small id="emailHelp" class="form-text text-muted" style="font-family: 'Square Peg', cursive;" >We'll never share your details with anyone else.</small>
56+
<!-- <small id="emailHelp" class="form-text text-muted" style="font-size: '14';font-family: 'Square Peg';">We'll never share your details with anyone else.</small> -->
5557
</div>
5658
<div class="form-group">
57-
<label for="lastname" style="font-family: 'Rubik Glitch', cursive;">Password</label>
59+
<label for="lastname" style="font-family: 'Courier Prime', monospace;color: #EEEEEE;text-shadow:2px 2px 4px #000000;">Password</label>
5860
<input type="password" class="form-control" name="pwd" id="lastname" placeholder="Password" style="font-family: 'Bungee', cursive;">
5961
</div>
6062

61-
<center><button style="font-family: 'Rubik Glitch', cursive;" type="submit" class="btn btn-primary">Login</button></center>
63+
<center><button type="submit" class="button button2">Login</button></center>
6264

6365
</form>
6466
</div>
@@ -76,7 +78,7 @@
7678
<footer class="page-footer font-small blue">
7779

7880
<!-- Copyright -->
79-
<div class="footer-copyright text-center py-3" style="color:white">© 2022 Copyright:
81+
<div class="footer-copyright text-center py-3" style="color:white">© 2023 Copyright:
8082
Bunker-API
8183
<a href="https://github.com/mathanamathav/bunker-api"><h6>Developed by JPM</h6></a>
8284
</div>

templates/output.html

+55-36
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,29 @@
1010
{% if load %}
1111

1212
<div class="container">
13-
<table class="table table-borderless text-center" align="center" style="margin: 0px auto;">
13+
<table class="table table-sm table-bordered text-center">
1414
<thead>
15-
<tr>
16-
<th scope="col">COURSE</th>
17-
<th scope="col">PERCENTAGE</th>
18-
<th scope="col">REMARK</th>
15+
<tr style="font-family: 'Courier Prime', monospace;font-size: small; color: #00ADB5;text-shadow:2px 2px 4px #000000;">
16+
<th scope="col" style="width: 10%">COURSE</th>
17+
<th scope="col" style="width: 10%">PHYSICAL</th>
18+
<th scope="col" style="width: 10%">WITH EXEMPTION</th>
19+
<th scope="col" style="width: 70%">REMARK</th>
1920
</tr>
2021
</thead>
2122
<tbody>
2223
{% for key in data %}
23-
<tr>
24+
<tr style="font-family: 'Courier Prime', monospace;font-size: small;color: #EEEEEE;text-shadow:2px 2px 4px #000000;">
2425
<td>{{ key['name'] }}</td>
2526
<td>{{key['percentage_of_attendance']}}</td>
27+
28+
{% if key['percentage_of_attendance_with_exemp'] > key['percentage_of_attendance_with_med_exemp'] %}
29+
<td>{{key['percentage_of_attendance_with_exemp']}}</td>
30+
{% else %}
31+
<td>{{key['percentage_of_attendance_with_med_exemp']}}</td>
32+
{% endif %}
33+
2634
{% if key.get("class_to_bunk",0) != 0 %}
27-
<td>Take leave : {{key.get("class_to_bunk",0)}}</td>
35+
<td>Bunk : {{key.get("class_to_bunk",0)}}</td>
2836
{% else %}
2937
<td>Attend : {{key.get("class_to_attend",0)}}</td>
3038
{% endif %}
@@ -34,46 +42,57 @@
3442
</table>
3543
</div>
3644
<br>
45+
<div class="card" style="background-color: #222831;border-radius: 25px;padding: 10px;">
46+
<center>
47+
<h4 style="font-family: 'Anton', sans-serif;color: #EEEEEE;text-shadow:2px 2px 4px #000000;">It is best to have a physical attendance of more than 75%.</h4>
48+
</center>
49+
</div>
3750
<br>
3851

3952
{% if cgpa.get("error", "") == "" %}
40-
<hr style="width:50%;height:2px;border: width 6px;">
53+
<hr style="width:50%;height:2px;border: width 6px;background-color: #EEEEEE;">
4154
<center class="container">
42-
<h3 style="color:blue;font-family: 'Bebas Neue', cursive;">CGPA upto {{ cgpa.get("lastest_sem") }} sem : {{ cgpa.get("latest_sem_cgpa") }}</h5>
55+
<h3 style="color: #00ADB5;font-family: 'Anton', sans-serif;text-shadow:2px 2px 4px #000000;">CGPA upto {{ cgpa.get("lastest_sem") }} sem : {{ cgpa.get("latest_sem_cgpa") }}</h5>
4356
{% endif %}
4457
</center>
4558

4659

47-
<hr style="width:50%;height:2px;border: width 6px;">
48-
{% for key in data %}
49-
<br>
50-
<center>
51-
<h1 style="font-family: 'Bebas Neue', cursive;">Course Code - {{ key['name'] }}</h1>
52-
{% if time_table.get(key['name'],"") != "" %}
53-
<h3 style="font-family: 'Bebas Neue', cursive;">{{ time_table.get(key['name'],"") }}</h3>
54-
{% endif %}
55-
56-
<hr style="width:50%;height:2px;border: width 4px;">
57-
<h4 style="font-family: 'Bebas Neue', cursive;">Updated date : {{key['attendance_to']}}</h4>
58-
59-
<h4 style="font-family: 'Bebas Neue', cursive;">Total Hours : {{key['total_hours']}}</h4>
60-
<h4 style="font-family: 'Bebas Neue', cursive;">Total Present : {{key['total_present']}}</h4>
61-
<h4 style="font-family: 'Bebas Neue', cursive;">Percentage of Attendance : {{key['percentage_of_attendance']}}</h4>
62-
{% if key.get("class_to_bunk",0) != 0 %}
63-
<h2 style="color:green;font-family: 'Bebas Neue', cursive;">Class To Take leave : {{key.get("class_to_bunk",0)}} 👍
64-
</h2>
65-
{% else %}
66-
<h2 style="color:red;font-family: 'Bebas Neue', cursive;">Class To Attend : {{key.get("class_to_attend",0)}} 👎</h2>
67-
{% endif %}
60+
<hr style="width:50%;height:2px;border: width 6px;background-color: #EEEEEE;">
6861

62+
{% for key in data %}
63+
<br>
64+
<div class="card" style="background-color: #222831;border-radius: 25px;">
65+
<center>
66+
<h1 style="font-family: 'Anton', sans-serif;color: #00ADB5;text-shadow:2px 2px 4px #000000;">Course Code - {{ key['name'] }}</h1>
67+
{% if time_table.get(key['name'],"") != "" %}
68+
<h3 style="font-family: 'Anton', sans-serif;color: #00ADB5;text-shadow:2px 2px 4px #000000;">{{ time_table.get(key['name'],"") }}</h3>
69+
{% endif %}
70+
71+
<h4 style="font-family: 'Bebas Neue', cursive;color: #EEEEEE;">Updated date : {{key['attendance_to']}}</h4>
72+
<h4 style="font-family: 'Bebas Neue', cursive;color: #EEEEEE;">Total Hours : {{key['total_hours']}}</h4>
73+
<h4 style="font-family: 'Bebas Neue', cursive;color: #EEEEEE;">Total Present : {{key['total_present']}}</h4>
74+
<h4 style="font-family: 'Bebas Neue', cursive;color: #EEEEEE;">Percentage of Attendance : {{key['percentage_of_attendance']}}</h4>
75+
76+
{% if key['percentage_of_attendance_with_exemp'] > key['percentage_of_attendance_with_med_exemp'] %}
77+
<h4 style="font-family: 'Bebas Neue', cursive;color: #EEEEEE;">Percentage of Attendance with exemption : {{key['percentage_of_attendance_with_exemp']}}</h4>
78+
{% else %}
79+
<h4 style="font-family: 'Bebas Neue', cursive;color: #EEEEEE;">Percentage of Attendance with exemption : {{key['percentage_of_attendance_with_med_exemp']}}</h4>
80+
{% endif %}
81+
82+
{% if key.get("class_to_bunk",0) != 0 %}
83+
<h2 style="color:green;font-family: 'Bebas Neue', cursive;text-shadow:2px 2px 4px #000000;">Class To Take leave : {{key.get("class_to_bunk",0)}} 👍
84+
</h2>
85+
{% else %}
86+
<h2 style="color:red;font-family: 'Bebas Neue', cursive;text-shadow:2px 2px 4px #000000;">Class To Attend : {{key.get("class_to_attend",0)}} 👎</h2>
87+
{% endif %}
88+
</center>
89+
</div>
6990

70-
</center>
91+
<br>
7192

72-
<br>
93+
{% endfor %}
7394

74-
{% endfor %}
75-
<br>
76-
<hr style="width:100%;height:4px;border: width 8px;">
95+
<hr style="width:100%;height:2px;border: width 6px;background-color: #EEEEEE;">
7796
<!--
7897
<center>
7998
<h1 style="font-family: 'Press Start 2P', cursive;">
@@ -95,7 +114,7 @@ <h1 style="font-family: 'Press Start 2P', cursive;">
95114
</center> -->
96115

97116
<center>
98-
<h4 style="font-family: 'Press Start 2P', cursive;">
117+
<h4 style="font-family: 'Press Start 2P', cursive;color: #00ADB5;">
99118
App in development!!
100119
</h4>
101120
</center>

0 commit comments

Comments
 (0)