mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
formatting
This commit is contained in:
parent
1910502161
commit
d4be5f9eb8
162
skoolos.py
162
skoolos.py
|
@ -174,25 +174,26 @@ def teacherCLI(user, password):
|
||||||
# 3. Get progress logs on a student
|
# 3. Get progress logs on a student
|
||||||
# 2. make an assignment for a class
|
# 2. make an assignment for a class
|
||||||
# 3. view student submissions for an assignment
|
# 3. view student submissions for an assignment
|
||||||
while(not EXIT):
|
while (not EXIT):
|
||||||
#Options: '1) Request Student', "2) Add assignment", "3) View student information", "4) Exit"
|
# Options: '1) Request Student', "2) Add assignment", "3) View student information", "4) Exit"
|
||||||
course = chooseGeneralTeacher(teacher)
|
course = chooseGeneralTeacher(teacher)
|
||||||
if course == "Exit SkoolOS":
|
if course == "Exit SkoolOS":
|
||||||
EXIT = True
|
EXIT = True
|
||||||
elif course == "Make New Class":
|
elif course == "Make New Class":
|
||||||
EXIT = makeClassTeacher(teacher)
|
EXIT = makeClassTeacher(teacher)
|
||||||
#selected a class
|
# selected a class
|
||||||
else:
|
else:
|
||||||
option = classOptionsTeacher(teacher, course)
|
option = classOptionsTeacher(teacher, course)
|
||||||
if(option == '1'):
|
if (option == '1'):
|
||||||
EXIT = addStudentsTeacher(teacher, course)
|
EXIT = addStudentsTeacher(teacher, course)
|
||||||
elif(option == '2'):
|
elif (option == '2'):
|
||||||
EXIT = addAssignmentTeacher(teacher, course)
|
EXIT = addAssignmentTeacher(teacher, course)
|
||||||
elif(option == '3'):
|
elif (option == '3'):
|
||||||
EXIT = viewStudentsTeacher(teacher, course)
|
EXIT = viewStudentsTeacher(teacher, course)
|
||||||
else:
|
else:
|
||||||
EXIT = True
|
EXIT = True
|
||||||
|
|
||||||
|
|
||||||
def chooseGeneralTeacher(teacher):
|
def chooseGeneralTeacher(teacher):
|
||||||
carray = []
|
carray = []
|
||||||
for c in teacher.classes:
|
for c in teacher.classes:
|
||||||
|
@ -200,56 +201,57 @@ def chooseGeneralTeacher(teacher):
|
||||||
carray.append("Make New Class")
|
carray.append("Make New Class")
|
||||||
carray.append("Exit SkoolOS")
|
carray.append("Exit SkoolOS")
|
||||||
courses = [
|
courses = [
|
||||||
{
|
{
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
'name': 'course',
|
'name': 'course',
|
||||||
'choices':carray,
|
'choices': carray,
|
||||||
'message': 'Select class: ',
|
'message': 'Select class: ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
course = prompt(courses)['course']
|
course = prompt(courses)['course']
|
||||||
return course
|
return course
|
||||||
|
|
||||||
|
|
||||||
def makeClassTeacher(teacher):
|
def makeClassTeacher(teacher):
|
||||||
questions = [
|
questions = [
|
||||||
{
|
|
||||||
'type': 'input',
|
|
||||||
'name': 'cname',
|
|
||||||
'message': 'Class Name (Must be: <subject>_<ion_user>): ',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
cname = prompt(questions)['cname']
|
|
||||||
print(cname)
|
|
||||||
while(not ("_" + teacher.username) in cname):
|
|
||||||
print("Incorrect naming format")
|
|
||||||
questions = [
|
|
||||||
{
|
{
|
||||||
'type': 'input',
|
'type': 'input',
|
||||||
'name': 'cname',
|
'name': 'cname',
|
||||||
'message': 'Class Name (Must be: <subject>_<ion_user>): ',
|
'message': 'Class Name (Must be: <subject>_<ion_user>): ',
|
||||||
},
|
},
|
||||||
|
]
|
||||||
|
cname = prompt(questions)['cname']
|
||||||
|
print(cname)
|
||||||
|
while (not ("_" + teacher.username) in cname):
|
||||||
|
print("Incorrect naming format")
|
||||||
|
questions = [
|
||||||
|
{
|
||||||
|
'type': 'input',
|
||||||
|
'name': 'cname',
|
||||||
|
'message': 'Class Name (Must be: <subject>_<ion_user>): ',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
cname = prompt(questions)['cname']
|
cname = prompt(questions)['cname']
|
||||||
|
|
||||||
teacher.makeClass(cname)
|
teacher.makeClass(cname)
|
||||||
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
|
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
|
||||||
questions = [
|
questions = [
|
||||||
{
|
{
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
'choices':soption,
|
'choices': soption,
|
||||||
'name': 'students',
|
'name': 'students',
|
||||||
'message': 'Add Students): ',
|
'message': 'Add Students): ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
choice = prompt(questions)['students'].split(")")[0]
|
choice = prompt(questions)['students'].split(")")[0]
|
||||||
if("1" == choice):
|
if ("1" == choice):
|
||||||
s = input("Student name: ")
|
s = input("Student name: ")
|
||||||
teacher.addStudent(s, cname)
|
teacher.addStudent(s, cname)
|
||||||
if("2" == choice):
|
if ("2" == choice):
|
||||||
print("File must be .txt and have 1 student username per line")
|
print("File must be .txt and have 1 student username per line")
|
||||||
path = input("Relative Path: ")
|
path = input("Relative Path: ")
|
||||||
while(not os.path.exists(path)):
|
while (not os.path.exists(path)):
|
||||||
if(path == 'N'):
|
if (path == 'N'):
|
||||||
return True
|
return True
|
||||||
print(path + " is not a valid path")
|
print(path + " is not a valid path")
|
||||||
path = input("Enter file path ('N' to exit): ")
|
path = input("Enter file path ('N' to exit): ")
|
||||||
|
@ -258,6 +260,7 @@ def makeClassTeacher(teacher):
|
||||||
teacher.reqAddStudentList(students, cname)
|
teacher.reqAddStudentList(students, cname)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def classOptionsTeacher(teacher, course):
|
def classOptionsTeacher(teacher, course):
|
||||||
print("Class: " + course)
|
print("Class: " + course)
|
||||||
unconf = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['unconfirmed']
|
unconf = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['unconfirmed']
|
||||||
|
@ -265,49 +268,50 @@ def classOptionsTeacher(teacher, course):
|
||||||
teacher.addStudent(s, course)
|
teacher.addStudent(s, course)
|
||||||
options = ['1) Request Student', "2) Add assignment", "3) View student information", "4) Exit"]
|
options = ['1) Request Student', "2) Add assignment", "3) View student information", "4) Exit"]
|
||||||
questions = [
|
questions = [
|
||||||
{
|
{
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
'name': 'course',
|
'name': 'course',
|
||||||
'choices':options,
|
'choices': options,
|
||||||
'message': 'Select option: ',
|
'message': 'Select option: ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
option = prompt(questions)['course'].split(")")[0]
|
option = prompt(questions)['course'].split(")")[0]
|
||||||
return option
|
return option
|
||||||
|
|
||||||
|
|
||||||
def addStudentsTeacher(teacher, course):
|
def addStudentsTeacher(teacher, course):
|
||||||
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
|
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
|
||||||
questions = [
|
questions = [
|
||||||
{
|
{
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
'choices':soption,
|
'choices': soption,
|
||||||
'name': 'students',
|
'name': 'students',
|
||||||
'message': 'Add list of students (input path): ',
|
'message': 'Add list of students (input path): ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
schoice = prompt(questions)['students'].split(")")[0]
|
schoice = prompt(questions)['students'].split(")")[0]
|
||||||
if(schoice == '1'):
|
if (schoice == '1'):
|
||||||
questions = [
|
questions = [
|
||||||
{
|
{
|
||||||
'type': 'input',
|
'type': 'input',
|
||||||
'name': 'student',
|
'name': 'student',
|
||||||
'message': 'Student Name: ',
|
'message': 'Student Name: ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
s = prompt(questions)['student']
|
s = prompt(questions)['student']
|
||||||
teacher.reqStudent(s, course)
|
teacher.reqStudent(s, course)
|
||||||
return False
|
return False
|
||||||
if(schoice == '2'):
|
if (schoice == '2'):
|
||||||
questions = [
|
questions = [
|
||||||
{
|
{
|
||||||
'type': 'input',
|
'type': 'input',
|
||||||
'name': 'path',
|
'name': 'path',
|
||||||
'message': 'Path: ',
|
'message': 'Path: ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
path = prompt(questions)['path']
|
path = prompt(questions)['path']
|
||||||
while(not os.path.exists(path)):
|
while (not os.path.exists(path)):
|
||||||
if(path == 'N'):
|
if (path == 'N'):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
print(path + " is not a valid path")
|
print(path + " is not a valid path")
|
||||||
path = input("Enter file path ('N' to exit): ")
|
path = input("Enter file path ('N' to exit): ")
|
||||||
|
@ -318,6 +322,7 @@ def addStudentsTeacher(teacher, course):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def addAssignmentTeacher(teacher, course):
|
def addAssignmentTeacher(teacher, course):
|
||||||
nlist = os.listdir(teacher.username + "/" + course)
|
nlist = os.listdir(teacher.username + "/" + course)
|
||||||
alist = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['assignments']
|
alist = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['assignments']
|
||||||
|
@ -327,36 +332,36 @@ def addAssignmentTeacher(teacher, course):
|
||||||
for n in nlist:
|
for n in nlist:
|
||||||
b = True
|
b = True
|
||||||
print(teacher.username + "/" + course + "/" + n)
|
print(teacher.username + "/" + course + "/" + n)
|
||||||
for a in alist:
|
for a in alist:
|
||||||
if(n in a or n == a):
|
if (n in a or n == a):
|
||||||
#print("Assignments: " + n)
|
# print("Assignments: " + n)
|
||||||
b = False
|
b = False
|
||||||
if(not os.path.isdir(teacher.username + "/" + course + "/" + n)):
|
if (not os.path.isdir(teacher.username + "/" + course + "/" + n)):
|
||||||
b = False
|
b = False
|
||||||
if(b):
|
if (b):
|
||||||
tlist.append(n)
|
tlist.append(n)
|
||||||
|
|
||||||
|
|
||||||
nlist = tlist
|
nlist = tlist
|
||||||
if(len(nlist) == 0):
|
if (len(nlist) == 0):
|
||||||
print("No new assignments found")
|
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
|
return False
|
||||||
questions = [
|
questions = [
|
||||||
{
|
{
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
'choices':nlist,
|
'choices': nlist,
|
||||||
'name': 'assignment',
|
'name': 'assignment',
|
||||||
'message': 'Select new assignment: ',
|
'message': 'Select new assignment: ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
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 + ":33.383124"
|
due = due + ":33.383124"
|
||||||
due = due.strip()
|
due = due.strip()
|
||||||
f = False
|
f = False
|
||||||
while(not f):
|
while (not f):
|
||||||
try:
|
try:
|
||||||
datetime.datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
datetime.datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
||||||
f = True
|
f = True
|
||||||
|
@ -364,10 +369,11 @@ def addAssignmentTeacher(teacher, course):
|
||||||
print("Due-date format is incorrect.")
|
print("Due-date format is incorrect.")
|
||||||
print(due)
|
print(due)
|
||||||
due = input("Enter due date (Example: 2020-08-11 16:58): ")
|
due = input("Enter due date (Example: 2020-08-11 16:58): ")
|
||||||
due = due + ":33.383124"
|
due = due + ":33.383124"
|
||||||
teacher.addAssignment(apath, course, due)
|
teacher.addAssignment(apath, course, due)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def viewStudentsTeacher(teacher, course):
|
def viewStudentsTeacher(teacher, course):
|
||||||
data = getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/classes/" + course)
|
data = getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/classes/" + course)
|
||||||
students = data["confirmed"]
|
students = data["confirmed"]
|
||||||
|
@ -379,7 +385,7 @@ def viewStudentsTeacher(teacher, course):
|
||||||
for s in unconf:
|
for s in unconf:
|
||||||
print(s)
|
print(s)
|
||||||
student = input("View student (Enter student's ion username): ")
|
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")
|
print("Student not affiliated with class")
|
||||||
student = input("View student ('N' to exit): ")
|
student = input("View student ('N' to exit): ")
|
||||||
if student == 'N':
|
if student == 'N':
|
||||||
|
@ -523,7 +529,7 @@ def authenticate():
|
||||||
url = browser.current_url
|
url = browser.current_url
|
||||||
gets = url_decode(url.replace("http://localhost:8000/login/?", ""))
|
gets = url_decode(url.replace("http://localhost:8000/login/?", ""))
|
||||||
while "http://localhost:8000/login/?username=" not in browser.current_url and (
|
while "http://localhost:8000/login/?username=" not in browser.current_url and (
|
||||||
not browser.current_url == "http://localhost:8000/"): # http://localhost:8000/
|
not browser.current_url == "http://localhost:8000/"): # http://localhost:8000/
|
||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
|
|
||||||
url = browser.current_url
|
url = browser.current_url
|
||||||
|
|
Loading…
Reference in New Issue
Block a user