formatting

This commit is contained in:
Nathaniel Kenschaft 2020-06-16 19:12:34 -04:00
parent 1910502161
commit d4be5f9eb8

View File

@ -174,25 +174,26 @@ def teacherCLI(user, password):
# 3. Get progress logs on a student
# 2. make an assignment for a class
# 3. view student submissions for an assignment
while(not EXIT):
#Options: '1) Request Student', "2) Add assignment", "3) View student information", "4) Exit"
while (not EXIT):
# Options: '1) Request Student', "2) Add assignment", "3) View student information", "4) Exit"
course = chooseGeneralTeacher(teacher)
if course == "Exit SkoolOS":
EXIT = True
elif course == "Make New Class":
EXIT = makeClassTeacher(teacher)
#selected a class
# selected a class
else:
option = classOptionsTeacher(teacher, course)
if(option == '1'):
if (option == '1'):
EXIT = addStudentsTeacher(teacher, course)
elif(option == '2'):
elif (option == '2'):
EXIT = addAssignmentTeacher(teacher, course)
elif(option == '3'):
elif (option == '3'):
EXIT = viewStudentsTeacher(teacher, course)
else:
EXIT = True
def chooseGeneralTeacher(teacher):
carray = []
for c in teacher.classes:
@ -203,13 +204,14 @@ def chooseGeneralTeacher(teacher):
{
'type': 'list',
'name': 'course',
'choices':carray,
'choices': carray,
'message': 'Select class: ',
},
]
course = prompt(courses)['course']
return course
def makeClassTeacher(teacher):
questions = [
{
@ -220,7 +222,7 @@ def makeClassTeacher(teacher):
]
cname = prompt(questions)['cname']
print(cname)
while(not ("_" + teacher.username) in cname):
while (not ("_" + teacher.username) in cname):
print("Incorrect naming format")
questions = [
{
@ -236,20 +238,20 @@ def makeClassTeacher(teacher):
questions = [
{
'type': 'list',
'choices':soption,
'choices': soption,
'name': 'students',
'message': 'Add Students): ',
},
]
choice = prompt(questions)['students'].split(")")[0]
if("1" == choice):
if ("1" == choice):
s = input("Student name: ")
teacher.addStudent(s, cname)
if("2" == choice):
if ("2" == choice):
print("File must be .txt and have 1 student username per line")
path = input("Relative Path: ")
while(not os.path.exists(path)):
if(path == 'N'):
while (not os.path.exists(path)):
if (path == 'N'):
return True
print(path + " is not a valid path")
path = input("Enter file path ('N' to exit): ")
@ -258,6 +260,7 @@ def makeClassTeacher(teacher):
teacher.reqAddStudentList(students, cname)
return False
def classOptionsTeacher(teacher, course):
print("Class: " + course)
unconf = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['unconfirmed']
@ -268,25 +271,26 @@ def classOptionsTeacher(teacher, course):
{
'type': 'list',
'name': 'course',
'choices':options,
'choices': options,
'message': 'Select option: ',
},
]
option = prompt(questions)['course'].split(")")[0]
return option
def addStudentsTeacher(teacher, course):
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
questions = [
{
'type': 'list',
'choices':soption,
'choices': soption,
'name': 'students',
'message': 'Add list of students (input path): ',
},
]
schoice = prompt(questions)['students'].split(")")[0]
if(schoice == '1'):
if (schoice == '1'):
questions = [
{
'type': 'input',
@ -297,7 +301,7 @@ def addStudentsTeacher(teacher, course):
s = prompt(questions)['student']
teacher.reqStudent(s, course)
return False
if(schoice == '2'):
if (schoice == '2'):
questions = [
{
'type': 'input',
@ -306,8 +310,8 @@ def addStudentsTeacher(teacher, course):
},
]
path = prompt(questions)['path']
while(not os.path.exists(path)):
if(path == 'N'):
while (not os.path.exists(path)):
if (path == 'N'):
sys.exit(0)
print(path + " is not a valid path")
path = input("Enter file path ('N' to exit): ")
@ -318,6 +322,7 @@ def addStudentsTeacher(teacher, course):
else:
return True
def addAssignmentTeacher(teacher, course):
nlist = os.listdir(teacher.username + "/" + course)
alist = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['assignments']
@ -328,24 +333,24 @@ def addAssignmentTeacher(teacher, course):
b = True
print(teacher.username + "/" + course + "/" + n)
for a in alist:
if(n in a or n == a):
#print("Assignments: " + n)
if (n in a or n == a):
# print("Assignments: " + n)
b = False
if(not os.path.isdir(teacher.username + "/" + course + "/" + n)):
if (not os.path.isdir(teacher.username + "/" + course + "/" + n)):
b = False
if(b):
if (b):
tlist.append(n)
nlist = tlist
if(len(nlist) == 0):
if (len(nlist) == 0):
print("No new assignments found")
print("To make an assignment: make a subdirectory in the " + course + " folder. Add a file within the new folder")
print(
"To make an assignment: make a subdirectory in the " + course + " folder. Add a file within the new folder")
return False
questions = [
{
'type': 'list',
'choices':nlist,
'choices': nlist,
'name': 'assignment',
'message': 'Select new assignment: ',
},
@ -356,7 +361,7 @@ def addAssignmentTeacher(teacher, course):
due = due + ":33.383124"
due = due.strip()
f = False
while(not f):
while (not f):
try:
datetime.datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
f = True
@ -368,6 +373,7 @@ def addAssignmentTeacher(teacher, course):
teacher.addAssignment(apath, course, due)
return False
def viewStudentsTeacher(teacher, course):
data = getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/classes/" + course)
students = data["confirmed"]
@ -379,7 +385,7 @@ def viewStudentsTeacher(teacher, course):
for s in unconf:
print(s)
student = input("View student (Enter student's ion username): ")
while((not student in str(data['confirmed'])) or (not student in str(data['unconfirmed']))):
while ((not student in str(data['confirmed'])) or (not student in str(data['unconfirmed']))):
print("Student not affiliated with class")
student = input("View student ('N' to exit): ")
if student == 'N':