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] 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)