ProfSathish ProfSathish commited on
Commit
d33237f
0 Parent(s):

Duplicate from ProfSathish/air-splitter

Browse files

Co-authored-by: ProfSathishBabu <ProfSathish@users.noreply.huggingface.co>

Files changed (8) hide show
  1. .env +1 -0
  2. .gitattributes +34 -0
  3. README.md +14 -0
  4. app.py +157 -0
  5. database.py +41 -0
  6. inputm.csv +0 -0
  7. ns.py +170 -0
  8. requirements.txt +5 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ DETA_KEY = d0ul3pby_octCdNyEhb9xaFS5caPfnsinhY8Xy6Jh
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Air Splitter
3
+ emoji: 🏢
4
+ colorFrom: yellow
5
+ colorTo: green
6
+ sdk: streamlit
7
+ sdk_version: 1.15.2
8
+ app_file: app.py
9
+ pinned: false
10
+ license: openrail
11
+ duplicated_from: ProfSathish/air-splitter
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ns
2
+ import csv
3
+ import streamlit as st
4
+ import pandas as pd
5
+ import os
6
+ import time
7
+ import streamlit_authenticator as stauth
8
+ import database as db
9
+
10
+ st.set_page_config(page_title="COPO - SPLITTER", page_icon=":bar_chart:")
11
+
12
+ placeholder = st.empty()
13
+
14
+ # --- USER AUTHENTICATION ---
15
+ users = db.fetch_all_users()
16
+
17
+ usernames = [user["key"] for user in users]
18
+ names = [user["name"] for user in users]
19
+ hashed_passwords = [user["password"] for user in users]
20
+
21
+ authenticator = stauth.Authenticate(names, usernames, hashed_passwords,"copo_generator", "abcdef", cookie_expiry_days=30)
22
+
23
+ name, authentication_status, username = authenticator.login("Login", "main")
24
+
25
+ if authentication_status == False:
26
+ st.error("Username/password is incorrect")
27
+
28
+ if authentication_status == None:
29
+ st.warning("Please enter your username and password")
30
+
31
+ if authentication_status:
32
+ placeholder.empty()
33
+ def save_input_file(input_file):
34
+ with open(os.path.join("inputm.csv"), "wb") as f:
35
+ f.write(input_file.getbuffer())
36
+ return st.success("Source File Uploaded")
37
+
38
+ st.title("COPO SPLITUP GENERATOR ")
39
+ authenticator.logout("Logout", "sidebar")
40
+
41
+ col1, col2, col3 = st.columns(3)
42
+
43
+ col4, col5 = st.columns([7,1])
44
+ with col1:
45
+ reg = st.selectbox(
46
+ 'Enter the regulation 13 | 17 | 21 : ',
47
+ (13, 17, 21))
48
+
49
+ with col2:
50
+ ass = st.selectbox(
51
+ 'Choose the assessment : ',
52
+ ("IA1", "IA2", "MODEL", "Lab", "Project", "Custom"))
53
+
54
+
55
+ if ass == "Custom":
56
+ with col3:
57
+ que_count = st.number_input('Enter the Question Count : ' , min_value=1, max_value=100, value=1, step=1)
58
+
59
+
60
+ dep = None
61
+ co_lister = []
62
+ ms_lister = []
63
+
64
+ if ass == "MODEL":
65
+ dep = st.selectbox(
66
+ 'Choose the Department',
67
+ ("S & H", "Other"))
68
+
69
+ if dep == "S & H":
70
+ dep = 1
71
+ elif dep == "Other":
72
+ dep = 2
73
+ if ass == "Custom":
74
+ st.markdown(f"""
75
+ <div style="margin-top:35px">
76
+
77
+ <div>
78
+ """, unsafe_allow_html=True)
79
+ st.write("COPO NUMBERS")
80
+ for i in range(que_count):
81
+ # que = st.text_input(f"Enter the question {i+1} co number : ", placeholder="CO1")
82
+ que = st.selectbox(f"Enter the question {i+1} co number : ",
83
+ ("CO - 1", "CO - 2", "CO - 3", "CO - 4", "CO - 5", "CO - 6", "CO - 7", "CO - 8", "CO - 9", "CO - 10", "CO - 11", "CO - 12", "CO - 13", "CO - 14", "CO - 15", "CO - 16", "CO - 17", "CO - 18", "CO - 19", "CO - 20"))
84
+ if que == f"CO - {i+1}":
85
+ deo = i+1
86
+ co_lister.append(deo)
87
+ que = 20
88
+
89
+ st.markdown(f"""
90
+ <div style="margin-top:35px">
91
+ <div>
92
+ """, unsafe_allow_html=True)
93
+ st.write("COPO MARKS")
94
+ for i in range(que_count):
95
+ mque = st.selectbox(f"Enter the question {i+1} mark : ",
96
+ (2, 13, 15, 16, 20))
97
+ ms_lister.append(mque)
98
+ st.markdown(f"""
99
+ <div style="margin-top:35px">
100
+
101
+ <div>
102
+ """, unsafe_allow_html=True)
103
+ with col4:
104
+ file_name = st.text_input('Enter the Output File Name: ', placeholder="COPO_File")
105
+ with col5:
106
+ st.markdown(f"""
107
+ <div style="margin-top:35px">
108
+
109
+ <div>
110
+ """, unsafe_allow_html=True)
111
+ st.button("Submit")
112
+
113
+
114
+ trunc_file = "inputm.csv"
115
+ f = open(trunc_file, "w+")
116
+ f.close()
117
+
118
+ # if ass != "Custom":
119
+ input_mark = st.text_area(f"Enter the marks of {ass}: ")
120
+ arr = [int(i) for i in input_mark.strip().split("\n") if i]
121
+
122
+ with open("inputm.csv", 'a') as my_file:
123
+ for i in arr:
124
+ my_file.write(str(i) + "\n")
125
+
126
+ if ass == "IA1":
127
+ ass = 1
128
+ elif ass == "IA2":
129
+ ass = 2
130
+ elif ass == "MODEL":
131
+ ass = 3
132
+ elif ass == "Lab":
133
+ ass = 4
134
+ elif ass == "Project":
135
+ ass = 5
136
+ elif ass == "Custom":
137
+ ass = 6
138
+
139
+
140
+
141
+ def getbtn(btn_func):
142
+ if btn_func:
143
+ st.warning("Wait while Generating...")
144
+ ns.ranCOS(reg, ass, file_name, dep, co_lister, ms_lister)
145
+ df = pd.read_csv(f"{file_name}.csv", skiprows = 2)
146
+ st.write(df)
147
+ time.sleep(3)
148
+ if file_name is not None:
149
+ with open(file_name + ".csv", 'rb') as my_file:
150
+ st.download_button(label = 'Download', data = my_file, file_name = file_name + '.xlsx', mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
151
+ os.remove(file_name + ".csv")
152
+ st.success("Generated Successfully!")
153
+
154
+ time.sleep(2)
155
+ os.remove(file_name + ".xlsx")
156
+
157
+ getbtn(st.button("Generate"))
database.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from deta import Deta # pip install deta
4
+ from dotenv import load_dotenv # pip install python-dotenv
5
+
6
+
7
+ # Load the environment variables
8
+ load_dotenv(".env")
9
+ DETA_KEY = os.getenv("DETA_KEY")
10
+
11
+ # Initialize with a project key
12
+ deta = Deta(DETA_KEY)
13
+
14
+ # This is how to create/connect a database
15
+ db = deta.Base("users_db")
16
+
17
+
18
+ def insert_user(username, name, password):
19
+ """Returns the user on a successful user creation, otherwise raises and error"""
20
+ return db.put({"key": username, "name": name, "password": password})
21
+
22
+
23
+ def fetch_all_users():
24
+ """Returns a dict of all users"""
25
+ res = db.fetch()
26
+ return res.items
27
+
28
+
29
+ def get_user(username):
30
+ """If not found, the function will return None"""
31
+ return db.get(username)
32
+
33
+
34
+ def update_user(username, updates):
35
+ """If the item is updated, returns None. Otherwise, an exception is raised"""
36
+ return db.update(updates, username)
37
+
38
+
39
+ def delete_user(username):
40
+ """Always returns None, even if the key does not exist"""
41
+ return db.delete(username)
inputm.csv ADDED
File without changes
ns.py ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random as ra
2
+ import csv
3
+ import pandas as pd
4
+
5
+ #Input
6
+ def getmarks():
7
+ with open('inputm.csv', newline='') as f:
8
+ reader = csv.reader(f)
9
+ print(reader)
10
+ ll = []
11
+ totall = [list(map(int, rec)) for rec in csv.reader(f, delimiter=',')]
12
+ for i in totall:
13
+ ll.append(i[0])
14
+ return ll
15
+
16
+ #totall=[rec for rec in csv.reader(f, delimiter=',')]
17
+
18
+
19
+ #RandomSplitter
20
+ #initialize
21
+ def ranCOS(reg, ass, assName, dep, co_lister, ms_lister):
22
+ print(reg,ass,assName)
23
+ rm =[] #randomMarks
24
+ ms=[]
25
+ co=[]
26
+ #print(reg, ass, dep)
27
+ if (reg == 13) or (reg == 17):
28
+ #print(reg)
29
+ if ass == 1:
30
+ ms = [2, 2, 2, 2, 2, 16, 16, 8] #markSplitup
31
+ co = [1, 1, 1, 2, 2, 1, 2, 1] #CO No
32
+ elif ass == 2:
33
+ ms = [2, 2, 2, 2, 2, 16, 16, 8] #markSplitup
34
+ co = [3, 3, 3, 4, 4, 3, 4, 3] #CO No
35
+ elif ass == 3 :
36
+ # dep=int(input("\nDepartment\n1.S & H \n2.Other \nchoose the department : "))
37
+ if dep==1:
38
+ ms = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16,
39
+ 16] #markSplitup
40
+ co = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 3, 4, 5] #CO No
41
+ elif dep == 2:
42
+ ms = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, 13, 13, 13, 13,
43
+ 15] #markSplitup
44
+ co = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 3, 4, 5, 5] #CO No
45
+ elif ass == 4:
46
+ ms = [20, 20, 20, 20, 20] #markSplitup
47
+ co = [1, 2, 3, 4, 5] #CO No
48
+ elif ass == 5:
49
+ ms = [20, 20, 20, 20, 20] #markSplitup
50
+ co = [1, 2, 3, 4, 5] #CO No
51
+ elif ass == 6:
52
+ # que_count=int(input("PLease enter Question Count : "))
53
+ for i in co_lister:
54
+ co.append(int(i))
55
+ for i in ms_lister:
56
+ ms.append(int(i))
57
+ # ms.append(int(input(f"Enter the question {i+1} mark : ")))
58
+
59
+ elif reg == 21:
60
+ if ass == 1:
61
+ ms = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 8] #markSplitup
62
+ co = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 1, 2, 3] #CO No
63
+ if ass == 2:
64
+ ms = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 8] #markSplitup
65
+ co = [4, 4, 4, 4, 5, 5, 5, 5, 3, 3, 4, 5, 3] #CO No
66
+ elif ass == 4:
67
+ ms = [20, 20, 20, 20, 20] #markSplitup
68
+ co = [1, 2, 3, 4, 5] #CO No
69
+ elif ass == 5:
70
+ ms = [20, 20, 20, 20, 20] #markSplitup
71
+ co = [1, 2, 3, 4, 5] #CO No
72
+ elif ass == 6:
73
+ # que_count=int(input("PLease enter Question Count : "))
74
+ # for i in range(que_count):
75
+ # co.append(int(input(f"Enter the question {i+1} co number : ")))
76
+ # for i in range(que_count):
77
+ # ms.append(int(input(f"Enter the question {i+1} mark : ")))
78
+
79
+ for i in co_lister:
80
+ co.append(int(i))
81
+ for i in ms_lister:
82
+ ms.append(int(i))
83
+ #print(ms,co)
84
+ #que_count = qcount
85
+ qno = [ i+1 for i in range(len(ms))]
86
+ wm = getmarks() # read the marks
87
+ #print(wm)
88
+ #splitter
89
+ for j in wm:
90
+ ml = {}
91
+ summ = j
92
+ while True:
93
+ for i in range(len(ms)):
94
+ #print(j)
95
+ if j == 0:
96
+ ml[i + 1] = 0
97
+ elif j < 41:
98
+ if j > 10:
99
+ ml[i + 1] = ra.randint(0, ms[i])
100
+ elif j < 6:
101
+ ml[i + 1] = ra.randint(0, 1)
102
+ else:
103
+ ml[i + 1] = ra.randint(0, 2)
104
+ elif j > 40 and j < 61:
105
+ if ms[i] < 3:
106
+ ml[i + 1] = ra.randint(0, ms[i])
107
+ else:
108
+ ml[i + 1] = ra.randint(5, ms[i])
109
+ elif j > 60 and j < 81:
110
+ if ms[i] < 3:
111
+ ml[i + 1] = ra.randint(1, ms[i])
112
+ else:
113
+ ml[i + 1] = ra.randint(7, ms[i])
114
+ elif j > 80 and j < 100:
115
+ if ms[i] < 3:
116
+ ml[i + 1] = ra.randint(2, ms[i])
117
+ else:
118
+ ml[i + 1] = ra.randint(9, ms[i])
119
+ else:
120
+ ml[i + 1] = ms[i]
121
+
122
+ #print(ml)
123
+ if sum(ml.values()) == summ:
124
+ rm.append(ml)
125
+ #print(rm)
126
+ break
127
+ #output
128
+ assName = assName + ".csv"
129
+ with open(assName, "w", newline="") as outfile:
130
+ writer = csv.writer(outfile)
131
+ writer.writerow(["KGiSL INSTITUTE of Technology"])
132
+ writer.writerow([f"Assessment Name : {assName}"])
133
+ co1spup=[sum([ms[v] for v in range(len(ms)) if co[v] == 1])]
134
+ co2spup=[sum([ms[v] for v in range(len(ms)) if co[v] == 2])]
135
+ co3spup=[sum([ms[v] for v in range(len(ms)) if co[v] == 3])]
136
+ co4spup=[sum([ms[v] for v in range(len(ms)) if co[v] == 4])]
137
+ co5spup=[sum([ms[v] for v in range(len(ms)) if co[v] == 5])]
138
+ writer.writerow([*['QNO ->'], *qno,*["Course Outcome SPUP"]])
139
+ writer.writerow([*['CO ->'], *co,*['co1Tot'], *['co2Tot'], *['co3Tot'],
140
+ *['co4Tot'], *['co5Tot']
141
+ #, *['co6Tot']
142
+ ])
143
+ writer.writerow([
144
+ *['TM | MS -> '], *ms,*co1spup,*co2spup,*co3spup,*co4spup,*co5spup])
145
+ #writer.writerow(list(ml.keys()))
146
+ for i in range(len(rm)):
147
+ spup = list(rm[i].values())
148
+ co1tot = [spup[v] for v in range(len(spup)) if co[v] == 1]
149
+ co2tot = [spup[v] for v in range(len(spup)) if co[v] == 2]
150
+ co3tot = [spup[v] for v in range(len(spup)) if co[v] == 3]
151
+ co4tot = [spup[v] for v in range(len(spup)) if co[v] == 4]
152
+ co5tot = [spup[v] for v in range(len(spup)) if co[v] == 5]
153
+ #co6tot = [spup[v] for v in range(len(spup)) if co[v] == 6]
154
+ #print(co1tot, co2tot, co3tot, co4tot, co5tot, co6tot)
155
+ writer.writerow([
156
+ *[sum(spup)], *spup, *[sum(co1tot)], *[sum(co2tot)],
157
+ *[sum(co3tot)], *[sum(co4tot)], *[sum(co5tot)]
158
+ #*[sum(co6tot)
159
+ ])
160
+ #writer.writerow(co1tot)
161
+
162
+
163
+ '''
164
+ # Reading the csv file
165
+ df_new = pd.read_csv('ghu.csv')
166
+ # saving xlsx file
167
+ GFG = pd.ExcelWriter('Names.xlsx')
168
+ df_new.to_excel(GFG, index=False)
169
+
170
+ GFG.save()'''
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ deta==1.1.0
2
+ pandas==1.5.2
3
+ python-dotenv==0.21.0
4
+ streamlit==1.15.2
5
+ streamlit_authenticator==0.1.5