teacher cli

This commit is contained in:
Raffu Khondaker 2020-06-14 23:43:49 -04:00
parent 5fe9863677
commit b31f6146d2
2 changed files with 35 additions and 18 deletions

View File

@ -66,8 +66,6 @@ class Teacher:
def __init__(self, data):
# teacher info already stored in API
# intitialze fields after GET request
self.first_name=data['first_name']
self.last_name=data['last_name']
self.git=data['git']
self.username=data['ion_user']
self.url= "http://127.0.0.1:8000/api/teachers/" + self.username + "/"
@ -177,13 +175,10 @@ class Teacher:
#update teacher instance in db, classes field
teacher={
'first_name':self.first_name,
'last_name':self.last_name,
'git':self.git,
'ion_user':self.username,
'url':self.url,
'classes':self.sclass,
'email':self.email
}
putDB(teacher, self.url)
@ -250,13 +245,10 @@ class Teacher:
s = s[:-1]
print(s)
data={
'first_name':self.first_name,
'last_name':self.last_name,
'git':self.git,
'ion_user':self.username,
'url':self.url,
'classes':s,
'email':self.email
}
print(putDB(data, self.url))
delDB("http://127.0.0.1:8000/api/classes/" + cname + "/")
@ -300,14 +292,10 @@ class Teacher:
return False
print(student['added_to'])
s={
'first_name':student["first_name"],
'last_name':student["last_name"],
'git':student["git"],
'ion_user':student["ion_user"],
'student_id':student["student_id"],
'added_to':student['added_to'],
'classes':student["classes"],
'email':student["email"],
'grade':student["grade"],
'completed':student["completed"],
'repo':student["repo"]

View File

@ -55,7 +55,7 @@ def main():
if(data['is_student']):
studentCLI(USER, PWD)
else:
teacherCLI()
teacherCLI(USER, PWD)
@ -63,7 +63,7 @@ def main():
# pass
def studentCLI(user, password):
from CLI import student
data = getStudent(user, password)
data = getUser(user, password)
student = student.Student(data)
choices = ['1) View Class','2) Exit SkoolOS']
questions = [
@ -92,12 +92,41 @@ def studentCLI(user, password):
course = prompt(courses)
if(choice == 2):
student.exitCLI()
def teacherCLI():
from CLI.teacher import Teacher
print("fail")
def teacherCLI(user, password):
from CLI import teacher
data = getUser(user, password)
teacher = teacher.Teacher(data)
choices = ['1) View Class','2) Exit SkoolOS']
questions = [
{
'type': 'list',
'name': 'choice',
'choices':choices,
'message': 'Select class: ',
},
]
choice = prompt(questions)
choice = int(choice['choice'].split(")")[0])
if(choice == 1):
carray = student.sclass.split(",")
if(len(carray) == 1 and carray[0] == ""):
print("No classes")
return
courses = [
{
'type': 'list',
'name': 'course',
'choices':carray,
'message': 'Select class: ',
},
]
course = prompt(courses)
if(choice == 2):
student.exitCLI()
def getStudent(ion_user, password):
def getUser(ion_user, password):
URL = "http://127.0.0.1:8000/api/students/" + ion_user + "/"
r = requests.get(url = URL, auth=(ion_user,password))
if(r.status_code == 200):