From 673a17ffe4b6fee61a4b8e26f7d7d0e37f99b8c8 Mon Sep 17 00:00:00 2001
From: Raffu Khondaker <2022rkhondak@tjhsst.edu>
Date: Tue, 16 Jun 2020 12:30:49 -0400
Subject: [PATCH 1/4] completed teachher.py
---
CLI/student.py | 9 ++--
CLI/teacher.py | 49 +++++++++----------
eharris1/APLit_eharris1/BookReport/rubric.txt | 7 +++
eharris1/APLit_eharris1/BookReport/sample.txt | 0
4 files changed, 35 insertions(+), 30 deletions(-)
create mode 100644 eharris1/APLit_eharris1/BookReport/rubric.txt
create mode 100644 eharris1/APLit_eharris1/BookReport/sample.txt
diff --git a/CLI/student.py b/CLI/student.py
index 8559979..cc0e29b 100644
--- a/CLI/student.py
+++ b/CLI/student.py
@@ -331,12 +331,13 @@ class Student:
if c['name'] == courses:
command("git checkout " + courses)
print(os.listdir())
- return
+ break
os.chdir(cdir)
print("Class not found")
return
def exitCLI(self):
+ print(os.getcwd())
self.update()
command("git checkout master")
@@ -370,10 +371,10 @@ class Student:
data = getStudent("2022rkhondak")
s = Student(data)
-#s.viewClass("APLit_eharris1")
-s.addClass("APLit_eharris1")
+s.viewClass("APLit_eharris1")
+#s.addClass("APLit_eharris1")
# #s.update()
-# s.exitCLI()
+s.exitCLI()
def main():
pass
diff --git a/CLI/teacher.py b/CLI/teacher.py
index b062c15..8f6af39 100644
--- a/CLI/teacher.py
+++ b/CLI/teacher.py
@@ -365,6 +365,7 @@ class Teacher:
def addAssignment(self, path, course, due):
parts = path.split("/")
aname = parts[len(parts)-1]
+ oname = aname + "_" + course
if(os.path.isdir(path) == 0 or len(parts) < 3) or aname in str(self.classes):
print("Not valid path.")
@@ -373,9 +374,9 @@ class Teacher:
print("Not in valid class directory")
return False
#parts of assignment name (Essay1, APLit)
- if((course in aname) == False):
- print("Assignment named incorrectly; could be "+ aname + "_" + course)
- return False
+ # if((course in aname) == False):
+ # print("Assignment named incorrectly; could be "+ aname + "_" + course)
+ # return False
ar = [x[2] for x in os.walk(path)]
print(ar)
@@ -383,10 +384,10 @@ class Teacher:
if len(folder) == 0:
print("Assignment is completely empty, needs a file.")
return False
- p1 = course.split("_")[0]
- if(p1 in aname == False):
- print(aname + "incorrectly formated: must be " + aname + "_" + p1 + ".")
- return False
+ # p1 = course.split("_")[0]
+ # if(p1 in aname == False):
+ # print(aname + "incorrectly formated: must be " + aname + "_" + p1 + ".")
+ # return False
try:
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
except:
@@ -397,9 +398,8 @@ class Teacher:
if(aname in str(course['assignments'])):
print("Assignment name already taken.")
return False
-
print(course['assignments'])
- input()
+ print(aname)
#################### FINISH VERIFYING
if(os.path.exists(os.getcwd() + "/" + self.username + "/Students/" + course['name']) == False):
@@ -428,14 +428,14 @@ class Teacher:
r = requests.get(url = 'http://127.0.0.1:8000/api/assignments/' + aname, auth=('raffukhondaker','hackgroup1'))
if(r.status_code != 200):
ass = {
- 'name': aname,
+ 'name': oname,
'path':path,
'classes':course['name'],
'teacher':self.username,
'due_date':due
}
postDB(ass, 'http://127.0.0.1:8000/api/assignments/')
- course['assignments'].append(aname)
+ course['assignments'].append(oname)
cinfo = {
"assignments": course['assignments'],
@@ -451,6 +451,7 @@ class Teacher:
def updateAssignment(self, path, course, due):
parts = path.split("/")
aname = parts[len(parts)-1]
+ oname=aname + "_" + course
if(os.path.isdir(path) == False):
print(path + " is not an assignment.")
return
@@ -460,7 +461,7 @@ class Teacher:
d = {
'due_date':due,
}
- patchDB(d, 'http://localhost:8000/api/assignments/' + aname + "/")
+ print(patchDB(d, 'http://localhost:8000/api/assignments/' + oname + "/"))
print("Due-date changed " + due)
except:
print("Due-date is the same")
@@ -471,19 +472,15 @@ class Teacher:
for st in slist:
if st in course['confirmed']:
spath = os.path.join(os.getcwd() + "/" + self.username + "/Students/" + course['name'], st)
- if(os.path.exists(spath + "/" + aname) == False):
- os.mkdir(spath + "/" + aname)
- print(st)
- print(copy_tree(path, spath + "/" + aname))
- os.chdir(spath)
- command('git checkout ' + course['name'])
- command('git pull origin ' + course['name'])
- command('git add .')
- command('git commit -m Hello')
- command('git push -u origin ' + course['name'])
- os.chdir(cdir)
- else:
- print(st + " already has assignment")
+ print(st)
+ print(copy_tree(path, spath + "/" + aname))
+ os.chdir(spath)
+ #command('git checkout ' + course['name'])
+ command('git add .')
+ command('git commit -m Hello')
+ command('git pull origin ' + course['name'])
+ command('git push -u origin ' + course['name'])
+ os.chdir(cdir)
#pull student's work, no modifications
def getStudents(self, course):
@@ -598,7 +595,7 @@ class Teacher:
data = getTeacher("eharris1")
t = Teacher(data)
#t.makeClass("APLit_eharris1")
-#t.addAssignment("eharris1/APLit_eharris1/Essay1_eharris1", "APLit_eharris1", '2020-08-11 16:58:33.383124')
+t.updateAssignment("eharris1/APLit_eharris1/BookReport", "APLit_eharris1", '2020-08-11 16:58:33.383124')
#ar = ['2022rkhondak','2022inafi','2023rumareti']
#extra = t.reqAddStudentList(ar, "APLit_eharris1")
#print(extra)
diff --git a/eharris1/APLit_eharris1/BookReport/rubric.txt b/eharris1/APLit_eharris1/BookReport/rubric.txt
new file mode 100644
index 0000000..a65722f
--- /dev/null
+++ b/eharris1/APLit_eharris1/BookReport/rubric.txt
@@ -0,0 +1,7 @@
+kskskksks
+kskskksks
+kskskksks
+kskskksks
+kskskksks
+kskskksks
+kskskksks
\ No newline at end of file
diff --git a/eharris1/APLit_eharris1/BookReport/sample.txt b/eharris1/APLit_eharris1/BookReport/sample.txt
new file mode 100644
index 0000000..e69de29
From 4b60133e82cb9857fcd3ef7e97300eee020c6c61 Mon Sep 17 00:00:00 2001
From: Raffu Khondaker <2022rkhondak@tjhsst.edu>
Date: Tue, 16 Jun 2020 13:54:42 -0400
Subject: [PATCH 2/4] removed extra files in cli
---
.sprofile | 1 +
.tprofile | 1 +
CLI/commands.py | 148 --------
CLI/index.html | 9 -
CLI/oauth/template.html | 23 --
CLI/s-git-oldd.py | 256 --------------
CLI/server.py | 23 --
CLI/student.py | 14 +-
CLI/t-git-old.py | 372 --------------------
CLI/teacher.py | 6 +-
eharris1/APLit_eharris1/Essay2/instruct.txt | 0
skoolos.py | 127 +++++--
snew.py | 25 +-
students.txt | 1 +
14 files changed, 132 insertions(+), 874 deletions(-)
create mode 100644 .sprofile
create mode 100644 .tprofile
delete mode 100644 CLI/commands.py
delete mode 100644 CLI/index.html
delete mode 100644 CLI/oauth/template.html
delete mode 100644 CLI/s-git-oldd.py
delete mode 100644 CLI/server.py
delete mode 100644 CLI/t-git-old.py
create mode 100644 eharris1/APLit_eharris1/Essay2/instruct.txt
create mode 100644 students.txt
diff --git a/.sprofile b/.sprofile
new file mode 100644
index 0000000..544f6b1
--- /dev/null
+++ b/.sprofile
@@ -0,0 +1 @@
+{"username": "2022rkhondak", "grade": 10, "is_student": true, "password": "hackgroup1"}
\ No newline at end of file
diff --git a/.tprofile b/.tprofile
new file mode 100644
index 0000000..b141284
--- /dev/null
+++ b/.tprofile
@@ -0,0 +1 @@
+{"username": "eharris1", "is_student": false, "password": "hackgroup1"}
\ No newline at end of file
diff --git a/CLI/commands.py b/CLI/commands.py
deleted file mode 100644
index 39ed5f7..0000000
--- a/CLI/commands.py
+++ /dev/null
@@ -1,148 +0,0 @@
-from __future__ import print_function, unicode_literals
-from PyInquirer import prompt, print_json
-import json
-import os
-import argparse
-
-
-'''
-my_parser = argparse.ArgumentParser(prog='skool', description='Let SkoolOS control your system', epilog="Try again")
-my_parser.add_argument('--init', action="store_true") #returns true if run argument
-args = my_parser.parse_args()
-
-update()
-outputs = vars(args)
-if(outputs['init']):
- start()
-'''
-
-#already ccrerrated account through website, has to login
-def update():
- #get data from database
- return
-
-def yesorno(question):
- questions = [
- {
- 'type': 'input',
- 'name': 'response',
- 'message': question,
- },
- ]
- answers = prompt(questions)
- if(answers["response"] == "y"):
- return True
- return False
-
-def login():
- #enter username
- #enter password
- questions = [
- {
- 'type': 'input',
- 'name': 'webmail',
- 'message': 'What\'s TJ Webmail',
- },
- {
- 'type': 'password',
- 'name': 'password',
- 'message': 'Password?',
- },
- ]
- user = prompt(questions)
- #reading from json of users (replace w GET to database) to check if user is registered
- with open('users.json', 'r') as json_file:
- data = json.load(json_file)
- for i in range(len(data)):
- if user["webmail"] == data[i]["webmail"]:
- if(user["password"] == data[i]["password"]):
- print("Logged in!")
- return data[i]
- else:
- print("Password incorrect. Try again.")
- return None
- print("User not found. Please Try again")
- return None
-
-#did not create account through website, has to signup/login
-def signup():
- questions = [
- {
- 'type': 'input',
- 'name': 'first-name',
- 'message': 'What\'s your first name',
- },
- {
- 'type': 'input',
- 'name': 'last-name',
- 'message': 'What\'s your last name?',
- },
- {
- 'type': 'list',
- 'name': 'grade',
- 'message': 'Grade?',
- 'choices':["9","10","11","12"]
- },
- {
- 'type': 'input',
- 'name': 'webmail',
- 'message': 'What\'s your TJ Webmail?',
- },
- {
- 'type': 'password',
- 'name': 'password',
- 'message': 'Password?',
- },
- ]
- user = prompt(questions)
- for i in user:
- if user[i] == "":
- print("Some forms were left blank. Try again.\n")
- return None
- if len(user["password"]) < 6:
- print("Password is too short. Try again.")
- return None
- if (("@tjhsst.edu" in user['webmail']) == False):
- print("Webmail entered was not a @tjhhsst.edu. Try again.")
- return None
-
- user["classes"] = []
- with open('users.json', 'r') as json_file:
- data = json.load(json_file)
- data.append(user)
- open("users.json", "w").write(str(json.dumps(data)))
- return user
-
-def relogin():
- questions = [
- {
- 'type': 'list',
- 'name': 'choice',
- 'message': '',
- 'choices':["Continue as current user","Login into new user","Sign up into new account"]
- },
- ]
- answer = prompt(questions)
-
-
-def setup(user):
- #Read classes/assignenments and setup directory:
- #SkoolOS/Math/Week1
- for c in user["classes"]:
- os.makedirs(c)
- for a in user["classes"][c]:
- os.makedirs(c + "/" + a)
-
-def start():
- if(os.path.exists(".login.txt") == False):
- b = yesorno("Do you have a SkoolOS account?(y/N)")
- if(b):
- user = login()
- if(user != None):
- setup(user)
- open(".login.txt", "w").write(str(user))
- else:
- user = signup()
- if(user != None):
- open(".login.txt").write(str(user))
-
diff --git a/CLI/index.html b/CLI/index.html
deleted file mode 100644
index a21b847..0000000
--- a/CLI/index.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- Sign in with Ion
-
-
- Sign in with
-
-
\ No newline at end of file
diff --git a/CLI/oauth/template.html b/CLI/oauth/template.html
deleted file mode 100644
index 6452ea8..0000000
--- a/CLI/oauth/template.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- Sign into Ion
-
-
-
-
-
-
-