<repo_name>saqib1707/RattleSnake<file_sep>/LargeCoachingInstitute/coachingtemp.py
import json
import os
max_batchstrength=3
noofbatches=4

class RattleSnake:
    def __init__(self):
        self.nametoadd=""
        self.phone_no=""
        self.marks=0
        self.batch=None
        self.username=""
        self.password=""

    def checkFileEmpty(self):
        if os.stat("StudentRecords.txt").st_size == 0:
            print "Empty File!!!Please add members to perform these operations"
            return True
        else:
            return False
        
    def addStudent(self):
        listobj=[]
        count=0
        string=""
        myModifiedList=""
        #noofStudents=input("How many students data u want to add ?? >>> ")
        #for i in range(noofStudents):
        self.nametoadd=raw_input("\nEnter student name to be added >>> ")
        self.phone_no=raw_input("Enter phone no:")
        with open("StudentRecords.txt") as readStudentFile:
            if self.checkFileEmpty()==False:
                jsonData=json.load(readStudentFile)
                if len(jsonData) in range(1,4):
                    self.batch=1
                elif len(jsonData) in range(4,8):
                    self.batch=2
                elif len(jsonData) in range(8,12):
                    self.batch=3
                elif len(jsonData) in range(11,15):
                    self.batch=4
            else:
                self.batch=1

        data= {"name":self.nametoadd,"phoneno":self.phone_no,"marks":self.marks,"batch":self.batch,"username":self.username,"password":<PASSWORD>}
        listobj.append(data)
        
        with open('StudentRecords.txt','a') as appendStudentFile:
            json.dump(listobj,appendStudentFile)
        with open('StudentRecords.txt') as readStudentFile:
            textdata=readStudentFile.read()
            for char in textdata:
                if count==1:
                    string+=char
                    if string=="][":
                        count=2
                        char=','
                if char==']':
                    count+=1
                    string+=char
                else:
                    myModifiedList+=char
                if count==2:
                    continue
            if count==1 or count==3:
                myModifiedList+=']'
        with open('StudentRecords.txt','w') as file:
            file.write(myModifiedList)
        jsonData=json.load(open("StudentRecords.txt"))
        open("StudentRecords.txt",'w').write(json.dumps(jsonData,indent=4))

    def removeStudent(self):
        if self.checkFileEmpty()==True:
            return
        with open('StudentRecords.txt') as readStudentFile:
            jsonData1=json.load(readStudentFile)
            nooftimes=input("How many student data u want to delete >>> ")
            for i in range(nooftimes):
                found=False
                #jsonfile=json.load(open("StudentRecords.txt"))
                if jsonData1==[]:
                    print "Student Database already empty!!!No more members to delete"
                    break
                self.nameToRemove=raw_input("Enter student name to be removed from Database >>> ")
                for i in range(len(jsonData1)):
                    if jsonData1[i]["name"]==self.nameToRemove :
                        jsonData1.pop(i)
                        print "%s deleted from Database "%self.nameToRemove
                        found=True
                        break
                if found==False:
                    print "\n%s not in the DataBase\n" %self.nameToRemove
                open('StudentRecords.txt','w').write(json.dumps(jsonData1,indent=4))
                os.system("pause")


    def showListOfStudents(self):
        listObj=[]
        with open('StudentRecords.txt') as infile:
            if self.checkFileEmpty()==False:
                data=json.load(infile)
                for i in range(len(data)):
                    dictionary={"name":data[i]['name'],"phoneno":data[i]['phoneno'],"marks":data[i]['marks'],"batch":data[i]['batch']}
                    listObj.append(dictionary)
                with open('Info.txt','w') as readFile:
                    json.dump(listObj,readFile,indent=4)
                os.system('Info.txt')     
        infile.close()

    def modifyData(self):
        with open('StudentRecords.txt') as infile:
            if self.checkFileEmpty()==False:
                jsonData=json.load(infile)
                self.dataToModify=raw_input("\nEnter student name whose data has to be modified >>> ")
                modification=True
                for i in range(len(jsonData)):
                    if jsonData[i]["name"]==self.dataToModify :
                        print "Press 1 to modify Student Name"
                        print "Press 2 to modify Student phone_no"
                        modify_choice=input(">>> ")
                        if modify_choice==1:
                            jsonData[i]["name"]=raw_input("Enter Modified Name:")
                            
                        elif modify_choice==2:
                            jsonData[i]["phone"]=raw_input("Enter Modified Phone no:")
                           
                        else:
                            print "Wrong choice"
                            modification=False

                        if modification==True:
                            print "Data Modified for %s"%self.dataToModify 
                        open("StudentRecords.txt",'w').write(json.dumps(jsonData,indent=4))
        infile.close()
        os.system("pause")


    

# Interface to access data of coaching students
def accessStuData():
    while(True):
        print "\nPress 1 to Add Students to the Database"
        print "Press 2 to Remove students from the Database"
        print "Press 3 to Print all the students in the Database"
        print "Press 4 to modify the basic info of students"
        print "Press 0 to go back to the previous menu"
            
        obj=RattleSnake()
        inputchoice=input(">>> ")

        if inputchoice==1:
            obj.addStudent()
                    
        elif inputchoice==2:
            obj.removeStudent()

        elif inputchoice==3:
            obj.showListOfStudents()

        elif inputchoice==4:
            obj.modifyData()

        else:
            break
    return
    <file_sep>/Error.py
def showError():
	print "Wrong Input"
<file_sep>/LargeCoachingInstitute/TeacherInterface.py
import json,Error,getpass,os

class TeacherInterface:
	def __init__(self):
		print

	def checkBatchEmpty(self,batch):
		with open('StudentRecords.txt') as readStudentFile:
			jsonData2=json.load(readStudentFile)
			for i in range(len(jsonData2)):
				if jsonData2[i]['batch']==batch:
					return False
			print "Batch is empty"
			return True

	def showListOfStudents(self,batch):
		if self.checkBatchEmpty(batch)==True:
			return
		listOfStudent=[]
		with open('StudentRecords.txt') as readStudentFile:
			jsonData2=json.load(readStudentFile)
			for i in range(len(jsonData2)):
				if jsonData2[i]['batch']==batch:
					#listOfStudent.append(jsonData2[i]['name'])
					print jsonData2[i]['name']," : ",jsonData2[i]['marks']
			
	def uploadMarks(self,batch):
		if self.checkBatchEmpty(batch)==True:
			return
		print "Upload Student Marks for the Latest Test"
		with open('StudentRecords.txt') as readStudentFile:
			jsonData2=json.load(readStudentFile)
			for i in range(len(jsonData2)):
				if jsonData2[i]['batch']==batch:
					jsonData2[i]['marks']=input(jsonData2[i]['name'])
			open('StudentRecords.txt','w').write(json.dumps(jsonData2,indent=4))
			print "Marks Uploaded Successfully"
			os.system("pause")
		with open('TeacherRecords.txt') as readTeacherFile:
			jsonData1=json.load(readTeacherFile)
			for i in range(len(jsonData1)):
				if jsonData1[i]['batch']==batch:
					jsonData1[i]['is_Marks_Updated']="True"
			open('TeacherRecords.txt','w').write(json.dumps(jsonData1,indent=4))

	def modifyMarks(self,batch):
		if self.checkBatchEmpty(batch)==True:
			return
		is_Modified=False
		print "Enter student name whose marks has to be modified"
		name=raw_input(">>>")
		with open('StudentRecords.txt') as readStudentFile:
			jsonData2=json.load(readStudentFile)
			for i  in range(len(jsonData2)):
				if jsonData2[i]['name']==name and jsonData2[i]['batch']==batch:
					jsonData2[i]['marks']=input('Enter modified marks >>> ')
					is_Modified=True
					print "Marks Modified for %s"%name
					os.system("pause")
					break
			if is_Modified==False:
				print "Modification Failure!!!Student not found"
			open('StudentRecords.txt','w').write(json.dumps(jsonData2,indent=4))

def main():
	batch=None
	username=raw_input("Username >>>")
	pwd=<PASSWORD>("<PASSWORD> >>>")
	with open('TeacherRecords.txt') as readTeacherFile:
		jsonData1=json.load(readTeacherFile)
		for i in range(len(jsonData1)):
			if jsonData1[i]['username']==username and jsonData1[i]['password']==pwd :
				batch=jsonData1[i]['batch']
				print "\n",jsonData1[i]['name']," -Batch ",batch,"\n","Access Granted"
				if jsonData1[i]['is_Marks_Updated']=="False":
					print "Reminder to upload the latest test marks"
				break
		if batch==None:
			print "Access Denied"
			print "Username or password or both are incorrect!!!Please try again"
			return
	while True:
		print "\n1. See the list of students in ur batch"
		print "2. Upload marks of the Latest Test"
		print "3. Modify marks of individual student"
		print "0. Quit"
		choice=input(">>>")
		obj=TeacherInterface()
		if choice==1:
			obj.showListOfStudents(batch)

		elif choice==2:
			obj.uploadMarks(batch)

		elif choice==3:
			obj.modifyMarks(batch)

		elif choice==0:
			break

		else:
			Error.showError()

if __name__=="__main__":
	main()
<file_sep>/LargeCoachingInstitute/StudentLogin.py
import json
import getpass 
import os  

#to check whether the StudentRecords file is completely empty or not
def checkFileEmpty():
        if os.stat("StudentRecords.txt").st_size == 0:
            print "Empty File!!!Please add members to perform these operations"
            return True
        else:
            return False
#for student to login(if signed up) to view their current marks and batch details
def login():
	found=False
	if checkFileEmpty()==True:              #checks whether the file is empty or not
		return
	username=raw_input("User Name >>>")
	pwd=<PASSWORD>.getpass("Password >>>")
	with open('StudentRecords.txt') as readFile:
		jsonData=json.load(readFile)
        for i in range(len(jsonData)):
        	if jsonData[i]['username']==username and jsonData[i]['password']==pwd:
        		#show his username,marks ,rank and current batch
        		found=True
        		print "\n",jsonData[i]['name'],"\nMarks:",jsonData[i]['marks'],"\tBatch:",jsonData[i]['batch'],"\n"
        if found==False:
        	print "\nNot registered or not admitted yet!!!If Registered ,then Sign Up!!!\n"
    
#for students who have been admitted 
def signUp():
	found=False
	countOfTry=0
	if checkFileEmpty()==True:              #checks whether the file is empty or not
		return
	name=raw_input("Name >>>")
	phoneno=raw_input("Phone No >>>")	
	with open('StudentRecords.txt') as readStudentFile:
		jsonData=json.load(readStudentFile)
		for i in range(len(jsonData)):
			if jsonData[i]['name']==name and jsonData[i]['phoneno']==phoneno and jsonData[i]['username']=="" and jsonData[i]['password']=="":
				found=True
				username=raw_input("UserName >>>")
				pwd=<PASSWORD>.getpass("Password >>>")
				confirmpwd=getpas.getpass("Confirm Password >>>")
				if pwd!=confirmpwd:
					print "Password don't match!!!Try Again(max. 3 times)"
					countOfTry+=1
					if countOfTry==2:
						break
				else:
					#Register the student username and password
					print "\nRegistration complete!!! Now Login to view your Current Status\n"
					os.system("pause")
					jsonData[i]['username']=username
					jsonData[i]['password']=pwd
					open('StudentRecords.txt','w').write(json.dumps(jsonData,indent=4))	
				break
		if found==False:
			print "\nNot admitted yet or data filled incorrectly or already registered\n"

while(True):	
	print "Press 1 to Login to view Results"
	print "Press 2 to Sign Up for the first time"
	print "Press 0 to exit"
	choicethree=input(">>> ")
	if choicethree==1:
		login()
	elif choicethree==2:
		signUp()
	elif choicethree==0:
		break
	else:
		Error.showError()


	

<file_sep>/LargeCoachingInstitute/administrator.py
import json
import coachingtemp
import os
import Error

class Administrator:
	def __init__(self):
		print

	def startNewTest(self):
		flag=True
		with open('TeacherRecords.txt','r') as readTeacherFile:
			jsonData=json.load(readTeacherFile)
			for i in range(len(jsonData)):
				if jsonData[i]['is_Marks_Updated']=="None":
					flag=False
					jsonData[i]['is_Marks_Updated']="False"
			if flag==False:
				print "New Test could not be started now.Reminders to teachers who have not submitted marksheet"
				os.system("pause")
				return
		print "Start a new Test"
		with open('TeacherRecords.txt') as readTeacherFile:
			jsonData=json.load(readTeacherFile)
			for i in range(len(jsonData)):
					jsonData[i]['is_Marks_Updated']="None"
			open('TeacherRecords.txt','w').write(json.dumps(jsonData,indent=4))

	def reMapping(self):
		count=0
		listObj=[]
		with open('TeacherRecords.txt','r') as readTeacherFile:
			jsonData=json.load(readTeacherFile)
			for i in range(len(jsonData)):
				if jsonData[i]['is_Marks_Updated']!="True":
					print "All students marks has not be uploaded!! ReMapping could not be done now"
					os.system("pause")
					return
		print "ReMapping of students"
		i=1
		with open('StudentRecords.txt','r') as readStudentFile:
			jsonData=json.load(readStudentFile)
			jsonDataSorted=sorted(jsonData,key=lambda k:k['marks'],reverse=True)
			for j in range(len(jsonDataSorted)):
				count+=1
				if count%5==0:
					i+=1
					count+=1
				jsonDataSorted[j]['batch']=i
		open('StudentRecords.txt','w').write(json.dumps(jsonDataSorted,indent=4))
		#showing the shuffled data
		for i in range(len(jsonDataSorted)):
			datadict={'name':jsonDataSorted[i]['name'],'marks':jsonDataSorted[i]['marks'],"batch":jsonDataSorted[i]['batch']}
			listObj.append(datadict)
		json.dump(listObj,open('MarkSheet.txt','w'))
		jsonDataSorted=json.load(open('MarkSheet.txt'))
		open('MarkSheet.txt','w').write(json.dumps(jsonDataSorted,indent=4))
		os.system('MarkSheet.txt')


def AdmInterface(choice):
	AdmObj=Administrator()
	if choice==2:
		AdmObj.startNewTest()    #upload marks for all the students
	elif choice==3:
		AdmObj.reMapping()       #Shuffle students and allot them batches

while(True):
	print "\nPress 1 to Access the Coaching Students Database"	
	print "Press 2 to start a new test(give reminders to teachers)"
	print "Press 3 for Batch Allotment"
	print "Press 0 to exit"
	choicefour=input(">>>")
	if choicefour==1:
		coachingtemp.accessStuData()
	elif choicefour==2 or choicefour==3:
		AdmInterface(choicefour)
	elif choicefour==0:
		break
	else:
		Error.showError()

<file_sep>/coaching_temp.py
import json
import os

class RattleSnake:
    def __init__(self):
        self.nametoadd=""
        self.phone_no=""
        self.marks=0
        self.batch=None
        self.username=""
        self.password=""

    def checkFileEmpty(self):
        if os.stat("C:\Users\Saqib\Desktop\Snake\Records.txt").st_size == 0:
            print "Empty File!!!Please add members to perform these operations"
            return True
        else:
            return False
        
    def addStudent(self):
        listobj=[]
        count=0
        string=""
        myModifiedList=""
        noofStudents=input("How many students data u want to add >>> ")
        for i in range(noofStudents):
            self.nametoadd=raw_input("\nEnter student name to be added >>> ")
            self.phone_no=raw_input("Enter phone no:")
            data= {"stu_name":self.nametoadd,"stu_phoneno":self.phone_no,"stu_marks":self.marks,"stu_batch":self.batch,"stu_username":self.username,"stu_password":self.<PASSWORD>}
            listobj.append(data)

        with open('C:\Users\Saqib\Desktop\Snake\Records.txt','a') as file:
            json.dump(listobj,file)
        with open('C:\Users\Saqib\Desktop\Snake\Records.txt','r') as file:
            textdata=file.read()
            for char in textdata:
                if count==1:
                    string+=char
                    if string=="][":
                        count=2
                        char=','
                if char==']':
                    count+=1
                    string+=char
                else:
                    myModifiedList+=char
                if count==2:
                    continue
            if count==1 or count==3:
                myModifiedList+=']'
        with open('C:\Users\Saqib\Desktop\Snake\Records.txt','w') as file:
            file.write(myModifiedList)
        jsonData=json.load(open("C:\Users\Saqib\Desktop\Snake\Records.txt"))
        open("C:\Users\Saqib\Desktop\Snake\Records.txt",'w').write(json.dumps(jsonData,indent=4))


    def removeStudent(self):
        with open('C:\Users\Saqib\Desktop\Snake\Records.txt') as infile:
            if self.checkFileEmpty()==False:
                jsonfile=json.load(infile)
                nooftimes=input("How many student data u want to delete >>> ")
                for i in range(nooftimes):
                    found=False
                    #jsonfile=json.load(open("C:\Users\Saqib\Desktop\Snake\Records.txt"))
                    if jsonfile==[]:
                        print "Student Database already empty!!!No more members to delete"
                        break
                    self.nameToRemove=raw_input("Enter student name to be removed from Database >>> ")
                    for i in range(len(jsonfile)):
                        if jsonfile[i]["stu_name"]==self.nameToRemove :
                            jsonfile.pop(i)
                            print "%s deleted from Database "%self.nameToRemove
                            found=True
                            break
                    if found==False:
                        print "\n%s not in the DataBase\n" %self.nameToRemove
                    open("C:\Users\Saqib\Desktop\Snake\Records.txt",'w').write(json.dumps(jsonfile,indent=4))


    def printListOfStudents(self):
        listObj=[]
        with open('C:\Users\Saqib\Desktop\Snake\Records.txt') as infile:
            if self.checkFileEmpty()==False:
                data=json.load(infile)
                for i in range(len(data)):
                    dictionary={"stu_name":data[i]['stu_name'],"stu_phoneno":data[i]['stu_phoneno'],"stu_marks":data[i]['stu_marks'],"stu_batch":data[i]['stu_batch']}
                    listObj.append(dictionary)
                with open('C:\Users\Saqib\Desktop\Snake\Info.txt','w') as readFile:
                    json.dump(listObj,readFile,indent=4)
                os.system('C:\Users\Saqib\Desktop\Snake\Info.txt')     
        infile.close()

    def modifyData(self):
        with open('C:\Users\Saqib\Desktop\Snake\Records.txt') as infile:
            if self.checkFileEmpty()==False:
                jsonData=json.load(infile)
                self.dataToModify=raw_input("Enter student name whose data has to be modified >>> ")
                modification=True
                for i in range(len(jsonData)):
                    if jsonData[i]["stu_name"]==self.dataToModify :
                        print "Press 1 to modify Student Name"
                        print "Press 2 to modify Student phone_no"
                        print "Press 3 to modify Student marks"
                        print "Press 4 to modify Student batch"
                        modify_choice=input("Enter ur choice >>> ")
                        if modify_choice==1:
                            jsonfile[i]["stu_name"]=raw_input("Enter Modified Name:")
                            
                        elif modify_choice==2:
                            jsonfile[i]["stu_phone"]=raw_input("Enter Modified Phone no:")
                           
                        elif modify_choice==3:
                            jsonfile[i]["stu_marks"]=raw_input("Enter Modified marks :")
                            
                        elif modify_choice==4:
                            jsonfile[i]["stu_batch"]=raw_input("Enter new batch:")
                           
                        else:
                            print "Wrong choice"
                            modification=False

                        if modification==True:
                            print "Data Modified for %s"%self.dataToModify 
                        open("C:\Users\Saqib\Desktop\Snake\Records.txt",'w').write(json.dumps(jsonfile,indent=4))
        infile.close()

    

# Interface to access data of coaching students
def accessStuData():
    while(True):
        print "Press 1 to Add Students to the Database"
        print "Press 2 to Remove students from the Database"
        print "Press 3 to Print all the students in the Database"
        print "Press 4 to modify the data of students"
        print "Press any other key to go back to the previous menu"
            
        obj=RattleSnake()
        inputchoice=input("Enter ur choice >>> ")

        if inputchoice==1:
            obj.addStudent()
                    
        elif inputchoice==2:
            obj.removeStudent()

        elif inputchoice==3:
            obj.printListOfStudents()

        elif inputchoice==4:
            obj.modifyData()

        else:
            break
    return
    <file_sep>/StudentLogin.py
import json
import getpass

def login():
	found=False
	username=raw_input("User Name >>>")
	pwd=getpass.getpass("Password >>>")
	with open('C:\Users\Saqib\Desktop\Snake\Records.txt') as readFile:
		jsonData=json.load(readFile)
		if jsonData==[]:
			print "Student database empty"
			return
        for i in range(len(jsonData)):
        	if jsonData[i]['stu_username']==username and jsonData[i]['stu_password']==pwd:
        		#show his username,marks ,rank and current batch
        		found=True
        		print "\n",jsonData[i]['stu_name'],"\nMarks:",jsonData[i]['stu_marks'],"\tBatch:",jsonData[i]['stu_batch'],"\n"
        if found==False:
        	print "\nNot registered or not admitted yet!!!If Registered ,then Sign Up!!!\n"

#for the first time users.
def signUp():
	found=False
	name=raw_input("Name >>>")
	phoneno=raw_input("Phone No >>>")
	with open('C:\Users\Saqib\Desktop\Snake\Records.txt') as readFile:
		jsonData=json.load(readFile)
	for i in range(len(jsonData)):
		if jsonData[i]['stu_name']==name and jsonData[i]['stu_phoneno']==phoneno:
			found=True
			username=raw_input("UserName >>>")
			pwd=getpass.getpass("Password >>>")
			confirmpwd=getpass.getpass("Confirm Password >>>")
			if pwd!=confirmpwd:
				print "Password don't match!!!"
			else:
				#Register the student username and password
				print "\nRegistration complete\n"
				jsonData[i]['stu_username']=username
				jsonData[i]['stu_password']=pwd
				open('C:\Users\Saqib\Desktop\Snake\Records.txt','w').write(json.dumps(jsonData,indent=4))
			break
	if found==False:
		print "\nNot admitted yet or data filled incorrectly\n"
while(True):	
	print "Press 1 to Login to view Results"
	print "Press 2 to Sign Up for the first time"
	print "Press 0 to exit"
	choicethree=input(">>> ")
	if choicethree==1:
		login()
	elif choicethree==2:
		signUp()
	elif choicethree==0:
		break
	else:
		Error.showError()


	

<file_sep>/administrator.py
import json
import coaching_temp
import os
import Error

class Administrator:
	def __init__(self):
		#print "In init of administrator"
		print ""
		print ""

	def uploadMarks(self):
		print "Upload of Students' Marks"
		listObj=[]
		with open('C:\Users\Saqib\Desktop\Snake\Records.txt') as readFile:
			jsonFile=json.load(readFile)
			readFile.close()
		with open('C:\Users\Saqib\Desktop\Snake\Records.txt','w') as writeFile:
			for i in range(len(jsonFile)):
				jsonFile[i]['stu_marks']=raw_input("Enter marks for %s :"%jsonFile[i]['stu_name'])
				datadict={'stu_name':jsonFile[i]['stu_name'],'stu_phoneno':jsonFile[i]['stu_phoneno'],'stu_marks':jsonFile[i]['stu_marks'],"stu_batch":jsonFile[i]['stu_batch'],"stu_username":jsonFile[i]['stu_username'],"stu_password":jsonFile[i]["stu_password"]}
				listObj.append(datadict)
			json.dump(listObj,writeFile)	
			writeFile.close()
		with open('C:\Users\Saqib\Desktop\Snake\Records.txt') as readFile:
			jsonFile=json.load(readFile)
		open('C:\Users\Saqib\Desktop\Snake\Records.txt','w').write(json.dumps(jsonFile,indent=4))
		#jsonFile=json.load(open('C:\Users\Saqib\Desktop\Snake\MarkSheet.txt'))	
		#open('C:\Users\Saqib\Desktop\Snake\MarkSheet.txt','w').write(json.dumps(jsonFile,indent=4))
		#os.system('C:\Users\Saqib\Desktop\Snake\MarkSheet.txt')


	def reMapping(self):
		count=0
		i=1
		listObj=[]
		print "ReMapping of students"
		with open('C:\Users\Saqib\Desktop\Snake\Records.txt','r') as readFile:
			jsonFile=json.load(readFile)
			jsonFileSorted=sorted(jsonFile,key=lambda k:k['stu_marks'],reverse=True)
			for j in range(len(jsonFileSorted)):
				count+=1
				if count%4==0:
					i+=1
				jsonFileSorted[j]['stu_batch']=i
		open('C:\Users\Saqib\Desktop\Snake\Records.txt','w').write(json.dumps(jsonFileSorted,indent=4))
		#showing the shuffled data
		for i in range(len(jsonFileSorted)):
			datadict={'stu_name':jsonFileSorted[i]['stu_name'],'stu_marks':jsonFileSorted[i]['stu_marks'],"stu_batch_alloted":jsonFileSorted[i]['stu_batch']}
			listObj.append(datadict)
		json.dump(listObj,open('C:\Users\Saqib\Desktop\Snake\MarkSheet.txt','w'))
		jsonFileSorted=json.load(open('C:\Users\Saqib\Desktop\Snake\MarkSheet.txt'))
		open('C:\Users\Saqib\Desktop\Snake\MarkSheet.txt','w').write(json.dumps(jsonFileSorted,indent=4))
		os.system('C:\Users\Saqib\Desktop\Snake\MarkSheet.txt')


def AdmInterface(choice):
	AdmObj=Administrator()
	if choice==2:
		AdmObj.uploadMarks()    #upload marks for all the students
	elif choice==3:
		AdmObj.reMapping()       #Shuffle students and allot them batches

while(True):
	print "Press 1 to Access the Coaching Students Database"	
	print "Press 2 to Upload the New MarkSheet of the latest Test"
	print "Press 3 to shuffle the Students based on their marks"
	print "Press 0 to exit"
	choicefour=input(">>>")
	if choicefour==1:
		coaching_temp.accessStuData()
	elif choicefour==2 or choicefour==3:
		AdmInterface(choicefour)
	elif choicefour==0:
		break
	else:
		Error.showError()

