Merge branch 'development' of github.com:Rushilwiz/SkoolOS into development

 Conflicts:
	CLI/student.py
This commit is contained in:
Nathaniel Kenschaft 2020-06-16 16:21:50 -04:00
commit 86746c5700
2 changed files with 106 additions and 27 deletions

View File

@ -230,17 +230,18 @@ class Student:
os.system(url) os.system(url)
cdir = os.getcwd() cdir = os.getcwd()
path1 = self.username + "/" + self.username os.chdir(self.username)
path2 = self.username # path1 = self.username + "/" + self.username
if (os.path.isdir(path1)): # path2 = self.username
os.chdir(path1) # if(os.path.isdir(path1)):
else: # os.chdir(path1)
os.chdir(self.username) # else:
command("git clone " + self.repo) # os.chdir(self.username)
os.chdir(self.username) # command("git clone " + self.repo)
# os.chdir(self.username)
# push to git, start at master # push to git, start at master
os.chdir(self.username) #os.chdir(self.username)
command("git checkout master") command("git checkout master")
command("git branch " + data['name']) command("git branch " + data['name'])
command("git commit -m initial") command("git commit -m initial")
@ -338,7 +339,8 @@ class Student:
if c['name'] == courses: if c['name'] == courses:
command("git checkout " + courses) command("git checkout " + courses)
print(os.listdir()) print(os.listdir())
break os.chdir(cdir)
return
os.chdir(cdir) os.chdir(cdir)
print("Class not found") print("Class not found")
return return

View File

@ -47,12 +47,29 @@ def main():
#webbrowser.open("http://127.0.0.1:8000/login", new=2) #webbrowser.open("http://127.0.0.1:8000/login", new=2)
authenticate() authenticate()
else: else:
try: profiles = os.listdir()
f = open('.tprofile','r') users = []
except: info = []
f = open('.sprofile','r') count = 1
data = json.loads(f.read()) for i in range(len(profiles)):
f.close() p = profiles[i]
if('profile' in p):
f = open(p,'r')
d = json.loads(f.read())
f.close()
info.append(d)
users.append(str(count) + ") " + d['username'])
count = count+1
user = [
{
'type': 'list',
'name': 'user',
'choices':users,
'message': 'Select User: ',
},
]
u = int(prompt(user)['user'].split(")")[0]) -1
data = info[u]
PWD = data['password'] PWD = data['password']
USER = data['username'] USER = data['username']
print(data['username']) print(data['username'])
@ -61,17 +78,24 @@ def main():
else: else:
teacherCLI(USER, PWD) teacherCLI(USER, PWD)
################################################ STUDENT METHODS
# while True:
# pass
def studentCLI(user, password): def studentCLI(user, password):
from CLI import student from CLI import student
data = getUser(user, password, 'student') data = getUser(user, password, 'student')
student = student.Student(data) student = student.Student(data)
student.update()
EXIT = False
while(not EXIT):
course = chooseClassStudent(student)
EXIT = classOptionsStudent(student, course)
#return class
def chooseClassStudent(student):
carray = student.sclass.split(",") carray = student.sclass.split(",")
if(len(carray) == 1 and carray[0] == ""): if(len(carray) == 1 and carray[0] == ""):
carray.remove("")
print("No classes") print("No classes")
return
carray.append("Exit SkoolOS") carray.append("Exit SkoolOS")
courses = [ courses = [
@ -84,11 +108,52 @@ def studentCLI(user, password):
] ]
course = prompt(courses)['course'] course = prompt(courses)['course']
print(course) print(course)
if course == "Exit SkoolOS": return course
def classOptionsStudent(student, course):
student.viewClass(course)
student.getAssignments(course, 100)
choices = ["Save","Back","Exit SkoolOS"]
options = [
{
'type': 'list',
'name': 'option',
'choices':choices,
'message': 'Select: ',
},
]
option = prompt(options)['option']
if(option == "Save"):
student.update()
print("Saved!")
classOptionsStudent(student, course)
if(option == "Back"):
student.exitCLI() student.exitCLI()
else: #dont exit cli
student.viewClass(course) return False
student.getAssignments(course, 100) if(option == "Exit SkoolOS"):
student.exitCLI()
#exit cli
return True
################################################ TEACHER METHODS
def chooseGeneralTeacher(teacher):
carray = []
for c in teacher.classes:
carray.append(c)
carray.append("Make New Class")
carray.append("Exit SkoolOS")
courses = [
{
'type': 'list',
'name': 'course',
'choices':carray,
'message': 'Select class: ',
},
]
course = prompt(courses)['course']
return course
def teacherCLI(user, password): def teacherCLI(user, password):
from CLI import teacher from CLI import teacher
@ -113,7 +178,7 @@ def teacherCLI(user, password):
'message': 'Select class: ', 'message': 'Select class: ',
}, },
] ]
course = prompt(courses)['course'] course = chooseGeneralTeacher(teacher)
if course == "Exit SkoolOS": if course == "Exit SkoolOS":
teacher.exitCLI() teacher.exitCLI()
if course == "Make New Class": if course == "Make New Class":
@ -157,7 +222,7 @@ def teacherCLI(user, password):
unconf = getDB("http://localhost:8000/api/classes/" + course)['unconfirmed'] unconf = getDB("http://localhost:8000/api/classes/" + course)['unconfirmed']
for s in unconf: for s in unconf:
teacher.addStudent(s, course) teacher.addStudent(s, course)
options = ['1) Request Student', "2) Add assignment", "3) View student information"] options = ['1) Request Student', "2) Add assignment", "3) View student information", "Exit"]
questions = [ questions = [
{ {
'type': 'list', 'type': 'list',
@ -206,7 +271,7 @@ def teacherCLI(user, password):
students = f.read().splitlines() students = f.read().splitlines()
teacher.reqAddStudentList(students, course) teacher.reqAddStudentList(students, course)
else: else:
sys.exit() sys.exit(0)
if(option == '2'): if(option == '2'):
nlist = os.listdir(teacher.username + "/" + course) nlist = os.listdir(teacher.username + "/" + course)
alist = getDB("http://localhost:8000/api/classes/" + course)['assignments'] alist = getDB("http://localhost:8000/api/classes/" + course)['assignments']
@ -241,10 +306,22 @@ def teacherCLI(user, password):
ass = prompt(questions)['assignment'] ass = prompt(questions)['assignment']
apath = teacher.username + "/" + course + "/" + ass apath = teacher.username + "/" + course + "/" + ass
due = input("Enter due date (Example: 2020-08-11 16:58): ") due = input("Enter due date (Example: 2020-08-11 16:58): ")
due = due + ":00.000000" due = due + ":33.383124"
due = due.strip() due = due.strip()
f = False
while(not f):
try:
datetime.datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
f = True
except:
print("Due-date format is incorrect.")
print(due)
due = input("Enter due date (Example: 2020-08-11 16:58): ")
due = due + ":33.383124"
teacher.addAssignment(apath, course, due) teacher.addAssignment(apath, course, due)
######################################################################
def getUser(ion_user, password, utype): def getUser(ion_user, password, utype):
if('student' in utype): if('student' in utype):