From 6056bc6e113ca93156eb9ae315f5e6173b621d89 Mon Sep 17 00:00:00 2001 From: Raffu Khondaker <2022rkhondak@tjhsst.edu> Date: Tue, 16 Jun 2020 16:01:11 -0400 Subject: [PATCH 1/4] basicc cli cocmpleted --- CLI/student.py | 21 +++++++++++---------- skoolos.py | 50 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/CLI/student.py b/CLI/student.py index 3281fda..badc6bb 100644 --- a/CLI/student.py +++ b/CLI/student.py @@ -227,17 +227,18 @@ class Student: os.system(url) cdir = os.getcwd() - path1 = self.username + "/" + self.username - path2 = self.username - if(os.path.isdir(path1)): - os.chdir(path1) - else: - os.chdir(self.username) - command("git clone " + self.repo) - os.chdir(self.username) + os.chdir(self.username) + # path1 = self.username + "/" + self.username + # path2 = self.username + # if(os.path.isdir(path1)): + # os.chdir(path1) + # else: + # os.chdir(self.username) + # command("git clone " + self.repo) + # os.chdir(self.username) #push to git, start at master - os.chdir(self.username) + #os.chdir(self.username) command("git checkout master") command("git branch " + data['name']) command("git commit -m initial") @@ -335,7 +336,7 @@ class Student: if c['name'] == courses: command("git checkout " + courses) print(os.listdir()) - break + return os.chdir(cdir) print("Class not found") return diff --git a/skoolos.py b/skoolos.py index c35c68e..0e33c8d 100644 --- a/skoolos.py +++ b/skoolos.py @@ -47,12 +47,29 @@ def main(): #webbrowser.open("http://127.0.0.1:8000/login", new=2) authenticate() else: - try: - f = open('.tprofile','r') - except: - f = open('.sprofile','r') - data = json.loads(f.read()) - f.close() + profiles = os.listdir() + users = [] + info = [] + count = 1 + for i in range(len(profiles)): + 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'] USER = data['username'] print(data['username']) @@ -68,6 +85,7 @@ def studentCLI(user, password): from CLI import student data = getUser(user, password, 'student') student = student.Student(data) + student.update() carray = student.sclass.split(",") if(len(carray) == 1 and carray[0] == ""): print("No classes") @@ -90,6 +108,10 @@ def studentCLI(user, password): student.viewClass(course) student.getAssignments(course, 100) +################################################ STUDENT METHODS + +################################################ TEACHER METHODS + def teacherCLI(user, password): from CLI import teacher data = getUser(user, password, 'teacher') @@ -157,7 +179,7 @@ def teacherCLI(user, password): unconf = getDB("http://localhost:8000/api/classes/" + course)['unconfirmed'] for s in unconf: 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 = [ { 'type': 'list', @@ -206,7 +228,7 @@ def teacherCLI(user, password): students = f.read().splitlines() teacher.reqAddStudentList(students, course) else: - sys.exit() + sys.exit(0) if(option == '2'): nlist = os.listdir(teacher.username + "/" + course) alist = getDB("http://localhost:8000/api/classes/" + course)['assignments'] @@ -241,8 +263,18 @@ def teacherCLI(user, password): ass = prompt(questions)['assignment'] apath = teacher.username + "/" + course + "/" + ass due = input("Enter due date (Example: 2020-08-11 16:58): ") - due = due + ":00.000000" + due = due + ":33.383124" 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) From 4241f51fa0d66c3391c16a4cbbe3a48d732967f9 Mon Sep 17 00:00:00 2001 From: Raffu Khondaker <2022rkhondak@tjhsst.edu> Date: Tue, 16 Jun 2020 16:15:47 -0400 Subject: [PATCH 2/4] finished studdent cli --- CLI/student.py | 1 + skoolos.py | 44 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/CLI/student.py b/CLI/student.py index badc6bb..ee16251 100644 --- a/CLI/student.py +++ b/CLI/student.py @@ -336,6 +336,7 @@ class Student: if c['name'] == courses: command("git checkout " + courses) print(os.listdir()) + os.chdir(cdir) return os.chdir(cdir) print("Class not found") diff --git a/skoolos.py b/skoolos.py index 0e33c8d..34d30ea 100644 --- a/skoolos.py +++ b/skoolos.py @@ -86,10 +86,19 @@ def studentCLI(user, password): data = getUser(user, password, 'student') student = student.Student(data) student.update() + EXIT = False + while(not EXIT): + course = chooseClassStudent(student) + EXIT = classOptionsStudent(student, course) + + +################################################ STUDENT METHODS +#return class +def chooseClassStudent(student): carray = student.sclass.split(",") if(len(carray) == 1 and carray[0] == ""): + carray.remove("") print("No classes") - return carray.append("Exit SkoolOS") courses = [ @@ -102,14 +111,35 @@ def studentCLI(user, password): ] course = prompt(courses)['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() - else: - student.viewClass(course) - student.getAssignments(course, 100) - -################################################ STUDENT METHODS + #dont exit cli + return False + if(option == "Exit SkoolOS"): + student.exitCLI() + #exit cli + return True + ################################################ TEACHER METHODS def teacherCLI(user, password): From f7624c3284e0fc3c6247a5b1a28aca9212f8c924 Mon Sep 17 00:00:00 2001 From: Raffu Khondaker <2022rkhondak@tjhsst.edu> Date: Tue, 16 Jun 2020 16:19:20 -0400 Subject: [PATCH 3/4] basic student cli done --- CLI/teacher.py | 3 --- skoolos.py | 23 +++++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CLI/teacher.py b/CLI/teacher.py index 2ba3032..f2b2de3 100644 --- a/CLI/teacher.py +++ b/CLI/teacher.py @@ -595,9 +595,6 @@ class Teacher: os.chdir(cdir) return False - def comment(self): - print("heheheh") - # data = getTeacher("eharris1") # t = Teacher(data) diff --git a/skoolos.py b/skoolos.py index 34d30ea..e11c15a 100644 --- a/skoolos.py +++ b/skoolos.py @@ -78,9 +78,8 @@ def main(): else: teacherCLI(USER, PWD) +################################################ STUDENT METHODS - # while True: - # pass def studentCLI(user, password): from CLI import student data = getUser(user, password, 'student') @@ -91,8 +90,6 @@ def studentCLI(user, password): course = chooseClassStudent(student) EXIT = classOptionsStudent(student, course) - -################################################ STUDENT METHODS #return class def chooseClassStudent(student): carray = student.sclass.split(",") @@ -141,6 +138,22 @@ def classOptionsStudent(student, course): ################################################ 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): from CLI import teacher @@ -307,6 +320,8 @@ def teacherCLI(user, password): due = due + ":33.383124" teacher.addAssignment(apath, course, due) +###################################################################### + def getUser(ion_user, password, utype): if('student' in utype): From 13d248202bddbc9342a1778ccfa985248e786daf Mon Sep 17 00:00:00 2001 From: Raffu Khondaker <2022rkhondak@tjhsst.edu> Date: Tue, 16 Jun 2020 16:20:43 -0400 Subject: [PATCH 4/4] put back hehehhe --- CLI/teacher.py | 3 +++ skoolos.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CLI/teacher.py b/CLI/teacher.py index f2b2de3..2ba3032 100644 --- a/CLI/teacher.py +++ b/CLI/teacher.py @@ -595,6 +595,9 @@ class Teacher: os.chdir(cdir) return False + def comment(self): + print("heheheh") + # data = getTeacher("eharris1") # t = Teacher(data) diff --git a/skoolos.py b/skoolos.py index e11c15a..2941c21 100644 --- a/skoolos.py +++ b/skoolos.py @@ -178,7 +178,7 @@ def teacherCLI(user, password): 'message': 'Select class: ', }, ] - course = prompt(courses)['course'] + course = chooseGeneralTeacher(teacher) if course == "Exit SkoolOS": teacher.exitCLI() if course == "Make New Class":