Spaces:
Runtime error
Runtime error
Update server.py
Browse files
server.py
CHANGED
|
@@ -1,15 +1,21 @@
|
|
| 1 |
-
import os
|
| 2 |
import pickle
|
| 3 |
import pandas as pd
|
| 4 |
from flask import Flask, request, render_template, session
|
| 5 |
from datetime import datetime
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
from teacherdashboard import get_feedback_counts
|
| 9 |
|
| 10 |
app = Flask(__name__)
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
@app.route('/')
|
|
@@ -46,6 +52,7 @@ def do_admin_login():
|
|
| 46 |
else :
|
| 47 |
return render_template('loginerror.html')
|
| 48 |
|
|
|
|
| 49 |
def teacherdashboard(teachernumber):
|
| 50 |
ttf, teachers_total_positive_feedbacks, teachers_total_negative_feedbacks, teachers_total_neutral_feedbacks, teachers_li = get_feedback_counts()
|
| 51 |
ttp, ttn, ttneu, tcp, tcn, tcneu, tep, ten, teneu, tlwp, tlwn, tlwneu, tlfp, tlfn, tlfneu, tecp, tecn, tecneu = teachers_li
|
|
@@ -84,7 +91,6 @@ def logout():
|
|
| 84 |
|
| 85 |
@app.route("/predict", methods=['POST'])
|
| 86 |
def predict():
|
| 87 |
-
|
| 88 |
teaching = request.form['teaching']
|
| 89 |
courseContent = request.form['coursecontent']
|
| 90 |
examination = request.form['examination']
|
|
@@ -162,6 +168,64 @@ def hoddashboard():
|
|
| 162 |
)
|
| 163 |
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
|
| 167 |
@app.route("/displayteacherfeedbacks")
|
|
@@ -169,8 +233,12 @@ def displayteacherfeedbacks():
|
|
| 169 |
if not session.get('logged_in'):
|
| 170 |
return render_template('login.html')
|
| 171 |
else:
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
|
| 176 |
@app.route("/display")
|
|
@@ -178,9 +246,112 @@ def display():
|
|
| 178 |
if not session.get('logged_in'):
|
| 179 |
return render_template('login.html')
|
| 180 |
else:
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
return render_template('feedbacks.html', tables=[df.to_html(classes='data', header="true")])
|
| 183 |
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
if __name__ == '__main__':
|
| 186 |
app.run()
|
|
|
|
|
|
|
| 1 |
import pickle
|
| 2 |
import pandas as pd
|
| 3 |
from flask import Flask, request, render_template, session
|
| 4 |
from datetime import datetime
|
| 5 |
+
import mysql.connector
|
| 6 |
+
|
|
|
|
| 7 |
|
| 8 |
app = Flask(__name__)
|
| 9 |
|
| 10 |
+
mysql = mysql.connector.connect(
|
| 11 |
+
host='sql12.freemysqlhosting.net',
|
| 12 |
+
user='sql12655233',
|
| 13 |
+
password='NlICXIsXJu',
|
| 14 |
+
database='sql12655233',
|
| 15 |
+
port=3306,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
app.secret_key = 'EASA-Final-abhi-2023'
|
| 19 |
|
| 20 |
|
| 21 |
@app.route('/')
|
|
|
|
| 52 |
else :
|
| 53 |
return render_template('loginerror.html')
|
| 54 |
|
| 55 |
+
|
| 56 |
def teacherdashboard(teachernumber):
|
| 57 |
ttf, teachers_total_positive_feedbacks, teachers_total_negative_feedbacks, teachers_total_neutral_feedbacks, teachers_li = get_feedback_counts()
|
| 58 |
ttp, ttn, ttneu, tcp, tcn, tcneu, tep, ten, teneu, tlwp, tlwn, tlwneu, tlfp, tlfn, tlfneu, tecp, tecn, tecneu = teachers_li
|
|
|
|
| 91 |
|
| 92 |
@app.route("/predict", methods=['POST'])
|
| 93 |
def predict():
|
|
|
|
| 94 |
teaching = request.form['teaching']
|
| 95 |
courseContent = request.form['coursecontent']
|
| 96 |
examination = request.form['examination']
|
|
|
|
| 168 |
)
|
| 169 |
|
| 170 |
|
| 171 |
+
def get_feedback_counts():
|
| 172 |
+
cursor = mysql.cursor(dictionary=True)
|
| 173 |
+
cursor.execute("SELECT * FROM `mytable2`")
|
| 174 |
+
res_dct = cursor.fetchall()
|
| 175 |
+
|
| 176 |
+
df = pd.DataFrame(res_dct)
|
| 177 |
+
|
| 178 |
+
index = df.index
|
| 179 |
+
no_of_feedbacks = len(index)
|
| 180 |
+
total_feedbacks = len(index)*6
|
| 181 |
+
|
| 182 |
+
df1 = df.groupby('teacher1score').count()[['teacher1']]
|
| 183 |
+
teacher1_negative_count = df1['teacher1'][-1]
|
| 184 |
+
teacher1_neutral_count = df1['teacher1'][0]
|
| 185 |
+
teacher1_positive_count = df1['teacher1'][1]
|
| 186 |
+
|
| 187 |
+
df1 = df.groupby('teacher2score').count()[['teacher2']]
|
| 188 |
+
teacher2_negative_count = df1['teacher2'][-1]
|
| 189 |
+
teacher2_neutral_count = df1['teacher2'][0]
|
| 190 |
+
teacher2_positive_count = df1['teacher2'][1]
|
| 191 |
+
|
| 192 |
+
df1 = df.groupby('teacher3score').count()[['teacher3']]
|
| 193 |
+
teacher3_negative_count = df1['teacher3'][-1]
|
| 194 |
+
teacher3_neutral_count = df1['teacher3'][0]
|
| 195 |
+
teacher3_positive_count = df1['teacher3'][1]
|
| 196 |
+
|
| 197 |
+
df1 = df.groupby('teacher4score').count()[['teacher4']]
|
| 198 |
+
teacher4_negative_count = df1['teacher4'][-1]
|
| 199 |
+
teacher4_neutral_count = df1['teacher4'][0]
|
| 200 |
+
teacher4_positive_count = df1['teacher4'][1]
|
| 201 |
+
|
| 202 |
+
df1 = df.groupby('teacher5score').count()[['teacher5']]
|
| 203 |
+
teacher5_negative_count = df1['teacher5'][-1]
|
| 204 |
+
teacher5_neutral_count = df1['teacher5'][0]
|
| 205 |
+
teacher5_positive_count = df1['teacher5'][1]
|
| 206 |
+
|
| 207 |
+
df1 = df.groupby('teacher6score').count()[['teacher6']]
|
| 208 |
+
teacher6_negative_count = df1['teacher6'][-1]
|
| 209 |
+
teacher6_neutral_count = df1['teacher6'][0]
|
| 210 |
+
teacher6_positive_count = df1['teacher6'][1]
|
| 211 |
+
|
| 212 |
+
total_positive_feedbacks = teacher1_positive_count + teacher2_positive_count + teacher3_positive_count + teacher4_positive_count + teacher5_positive_count + teacher6_positive_count
|
| 213 |
+
total_neutral_feedbacks = teacher1_neutral_count + teacher2_neutral_count + teacher3_neutral_count + teacher4_neutral_count + teacher5_neutral_count + teacher6_neutral_count
|
| 214 |
+
total_negative_feedbacks = teacher1_negative_count + teacher2_negative_count + teacher3_negative_count +teacher4_negative_count + teacher5_negative_count + teacher6_negative_count
|
| 215 |
+
|
| 216 |
+
li = [teacher1_positive_count,teacher1_negative_count,teacher1_neutral_count,
|
| 217 |
+
teacher2_positive_count,teacher2_negative_count,teacher2_neutral_count,
|
| 218 |
+
teacher3_positive_count,teacher3_negative_count,teacher3_neutral_count,
|
| 219 |
+
teacher4_positive_count,teacher4_negative_count,teacher4_neutral_count,
|
| 220 |
+
teacher5_positive_count,teacher5_negative_count,teacher5_neutral_count,
|
| 221 |
+
teacher6_positive_count,teacher6_negative_count,teacher6_neutral_count]
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
return no_of_feedbacks,\
|
| 225 |
+
int(round(total_positive_feedbacks / total_feedbacks * 100)),\
|
| 226 |
+
int(round(total_negative_feedbacks / total_feedbacks * 100)),\
|
| 227 |
+
int(round(total_neutral_feedbacks / total_feedbacks * 100)),\
|
| 228 |
+
li
|
| 229 |
|
| 230 |
|
| 231 |
@app.route("/displayteacherfeedbacks")
|
|
|
|
| 233 |
if not session.get('logged_in'):
|
| 234 |
return render_template('login.html')
|
| 235 |
else:
|
| 236 |
+
cursor = mysql.cursor(dictionary=True)
|
| 237 |
+
cursor.execute("SELECT * FROM `mytable2`")
|
| 238 |
+
res_dct = cursor.fetchall()
|
| 239 |
+
|
| 240 |
+
df = pd.DataFrame(res_dct)
|
| 241 |
+
return render_template('teacherfeedbacks.html', tables=[df.to_html(classes='data', header="true")])
|
| 242 |
|
| 243 |
|
| 244 |
@app.route("/display")
|
|
|
|
| 246 |
if not session.get('logged_in'):
|
| 247 |
return render_template('login.html')
|
| 248 |
else:
|
| 249 |
+
cursor = mysql.cursor(dictionary=True)
|
| 250 |
+
cursor.execute("SELECT * FROM `mytable`")
|
| 251 |
+
res_dct = cursor.fetchall()
|
| 252 |
+
|
| 253 |
+
df = pd.DataFrame(res_dct)
|
| 254 |
return render_template('feedbacks.html', tables=[df.to_html(classes='data', header="true")])
|
| 255 |
|
| 256 |
|
| 257 |
+
def write_to_csv_departments(time,teachingscore,teaching,courseContentscore,courseContent,
|
| 258 |
+
examinationscore,examination,labWorkscore,labWork,libraryFacilitiesscore,
|
| 259 |
+
libraryFacilities,extraCurricularscore,extraCurricular):
|
| 260 |
+
|
| 261 |
+
cursor = mysql.cursor(dictionary=True)
|
| 262 |
+
cursor.execute("INSERT INTO `mytable`(`Timestamp`, `teachingscore`, `teaching`, `courseContentscore`, `courseContent`, `examinationscore`, `examination`, `labWorkscore`, `labWork`, `libraryFacilitiesscore`, `libraryFacilities`, `extraCurricularscore`, `extraCurricular`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);", (
|
| 263 |
+
time, teachingscore, teaching, courseContentscore,courseContent, examinationscore,examination,labWorkscore,labWork,libraryFacilitiesscore,libraryFacilities,extraCurricularscore,extraCurricular,
|
| 264 |
+
))
|
| 265 |
+
mysql.commit()
|
| 266 |
+
cursor.close()
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
def write_to_csv_teachers(teacher1,teacher1score,teacher2,teacher2score,teacher3,teacher3score,
|
| 270 |
+
teacher4,teacher4score,teacher5,teacher5score,teacher6,teacher6score):
|
| 271 |
+
|
| 272 |
+
cursor = mysql.cursor(dictionary=True)
|
| 273 |
+
cursor.execute("INSERT INTO `mytable2`(`teacher1`, `teacher1score`, `teacher2`, `teacher2score`, `teacher3`, `teacher3score`, `teacher4`, `teacher4score`, `teacher5`, `teacher5score`, `teacher6`, `teacher6score`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", (
|
| 274 |
+
teacher1, teacher1score, teacher2, teacher2score, teacher3, teacher3score, teacher4, teacher4score, teacher5, teacher5score, teacher6, teacher6score,
|
| 275 |
+
))
|
| 276 |
+
|
| 277 |
+
mysql.commit()
|
| 278 |
+
cursor.close()
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def get_counts():
|
| 282 |
+
cursor = mysql.cursor(dictionary=True)
|
| 283 |
+
cursor.execute("SELECT * FROM `mytable`")
|
| 284 |
+
res_dct = cursor.fetchall()
|
| 285 |
+
|
| 286 |
+
df = pd.DataFrame(res_dct)
|
| 287 |
+
index = df.index
|
| 288 |
+
no_of_students = len(index)
|
| 289 |
+
total_feedbacks = len(index)*6
|
| 290 |
+
|
| 291 |
+
df1 = df.groupby('teachingscore').count()[['teaching']]
|
| 292 |
+
teaching_negative_count = df1['teaching'][-1]
|
| 293 |
+
teaching_neutral_count = df1['teaching'][0]
|
| 294 |
+
teaching_positive_count = df1['teaching'][1]
|
| 295 |
+
|
| 296 |
+
df1 = df.groupby('coursecontentscore').count()[['coursecontent']]
|
| 297 |
+
coursecontent_negative_count = df1['coursecontent'][-1]
|
| 298 |
+
coursecontent_neutral_count = df1['coursecontent'][0]
|
| 299 |
+
coursecontent_positive_count = df1['coursecontent'][1]
|
| 300 |
+
|
| 301 |
+
df1 = df.groupby('examinationscore').count()[['examination']]
|
| 302 |
+
examination_negative_count = df1['examination'][-1]
|
| 303 |
+
examination_neutral_count = df1['examination'][0]
|
| 304 |
+
examination_positive_count = df1['examination'][1]
|
| 305 |
+
|
| 306 |
+
df1 = df.groupby('labworkscore').count()[['labwork']]
|
| 307 |
+
labwork_negative_count = df1['labwork'][-1]
|
| 308 |
+
labwork_neutral_count = df1['labwork'][0]
|
| 309 |
+
labwork_positive_count = df1['labwork'][1]
|
| 310 |
+
|
| 311 |
+
df1 = df.groupby('libraryfacilitiesscore').count()[['libraryfacilities']]
|
| 312 |
+
libraryfacilities_negative_count = df1['libraryfacilities'][-1]
|
| 313 |
+
libraryfacilities_neutral_count = df1['libraryfacilities'][0]
|
| 314 |
+
libraryfacilities_positive_count = df1['libraryfacilities'][1]
|
| 315 |
+
|
| 316 |
+
df1 = df.groupby('extracurricularscore').count()[['extracurricular']]
|
| 317 |
+
extracurricular_negative_count = df1['extracurricular'][-1]
|
| 318 |
+
extracurricular_neutral_count = df1['extracurricular'][0]
|
| 319 |
+
extracurricular_positive_count = df1['extracurricular'][1]
|
| 320 |
+
|
| 321 |
+
total_positive_feedbacks = teaching_positive_count + coursecontent_positive_count + examination_positive_count + labwork_positive_count + libraryfacilities_positive_count + extracurricular_positive_count
|
| 322 |
+
total_neutral_feedbacks = teaching_neutral_count + coursecontent_neutral_count + examination_neutral_count + labwork_neutral_count + libraryfacilities_neutral_count + extracurricular_neutral_count
|
| 323 |
+
total_negative_feedbacks = teaching_negative_count + coursecontent_negative_count + examination_negative_count +labwork_negative_count + libraryfacilities_negative_count + extracurricular_negative_count
|
| 324 |
+
|
| 325 |
+
li = [teaching_positive_count,teaching_negative_count,teaching_neutral_count,
|
| 326 |
+
coursecontent_positive_count,coursecontent_negative_count,coursecontent_neutral_count,
|
| 327 |
+
examination_positive_count,examination_negative_count,examination_neutral_count,
|
| 328 |
+
labwork_positive_count,labwork_negative_count,labwork_neutral_count,
|
| 329 |
+
libraryfacilities_positive_count,libraryfacilities_negative_count,libraryfacilities_neutral_count,
|
| 330 |
+
extracurricular_positive_count,extracurricular_negative_count,extracurricular_neutral_count]
|
| 331 |
+
|
| 332 |
+
return no_of_students,\
|
| 333 |
+
int(round(total_positive_feedbacks / total_feedbacks * 100)),\
|
| 334 |
+
int(round(total_negative_feedbacks / total_feedbacks * 100)),\
|
| 335 |
+
int(round(total_neutral_feedbacks / total_feedbacks * 100)),\
|
| 336 |
+
li
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def get_tables():
|
| 340 |
+
cursor = mysql.cursor(dictionary=True)
|
| 341 |
+
cursor.execute("SELECT * FROM `mytable`")
|
| 342 |
+
res_dct = cursor.fetchall()
|
| 343 |
+
df = pd.DataFrame(res_dct)
|
| 344 |
+
df = df.tail(5)
|
| 345 |
+
return [df.to_html(classes='data')]
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
def get_titles():
|
| 349 |
+
cursor = mysql.cursor(dictionary=True)
|
| 350 |
+
cursor.execute("SELECT * FROM `mytable`")
|
| 351 |
+
res_dct = cursor.fetchall()
|
| 352 |
+
df = pd.DataFrame(res_dct)
|
| 353 |
+
return df.columns.values
|
| 354 |
+
|
| 355 |
+
|
| 356 |
if __name__ == '__main__':
|
| 357 |
app.run()
|