mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-06-06 18:16:04 -04:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
commit
f825713f2f
|
@ -9,6 +9,7 @@ import time
|
||||||
import pyperclip
|
import pyperclip
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
# git clone student directory ==> <student-id>/classes/assignments
|
# git clone student directory ==> <student-id>/classes/assignments
|
||||||
|
|
||||||
# get teacher info from api
|
# get teacher info from api
|
||||||
|
@ -28,30 +29,35 @@ def getStudent(ion_user):
|
||||||
return None
|
return None
|
||||||
print(r.status_code)
|
print(r.status_code)
|
||||||
|
|
||||||
|
#makes a GET request to given url, returns dict
|
||||||
def getDB(url):
|
def getDB(url):
|
||||||
r = requests.get(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.get(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("GET:" + str(r.status_code))
|
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):
|
||||||
|
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):
|
def postDB(data, url):
|
||||||
r = requests.post(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.post(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("POST:" + str(r.status_code))
|
print("POST:" + str(r.status_code))
|
||||||
return (r.json())
|
return (r.json())
|
||||||
|
|
||||||
|
#makes a PUT (overwrites instance) request to given url, returns dict
|
||||||
def putDB(data, url):
|
def putDB(data, url):
|
||||||
r = requests.put(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.put(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("PUT:" + str(r.status_code))
|
print("PUT:" + str(r.status_code))
|
||||||
return (r.json())
|
return (r.json())
|
||||||
|
|
||||||
def patchDB(data, url):
|
#makes a DELETE (delete instance) request to given url, returns dict
|
||||||
r = requests.patch(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
|
||||||
print("PATH:" + str(r.status_code))
|
|
||||||
return(r.json())
|
|
||||||
|
|
||||||
def delDB(url):
|
def delDB(url):
|
||||||
r = requests.delete(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.delete(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("DELETE:" + str(r.status_code))
|
print("DELETE:" + str(r.status_code))
|
||||||
return None
|
|
||||||
|
|
||||||
def command(command):
|
def command(command):
|
||||||
ar = []
|
ar = []
|
||||||
|
@ -64,6 +70,7 @@ def command(command):
|
||||||
print(output.decode('utf-8'))
|
print(output.decode('utf-8'))
|
||||||
return output.decode('utf-8')
|
return output.decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
|
|
||||||
# public methods: deleteClass, makeClass, update
|
# public methods: deleteClass, makeClass, update
|
||||||
|
@ -223,17 +230,18 @@ class Student:
|
||||||
os.system(url)
|
os.system(url)
|
||||||
|
|
||||||
cdir = os.getcwd()
|
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
|
# push to git, start at master
|
||||||
os.chdir(self.username)
|
#os.chdir(self.username)
|
||||||
command("git checkout master")
|
command("git checkout master")
|
||||||
command("git branch " + data['name'])
|
command("git branch " + data['name'])
|
||||||
command("git commit -m initial")
|
command("git commit -m initial")
|
||||||
|
@ -331,7 +339,8 @@ class Student:
|
||||||
if c['name'] == courses:
|
if c['name'] == courses:
|
||||||
command("git checkout " + courses)
|
command("git checkout " + courses)
|
||||||
print(os.listdir())
|
print(os.listdir())
|
||||||
break
|
os.chdir(cdir)
|
||||||
|
return
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
print("Class not found")
|
print("Class not found")
|
||||||
return
|
return
|
||||||
|
@ -369,6 +378,7 @@ class Student:
|
||||||
command('git checkout master')
|
command('git checkout master')
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
|
|
||||||
|
|
||||||
# data = getStudent("2022rkhondak")
|
# data = getStudent("2022rkhondak")
|
||||||
# s = Student(data)
|
# s = Student(data)
|
||||||
# s.viewClass("APLit_eharris1")
|
# s.viewClass("APLit_eharris1")
|
||||||
|
@ -379,6 +389,7 @@ class Student:
|
||||||
def main():
|
def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# stuff only to run when not called via 'import' here
|
# stuff only to run when not called via 'import' here
|
||||||
main()
|
main()
|
||||||
|
|
238
CLI/teacher.py
238
CLI/teacher.py
|
@ -9,6 +9,8 @@ import time
|
||||||
import pyperclip
|
import pyperclip
|
||||||
from distutils.dir_util import copy_tree
|
from distutils.dir_util import copy_tree
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
# from django.conf import settings
|
# from django.conf import settings
|
||||||
# import django
|
# import django
|
||||||
|
|
||||||
|
@ -25,46 +27,88 @@ from datetime import datetime
|
||||||
|
|
||||||
# get teacher info from api
|
# get teacher info from api
|
||||||
def getTeacher(ion_user):
|
def getTeacher(ion_user):
|
||||||
|
"""
|
||||||
|
Gets information about a teacher from the api
|
||||||
|
:param ion_user: a teacher
|
||||||
|
:return: teacher information or error
|
||||||
|
"""
|
||||||
URL = "http://127.0.0.1:8000/api/teachers/" + ion_user + "/"
|
URL = "http://127.0.0.1:8000/api/teachers/" + ion_user + "/"
|
||||||
r = requests.get(url=URL, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.get(url=URL, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
if(r.status_code == 200):
|
if r.status_code == 200:
|
||||||
data = r.json()
|
data = r.json()
|
||||||
return data
|
return data
|
||||||
elif(r.status_code == 404):
|
elif r.status_code == 404:
|
||||||
return None
|
return None
|
||||||
print("Make new account!")
|
print("Make new account!")
|
||||||
elif(r.status_code == 403):
|
elif r.status_code == 403:
|
||||||
return None
|
return None
|
||||||
print("Invalid username/password")
|
print("Invalid username/password")
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
print(r.status_code)
|
print(r.status_code)
|
||||||
|
|
||||||
|
#makes a GET request to given url, returns dict
|
||||||
def getDB(url):
|
def getDB(url):
|
||||||
|
"""
|
||||||
|
Sends a GET request to the URL
|
||||||
|
:param url: URL for request
|
||||||
|
"""
|
||||||
r = requests.get(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.get(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("GET:" + str(r.status_code))
|
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):
|
def patchDB(data, url):
|
||||||
|
"""
|
||||||
|
Sends a PATCH request to the URL
|
||||||
|
:param data:
|
||||||
|
:param url: URL for request
|
||||||
|
"""
|
||||||
r = requests.patch(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.patch(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("PATCH:" + str(r.status_code))
|
print("PATCH:" + str(r.status_code))
|
||||||
return(r.json())
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
#makes a POST (makes new instance) request to given url, returns dict
|
||||||
def postDB(data, url):
|
def postDB(data, url):
|
||||||
|
"""
|
||||||
|
Sends a POST request to the URL
|
||||||
|
:param data:
|
||||||
|
:param url: URL for request
|
||||||
|
"""
|
||||||
r = requests.post(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.post(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("POST:" + str(r.status_code))
|
print("POST:" + str(r.status_code))
|
||||||
return(r.json())
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
#makes a PUT (overwrites instance) request to given url, returns dict
|
||||||
def putDB(data, url):
|
def putDB(data, url):
|
||||||
|
"""
|
||||||
|
Sends a PUT request to the URL
|
||||||
|
:param data:
|
||||||
|
:param url: URL for request
|
||||||
|
"""
|
||||||
r = requests.put(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.put(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("PUT:" + str(r.status_code))
|
print("PUT:" + str(r.status_code))
|
||||||
return(r.json())
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
#makes a DELETE (delete instance) request to given url, returns dict
|
||||||
def delDB(url):
|
def delDB(url):
|
||||||
|
"""
|
||||||
|
Sends a DELETE request to the URL
|
||||||
|
:param url: URL for request
|
||||||
|
"""
|
||||||
r = requests.delete(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.delete(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
print("DELETE:" + str(r.status_code))
|
print("DELETE:" + str(r.status_code))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def command(command):
|
def command(command):
|
||||||
|
"""
|
||||||
|
Runs a shell command
|
||||||
|
:param command: shell command
|
||||||
|
"""
|
||||||
ar = []
|
ar = []
|
||||||
command = command.split(" ")
|
command = command.split(" ")
|
||||||
for c in command:
|
for c in command:
|
||||||
|
@ -74,6 +118,7 @@ def command(command):
|
||||||
output = process.communicate()[1]
|
output = process.communicate()[1]
|
||||||
print(output.decode('utf-8'))
|
print(output.decode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
|
|
||||||
# public methods: deleteClass, makeClass, update
|
# public methods: deleteClass, makeClass, update
|
||||||
|
@ -81,6 +126,10 @@ class Teacher:
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
# teacher info already stored in API
|
# teacher info already stored in API
|
||||||
# intitialze fields after GET request
|
# intitialze fields after GET request
|
||||||
|
"""
|
||||||
|
Initializes a Teacher with the data from the api
|
||||||
|
:param data: api data
|
||||||
|
"""
|
||||||
self.git = data['git']
|
self.git = data['git']
|
||||||
self.username = data['ion_user']
|
self.username = data['ion_user']
|
||||||
self.url = "http://127.0.0.1:8000/api/teachers/" + self.username + "/"
|
self.url = "http://127.0.0.1:8000/api/teachers/" + self.username + "/"
|
||||||
|
@ -89,27 +138,30 @@ class Teacher:
|
||||||
|
|
||||||
# array
|
# array
|
||||||
self.classes = data['classes']
|
self.classes = data['classes']
|
||||||
if(os.path.isdir(self.username + "/Students")):
|
if os.path.isdir(self.username + "/Students"):
|
||||||
print("Synced to " + self.username)
|
print("Synced to " + self.username)
|
||||||
else:
|
else:
|
||||||
os.makedirs(self.username + "/Students")
|
os.makedirs(self.username + "/Students")
|
||||||
|
|
||||||
# 2020-05-11 12:25:00
|
# 2020-05-11 12:25:00
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# class name format: <course-name>_<ion_user>
|
# class name format: <course-name>_<ion_user>
|
||||||
|
|
||||||
# turn existing directory into class, Pre-condition: directory exists
|
# turn existing directory into class, Pre-condition: directory exists
|
||||||
# relative path to class: 2022rkhondak/Math4
|
# relative path to class: 2022rkhondak/Math4
|
||||||
def checkClass(self, path):
|
def checkClass(self, path):
|
||||||
|
"""
|
||||||
|
Checks if a directory is valid for creating a class
|
||||||
|
:param path: path to the new class directory
|
||||||
|
"""
|
||||||
cname = path.split("/")
|
cname = path.split("/")
|
||||||
cname = cname[len(cname) - 1]
|
cname = cname[len(cname) - 1]
|
||||||
if(os.path.isfile(path)):
|
if os.path.isfile(path):
|
||||||
print(path + " must be in a Class directory.")
|
print(path + " must be in a Class directory.")
|
||||||
return False
|
return False
|
||||||
if(("_" + self.username) in cname) == False:
|
if not (("_" + self.username) in cname):
|
||||||
print("Incorrect class name: Must be in the format: " + self.username+ "/<course-name>_<ion_user>, not " + path)
|
print(
|
||||||
|
"Incorrect class name: Must be in the format: " + self.username + "/<course-name>_<ion_user>, not " + path)
|
||||||
return False
|
return False
|
||||||
dirs = os.listdir(path)
|
dirs = os.listdir(path)
|
||||||
# checks if there is a file (not within Assignments) in class, need at least 1
|
# checks if there is a file (not within Assignments) in class, need at least 1
|
||||||
|
@ -119,44 +171,52 @@ class Teacher:
|
||||||
as_bad = ""
|
as_bad = ""
|
||||||
|
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
if(os.path.isfile(d)):
|
if os.path.isfile(d):
|
||||||
deffile = True
|
deffile = True
|
||||||
else:
|
else:
|
||||||
# checks if there is a file in an Assignment, need at least 1
|
# checks if there is a file in an Assignment, need at least 1
|
||||||
as_file = False
|
as_file = False
|
||||||
asdir = os.listdir(path + "/" + d)
|
asdir = os.listdir(path + "/" + d)
|
||||||
for a in asdir:
|
for a in asdir:
|
||||||
if(os.path.isfile(path + "/" + d + "/" +a)):
|
if os.path.isfile(path + "/" + d + "/" + a):
|
||||||
as_file = True
|
as_file = True
|
||||||
if(as_file==False):
|
if not as_file:
|
||||||
as_bad = d
|
as_bad = d
|
||||||
break
|
break
|
||||||
if(as_file==False):
|
if not as_file:
|
||||||
print("Assignment '" + as_bad + "' does not have a default file!")
|
print("Assignment '" + as_bad + "' does not have a default file!")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if(deffile==False):
|
if not deffile:
|
||||||
print("Need a default file in the " + path + " Directory!")
|
print("Need a default file in the " + path + " Directory!")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def checkInDB(self, path):
|
def checkInDB(self, path):
|
||||||
|
"""
|
||||||
|
Checks if "path" is in the database
|
||||||
|
:param path: path to directory
|
||||||
|
"""
|
||||||
n = path.split("/")
|
n = path.split("/")
|
||||||
n = n[len(n) - 1]
|
n = n[len(n) - 1]
|
||||||
for c in self.classes:
|
for c in self.classes:
|
||||||
if(n == c['name']):
|
if n == c['name']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# make class from existing directory, add to git and api
|
# make class from existing directory, add to git and api
|
||||||
def addClass(self, path):
|
def addClass(self, path):
|
||||||
|
"""
|
||||||
|
Creates a class from an existing directory, adding it to the proper git repository and the api
|
||||||
|
:param path:
|
||||||
|
"""
|
||||||
cname = path.split("/")
|
cname = path.split("/")
|
||||||
cname = cname[len(cname) - 1]
|
cname = cname[len(cname) - 1]
|
||||||
for c in self.classes:
|
for c in self.classes:
|
||||||
if c == cname:
|
if c == cname:
|
||||||
print(cname + " already exists.")
|
print(cname + " already exists.")
|
||||||
return
|
return
|
||||||
if (self.checkClass(path)):
|
if self.checkClass(path):
|
||||||
cpath = self.username + "/" + cname
|
cpath = self.username + "/" + cname
|
||||||
data = {
|
data = {
|
||||||
"name": cname,
|
"name": cname,
|
||||||
|
@ -167,19 +227,24 @@ class Teacher:
|
||||||
}
|
}
|
||||||
# make class instance in db
|
# make class instance in db
|
||||||
postDB(data, 'http://127.0.0.1:8000/api/classes/')
|
postDB(data, 'http://127.0.0.1:8000/api/classes/')
|
||||||
|
time.sleep(1)
|
||||||
self.classes.append(cname)
|
self.classes.append(cname)
|
||||||
# add to instance
|
# add to instance
|
||||||
#upate self.classes
|
# update self.classes
|
||||||
data = {
|
data = {
|
||||||
'classes': self.classes
|
'classes': self.classes
|
||||||
}
|
}
|
||||||
print(self.username)
|
print(self.classes)
|
||||||
print(patchDB(data, 'http://127.0.0.1:8000/api/teachers/' + self.username + "/"))
|
print(patchDB(data, 'http://127.0.0.1:8000/api/teachers/' + self.username + "/"))
|
||||||
|
|
||||||
# make a new class from scratch
|
# make a new class from scratch
|
||||||
# subject: string, assignments: list
|
# subject: string, assignments: list
|
||||||
# class name must be: <subject>_<ion_user>
|
# class name must be: <subject>_<ion_user>
|
||||||
def makeClass(self, cname):
|
def makeClass(self, cname):
|
||||||
|
"""
|
||||||
|
Makes a class with its own new directory
|
||||||
|
:param cname: name of class
|
||||||
|
"""
|
||||||
# check if class exists
|
# check if class exists
|
||||||
path = self.username + "/" + cname
|
path = self.username + "/" + cname
|
||||||
isclass = False
|
isclass = False
|
||||||
|
@ -188,13 +253,13 @@ class Teacher:
|
||||||
if c['name'] == cname:
|
if c['name'] == cname:
|
||||||
isclass = True
|
isclass = True
|
||||||
break
|
break
|
||||||
if(os.path.exists(path) or isclass):
|
if os.path.exists(path) or isclass:
|
||||||
print("Class already exists: " + cname)
|
print("Class already exists: " + cname)
|
||||||
if(isclass):
|
if isclass:
|
||||||
print("Class already exists in Database")
|
print("Class already exists in Database")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if((("_" + self.username) in cname) == False):
|
if not (("_" + self.username) in cname):
|
||||||
print("class name must be: " + cname + "_" + self.username)
|
print("class name must be: " + cname + "_" + self.username)
|
||||||
return
|
return
|
||||||
cdir = os.getcwd()
|
cdir = os.getcwd()
|
||||||
|
@ -213,10 +278,14 @@ class Teacher:
|
||||||
self.addClass(path)
|
self.addClass(path)
|
||||||
|
|
||||||
def deleteClass(self, path):
|
def deleteClass(self, path):
|
||||||
if(os.path.exists(path) == False):
|
"""
|
||||||
|
Deletes an existing class
|
||||||
|
:param path: class directory path
|
||||||
|
"""
|
||||||
|
if not os.path.exists(path):
|
||||||
print(path + " does not exist locally.")
|
print(path + " does not exist locally.")
|
||||||
resp = input("Do you want to delete " + path + " from the SkoolOS system? (y/N) ")
|
resp = input("Do you want to delete " + path + " from the SkoolOS system? (y/N) ")
|
||||||
if(resp != 'y'):
|
if resp != 'y':
|
||||||
return
|
return
|
||||||
|
|
||||||
cname = path.split("/")
|
cname = path.split("/")
|
||||||
|
@ -225,7 +294,7 @@ class Teacher:
|
||||||
print("DELETE: " + self.classes[i]['name'])
|
print("DELETE: " + self.classes[i]['name'])
|
||||||
for i in range(len(self.classes)):
|
for i in range(len(self.classes)):
|
||||||
c = self.classes[i]
|
c = self.classes[i]
|
||||||
if(c == cname):
|
if c == cname:
|
||||||
del self.classes[i]
|
del self.classes[i]
|
||||||
# data={
|
# data={
|
||||||
# 'classes':self.classes,
|
# 'classes':self.classes,
|
||||||
|
@ -242,28 +311,39 @@ class Teacher:
|
||||||
|
|
||||||
# remove from student directories
|
# remove from student directories
|
||||||
|
|
||||||
|
|
||||||
def isStudent(self, student):
|
def isStudent(self, student):
|
||||||
r = requests.get(url = "http://127.0.0.1:8000/api/students/" + student + "/", auth=('raffukhondaker','hackgroup1'))
|
"""
|
||||||
if(r.status_code != 200):
|
Checks if the student exists
|
||||||
|
:param student: a student
|
||||||
|
:return: True if student exists, False otherwise
|
||||||
|
"""
|
||||||
|
r = requests.get(url="http://127.0.0.1:8000/api/students/" + student + "/",
|
||||||
|
auth=('raffukhondaker', 'hackgroup1'))
|
||||||
|
if r.status_code != 200:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def reqStudent(self, sname, cname):
|
def reqStudent(self, sname, cname):
|
||||||
if(self.isStudent(sname) == False):
|
"""
|
||||||
|
Request student informatiion from the api
|
||||||
|
:param sname: student's name
|
||||||
|
:param cname: class name
|
||||||
|
:return: True if successful
|
||||||
|
"""
|
||||||
|
if not self.isStudent(sname):
|
||||||
print(sname + " does not exist.")
|
print(sname + " does not exist.")
|
||||||
return False
|
return False
|
||||||
course = getDB("http://127.0.0.1:8000/api/classes/" + cname)
|
course = getDB("http://127.0.0.1:8000/api/classes/" + cname)
|
||||||
if(sname in str(course['unconfirmed'])):
|
if sname in str(course['unconfirmed']):
|
||||||
print(sname + " already requested.")
|
print(sname + " already requested.")
|
||||||
return True
|
return True
|
||||||
if(sname in str(course['confirmed'])):
|
if sname in str(course['confirmed']):
|
||||||
print (sname + " alredy enrolled.")
|
print(sname + " already enrolled.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
|
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
|
||||||
try:
|
try:
|
||||||
if(student['added_to']==""):
|
if student['added_to'] == "":
|
||||||
student['added_to'] = course['name']
|
student['added_to'] = course['name']
|
||||||
else:
|
else:
|
||||||
student['added_to'] = student['added_to'] + "," + course['name']
|
student['added_to'] = student['added_to'] + "," + course['name']
|
||||||
|
@ -275,8 +355,8 @@ class Teacher:
|
||||||
'added_to': student['added_to'],
|
'added_to': student['added_to'],
|
||||||
}
|
}
|
||||||
student = patchDB(data, "http://localhost:8000/api/students/" + student['ion_user'] + "/")
|
student = patchDB(data, "http://localhost:8000/api/students/" + student['ion_user'] + "/")
|
||||||
student = getDB( "http://localhost:8000/api/students/" + (sname)+ "/")
|
student = getDB("http://localhost:8000/api/students/" + sname + "/")
|
||||||
if(course['unconfirmed']==[]):
|
if not course['unconfirmed']:
|
||||||
course['unconfirmed'] = student['ion_user']
|
course['unconfirmed'] = student['ion_user']
|
||||||
else:
|
else:
|
||||||
course['unconfirmed'] = course['unconfirmed'].append(student['ion_user'])
|
course['unconfirmed'] = course['unconfirmed'].append(student['ion_user'])
|
||||||
|
@ -290,20 +370,27 @@ class Teacher:
|
||||||
# Student should have confirmed on their endd, but class had not been updated yet
|
# Student should have confirmed on their endd, but class had not been updated yet
|
||||||
# git clone confirmed student repo, copy files into repo and push branch
|
# git clone confirmed student repo, copy files into repo and push branch
|
||||||
def addStudent(self, sname, cname):
|
def addStudent(self, sname, cname):
|
||||||
if(self.isStudent(sname) == False):
|
"""
|
||||||
|
Adds a student to a class
|
||||||
|
:param sname: student name
|
||||||
|
:param cname: class name
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if not self.isStudent(sname):
|
||||||
print(sname + " does not exist.")
|
print(sname + " does not exist.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
|
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
|
||||||
course = getDB("http://127.0.0.1:8000/api/classes/" + cname)
|
course = getDB("http://127.0.0.1:8000/api/classes/" + cname)
|
||||||
|
|
||||||
if(os.path.exists(self.username + "/Students/" + cname + "/" + student['ion_user']) or (student['ion_user'] in course['confirmed']) == True):
|
if (os.path.exists(self.username + "/Students/" + cname + "/" + student['ion_user']) or (
|
||||||
|
student['ion_user'] in course['confirmed']) == True):
|
||||||
print(student['ion_user'] + " already added to class")
|
print(student['ion_user'] + " already added to class")
|
||||||
return True
|
return True
|
||||||
if((cname in student['added_to']) == True or (cname in student['classes']) == False):
|
if (cname in student['added_to']) or not (cname in student['classes']):
|
||||||
print(student['ion_user'] + " has not confirmed class yet")
|
print(student['ion_user'] + " has not confirmed class yet")
|
||||||
return False
|
return False
|
||||||
if((student['ion_user'] in course['unconfirmed']) == False):
|
if not (student['ion_user'] in course['unconfirmed']):
|
||||||
print(course['unconfirmed'])
|
print(course['unconfirmed'])
|
||||||
print(student['ion_user'] + " has not been requested to join yet.")
|
print(student['ion_user'] + " has not been requested to join yet.")
|
||||||
return False
|
return False
|
||||||
|
@ -313,9 +400,9 @@ class Teacher:
|
||||||
cpath = self.username + "/" + cname
|
cpath = self.username + "/" + cname
|
||||||
path = self.username + "/Students/" + cname
|
path = self.username + "/Students/" + cname
|
||||||
spath = self.username + "/Students/" + cname + "/" + student['ion_user']
|
spath = self.username + "/Students/" + cname + "/" + student['ion_user']
|
||||||
if(os.path.isdir(path) == False):
|
if not os.path.isdir(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if(os.path.isdir(spath) == False):
|
if not os.path.isdir(spath):
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
command("git clone " + student['repo'])
|
command("git clone " + student['repo'])
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
|
@ -332,13 +419,13 @@ class Teacher:
|
||||||
command('git push -u origin ' + cname)
|
command('git push -u origin ' + cname)
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
|
|
||||||
if(course['confirmed']==[]):
|
if not course['confirmed']:
|
||||||
course['confirmed'] = student['ion_user']
|
course['confirmed'] = student['ion_user']
|
||||||
else:
|
else:
|
||||||
course['confirmed'].append(student['ion_user'])
|
course['confirmed'].append(student['ion_user'])
|
||||||
|
|
||||||
# only 1 pereson on confirmeed
|
# only 1 pereson on confirmeed
|
||||||
if(len(course['unconfirmed']) == 1):
|
if len(course['unconfirmed']) == 1:
|
||||||
course['unconfirmed'] = []
|
course['unconfirmed'] = []
|
||||||
# mutiple
|
# mutiple
|
||||||
else:
|
else:
|
||||||
|
@ -353,16 +440,29 @@ class Teacher:
|
||||||
|
|
||||||
# goes through list of studennts, tries to add, then request, return unconfirmed students
|
# goes through list of studennts, tries to add, then request, return unconfirmed students
|
||||||
def reqAddStudentList(self, array, cname):
|
def reqAddStudentList(self, array, cname):
|
||||||
|
"""
|
||||||
|
Runs addStudent() on all students in array
|
||||||
|
:param array: an array of students
|
||||||
|
:param cname: class name
|
||||||
|
:return: students that have not confirmed the request
|
||||||
|
"""
|
||||||
unconf = []
|
unconf = []
|
||||||
for i in range(len(array)):
|
for i in range(len(array)):
|
||||||
a = array[i]
|
a = array[i]
|
||||||
if(self.addStudent(a, cname) == False):
|
if not self.addStudent(a, cname):
|
||||||
self.reqStudent(a, cname)
|
self.reqStudent(a, cname)
|
||||||
unconf.append(a)
|
unconf.append(a)
|
||||||
return unconf
|
return unconf
|
||||||
|
|
||||||
# add local path to student directory, make new instance in api
|
# add local path to student directory, make new instance in api
|
||||||
def addAssignment(self, path, course, due):
|
def addAssignment(self, path, course, due):
|
||||||
|
"""
|
||||||
|
Creates an assignment for "course" that is due on "due"
|
||||||
|
:param path: directory of assignment
|
||||||
|
:param course: course name
|
||||||
|
:param due: due date
|
||||||
|
:return: False if unsuccessful
|
||||||
|
"""
|
||||||
parts = path.split("/")
|
parts = path.split("/")
|
||||||
aname = parts[len(parts) - 1]
|
aname = parts[len(parts) - 1]
|
||||||
oname = aname + "_" + course
|
oname = aname + "_" + course
|
||||||
|
@ -370,7 +470,7 @@ class Teacher:
|
||||||
if (os.path.isdir(path) == 0 or len(parts) < 3) or aname in str(self.classes):
|
if (os.path.isdir(path) == 0 or len(parts) < 3) or aname in str(self.classes):
|
||||||
print("Not valid path.")
|
print("Not valid path.")
|
||||||
return False
|
return False
|
||||||
if((parts[1] in str(self.classes)) == False):
|
if not (parts[1] in str(self.classes)):
|
||||||
print("Not in valid class directory")
|
print("Not in valid class directory")
|
||||||
return False
|
return False
|
||||||
# parts of assignment name (Essay1, APLit)
|
# parts of assignment name (Essay1, APLit)
|
||||||
|
@ -395,14 +495,14 @@ class Teacher:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
course = getDB("http://127.0.0.1:8000/api/classes/" + course)
|
course = getDB("http://127.0.0.1:8000/api/classes/" + course)
|
||||||
if(aname in str(course['assignments'])):
|
if aname in str(course['assignments']):
|
||||||
print("Assignment name already taken.")
|
print("Assignment name already taken.")
|
||||||
return False
|
return False
|
||||||
print(course['assignments'])
|
print(course['assignments'])
|
||||||
print(aname)
|
print(aname)
|
||||||
#################### FINISH VERIFYING
|
#################### FINISH VERIFYING
|
||||||
|
|
||||||
if(os.path.exists(os.getcwd() + "/" + self.username + "/Students/" + course['name']) == False):
|
if not os.path.exists(os.getcwd() + "/" + self.username + "/Students/" + course['name']):
|
||||||
print("No students in this class yet")
|
print("No students in this class yet")
|
||||||
return True
|
return True
|
||||||
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
|
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
|
||||||
|
@ -410,7 +510,7 @@ class Teacher:
|
||||||
for st in slist:
|
for st in slist:
|
||||||
if st in str(course['confirmed']):
|
if st in str(course['confirmed']):
|
||||||
spath = os.path.join(os.getcwd() + "/" + self.username + "/Students/" + course['name'], st)
|
spath = os.path.join(os.getcwd() + "/" + self.username + "/Students/" + course['name'], st)
|
||||||
if(os.path.exists(spath + "/" + aname) == False):
|
if not os.path.exists(spath + "/" + aname):
|
||||||
os.mkdir(spath + "/" + aname)
|
os.mkdir(spath + "/" + aname)
|
||||||
print(st)
|
print(st)
|
||||||
print(copy_tree(path, spath + "/" + aname))
|
print(copy_tree(path, spath + "/" + aname))
|
||||||
|
@ -426,7 +526,7 @@ class Teacher:
|
||||||
|
|
||||||
# check if assignment already exists
|
# check if assignment already exists
|
||||||
r = requests.get(url='http://127.0.0.1:8000/api/assignments/' + aname, auth=('raffukhondaker', 'hackgroup1'))
|
r = requests.get(url='http://127.0.0.1:8000/api/assignments/' + aname, auth=('raffukhondaker', 'hackgroup1'))
|
||||||
if(r.status_code != 200):
|
if r.status_code != 200:
|
||||||
ass = {
|
ass = {
|
||||||
'name': oname,
|
'name': oname,
|
||||||
'path': path,
|
'path': path,
|
||||||
|
@ -452,11 +552,11 @@ class Teacher:
|
||||||
parts = path.split("/")
|
parts = path.split("/")
|
||||||
aname = parts[len(parts) - 1]
|
aname = parts[len(parts) - 1]
|
||||||
oname = aname + "_" + course
|
oname = aname + "_" + course
|
||||||
if(os.path.isdir(path) == False):
|
if not os.path.isdir(path):
|
||||||
print(path + " is not an assignment.")
|
print(path + " is not an assignment.")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
if(due != None or due == ""):
|
if due != None or due == "":
|
||||||
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
||||||
d = {
|
d = {
|
||||||
'due_date': due,
|
'due_date': due,
|
||||||
|
@ -484,7 +584,7 @@ class Teacher:
|
||||||
|
|
||||||
# pull student's work, no modifications
|
# pull student's work, no modifications
|
||||||
def getStudents(self, course):
|
def getStudents(self, course):
|
||||||
if((course in self.sclass) == False):
|
if not (course in self.sclass):
|
||||||
print(course + " not a class.")
|
print(course + " not a class.")
|
||||||
return
|
return
|
||||||
path = self.username + "/Students/" + course
|
path = self.username + "/Students/" + course
|
||||||
|
@ -499,7 +599,7 @@ class Teacher:
|
||||||
def getCommits(self, student, course, commits):
|
def getCommits(self, student, course, commits):
|
||||||
course = getDB("http://127.0.0.1:8000/api/classes/" + course)
|
course = getDB("http://127.0.0.1:8000/api/classes/" + course)
|
||||||
try:
|
try:
|
||||||
if((student in course['confirmed']) == False):
|
if not (student in course['confirmed']):
|
||||||
print("Student not in class")
|
print("Student not in class")
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
|
@ -508,19 +608,20 @@ class Teacher:
|
||||||
|
|
||||||
cdir = os.getcwd()
|
cdir = os.getcwd()
|
||||||
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
|
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
|
||||||
process = subprocess.Popen(['git', 'log', '-' + str(commits), course['name']], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
process = subprocess.Popen(['git', 'log', '-' + str(commits), course['name']], stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
p = process.poll()
|
p = process.poll()
|
||||||
output = process.communicate()[0].decode('utf-8').split('\n\n')
|
output = process.communicate()[0].decode('utf-8').split('\n\n')
|
||||||
months = ['Jan', 'Feb', 'Mar', "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
|
months = ['Jan', 'Feb', 'Mar', "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
|
||||||
fout = []
|
fout = []
|
||||||
for i in range(len(output)):
|
for i in range(len(output)):
|
||||||
if("Date" in output[i]):
|
if "Date" in output[i]:
|
||||||
c = output[i].split("\n")
|
c = output[i].split("\n")
|
||||||
for k in range(len(c)):
|
for k in range(len(c)):
|
||||||
temp = []
|
temp = []
|
||||||
if('commit' in c[k]):
|
if 'commit' in c[k]:
|
||||||
c[k] = c[k].replace('commit', '').strip()
|
c[k] = c[k].replace('commit', '').strip()
|
||||||
elif('Date:' in c[k]):
|
elif 'Date:' in c[k]:
|
||||||
c[k] = c[k].replace('Date:', '').strip()
|
c[k] = c[k].replace('Date:', '').strip()
|
||||||
date = c[2].split(" ")
|
date = c[2].split(" ")
|
||||||
times = date[3].split(":")
|
times = date[3].split(":")
|
||||||
|
@ -538,6 +639,12 @@ class Teacher:
|
||||||
return fout
|
return fout
|
||||||
|
|
||||||
def getChanges(self, student, course, commits):
|
def getChanges(self, student, course, commits):
|
||||||
|
"""
|
||||||
|
Checks for new submissions by a student
|
||||||
|
:param student: the student
|
||||||
|
:param course: the course
|
||||||
|
:param commits: commits the CLI has made for the assignment
|
||||||
|
"""
|
||||||
course = getDB("http://127.0.0.1:8000/api/classes/" + course + "/")
|
course = getDB("http://127.0.0.1:8000/api/classes/" + course + "/")
|
||||||
ar = self.getCommits(student, course['name'], commits)
|
ar = self.getCommits(student, course['name'], commits)
|
||||||
commit = ar[len(ar) - 1][0]
|
commit = ar[len(ar) - 1][0]
|
||||||
|
@ -546,7 +653,8 @@ class Teacher:
|
||||||
print("START: " + start)
|
print("START: " + start)
|
||||||
cdir = os.getcwd()
|
cdir = os.getcwd()
|
||||||
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
|
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
|
||||||
process = subprocess.Popen(['git', 'diff', commit, '--name-status'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
process = subprocess.Popen(['git', 'diff', commit, '--name-status'], stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
p = process.poll()
|
p = process.poll()
|
||||||
output = process.communicate()[0].decode('utf-8')
|
output = process.communicate()[0].decode('utf-8')
|
||||||
print(output)
|
print(output)
|
||||||
|
@ -559,6 +667,7 @@ class Teacher:
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
# check if assignment changed after due date
|
# check if assignment changed after due date
|
||||||
|
|
||||||
def afterSubmit(self, course, assignment, student):
|
def afterSubmit(self, course, assignment, student):
|
||||||
|
|
||||||
assignment = getDB("http://127.0.0.1:8000/api/assignments/" + assignment)
|
assignment = getDB("http://127.0.0.1:8000/api/assignments/" + assignment)
|
||||||
|
@ -576,11 +685,11 @@ class Teacher:
|
||||||
process = subprocess.Popen(['git', 'show', l[0]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.Popen(['git', 'show', l[0]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
p = process.poll()
|
p = process.poll()
|
||||||
output = process.communicate()[0].decode('utf-8')
|
output = process.communicate()[0].decode('utf-8')
|
||||||
if(assignment['name'] in output):
|
if assignment['name'] in output:
|
||||||
print(l[1])
|
print(l[1])
|
||||||
print(assignment['due_date'])
|
print(assignment['due_date'])
|
||||||
print("--------------")
|
print("--------------")
|
||||||
if(l[1] > assignment['due_date']):
|
if l[1] > assignment['due_date']:
|
||||||
print("LATE")
|
print("LATE")
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
return True
|
return True
|
||||||
|
@ -589,6 +698,10 @@ class Teacher:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def comment(self):
|
def comment(self):
|
||||||
|
"""
|
||||||
|
The ultimate form of laughter
|
||||||
|
:return: pure joy
|
||||||
|
"""
|
||||||
print("heheheh")
|
print("heheheh")
|
||||||
|
|
||||||
|
|
||||||
|
@ -614,4 +727,3 @@ TO-DO
|
||||||
- check differences between commits
|
- check differences between commits
|
||||||
- check if student changes file after submissionn deadline
|
- check if student changes file after submissionn deadline
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
# SkoolOS
|
# SkoolOS
|
||||||
Revolutionizing the interface between students and teachers through one easy service
|
Revolutionizing the interface between students and teachers through one easy service
|
||||||
[](https://skoolos.readthedocs.io/en/latest/?badge=latest)
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
0
eharris1/Art12_eharris1/Painting1/rubric.txt
Normal file
0
eharris1/Art12_eharris1/Painting1/rubric.txt
Normal file
0
eharris1/Art12_eharris1/README.md
Normal file
0
eharris1/Art12_eharris1/README.md
Normal file
0
eharris1/English11_eharris1/README.md
Normal file
0
eharris1/English11_eharris1/README.md
Normal file
|
@ -47,12 +47,29 @@ def main():
|
||||||
#webbrowser.open("http://127.0.0.1:8000/login", new=2)
|
#webbrowser.open("http://127.0.0.1:8000/login", new=2)
|
||||||
authenticate()
|
authenticate()
|
||||||
else:
|
else:
|
||||||
try:
|
profiles = os.listdir()
|
||||||
f = open('.tprofile','r')
|
users = []
|
||||||
except:
|
info = []
|
||||||
f = open('.sprofile','r')
|
count = 1
|
||||||
data = json.loads(f.read())
|
for i in range(len(profiles)):
|
||||||
|
p = profiles[i]
|
||||||
|
if('profile' in p):
|
||||||
|
f = open(p,'r')
|
||||||
|
d = json.loads(f.read())
|
||||||
f.close()
|
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']
|
PWD = data['password']
|
||||||
USER = data['username']
|
USER = data['username']
|
||||||
print(data['username'])
|
print(data['username'])
|
||||||
|
@ -61,17 +78,24 @@ def main():
|
||||||
else:
|
else:
|
||||||
teacherCLI(USER, PWD)
|
teacherCLI(USER, PWD)
|
||||||
|
|
||||||
|
################################################ STUDENT METHODS
|
||||||
|
|
||||||
# while True:
|
|
||||||
# pass
|
|
||||||
def studentCLI(user, password):
|
def studentCLI(user, password):
|
||||||
from CLI import student
|
from CLI import student
|
||||||
data = getUser(user, password, 'student')
|
data = getUser(user, password, 'student')
|
||||||
student = student.Student(data)
|
student = student.Student(data)
|
||||||
|
student.update()
|
||||||
|
EXIT = False
|
||||||
|
while(not EXIT):
|
||||||
|
course = chooseClassStudent(student)
|
||||||
|
EXIT = classOptionsStudent(student, course)
|
||||||
|
|
||||||
|
#return class
|
||||||
|
def chooseClassStudent(student):
|
||||||
carray = student.sclass.split(",")
|
carray = student.sclass.split(",")
|
||||||
if(len(carray) == 1 and carray[0] == ""):
|
if(len(carray) == 1 and carray[0] == ""):
|
||||||
|
carray.remove("")
|
||||||
print("No classes")
|
print("No classes")
|
||||||
return
|
|
||||||
|
|
||||||
carray.append("Exit SkoolOS")
|
carray.append("Exit SkoolOS")
|
||||||
courses = [
|
courses = [
|
||||||
|
@ -84,11 +108,52 @@ def studentCLI(user, password):
|
||||||
]
|
]
|
||||||
course = prompt(courses)['course']
|
course = prompt(courses)['course']
|
||||||
print(course)
|
print(course)
|
||||||
if course == "Exit SkoolOS":
|
return course
|
||||||
student.exitCLI()
|
|
||||||
else:
|
def classOptionsStudent(student, course):
|
||||||
student.viewClass(course)
|
student.viewClass(course)
|
||||||
student.getAssignments(course, 100)
|
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()
|
||||||
|
#dont exit cli
|
||||||
|
return False
|
||||||
|
if(option == "Exit SkoolOS"):
|
||||||
|
student.exitCLI()
|
||||||
|
#exit cli
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
################################################ 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):
|
def teacherCLI(user, password):
|
||||||
from CLI import teacher
|
from CLI import teacher
|
||||||
|
@ -100,9 +165,11 @@ def teacherCLI(user, password):
|
||||||
# 3. Get progress logs on a student
|
# 3. Get progress logs on a student
|
||||||
# 2. make an assignment for a class
|
# 2. make an assignment for a class
|
||||||
# 3. view student submissions for an assignment
|
# 3. view student submissions for an assignment
|
||||||
carray = teacher.classes
|
carray = []
|
||||||
carray.append("Exit SkoolOS")
|
for c in teacher.classes:
|
||||||
|
carray.append(c)
|
||||||
carray.append("Make New Class")
|
carray.append("Make New Class")
|
||||||
|
carray.append("Exit SkoolOS")
|
||||||
courses = [
|
courses = [
|
||||||
{
|
{
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
|
@ -111,7 +178,7 @@ def teacherCLI(user, password):
|
||||||
'message': 'Select class: ',
|
'message': 'Select class: ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
course = prompt(courses)['course']
|
course = chooseGeneralTeacher(teacher)
|
||||||
if course == "Exit SkoolOS":
|
if course == "Exit SkoolOS":
|
||||||
teacher.exitCLI()
|
teacher.exitCLI()
|
||||||
if course == "Make New Class":
|
if course == "Make New Class":
|
||||||
|
@ -119,10 +186,11 @@ def teacherCLI(user, password):
|
||||||
{
|
{
|
||||||
'type': 'input',
|
'type': 'input',
|
||||||
'name': 'cname',
|
'name': 'cname',
|
||||||
'message': 'Class Name: ',
|
'message': 'Class Name (Must be: <subject>_<ion_user>): ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
cname = prompt(questions)['cname']
|
cname = prompt(questions)['cname']
|
||||||
|
print(cname)
|
||||||
teacher.makeClass(cname)
|
teacher.makeClass(cname)
|
||||||
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
|
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
|
||||||
questions = [
|
questions = [
|
||||||
|
@ -130,7 +198,7 @@ def teacherCLI(user, password):
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
'choices':soption,
|
'choices':soption,
|
||||||
'name': 'students',
|
'name': 'students',
|
||||||
'message': 'Add list of students (input path): ',
|
'message': 'Add Students): ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
choice = prompt(questions)['students'].split(")")[0]
|
choice = prompt(questions)['students'].split(")")[0]
|
||||||
|
@ -138,16 +206,23 @@ def teacherCLI(user, password):
|
||||||
s = input("Student name: ")
|
s = input("Student name: ")
|
||||||
teacher.addStudent(s, cname)
|
teacher.addStudent(s, cname)
|
||||||
if("2" == choice):
|
if("2" == choice):
|
||||||
p = input("Relativee Path: ")
|
print("File must be .txt and have 1 student username per line")
|
||||||
if(os.path.exists(p)):
|
path = input("Relative Path: ")
|
||||||
print(p + " does not exist.")
|
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:
|
else:
|
||||||
print("Class: " + course)
|
print("Class: " + course)
|
||||||
unconf = getDB("http://localhost:8000/api/classes/" + course)['unconfirmed']
|
unconf = getDB("http://localhost:8000/api/classes/" + course)['unconfirmed']
|
||||||
for s in unconf:
|
for s in unconf:
|
||||||
teacher.addStudent()
|
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 = [
|
questions = [
|
||||||
{
|
{
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
|
@ -196,7 +271,7 @@ def teacherCLI(user, password):
|
||||||
students = f.read().splitlines()
|
students = f.read().splitlines()
|
||||||
teacher.reqAddStudentList(students, course)
|
teacher.reqAddStudentList(students, course)
|
||||||
else:
|
else:
|
||||||
sys.exit()
|
sys.exit(0)
|
||||||
if(option == '2'):
|
if(option == '2'):
|
||||||
nlist = os.listdir(teacher.username + "/" + course)
|
nlist = os.listdir(teacher.username + "/" + course)
|
||||||
alist = getDB("http://localhost:8000/api/classes/" + course)['assignments']
|
alist = getDB("http://localhost:8000/api/classes/" + course)['assignments']
|
||||||
|
@ -230,9 +305,23 @@ def teacherCLI(user, password):
|
||||||
]
|
]
|
||||||
ass = prompt(questions)['assignment']
|
ass = prompt(questions)['assignment']
|
||||||
apath = teacher.username + "/" + course + "/" + ass
|
apath = teacher.username + "/" + course + "/" + ass
|
||||||
|
due = input("Enter due date (Example: 2020-08-11 16:58): ")
|
||||||
|
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)
|
teacher.addAssignment(apath, course, due)
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def getUser(ion_user, password, utype):
|
def getUser(ion_user, password, utype):
|
||||||
if('student' in utype):
|
if('student' in utype):
|
||||||
|
@ -315,9 +404,9 @@ def authenticate():
|
||||||
#Macos: chromdriver-mac
|
#Macos: chromdriver-mac
|
||||||
#Windows: chromdriver.exe
|
#Windows: chromdriver.exe
|
||||||
if('CLI' in os.getcwd()):
|
if('CLI' in os.getcwd()):
|
||||||
path = os.path.join(os.getcwd(), '../','chromedriver/chromedriver-mac')
|
path = os.path.join(os.getcwd(), '../','chromedriver-mac')
|
||||||
else:
|
else:
|
||||||
path = os.path.join(os.getcwd(), 'chromedriver/chromedriver-mac')
|
path = os.path.join(os.getcwd(), 'chromedriver-mac')
|
||||||
|
|
||||||
browser = webdriver.Chrome(path)
|
browser = webdriver.Chrome(path)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user