mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
Merge branch 'development' of https://github.com/rushilwiz/SkoolOs into development
Merged working with local .
This commit is contained in:
commit
511b249b47
1
.profile
Normal file
1
.profile
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{'absences': 2, 'address': None, 'counselor': {'first_name': 'Sean', 'full_name': 'Sean Burke', 'id': 37, 'last_name': 'Burke', 'url': 'https://ion.tjhsst.edu/api/profile/37', 'user_type': 'counselor', 'username': 'SPBurke'}, 'display_name': 'Raffu Khondaker', 'emails': [], 'first_name': 'Raffu', 'full_name': 'Raffu Khondaker', 'grade': {'name': 'sophomore', 'number': 10}, 'graduation_year': 2022, 'id': 36508, 'ion_username': '2022rkhondak', 'is_announcements_admin': False, 'is_eighth_admin': False, 'is_student': True, 'is_teacher': False, 'last_name': 'Khondaker', 'middle_name': 'Al', 'nickname': '', 'phones': [], 'picture': 'https://ion.tjhsst.edu/api/profile/36508/picture', 'sex': 'Male', 'short_name': 'Raffu', 'title': None, 'tj_email': '2022rkhondak@tjhsst.edu', 'user_type': 'student', 'websites': []}
|
0
CLI/.profile
Normal file
0
CLI/.profile
Normal file
|
@ -1,2 +0,0 @@
|
||||||
import os
|
|
||||||
os.spawnl(os.P_DETACH, 'some_long_running_command')
|
|
|
@ -14,7 +14,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="d-flex align-items-center justify-content-center" style="height: 100vh">
|
<div class="d-flex align-items-center justify-content-center" style="height: 100vh">
|
||||||
<a href="https://ion.tjhsst.edu/oauth/authorize/?response_type=code&client_id=QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=read&state=5EVwgQRAWaQngvshhCbYiTwC9Rpi7N" title="Ion" class="border border-dark p-3 btn btn-lg mx-auto" style="box-shadow: 5px 10px;">
|
<a href="https://ion.tjhsst.edu/oauth/authorize/?response_type=code&client_id=QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=read&state=81xYFv6S9CLi7laXQ64gJWskDJUMMb" title="Ion" class="border border-dark p-3 btn btn-lg mx-auto" style="box-shadow: 5px 10px;">
|
||||||
<img src="https://ion.tjhsst.edu/static/img/favicon.png">
|
<img src="https://ion.tjhsst.edu/static/img/favicon.png">
|
||||||
Sign in with Ion
|
Sign in with Ion
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
asgiref==3.2.7
|
|
||||||
certifi==2020.4.5.1
|
|
||||||
chardet==3.0.4
|
|
||||||
click==7.1.2
|
|
||||||
Django==3.0.7
|
|
||||||
django-cors-middleware==1.5.0
|
|
||||||
django-oauth-toolkit==1.3.2
|
|
||||||
djangorestframework==3.11.0
|
|
||||||
idna==2.9
|
|
||||||
oauthlib==3.1.0
|
|
||||||
prompt-toolkit==1.0.14
|
|
||||||
Pygments==2.6.1
|
|
||||||
PyInquirer==1.0.3
|
|
||||||
pytz==2020.1
|
|
||||||
regex==2020.5.14
|
|
||||||
requests==2.23.0
|
|
||||||
selenium==3.141.0
|
|
||||||
six==1.15.0
|
|
||||||
sqlparse==0.3.1
|
|
||||||
urllib3==1.25.9
|
|
||||||
wcwidth==0.2.3
|
|
46
CLI/s-git.py
46
CLI/s-git.py
|
@ -7,6 +7,7 @@ import json
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
import pyperclip
|
import pyperclip
|
||||||
|
import datetime
|
||||||
|
|
||||||
#git clone student directory ==> <student-id>/classes/assignments
|
#git clone student directory ==> <student-id>/classes/assignments
|
||||||
|
|
||||||
|
@ -147,11 +148,38 @@ class Student:
|
||||||
print(putDB(data, self.url))
|
print(putDB(data, self.url))
|
||||||
print("Synced to " + self.username)
|
print("Synced to " + self.username)
|
||||||
|
|
||||||
|
def getClasses(self):
|
||||||
|
classes = self.classes
|
||||||
|
for c in classes:
|
||||||
|
print(c['name'])
|
||||||
|
|
||||||
|
def getAssignments(self, course, span):
|
||||||
|
span = datetime.timedelta(span, 0)
|
||||||
|
classes = self.classes
|
||||||
|
for c in classes:
|
||||||
|
print(c['name'])
|
||||||
|
alist = c['assignments'].split(",")
|
||||||
|
for a in alist:
|
||||||
|
ass = getDB("http://127.0.0.1:8000/api/assignments/" + a)
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
try:
|
||||||
|
due = ass['due_date'].replace("T", " ").replace("Z", "")
|
||||||
|
due = datetime.datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
||||||
|
diff = now - due
|
||||||
|
zero = datetime.timedelta(0,0)
|
||||||
|
#check due ddate is in span range is now past date (- timdelta)
|
||||||
|
if(diff < span and diff > zero):
|
||||||
|
print((now-due))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
pass
|
||||||
|
|
||||||
#update API and Github, all assignments / classes
|
#update API and Github, all assignments / classes
|
||||||
def update(self):
|
def update(self):
|
||||||
cdir = os.getcwd()
|
cdir = os.getcwd()
|
||||||
os.chdir(self.username)
|
os.chdir(self.username)
|
||||||
|
command("git checkout master")
|
||||||
for c in self.classes:
|
for c in self.classes:
|
||||||
print("UPDATING CLASS: " + str(c['name']))
|
print("UPDATING CLASS: " + str(c['name']))
|
||||||
data = getDB("http://127.0.0.1:8000/api/classes/" + str(c['name']))
|
data = getDB("http://127.0.0.1:8000/api/classes/" + str(c['name']))
|
||||||
|
@ -167,6 +195,19 @@ class Student:
|
||||||
print("ADDING CLASS: " + str(c['name']))
|
print("ADDING CLASS: " + str(c['name']))
|
||||||
self.addClass(str(c['name']))
|
self.addClass(str(c['name']))
|
||||||
command("git checkout master")
|
command("git checkout master")
|
||||||
|
|
||||||
|
#updates 1 class, does not switch to master
|
||||||
|
def updateClass(self, course):
|
||||||
|
if((course in self.sclass) == False):
|
||||||
|
print("Class not found")
|
||||||
|
return
|
||||||
|
cdir = os.getcwd()
|
||||||
|
os.chdir(self.username)
|
||||||
|
command("git checkout " + course)
|
||||||
|
command("git add .")
|
||||||
|
command("git commit -m " + course)
|
||||||
|
command("git pull origin " + course)
|
||||||
|
command("git push -u origin " + course)
|
||||||
|
|
||||||
#class name format: <course-name>_<ion_user>
|
#class name format: <course-name>_<ion_user>
|
||||||
|
|
||||||
|
@ -347,5 +388,8 @@ class Student:
|
||||||
|
|
||||||
data = getStudent("2022rkhondak")
|
data = getStudent("2022rkhondak")
|
||||||
s = Student(data)
|
s = Student(data)
|
||||||
# s.viewClass("English11_eharris1")
|
#s.viewClass("APLit_eharris1")
|
||||||
|
#s.updateClass("APLit_eharris1")
|
||||||
|
#s.update()
|
||||||
s.exitCLI()
|
s.exitCLI()
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import http.server
|
||||||
import socketserver
|
import socketserver
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from werkzeug.urls import url_decode
|
from werkzeug.urls import url_decode
|
||||||
|
import pprint
|
||||||
|
|
||||||
client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6'
|
client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6'
|
||||||
client_secret = r'0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2f1l2HzZHsQ7ijC74A0mrOhhCVeZugqAmOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY'
|
client_secret = r'0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2f1l2HzZHsQ7ijC74A0mrOhhCVeZugqAmOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY'
|
||||||
|
@ -29,19 +30,29 @@ def main():
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
if not os.path.exists(".profile"):
|
if not os.path.exists(".profile"):
|
||||||
|
print(76546789876545678765)
|
||||||
authenticate()
|
authenticate()
|
||||||
print(open(".profile", "r").read())
|
print(open(".profile", "r").read())
|
||||||
else:
|
else:
|
||||||
print(open(".profile", "r").read())
|
print(open(".profile", "r").read())
|
||||||
|
|
||||||
while True:
|
# while True:
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
def authenticate():
|
def authenticate():
|
||||||
oauth = OAuth2Session(client_id=client_id, redirect_uri=redirect_uri, scope=scope)
|
oauth = OAuth2Session(client_id=client_id, redirect_uri=redirect_uri, scope=scope)
|
||||||
authorization_url, state = oauth.authorization_url("https://ion.tjhsst.edu/oauth/authorize/")
|
authorization_url, state = oauth.authorization_url("https://ion.tjhsst.edu/oauth/authorize/")
|
||||||
|
|
||||||
|
cdir = os.getcwd()
|
||||||
|
#Linux: chromdriver-linux
|
||||||
|
#Macos: chromdriver-mac
|
||||||
|
#Windows: chromdriver.exe
|
||||||
|
path = os.path.join(cdir, "chromedriver-mac")
|
||||||
|
print(path)
|
||||||
|
browser = webdriver.Chrome(path)
|
||||||
|
browser = webdriver.Safari()
|
||||||
|
|
||||||
web_dir = os.path.join(os.path.dirname(__file__), 'oauth')
|
web_dir = os.path.join(os.path.dirname(__file__), 'oauth')
|
||||||
os.chdir(web_dir)
|
os.chdir(web_dir)
|
||||||
if os.path.exists("index.html"):
|
if os.path.exists("index.html"):
|
||||||
|
@ -58,7 +69,6 @@ def authenticate():
|
||||||
server.daemon = True
|
server.daemon = True
|
||||||
server.start()
|
server.start()
|
||||||
|
|
||||||
browser = webdriver.Chrome()
|
|
||||||
browser.get("localhost:8000/")
|
browser.get("localhost:8000/")
|
||||||
|
|
||||||
while "http://localhost:8000/?code" not in browser.current_url:
|
while "http://localhost:8000/?code" not in browser.current_url:
|
||||||
|
@ -83,18 +93,20 @@ def authenticate():
|
||||||
|
|
||||||
# And finally get the user's profile!
|
# And finally get the user's profile!
|
||||||
profile = requests.get("https://ion.tjhsst.edu/api/profile", headers=headers).json()
|
profile = requests.get("https://ion.tjhsst.edu/api/profile", headers=headers).json()
|
||||||
print(profile)
|
|
||||||
|
pprint.pprint(profile)
|
||||||
username = profile['ion_username']
|
username = profile['ion_username']
|
||||||
email = profile['tj_email']
|
email = profile['tj_email']
|
||||||
first_name = profile['first_name']
|
first_name = profile['first_name']
|
||||||
last_name = profile['last_name']
|
last_name = profile['last_name']
|
||||||
|
|
||||||
os.chdir("..")
|
os.chdir(cdir)
|
||||||
profileFile = open(".profile", "w")
|
profileFile = open(".profile", "w")
|
||||||
profileFile.write(profile.text())
|
#profileFile.write(profile.text())
|
||||||
|
profileFile.write(str(profile))
|
||||||
profileFile.close()
|
profileFile.close()
|
||||||
|
|
||||||
# sys.exit
|
sys.exit
|
||||||
|
|
||||||
|
|
||||||
def create_server():
|
def create_server():
|
||||||
|
|
203
CLI/t-git.py
203
CLI/t-git.py
|
@ -154,7 +154,7 @@ class Teacher:
|
||||||
if (self.checkClass(path)):
|
if (self.checkClass(path)):
|
||||||
cname = path.split("/")
|
cname = path.split("/")
|
||||||
cname = cname[len(cname)-1]
|
cname = cname[len(cname)-1]
|
||||||
cpath = self.username + "/" + cname[len(cname)-1]
|
cpath = self.username + "/" + cname
|
||||||
data = {
|
data = {
|
||||||
"name": cname,
|
"name": cname,
|
||||||
"repo": "",
|
"repo": "",
|
||||||
|
@ -193,7 +193,7 @@ class Teacher:
|
||||||
#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, assignments):
|
def makeClass(self, cname):
|
||||||
#check if class exists
|
#check if class exists
|
||||||
path = self.username + "/" + cname
|
path = self.username + "/" + cname
|
||||||
isclass = False
|
isclass = False
|
||||||
|
@ -216,7 +216,7 @@ class Teacher:
|
||||||
f=open(path + "/README.md", "w")
|
f=open(path + "/README.md", "w")
|
||||||
f.close()
|
f.close()
|
||||||
#push to remote repo
|
#push to remote repo
|
||||||
os.chdir(path)
|
# os.chdir(path)
|
||||||
# for a in assignments:
|
# for a in assignments:
|
||||||
|
|
||||||
# os.mkdir(a)
|
# os.mkdir(a)
|
||||||
|
@ -280,14 +280,14 @@ class Teacher:
|
||||||
def reqStudent(self, sname, cname):
|
def reqStudent(self, sname, cname):
|
||||||
if(self.isStudent(sname) == False):
|
if(self.isStudent(sname) == False):
|
||||||
print(sname + " does not exist.")
|
print(sname + " does not exist.")
|
||||||
return
|
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 course['unconfirmed']):
|
if(sname in course['unconfirmed']):
|
||||||
print (sname + " already requested.")
|
print (sname + " already requested.")
|
||||||
return
|
return True
|
||||||
if(sname in course['confirmed']):
|
if(sname in course['confirmed']):
|
||||||
print (sname + " alredy enrolled.")
|
print (sname + " alredy enrolled.")
|
||||||
return
|
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:
|
||||||
|
@ -297,7 +297,7 @@ class Teacher:
|
||||||
student['added_to']=student['added_to']+ "," + course['name']
|
student['added_to']=student['added_to']+ "," + course['name']
|
||||||
except:
|
except:
|
||||||
print(sname + " does not exist.")
|
print(sname + " does not exist.")
|
||||||
return
|
return False
|
||||||
print(student['added_to'])
|
print(student['added_to'])
|
||||||
s={
|
s={
|
||||||
'first_name':student["first_name"],
|
'first_name':student["first_name"],
|
||||||
|
@ -323,31 +323,34 @@ class Teacher:
|
||||||
"repo": "",
|
"repo": "",
|
||||||
"path": self.username + "/" + course['name'],
|
"path": self.username + "/" + course['name'],
|
||||||
"teacher": self.username,
|
"teacher": self.username,
|
||||||
"assignments": "",
|
"assignments": course['assignments'],
|
||||||
"default_file": "",
|
"default_file": "",
|
||||||
"confirmed": course["confirmed"],
|
"confirmed": course["confirmed"],
|
||||||
"unconfirmed": course['unconfirmed']
|
"unconfirmed": course['unconfirmed']
|
||||||
}
|
}
|
||||||
print(putDB(cinfo, course['url']))
|
print(putDB(cinfo, course['url']))
|
||||||
|
return True
|
||||||
|
|
||||||
#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):
|
if(self.isStudent(sname) == False):
|
||||||
print(sname + " does not exist.")
|
print(sname + " does not exist.")
|
||||||
return
|
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((student['ion_user'] in course['unconfirmed']) == False):
|
|
||||||
print("Student has not been requested to join yet.")
|
|
||||||
return
|
|
||||||
if((cname in student['added_to']) == True or (cname in student['classes']) == False):
|
|
||||||
print("Student has not confirmed class yet")
|
|
||||||
return
|
|
||||||
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 already added to class")
|
print(student['ion_user'] + " already added to class")
|
||||||
|
return True
|
||||||
|
if((cname in student['added_to']) == True or (cname in student['classes']) == False):
|
||||||
|
print(student['ion_user']+ " has not confirmed class yet")
|
||||||
|
return False
|
||||||
|
if((student['ion_user'] in course['unconfirmed']) == False):
|
||||||
|
print(course['unconfirmed'])
|
||||||
|
print(student['ion_user']+" has not been requested to join yet.")
|
||||||
|
return False
|
||||||
|
|
||||||
#git clone and make student/class directories
|
#git clone and make student/class directories
|
||||||
cdir = os.getcwd()
|
cdir = os.getcwd()
|
||||||
|
@ -362,67 +365,97 @@ class Teacher:
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
|
|
||||||
#push to git
|
#push to git
|
||||||
copy_tree(cpath, path + "/" + student['ion_user'])
|
|
||||||
os.chdir(spath)
|
os.chdir(spath)
|
||||||
command('git checkout ' + cname)
|
command('git checkout ' + cname)
|
||||||
command('git pull origin ' + cname)
|
command('git pull origin ' + cname)
|
||||||
|
os.chdir(cdir)
|
||||||
|
copy_tree(cpath, path + "/" + student['ion_user'])
|
||||||
|
os.chdir(spath)
|
||||||
command('git add .')
|
command('git add .')
|
||||||
command('git commit -m Hello')
|
command('git commit -m Hello')
|
||||||
command('git push -u origin ' + cname)
|
command('git push -u origin ' + cname)
|
||||||
command('git checkout master')
|
os.chdir(cdir)
|
||||||
|
|
||||||
if(course['confirmed']==""):
|
if(course['confirmed']==""):
|
||||||
course['confirmed']=student['ion_user']
|
course['confirmed']=student['ion_user']
|
||||||
else:
|
else:
|
||||||
course['confirmed']=course['confirmed']+ "," + student['ion_user']
|
course['confirmed']=course['confirmed']+ "," + student['ion_user']
|
||||||
|
|
||||||
|
#only 1 pereson on confirmeed
|
||||||
|
if(("," in course['unconfirmed']) == False):
|
||||||
|
course['unconfirmed']=""
|
||||||
|
#mutiple
|
||||||
|
else:
|
||||||
|
course['unconfirmed']= course['unconfirmed'].replace("," + student['ion_user'], "")
|
||||||
|
course['unconfirmed']= course['unconfirmed'].replace(student['ion_user']+",", "")
|
||||||
|
|
||||||
cinfo = {
|
cinfo = {
|
||||||
"name": course['name'],
|
"name": course['name'],
|
||||||
"repo": "",
|
"repo": "",
|
||||||
"path": course['path'],
|
"path": course['path'],
|
||||||
"teacher": course['name'],
|
"teacher": self.username,
|
||||||
"assignments": "",
|
"assignments": course['assignments'],
|
||||||
"default_file": "",
|
"default_file": "",
|
||||||
"confirmed": course["confirmed"],
|
"confirmed": course["confirmed"],
|
||||||
"unconfirmed": course['unconfirmed']
|
"unconfirmed": course['unconfirmed']
|
||||||
}
|
}
|
||||||
print(putDB(cinfo, course['url']))
|
print(putDB(cinfo, course['url']))
|
||||||
|
return True
|
||||||
|
|
||||||
|
#goes through list of studennts, tries to add, then request, return unconfirmed students
|
||||||
|
def reqAddStudentList(self, array, cname):
|
||||||
|
unconf = []
|
||||||
|
for i in range(len(array)):
|
||||||
|
a = array[i]
|
||||||
|
if(self.addStudent(a, cname) == False):
|
||||||
|
self.reqStudent(a, cname)
|
||||||
|
unconf.append(a)
|
||||||
|
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):
|
||||||
parts = path.split("/")
|
parts = path.split("/")
|
||||||
aname = parts[len(parts)-1]
|
aname = parts[len(parts)-1]
|
||||||
|
|
||||||
if(os.path.isdir(path) == 0 or len(parts) < 3) or aname in self.sclass:
|
if(os.path.isdir(path) == 0 or len(parts) < 3) or aname in self.sclass:
|
||||||
print("Not valid path.")
|
print("Not valid path.")
|
||||||
return
|
return False
|
||||||
if((parts[1] in self.sclass) == False):
|
if((parts[1] in self.sclass) == False):
|
||||||
print("Not in valid class directory")
|
print("Not in valid class directory")
|
||||||
return
|
return False
|
||||||
|
#parts of assignment name (Essay1, APLit)
|
||||||
|
if((course in aname) == False):
|
||||||
|
print("Assignment named incorrectly; could be "+ aname + "_" + course)
|
||||||
|
return False
|
||||||
|
|
||||||
ar = [x[2] for x in os.walk(path)]
|
ar = [x[2] for x in os.walk(path)]
|
||||||
print(ar)
|
print(ar)
|
||||||
for folder in ar:
|
for folder in ar:
|
||||||
if len(folder) == 0:
|
if len(folder) == 0:
|
||||||
print("Assignment is completely empty, need a file.")
|
print("Assignment is completely empty, needs a file.")
|
||||||
return
|
return False
|
||||||
aname = parts[len(parts)-1]
|
|
||||||
p1 = course.split("_")[0]
|
p1 = course.split("_")[0]
|
||||||
if(p1 in aname == False):
|
if(p1 in aname == False):
|
||||||
print(aname + "incorrectly formated: must be " + aname + "_" + p1 + ".")
|
print(aname + "incorrectly formated: must be " + aname + "_" + p1 + ".")
|
||||||
return
|
return False
|
||||||
try:
|
try:
|
||||||
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
||||||
except:
|
except:
|
||||||
print("Due-date format is incorrect")
|
print("Due-date format is incorrect")
|
||||||
return
|
return False
|
||||||
|
|
||||||
ass = {
|
|
||||||
'name': aname,
|
|
||||||
'path':path,
|
|
||||||
'classes':course,
|
|
||||||
'teacher':self.username,
|
|
||||||
'due_date':due
|
|
||||||
}
|
|
||||||
postDB(ass, 'http://127.0.0.1:8000/api/assignments/' + aname + "/")
|
|
||||||
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 course['assignments']):
|
||||||
|
print("Assignment name already taken.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print(course['assignments'])
|
||||||
|
input()
|
||||||
|
#################### FINISH VERIFYING
|
||||||
|
|
||||||
|
if(os.path.exists(os.getcwd() + "/" + self.username + "/Students/" + course['name']) == False):
|
||||||
|
print("No students in this class yet")
|
||||||
|
return True
|
||||||
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
|
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
|
||||||
cdir = os.getcwd()
|
cdir = os.getcwd()
|
||||||
for st in slist:
|
for st in slist:
|
||||||
|
@ -441,6 +474,38 @@ class Teacher:
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
else:
|
else:
|
||||||
print(st + " already has assignment")
|
print(st + " already has assignment")
|
||||||
|
|
||||||
|
#check if assignment already exists
|
||||||
|
r = requests.get(url = 'http://127.0.0.1:8000/api/assignments/' + aname, auth=('raffukhondaker','hackgroup1'))
|
||||||
|
if(r.status_code != 200):
|
||||||
|
ass = {
|
||||||
|
'name': aname,
|
||||||
|
'path':path,
|
||||||
|
'classes':course['name'],
|
||||||
|
'teacher':self.username,
|
||||||
|
'due_date':due
|
||||||
|
}
|
||||||
|
postDB(ass, 'http://127.0.0.1:8000/api/assignments/')
|
||||||
|
if(course['assignments'] == ""):
|
||||||
|
course['assignments'] = aname
|
||||||
|
else:
|
||||||
|
course['assignments'] = course['assignments'] + "," + aname
|
||||||
|
|
||||||
|
cinfo = {
|
||||||
|
"name": course['name'],
|
||||||
|
"repo": "",
|
||||||
|
"path": course['path'],
|
||||||
|
"teacher": "eharris1",
|
||||||
|
"assignments": course['assignments'],
|
||||||
|
"default_file": "",
|
||||||
|
"confirmed": course["confirmed"],
|
||||||
|
"unconfirmed": course['unconfirmed']
|
||||||
|
}
|
||||||
|
putDB(cinfo, "http://127.0.0.1:8000/api/classes/" + course['name'] + "/")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print("Assignment already addedd")
|
||||||
|
return True
|
||||||
|
|
||||||
#try to avoid
|
#try to avoid
|
||||||
#copy modified assignments to student directories
|
#copy modified assignments to student directories
|
||||||
|
@ -491,7 +556,7 @@ class Teacher:
|
||||||
command('git pull origin ' + course)
|
command('git pull origin ' + course)
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
|
|
||||||
def getHistory(self, student, course):
|
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((student in course['confirmed']) == False):
|
||||||
|
@ -503,10 +568,11 @@ 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', '-30', 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 = []
|
||||||
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")
|
||||||
|
@ -524,9 +590,27 @@ class Teacher:
|
||||||
mon = m
|
mon = m
|
||||||
d1 = datetime(int(date[4]), mon, int(date[2]), int(times[0]), int(times[1]))
|
d1 = datetime(int(date[4]), mon, int(date[2]), int(times[0]), int(times[1]))
|
||||||
#datetime1 = datetime.strptime('07/11/2019 02:45PM', '%m/%d/%Y %I:%M%p')
|
#datetime1 = datetime.strptime('07/11/2019 02:45PM', '%m/%d/%Y %I:%M%p')
|
||||||
output[i] = [c[0], d1]
|
fout.append([c[0],d1])
|
||||||
|
#output[i] = [c[0], d1]
|
||||||
|
#print(output[i])
|
||||||
|
print(fout)
|
||||||
|
os.chdir(cdir)
|
||||||
|
return fout
|
||||||
|
|
||||||
|
def getChanges(self, student, course, commits):
|
||||||
|
course = getDB("http://127.0.0.1:8000/api/classes/" + course + "/")
|
||||||
|
ar = self.getCommits(student, course['name'], commits)
|
||||||
|
commit = ar[len(ar)-1][0]
|
||||||
|
start = ""
|
||||||
|
print("END:" + commit)
|
||||||
|
print("START: " + start)
|
||||||
|
cdir = os.getcwd()
|
||||||
|
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
|
||||||
|
process = subprocess.Popen(['git', 'diff', commit, '--name-status'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
p=process.poll()
|
||||||
|
output = process.communicate()[0].decode('utf-8')
|
||||||
|
print(output)
|
||||||
os.chdir(cdir)
|
os.chdir(cdir)
|
||||||
return output
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
assignment = {
|
assignment = {
|
||||||
|
@ -536,15 +620,14 @@ 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()
|
assignment = getDB("http://127.0.0.1:8000/api/assignments/" + assignment)
|
||||||
'''
|
# assignment = {
|
||||||
assignment = {
|
# 'name': assignment,
|
||||||
'name': assignment,
|
# 'due_date': "2020-04-11 16:58:33.383124",
|
||||||
'due_date': "2020-04-11 16:58:33.383124",
|
# 'classes':course
|
||||||
'classes':course
|
# }
|
||||||
}
|
log = self.getCommits(student, course, 30)
|
||||||
log = self.getHistory(student, course)
|
|
||||||
assignment['due_date'] = datetime.strptime(assignment['due_date'], '%Y-%m-%d %H:%M:%S.%f')
|
assignment['due_date'] = datetime.strptime(assignment['due_date'], '%Y-%m-%d %H:%M:%S.%f')
|
||||||
late = False
|
late = False
|
||||||
cdir = os.getcwd()
|
cdir = os.getcwd()
|
||||||
|
@ -571,4 +654,24 @@ class Teacher:
|
||||||
|
|
||||||
data = getTeacher("eharris1")
|
data = getTeacher("eharris1")
|
||||||
t = Teacher(data)
|
t = Teacher(data)
|
||||||
t.getStudents("English11_eharris1")
|
# t.makeClass("APLit_eharris1")
|
||||||
|
#t.addAssignment("eharris1/APLit_eharris1/Lab3_APLit_eharris1", "APLit_eharris1", '2020-08-11 16:58:33.383124')
|
||||||
|
#ar = ['2022rkhondak','2022inafi','2023rumareti']
|
||||||
|
#extra = t.reqAddStudentList(ar, "APLit_eharris1")
|
||||||
|
#print(extra)
|
||||||
|
t.getStudents('2022rkhondak')
|
||||||
|
t.getChanges('2022rkhondak','APLit_eharris1', 10)
|
||||||
|
|
||||||
|
'''
|
||||||
|
TO-DO
|
||||||
|
- More checks
|
||||||
|
- add students to APLit_eharris1
|
||||||
|
- make new class, make newe assignment, add/req students, make assignment
|
||||||
|
- Add assignment to class after being made
|
||||||
|
- Check if assignment name is taken
|
||||||
|
- getUsage on student
|
||||||
|
- comit history
|
||||||
|
- check differences between commits
|
||||||
|
- check if student changes file after submissionn deadline
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import textract
|
|
||||||
text = textract.process('test.py')
|
|
28
Website/api/migrations/0004_auto_20200612_0813.py
Normal file
28
Website/api/migrations/0004_auto_20200612_0813.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 3.0.7 on 2020-06-12 08:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('api', '0003_auto_20200612_0135'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='classes',
|
||||||
|
name='assignments',
|
||||||
|
field=models.TextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='classes',
|
||||||
|
name='default_file',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=100),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='classes',
|
||||||
|
name='repo',
|
||||||
|
field=models.URLField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
]
|
|
@ -20,11 +20,11 @@ class Assignment(models.Model):
|
||||||
|
|
||||||
class Classes(models.Model):
|
class Classes(models.Model):
|
||||||
name = models.CharField(primary_key=True, max_length=100)
|
name = models.CharField(primary_key=True, max_length=100)
|
||||||
repo=models.URLField(default="")
|
repo=models.URLField(default="", blank=True)
|
||||||
path=models.CharField(max_length=100, default="")
|
path=models.CharField(max_length=100, default="")
|
||||||
teacher=models.CharField(max_length=100, default="")
|
teacher=models.CharField(max_length=100, default="")
|
||||||
assignments=models.CharField(max_length=100, default="")
|
assignments=models.TextField(default="", blank=True)
|
||||||
default_file=models.CharField(max_length=100, default="")
|
default_file=models.CharField(max_length=100, default="", blank=True)
|
||||||
confirmed=models.TextField(default="", blank=True)
|
confirmed=models.TextField(default="", blank=True)
|
||||||
unconfirmed=models.TextField(default="", blank=True)
|
unconfirmed=models.TextField(default="", blank=True)
|
||||||
|
|
||||||
|
|
BIN
chromedriver-mac
Executable file
BIN
chromedriver-mac
Executable file
Binary file not shown.
0
eharris1/APLit_eharris1/Cuisine_APLit/instruct.txt
Normal file
0
eharris1/APLit_eharris1/Cuisine_APLit/instruct.txt
Normal file
0
eharris1/APLit_eharris1/Cuisine_APLit/rubric.txt
Normal file
0
eharris1/APLit_eharris1/Cuisine_APLit/rubric.txt
Normal file
0
eharris1/APLit_eharris1/Essay2_APLit/rubric.txt
Normal file
0
eharris1/APLit_eharris1/Essay2_APLit/rubric.txt
Normal file
0
eharris1/APLit_eharris1/README.md
Normal file
0
eharris1/APLit_eharris1/README.md
Normal file
0
eharris1/APLit_eharris1/Test1_APLit/instruct.txt
Normal file
0
eharris1/APLit_eharris1/Test1_APLit/instruct.txt
Normal file
1
eharris1/English11_eharris1/Journal1_English11/entry.txt
Normal file
1
eharris1/English11_eharris1/Journal1_English11/entry.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -4,6 +4,7 @@ chardet==3.0.4
|
||||||
click==7.1.2
|
click==7.1.2
|
||||||
Django==3.0.7
|
Django==3.0.7
|
||||||
django-cors-middleware==1.5.0
|
django-cors-middleware==1.5.0
|
||||||
|
django-crispy-forms==1.9.1
|
||||||
django-oauth-toolkit==1.3.2
|
django-oauth-toolkit==1.3.2
|
||||||
djangorestframework==3.11.0
|
djangorestframework==3.11.0
|
||||||
idna==2.9
|
idna==2.9
|
||||||
|
|
Loading…
Reference in New Issue
Block a user