File size: 5,571 Bytes
39f528e
 
 
 
 
 
 
 
c2f3c2c
2dcdc14
 
 
 
845f8bb
2dcdc14
 
 
 
 
 
 
 
 
 
 
39f528e
 
 
 
 
 
c2f3c2c
2dcdc14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39f528e
 
 
c2f3c2c
39f528e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2f3c2c
39f528e
 
 
 
 
c2f3c2c
 
39f528e
 
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
import csv
import pandas as pd
import numpy as np
import os

def write_to_csv_departments(time,teachingscore,teaching,courseContentscore,courseContent,
                 examinationscore,examination,labWorkscore,labWork,libraryFacilitiesscore,
                 libraryFacilities,extraCurricularscore,extraCurricular):
    csv_file_path = 'dataset/database.csv'
    df = pd.read_csv(csv_file_path)
    header = df.columns.tolist()
    
    # Creating a dictionary for the new row
    new_row = {'Timestamp': time, 'teachingscore': teachingscore, 'teaching': teaching,
               'coursecontentscore': courseContentscore, 'coursecontent': courseContent,
               'examinationscore': examinationscore, 'examination': examination,
               'labworkscore': labWorkscore, 'labwork': labWork, 'libraryfacilitiesscore': libraryFacilitiesscore,
               'libraryfacilities': libraryFacilities, 'extracurricularscore': extraCurricularscore,
               'extracurricular': extraCurricular, 'Email Address': ''}
    
    # Appending the new row to the DataFrame
    df = df.append(new_row, ignore_index=True)
    
    # Writing the DataFrame back to the CSV file
    df.to_csv(csv_file_path, index=False)




def write_to_csv_teachers(teacher1,teacher1score,teacher2,teacher2score,teacher3,teacher3score,
                          teacher4,teacher4score,teacher5,teacher5score,teacher6,teacher6score):
    csv_file_path = 'dataset/teacherdb.csv'
    
    # Read the existing headers
    df = pd.read_csv(csv_file_path)
    header = df.columns.tolist()
    
    # Create a dictionary for the new row
    new_row = {'teacher1': teacher1, 'teacher1score': teacher1score,
               'teacher2': teacher2, 'teacher2score': teacher2score,
               'teacher3': teacher3, 'teacher3score': teacher3score,
               'teacher4': teacher4, 'teacher4score': teacher4score,
               'teacher5': teacher5, 'teacher5score': teacher5score,
               'teacher6': teacher6, 'teacher6score': teacher6score}
    
    # Append the new row to the DataFrame
    df = df.append(new_row, ignore_index=True)
    
    # Write the DataFrame back to the CSV file
    df.to_csv(csv_file_path, index=False)


def get_counts():
    csv_file_path = 'dataset/database.csv'
    df = pd.read_csv(csv_file_path)
    index = df.index
    no_of_students = len(index)
    total_feedbacks = len(index)*6

    df1 = df.groupby('teachingscore').count()[['teaching']]
    teaching_negative_count = df1['teaching'][-1]
    teaching_neutral_count = df1['teaching'][0]
    teaching_positive_count = df1['teaching'][1]

    df1 = df.groupby('coursecontentscore').count()[['coursecontent']]
    coursecontent_negative_count = df1['coursecontent'][-1]
    coursecontent_neutral_count = df1['coursecontent'][0]
    coursecontent_positive_count = df1['coursecontent'][1]

    df1 = df.groupby('examinationscore').count()[['examination']]
    examination_negative_count = df1['examination'][-1]
    examination_neutral_count = df1['examination'][0]
    examination_positive_count = df1['examination'][1]

    df1 = df.groupby('labworkscore').count()[['labwork']]
    labwork_negative_count = df1['labwork'][-1]
    labwork_neutral_count = df1['labwork'][0]
    labwork_positive_count = df1['labwork'][1]

    df1 = df.groupby('libraryfacilitiesscore').count()[['libraryfacilities']]
    libraryfacilities_negative_count = df1['libraryfacilities'][-1]
    libraryfacilities_neutral_count = df1['libraryfacilities'][0]
    libraryfacilities_positive_count = df1['libraryfacilities'][1]

    df1 = df.groupby('extracurricularscore').count()[['extracurricular']]
    extracurricular_negative_count = df1['extracurricular'][-1]
    extracurricular_neutral_count = df1['extracurricular'][0]
    extracurricular_positive_count = df1['extracurricular'][1]

    total_positive_feedbacks = teaching_positive_count + coursecontent_positive_count + examination_positive_count + labwork_positive_count + libraryfacilities_positive_count + extracurricular_positive_count
    total_neutral_feedbacks = teaching_neutral_count + coursecontent_neutral_count + examination_neutral_count + labwork_neutral_count + libraryfacilities_neutral_count + extracurricular_neutral_count
    total_negative_feedbacks = teaching_negative_count + coursecontent_negative_count + examination_negative_count +labwork_negative_count + libraryfacilities_negative_count + extracurricular_negative_count

    li = [teaching_positive_count,teaching_negative_count,teaching_neutral_count,
          coursecontent_positive_count,coursecontent_negative_count,coursecontent_neutral_count,
          examination_positive_count,examination_negative_count,examination_neutral_count,
          labwork_positive_count,labwork_negative_count,labwork_neutral_count,
          libraryfacilities_positive_count,libraryfacilities_negative_count,libraryfacilities_neutral_count,
          extracurricular_positive_count,extracurricular_negative_count,extracurricular_neutral_count]

    return no_of_students,\
           int(round(total_positive_feedbacks / total_feedbacks * 100)),\
           int(round(total_negative_feedbacks / total_feedbacks * 100)),\
           int(round(total_neutral_feedbacks / total_feedbacks * 100)),\
            li

def get_tables():
    csv_file_path = 'dataset/database.csv'
    df = pd.read_csv(csv_file_path)
    df = df.tail(5)
    return [df.to_html(classes='data')]

def get_titles():
    csv_file_path = 'dataset/database.csv'
    df = pd.read_csv('dataset/database.csv')
    return df.columns.values