|
|
|
|
|
import gradio as gr |
|
|
import numpy as np |
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
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] |
|
|
|
|
|
|
|
|
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]]) |
|
|
|
|
|
|
|
|
k = -1 |
|
|
count = 0 |
|
|
|
|
|
for i in range(len(data)): |
|
|
|
|
|
k = k+1 |
|
|
|
|
|
lst=data[i].split() |
|
|
for j in lst: |
|
|
|
|
|
subsData[k].append(j) |
|
|
|
|
|
if len(lst)==0: |
|
|
|
|
|
subsData.remove(subsData[k]) |
|
|
k = k-1 |
|
|
|
|
|
|
|
|
|
|
|
compensations = [] |
|
|
for sub1 in range(k): |
|
|
|
|
|
|
|
|
for sub2 in range(sub1+1, k+1): |
|
|
|
|
|
compensations.append([subsData[sub1][0]+"/"+subsData[sub2][0]]) |
|
|
|
|
|
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]) |
|
|
|
|
|
|
|
|
compensations[count].append(len(cmn_lst)) |
|
|
cmn_lst = ' '.join(cmn_lst) |
|
|
compensations[count].append(cmn_lst) |
|
|
count=count+1 |
|
|
|
|
|
|
|
|
for i in range(len(compensations)): |
|
|
for j in range(len(compensations[0])): |
|
|
|
|
|
if compensations[i][j] == 0: |
|
|
compensations[i][j+1]="NONE" |
|
|
|
|
|
print(pd.DataFrame(compensations)) |
|
|
|
|
|
|
|
|
|
|
|
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>") |
|
|
|
|
|
|
|
|
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")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ENGLISH HL")) |
|
|
|
|
|
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")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for HINDI B HL")) |
|
|
with gr.Row(): |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH AB INITIO SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH AB INITIO HL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH B SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for SPANISH B HL")) |
|
|
with gr.Row(): |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH AB INITIO SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH AB INITIO HL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH B SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for FRENCH B HL")) |
|
|
|
|
|
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")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for BM HL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ECON SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ECON HL")) |
|
|
with gr.Row(): |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PSYCH SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PSYCH HL")) |
|
|
|
|
|
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")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for CHEM HL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for BIO SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for BIO HL")) |
|
|
with gr.Row(): |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PHYSICS SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for PHYSICS HL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for CS SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for CS HL")) |
|
|
|
|
|
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")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for MAA HL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for MAI SL")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for MAI HL")) |
|
|
|
|
|
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")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for VA HL")) |
|
|
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")) |
|
|
inpSubsData.append(gr.Textbox(placeholder="Enter student list here",label="Student List for ESS HL")) |
|
|
|
|
|
sbmt_btn = gr.Button("Accept Data") |
|
|
|
|
|
sort_btn = gr.Radio(["All","Max 3","Max 2","Max 1","No Compensations"],value='None', show_label=False) |
|
|
|
|
|
|
|
|
out=gr.Dataframe(headers=["Parallel Subjects","No. of Compensations","Compensations"]) |
|
|
|
|
|
|
|
|
sbmt_btn.click(prepData, inpSubsData, out) |
|
|
sort_btn.change(sortData, inputs=[sort_btn, out], outputs=out) |
|
|
|
|
|
heart.launch() |