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

 Conflicts:
	CLI/student.py
	CLI/teacher.py
This commit is contained in:
Nathaniel Kenschaft 2020-06-16 15:07:20 -04:00
commit d256ed6036
6 changed files with 35 additions and 22 deletions

View File

@ -29,35 +29,34 @@ def getStudent(ion_user):
return None
print(r.status_code)
#makes a GET request to given url, returns dict
def getDB(url):
r = requests.get(url=url, auth=('raffukhondaker', 'hackgroup1'))
print("GET:" + str(r.status_code))
return (r.json())
#makes a PATCH (updates instance) request to given url, returns dict
def patchDB(data, url):
r = requests.patch(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
print("PATCH:" + str(r.status_code))
return(r.json())
#makes a POST (makes new instance) request to given url, returns dict
def postDB(data, url):
r = requests.post(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
print("POST:" + str(r.status_code))
return (r.json())
#makes a PUT (overwrites instance) request to given url, returns dict
def putDB(data, url):
r = requests.put(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
print("PUT:" + str(r.status_code))
return (r.json())
def patchDB(data, url):
r = requests.patch(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
print("PATH:" + str(r.status_code))
return (r.json())
#makes a DELETE (delete instance) request to given url, returns dict
def delDB(url):
r = requests.delete(url=url, auth=('raffukhondaker', 'hackgroup1'))
print("DELETE:" + str(r.status_code))
return None
def command(command):

View File

@ -47,7 +47,7 @@ def getTeacher(ion_user):
return None
print(r.status_code)
#makes a GET request to given url, returns dict
def getDB(url):
"""
Sends a GET request to the URL
@ -55,9 +55,9 @@ def getDB(url):
"""
r = requests.get(url=url, auth=('raffukhondaker', 'hackgroup1'))
print("GET:" + str(r.status_code))
return r.json()
return(r.json())
#makes a PATCH (updates instance) request to given url, returns dict
def patchDB(data, url):
"""
Sends a PATCH request to the URL
@ -69,6 +69,7 @@ def patchDB(data, url):
return r.json()
#makes a POST (makes new instance) request to given url, returns dict
def postDB(data, url):
"""
Sends a POST request to the URL
@ -80,6 +81,7 @@ def postDB(data, url):
return r.json()
#makes a PUT (overwrites instance) request to given url, returns dict
def putDB(data, url):
"""
Sends a PUT request to the URL
@ -91,6 +93,7 @@ def putDB(data, url):
return r.json()
#makes a DELETE (delete instance) request to given url, returns dict
def delDB(url):
"""
Sends a DELETE request to the URL
@ -208,13 +211,14 @@ class Teacher:
}
# make class instance in db
postDB(data, 'http://127.0.0.1:8000/api/classes/')
time.sleep(1)
self.classes.append(cname)
# add to instance
# update self.classes
data = {
'classes': self.classes
}
print(self.username)
print(self.classes)
print(patchDB(data, 'http://127.0.0.1:8000/api/teachers/' + self.username + "/"))
# make a new class from scratch

View File

View File

View File

@ -100,9 +100,11 @@ 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
carray = teacher.classes
carray.append("Exit SkoolOS")
carray = []
for c in teacher.classes:
carray.append(c)
carray.append("Make New Class")
carray.append("Exit SkoolOS")
courses = [
{
'type': 'list',
@ -119,10 +121,11 @@ def teacherCLI(user, password):
{
'type': 'input',
'name': 'cname',
'message': 'Class Name: ',
'message': 'Class Name (Must be: <subject>_<ion_user>): ',
},
]
cname = prompt(questions)['cname']
print(cname)
teacher.makeClass(cname)
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
questions = [
@ -130,7 +133,7 @@ def teacherCLI(user, password):
'type': 'list',
'choices':soption,
'name': 'students',
'message': 'Add list of students (input path): ',
'message': 'Add Students): ',
},
]
choice = prompt(questions)['students'].split(")")[0]
@ -138,15 +141,22 @@ def teacherCLI(user, password):
s = input("Student name: ")
teacher.addStudent(s, cname)
if("2" == choice):
p = input("Relativee Path: ")
if(os.path.exists(p)):
print(p + " does not exist.")
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'):
sys.exit(0)
print(path + " is not a valid path")
path = input("Enter file path ('N' to exit): ")
f = open(path, 'r')
students = f.read().splitlines()
teacher.reqAddStudentList(students, cname)
else:
print("Class: " + course)
unconf = getDB("http://localhost:8000/api/classes/" + course)['unconfirmed']
for s in unconf:
teacher.addStudent()
teacher.addStudent(s, course)
options = ['1) Request Student', "2) Add assignment", "3) View student information"]
questions = [
{