File size: 10,492 Bytes
c3ba3ba 6369325 c3ba3ba 6369325 c3ba3ba 6369325 c3ba3ba 6369325 c3ba3ba 6369325 c3ba3ba 6369325 c3ba3ba 6369325 c3ba3ba 6369325 c3ba3ba ad87352 c3ba3ba 13cf37b |
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
#Import libraries
import gradio as gr
import numpy as np
import pandas as pd
#Assembling and Processing Data
def prepData(engSL,engHL,
hindiBSL,hindiBHL,
spanAbSL,spanAbHL,spanBSL,spanBHL,
frenchAbSL,frenchAbHL,frenchBSL,frenchBHL,
bmSL,bmHL,econSL,econHL,
psychSL,psychHL,
chemSL,chemHL,bioSL,bioHL,
phySL,phyHL,csSL,csHL,
maaSL,maaHL,maiSL,maiHL,
vaSL,vaHL,
essSL,essHL):
data = [engSL,engHL,
hindiBSL,hindiBHL,
spanAbSL,spanAbHL,spanBSL,spanBHL,
frenchAbSL,frenchAbHL,frenchBSL,frenchBHL,
bmSL,bmHL,econSL,econHL,
psychSL,psychHL,
chemSL,chemHL,bioSL,bioHL,
phySL,phyHL,csSL,csHL,
maaSL,maaHL,maiSL,maiHL,
vaSL,vaHL,
essSL,essHL]
#Location for assmebling all subjects data
subsData = []
subs = "engSL engHL hindiBSL hindiBHL spanAbSL spanAbHL spanBSL spanBHL frenchAbSL frenchAbHL frenchBSL frenchBHL bmSL bmHL econSL econHL psychSL psychHL chemSL chemHL bioSL bioHL phySL phyHL csSL csHL maaSL maaHL maiSL maiHL vaSL vaHL essSL essHL"
subs = subs.split()
for i in range(len(subs)):
subsData.append([subs[i]])
#Counters
k = -1
count = 0
for i in range(len(data)):
#Inside each subject
k = k+1
#print(i,k)
lst=data[i].split()
for j in lst:
#print(k,j)
subsData[k].append(j)
if len(lst)==0:
#print("entered")
subsData.remove(subsData[k])
k = k-1
#Processing Data
compensations = []
for sub1 in range(k):
#compensations = []
for sub2 in range(sub1+1, k+1):
#print(temp[sub1][0],temp[sub2][0])
compensations.append([subsData[sub1][0]+"/"+subsData[sub2][0]])
#compensations.append(list('/'.join(compensations[count])))
cmn_lst = []
for i in range(1,len(subsData[sub1])):
for j in range(1,len(subsData[sub2])):
if subsData[sub1][i] == subsData[sub2][j]:
cmn_lst.append(subsData[sub2][j])
#print(temp[sub2][j])
compensations[count].append(len(cmn_lst))
cmn_lst = ' '.join(cmn_lst)
compensations[count].append(cmn_lst)
count=count+1
#print(compensations)
for i in range(len(compensations)):
for j in range(len(compensations[0])):
#print(compensations[i][j])
if compensations[i][j] == 0:
compensations[i][j+1]="NONE"
print(pd.DataFrame(compensations))
#print(pd.DataFrame(subsData).head())
return compensations
def sortData(btnVal,compensation):
compensations = compensation.values.tolist()
print(type(compensations))
print(compensations[1][1])
if btnVal == "All":
return compensations
if btnVal == "Max 3":
count = -1
three = compensations
for rowNo in range(len(three)):
count = count + 1
if three[count][1] > 3:
three.remove(three[count])
count = count - 1
return three
if btnVal == "Max 2":
count = -1
two = compensations
for rowNo in range(len(two)):
count = count + 1
if two[count][1] > 2:
two.remove(two[count])
count = count - 1
return two
if btnVal == "Max 1":
count = -1
one = compensations
for rowNo in range(len(one)):
count = count + 1
if one[count][1] > 1:
one.remove(one[count])
count = count - 1
return one
if btnVal == "No Compensations":
count = -1
none = compensations
for rowNo in range(len(none)):
count = count + 1
if none[count][1] > 0:
none.remove(none[count])
count = count - 1
return none
with gr.Blocks() as heart:
gr.HTML("<div style='font-size: 35px; font-family: Georgia; color: black; text-align: center'>Schedule Management Helper</div>")
#Entry fields are here
inpSubsData = []
gr.HTML("<div style='font-size: 20px; font-family: Georgia; color: black'>Group I - English Language and Literature</div>")
with gr.Column():
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ENGLISH SL")) #1
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ENGLISH HL")) #2
gr.HTML("<div style='font-size: 20px; font-family: Georgia; color: black'>Group II - Language Acquisition- Hindi B, Spanish, French</div>")
with gr.Column():
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for HINDI B SL")) #3
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for HINDI B HL")) #4
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH AB INITIO SL")) #5
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH AB INITIO HL")) #6
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH B SL")) #7
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH B HL")) #8
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH AB INITIO SL")) #9
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH AB INITIO HL")) #10
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH B SL")) #11
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH B HL")) #12
gr.HTML("<div style='font-size: 20px; font-family: Georgia; color: black'>Group III - Business Management, Economics, Psychology</div>")
with gr.Column():
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for BM SL")) #13
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for BM HL")) #14
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ECON SL")) #15
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ECON HL")) #16
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PSYCH SL")) #17
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PSYCH HL")) #18
gr.HTML("<div style='font-size: 20px; font-family: Georgia; color: black'>Group IV - Chemistry, Biology, Physics, Computer Science</div>")
with gr.Column():
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for CHEM SL")) #19
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for CHEM HL")) #20
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for BIO SL")) #21
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for BIO HL")) #22
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PHYSICS SL")) #23
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PHYSICS HL")) #24
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for CS SL")) #25
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for CS HL")) #26
gr.HTML("<div style='font-size: 20px; font-family: Georgia; color: black'>Group V - Mathematics Analysis and Approaches and Mathematics Application and Interpretation</div>")
with gr.Column():
with gr.Row():
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for MAA SL")) #27
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for MAA HL")) #28
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for MAI SL")) #29
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for MAI HL")) #30
with gr.Row():
with gr.Column():
gr.HTML("<div style='font-size: 20px; font-family: Georgia; color: black'>Group VI - Arts- Visual arts</div>")
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for VA SL")) #31
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for VA HL")) #32
with gr.Column():
gr.HTML("<div style='font-size: 20px; font-family: Georgia; color: black'>Group III & IV - Environmental Societies and Systems</div>")
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ESS SL")) #33
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ESS HL")) #34
sbmt_btn = gr.Button("Accept Data")
sort_btn = gr.Radio(["All","Max 3","Max 2","Max 1","No Compensations"],value='None', show_label=False)
#Output is here
out=gr.Dataframe(headers=["Parallel Subjects","No. of Compensations","Compensations"])
#Button Functions
sbmt_btn.click(prepData, inpSubsData, out)
sort_btn.change(sortData, inputs=[sort_btn, out], outputs=out)
heart.launch() |