mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
more documentation
This commit is contained in:
parent
a9ee300708
commit
71f288eaae
240
CLI/student.py
240
CLI/student.py
|
@ -9,77 +9,85 @@ import time
|
|||
import pyperclip
|
||||
import datetime
|
||||
|
||||
#git clone student directory ==> <student-id>/classes/assignments
|
||||
|
||||
#get teacher info from api
|
||||
# git clone student directory ==> <student-id>/classes/assignments
|
||||
|
||||
# get teacher info from api
|
||||
def getStudent(ion_user):
|
||||
URL = "http://127.0.0.1:8000/api/students/" + ion_user + "/"
|
||||
r = requests.get(url = URL, auth=('raffukhondaker','hackgroup1'))
|
||||
if(r.status_code == 200):
|
||||
data = r.json()
|
||||
return data
|
||||
elif(r.status_code == 404):
|
||||
return None
|
||||
print("Make new account!")
|
||||
elif(r.status_code == 403):
|
||||
return None
|
||||
print("Invalid username/password")
|
||||
else:
|
||||
return None
|
||||
print(r.status_code)
|
||||
URL = "http://127.0.0.1:8000/api/students/" + ion_user + "/"
|
||||
r = requests.get(url=URL, auth=('raffukhondaker', 'hackgroup1'))
|
||||
if (r.status_code == 200):
|
||||
data = r.json()
|
||||
return data
|
||||
elif (r.status_code == 404):
|
||||
return None
|
||||
print("Make new account!")
|
||||
elif (r.status_code == 403):
|
||||
return None
|
||||
print("Invalid username/password")
|
||||
else:
|
||||
return None
|
||||
print(r.status_code)
|
||||
|
||||
|
||||
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))
|
||||
return(r.json())
|
||||
return (r.json())
|
||||
|
||||
|
||||
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))
|
||||
return(r.json())
|
||||
return (r.json())
|
||||
|
||||
|
||||
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))
|
||||
return(r.json())
|
||||
return (r.json())
|
||||
|
||||
|
||||
def patchDB(data, url):
|
||||
r = requests.patch(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
r = requests.patch(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||
print("PATH:" + str(r.status_code))
|
||||
return(r.json())
|
||||
return (r.json())
|
||||
|
||||
|
||||
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))
|
||||
return None
|
||||
|
||||
|
||||
def command(command):
|
||||
ar = []
|
||||
command = command.split(" ")
|
||||
for c in command:
|
||||
ar.append(c)
|
||||
process = subprocess.Popen(ar, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
p=process.poll()
|
||||
process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = process.poll()
|
||||
output = process.communicate()[0]
|
||||
print(output.decode('utf-8'))
|
||||
return output.decode('utf-8')
|
||||
|
||||
|
||||
####################################################################################################################################
|
||||
|
||||
#public methods: deleteClass, makeClass, update
|
||||
# public methods: deleteClass, makeClass, update
|
||||
class Student:
|
||||
def __init__(self, data):
|
||||
# teacher info already stored in API
|
||||
# intitialze fields after GET request
|
||||
self.git=data['git']
|
||||
self.username=data['ion_user']
|
||||
self.url= "http://127.0.0.1:8000/api/students/" + self.username + "/"
|
||||
self.git = data['git']
|
||||
self.username = data['ion_user']
|
||||
self.url = "http://127.0.0.1:8000/api/students/" + self.username + "/"
|
||||
self.grade = data['grade']
|
||||
self.completed = data['completed']
|
||||
self.user = data['user']
|
||||
#classes in id form (Example: 4,5)
|
||||
#storing actual classes
|
||||
cid=data['classes'].split(",")
|
||||
self.completed = data['completed']
|
||||
self.user = data['user']
|
||||
# classes in id form (Example: 4,5)
|
||||
# storing actual classes
|
||||
cid = data['classes'].split(",")
|
||||
try:
|
||||
cid.remove('')
|
||||
except:
|
||||
|
@ -88,16 +96,16 @@ class Student:
|
|||
cid.remove("")
|
||||
except:
|
||||
pass
|
||||
classes=[]
|
||||
classes = []
|
||||
for c in cid:
|
||||
url = "http://127.0.0.1:8000/api/classes/" + str(c) + "/"
|
||||
classes.append(getDB(url))
|
||||
|
||||
|
||||
self.classes = classes
|
||||
self.sclass=str(data['classes'])
|
||||
|
||||
#storing added_to classes
|
||||
nid=data['added_to'].split(",")
|
||||
self.sclass = str(data['classes'])
|
||||
|
||||
# storing added_to classes
|
||||
nid = data['added_to'].split(",")
|
||||
try:
|
||||
nid.remove('')
|
||||
except:
|
||||
|
@ -106,21 +114,21 @@ class Student:
|
|||
nid.remove("")
|
||||
except:
|
||||
pass
|
||||
nclasses=[]
|
||||
nclasses = []
|
||||
for c in nid:
|
||||
url = "http://127.0.0.1:8000/api/classes/" + str(c) + "/"
|
||||
nclasses.append(getDB(url))
|
||||
|
||||
|
||||
self.new = nclasses
|
||||
self.snew=str(data['added_to'])
|
||||
self.snew = str(data['added_to'])
|
||||
self.repo = data['repo']
|
||||
|
||||
if(os.path.isdir(self.username) == False):
|
||||
if(self.repo == ""):
|
||||
user= self.git
|
||||
pwd= input("Enter Github password: ")
|
||||
#curl -i -u USER:PASSWORD -d '{"name":"REPO"}' https://api.github.com/user/repos
|
||||
url= "curl -i -u " + user + ":" + pwd + " -d '" + '{"name":"' + self.username + '"}' + "' " + "https://api.github.com/user/repos"
|
||||
if (os.path.isdir(self.username) == False):
|
||||
if (self.repo == ""):
|
||||
user = self.git
|
||||
pwd = input("Enter Github password: ")
|
||||
# curl -i -u USER:PASSWORD -d '{"name":"REPO"}' https://api.github.com/user/repos
|
||||
url = "curl -i -u " + user + ":" + pwd + " -d '" + '{"name":"' + self.username + '"}' + "' " + "https://api.github.com/user/repos"
|
||||
print(url)
|
||||
os.system(url)
|
||||
cdir = os.getcwd()
|
||||
|
@ -133,11 +141,11 @@ class Student:
|
|||
command('git push -u origin master')
|
||||
os.chdir(cdir)
|
||||
self.repo = 'https://github.com/' + self.git + '/' + self.username + '.git'
|
||||
data={
|
||||
'repo':self.repo
|
||||
data = {
|
||||
'repo': self.repo
|
||||
}
|
||||
print(patchDB(data, self.url))
|
||||
print("Synced to " + self.username)
|
||||
print("Synced to " + self.username)
|
||||
|
||||
def getClasses(self):
|
||||
classes = self.classes
|
||||
|
@ -157,16 +165,16 @@ class Student:
|
|||
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(a + " due in:" + str(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(a + " due in:" + str(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):
|
||||
cdir = os.getcwd()
|
||||
os.chdir(self.username)
|
||||
|
@ -187,10 +195,10 @@ class Student:
|
|||
self.addClass(str(c['name']))
|
||||
command("git checkout master")
|
||||
print(os.getcwd())
|
||||
|
||||
#updates 1 class, does not switch to master
|
||||
|
||||
# updates 1 class, does not switch to master
|
||||
def updateClass(self, course):
|
||||
if((course in self.sclass) == False):
|
||||
if ((course in self.sclass) == False):
|
||||
print("Class not found")
|
||||
return
|
||||
cdir = os.getcwd()
|
||||
|
@ -201,45 +209,45 @@ class Student:
|
|||
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>
|
||||
|
||||
#add classes from 'new' field
|
||||
# add classes from 'new' field
|
||||
def addClass(self, cid):
|
||||
|
||||
data = getDB('http://127.0.0.1:8000/api/classes/'+ str(cid))
|
||||
if((cid in self.snew) == False or (self.username in data['confirmed'])):
|
||||
data = getDB('http://127.0.0.1:8000/api/classes/' + str(cid))
|
||||
if ((cid in self.snew) == False or (self.username in data['confirmed'])):
|
||||
print("Already enrolled in this class.")
|
||||
return None
|
||||
if((cid in self.sclass) or (self.username in data['unconfirmed']) == False):
|
||||
if ((cid in self.sclass) or (self.username in data['unconfirmed']) == False):
|
||||
print("Not added by teacher yet.")
|
||||
return None
|
||||
|
||||
#add class teacher as cocllaborator to student repo
|
||||
# add class teacher as cocllaborator to student repo
|
||||
print(os.getcwd())
|
||||
pwd= input("Enter Github password: ")
|
||||
pwd = input("Enter Github password: ")
|
||||
tgit = getDB("http://127.0.0.1:8000/api/teachers/" + data['teacher'] + "/")['git']
|
||||
url= "curl -i -u " + self.git + ":" + pwd + " -X PUT -d '' " + "'https://api.github.com/repos/" + self.git + "/" + self.username + "/collaborators/" + tgit + "'"
|
||||
url = "curl -i -u " + self.git + ":" + pwd + " -X PUT -d '' " + "'https://api.github.com/repos/" + self.git + "/" + self.username + "/collaborators/" + tgit + "'"
|
||||
print(url)
|
||||
os.system(url)
|
||||
|
||||
cdir = os.getcwd()
|
||||
path1 = self.username + "/" + self.username
|
||||
path2 = self.username
|
||||
if(os.path.isdir(path1)):
|
||||
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)
|
||||
command("git checkout master")
|
||||
command("git branch " + data['name'])
|
||||
command("git commit -m initial")
|
||||
command("git push origin " + data['name'])
|
||||
command("git checkout master")
|
||||
#git clone --single-branch --branch <branchname> <remote-repo>
|
||||
# git clone --single-branch --branch <branchname> <remote-repo>
|
||||
os.chdir(cdir)
|
||||
|
||||
# data['unconfirmed'] = data['unconfirmed'].replace("," + self.username, "")
|
||||
|
@ -250,79 +258,79 @@ class Student:
|
|||
# print(data['confirmed'])
|
||||
# print(putDB(data, 'http://127.0.0.1:8000/api/classes/'+ str(cid) + "/"))
|
||||
|
||||
#add teacher as collaborator
|
||||
#curl -i -u "USER:PASSWORDD" -X PUT -d '' 'https://api.github.com/repos/USER/REPO/collaborators/COLLABORATOR'
|
||||
# add teacher as collaborator
|
||||
# curl -i -u "USER:PASSWORDD" -X PUT -d '' 'https://api.github.com/repos/USER/REPO/collaborators/COLLABORATOR'
|
||||
user = self.git
|
||||
|
||||
self.classes.append(data)
|
||||
if(len(self.sclass)==0):
|
||||
if (len(self.sclass) == 0):
|
||||
self.sclass = data['name']
|
||||
else:
|
||||
self.sclass = self.sclass + "," + str(data['name'])
|
||||
|
||||
#upddate self.new
|
||||
snew=""
|
||||
# upddate self.new
|
||||
snew = ""
|
||||
new = []
|
||||
for i in range(len(self.new)):
|
||||
if(self.new[i]['name'] == data['name']):
|
||||
if (self.new[i]['name'] == data['name']):
|
||||
del self.new[i]
|
||||
#recreate sclass field, using ids
|
||||
# recreate sclass field, using ids
|
||||
for c in self.new:
|
||||
snew = snew + str(c['name']) + ","
|
||||
new.append(getDB("http://127.0.0.1:8000/api/classes/" + str(cid)))
|
||||
self.snew=snew
|
||||
self.new=new
|
||||
self.snew = snew
|
||||
self.new = new
|
||||
break
|
||||
|
||||
#update teacher instance in db, classes field
|
||||
data={
|
||||
'user':self.user,
|
||||
'added_to':self.snew,
|
||||
'classes':self.sclass
|
||||
|
||||
# update teacher instance in db, classes field
|
||||
data = {
|
||||
'user': self.user,
|
||||
'added_to': self.snew,
|
||||
'classes': self.sclass
|
||||
}
|
||||
print(self.url)
|
||||
print(patchDB(data, self.url))
|
||||
return data
|
||||
|
||||
|
||||
def submit(self, path):
|
||||
#2022rkhondak/English11_eharris1/Essay1
|
||||
#check if valid assignment
|
||||
# 2022rkhondak/English11_eharris1/Essay1
|
||||
# check if valid assignment
|
||||
parts = path.split("/")
|
||||
if(len(parts) != 3):
|
||||
if (len(parts) != 3):
|
||||
print("Assignment path too short")
|
||||
return
|
||||
isclass = False
|
||||
for c in self.classes:
|
||||
if(c['name'] == parts[1]):
|
||||
isclass==True
|
||||
for c in self.classes:
|
||||
if (c['name'] == parts[1]):
|
||||
isclass == True
|
||||
break
|
||||
if(parts[0] != self.username and isclass and os.path.isdir(path) == False):
|
||||
if (parts[0] != self.username and isclass and os.path.isdir(path) == False):
|
||||
print("Not valid assignment")
|
||||
return
|
||||
if((parts[1] + "/" + parts[2]) in self.completed):
|
||||
if ((parts[1] + "/" + parts[2]) in self.completed):
|
||||
print(parts[2] + " already submited. ")
|
||||
# return
|
||||
resp = input("Are you sure you want to submit? You cannot do this again.(y/N) ")
|
||||
if(resp == 'y'):
|
||||
if (resp == 'y'):
|
||||
os.chdir(self.username + "/" + parts[1])
|
||||
command("git add .")
|
||||
command("git commit -m submit")
|
||||
command("git tag " + parts[1] + "-final")
|
||||
command("git push -u origin " + self.username + " --tags")
|
||||
self.completed = self.completed + "," + parts[1] + "/" + parts[2]
|
||||
data={
|
||||
'user':self.user,
|
||||
'git':self.git,
|
||||
'ion_user':self.username,
|
||||
'student_id':self.student_id,
|
||||
'added_to':self.snew,
|
||||
'url':self.url,
|
||||
'classes':self.sclass,
|
||||
'grade':self.grade,
|
||||
'completed':self.completed
|
||||
data = {
|
||||
'user': self.user,
|
||||
'git': self.git,
|
||||
'ion_user': self.username,
|
||||
'student_id': self.student_id,
|
||||
'added_to': self.snew,
|
||||
'url': self.url,
|
||||
'classes': self.sclass,
|
||||
'grade': self.grade,
|
||||
'completed': self.completed
|
||||
}
|
||||
#print(putDB(data, "http://127.0.0.1:8000/api/students/" + self.username + "/"))
|
||||
|
||||
# print(putDB(data, "http://127.0.0.1:8000/api/students/" + self.username + "/"))
|
||||
|
||||
def viewClass(self, courses):
|
||||
self.update()
|
||||
cdir = os.getcwd()
|
||||
|
@ -335,12 +343,12 @@ class Student:
|
|||
os.chdir(cdir)
|
||||
print("Class not found")
|
||||
return
|
||||
|
||||
|
||||
def exitCLI(self):
|
||||
print(os.getcwd())
|
||||
self.update()
|
||||
command("git checkout master")
|
||||
|
||||
|
||||
def submit(self, course, assignment):
|
||||
cdir = os.getcwd()
|
||||
os.chdir(self.username)
|
||||
|
@ -355,7 +363,7 @@ class Student:
|
|||
if a == assignment:
|
||||
inclass = True
|
||||
break
|
||||
if(inclass == False):
|
||||
if (inclass == False):
|
||||
print(assignment + " not an assignment of " + course)
|
||||
command('git checkout master')
|
||||
os.chdir(cdir)
|
||||
|
@ -369,6 +377,7 @@ class Student:
|
|||
command('git checkout master')
|
||||
os.chdir(cdir)
|
||||
|
||||
|
||||
# data = getStudent("2022rkhondak")
|
||||
# s = Student(data)
|
||||
# s.viewClass("APLit_eharris1")
|
||||
|
@ -379,6 +388,7 @@ class Student:
|
|||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# stuff only to run when not called via 'import' here
|
||||
main()
|
||||
# stuff only to run when not called via 'import' here
|
||||
main()
|
||||
|
|
434
CLI/teacher.py
434
CLI/teacher.py
|
@ -8,7 +8,9 @@ import shutil
|
|||
import time
|
||||
import pyperclip
|
||||
from distutils.dir_util import copy_tree
|
||||
from datetime import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# from django.conf import settings
|
||||
# import django
|
||||
|
||||
|
@ -21,211 +23,250 @@ from datetime import datetime
|
|||
# django.setup()
|
||||
|
||||
# from ..Website.api.models import *
|
||||
#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
|
||||
def getTeacher(ion_user):
|
||||
URL = "http://127.0.0.1:8000/api/teachers/" + ion_user + "/"
|
||||
r = requests.get(url = URL, auth=('raffukhondaker','hackgroup1'))
|
||||
if(r.status_code == 200):
|
||||
data = r.json()
|
||||
return data
|
||||
elif(r.status_code == 404):
|
||||
return None
|
||||
print("Make new account!")
|
||||
elif(r.status_code == 403):
|
||||
return None
|
||||
print("Invalid username/password")
|
||||
else:
|
||||
return None
|
||||
print(r.status_code)
|
||||
"""
|
||||
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 + "/"
|
||||
r = requests.get(url=URL, auth=('raffukhondaker', 'hackgroup1'))
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
return data
|
||||
elif r.status_code == 404:
|
||||
return None
|
||||
print("Make new account!")
|
||||
elif r.status_code == 403:
|
||||
return None
|
||||
print("Invalid username/password")
|
||||
else:
|
||||
return None
|
||||
print(r.status_code)
|
||||
|
||||
|
||||
def getDB(url):
|
||||
r = requests.get(url = url, auth=('raffukhondaker','hackgroup1'))
|
||||
"""
|
||||
Sends a GET request to the URL
|
||||
:param url: URL for request
|
||||
"""
|
||||
r = requests.get(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
||||
print("GET:" + str(r.status_code))
|
||||
return(r.json())
|
||||
return r.json()
|
||||
|
||||
|
||||
def patchDB(data, url):
|
||||
r = requests.patch(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
"""
|
||||
Sends a PATCH request to the URL
|
||||
:param data:
|
||||
:param url: URL for request
|
||||
"""
|
||||
r = requests.patch(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||
print("PATCH:" + str(r.status_code))
|
||||
return(r.json())
|
||||
return r.json()
|
||||
|
||||
|
||||
def postDB(data, url):
|
||||
r = requests.post(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
"""
|
||||
Sends a POST request to the URL
|
||||
:param data:
|
||||
:param url: URL for request
|
||||
"""
|
||||
r = requests.post(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||
print("POST:" + str(r.status_code))
|
||||
return(r.json())
|
||||
return r.json()
|
||||
|
||||
|
||||
def putDB(data, url):
|
||||
r = requests.put(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
"""
|
||||
Sends a PUT request to the URL
|
||||
:param data:
|
||||
:param url: URL for request
|
||||
"""
|
||||
r = requests.put(url=url, data=data, auth=('raffukhondaker', 'hackgroup1'))
|
||||
print("PUT:" + str(r.status_code))
|
||||
return(r.json())
|
||||
return r.json()
|
||||
|
||||
|
||||
def delDB(url):
|
||||
r = requests.delete(url = url, auth=('raffukhondaker','hackgroup1'))
|
||||
"""
|
||||
Sends a DELETE request to the URL
|
||||
:param url: URL for request
|
||||
"""
|
||||
r = requests.delete(url=url, auth=('raffukhondaker', 'hackgroup1'))
|
||||
print("DELETE:" + str(r.status_code))
|
||||
return None
|
||||
|
||||
|
||||
def command(command):
|
||||
ar = []
|
||||
command = command.split(" ")
|
||||
for c in command:
|
||||
ar.append(c)
|
||||
process = subprocess.Popen(ar, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
p=process.poll()
|
||||
process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = process.poll()
|
||||
output = process.communicate()[1]
|
||||
print(output.decode('utf-8'))
|
||||
|
||||
|
||||
####################################################################################################################################
|
||||
|
||||
#public methods: deleteClass, makeClass, update
|
||||
# public methods: deleteClass, makeClass, update
|
||||
class Teacher:
|
||||
def __init__(self, data):
|
||||
# teacher info already stored in API
|
||||
# intitialze fields after GET request
|
||||
self.git=data['git']
|
||||
self.username=data['ion_user']
|
||||
self.url= "http://127.0.0.1:8000/api/teachers/" + self.username + "/"
|
||||
"""
|
||||
Initializes a Teacher with the data from the api
|
||||
:param data: api data
|
||||
"""
|
||||
self.git = data['git']
|
||||
self.username = data['ion_user']
|
||||
self.url = "http://127.0.0.1:8000/api/teachers/" + self.username + "/"
|
||||
self.id = data['user']
|
||||
#classes in id form (Example: 4,5)
|
||||
|
||||
#array
|
||||
self.classes=data['classes']
|
||||
if(os.path.isdir(self.username + "/Students")):
|
||||
print("Synced to " + self.username)
|
||||
# classes in id form (Example: 4,5)
|
||||
|
||||
# array
|
||||
self.classes = data['classes']
|
||||
if os.path.isdir(self.username + "/Students"):
|
||||
print("Synced to " + self.username)
|
||||
else:
|
||||
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
|
||||
#relative path to class: 2022rkhondak/Math4
|
||||
def checkClass(self,path):
|
||||
# turn existing directory into class, Pre-condition: directory exists
|
||||
# relative path to class: 2022rkhondak/Math4
|
||||
def checkClass(self, path):
|
||||
cname = path.split("/")
|
||||
cname = cname[len(cname)-1]
|
||||
if(os.path.isfile(path)):
|
||||
cname = cname[len(cname) - 1]
|
||||
if os.path.isfile(path):
|
||||
print(path + " must be in a Class directory.")
|
||||
return False
|
||||
if(("_" + self.username) in cname) == False:
|
||||
print("Incorrect class name: Must be in the format: " + self.username+ "/<course-name>_<ion_user>, not " + path)
|
||||
if not (("_" + self.username) in cname):
|
||||
print(
|
||||
"Incorrect class name: Must be in the format: " + self.username + "/<course-name>_<ion_user>, not " + path)
|
||||
return False
|
||||
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
|
||||
deffile = False
|
||||
#checks if there is a file in an Assignment, need at least 1 (default True in case no assignments)
|
||||
# checks if there is a file in an Assignment, need at least 1 (default True in case no assignments)
|
||||
as_file = True
|
||||
as_bad = ""
|
||||
|
||||
for d in dirs:
|
||||
if(os.path.isfile(d)):
|
||||
deffile=True
|
||||
if os.path.isfile(d):
|
||||
deffile = True
|
||||
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
|
||||
asdir = os.listdir(path + "/" + d)
|
||||
for a in asdir:
|
||||
if(os.path.isfile(path + "/" + d + "/" +a)):
|
||||
as_file=True
|
||||
if(as_file==False):
|
||||
if os.path.isfile(path + "/" + d + "/" + a):
|
||||
as_file = True
|
||||
if not as_file:
|
||||
as_bad = d
|
||||
break
|
||||
if(as_file==False):
|
||||
if not as_file:
|
||||
print("Assignment '" + as_bad + "' does not have a default file!")
|
||||
return False
|
||||
|
||||
if(deffile==False):
|
||||
if not deffile:
|
||||
print("Need a default file in the " + path + " Directory!")
|
||||
return False
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def checkInDB(self, path):
|
||||
n = path.split("/")
|
||||
n = n[len(n)-1]
|
||||
n = path.split("/")
|
||||
n = n[len(n) - 1]
|
||||
for c in self.classes:
|
||||
if(n == c['name']):
|
||||
if n == c['name']:
|
||||
return True
|
||||
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):
|
||||
cname = path.split("/")
|
||||
cname = cname[len(cname)-1]
|
||||
cname = cname[len(cname) - 1]
|
||||
for c in self.classes:
|
||||
if c == cname:
|
||||
print(cname + " already exists.")
|
||||
return
|
||||
if (self.checkClass(path)):
|
||||
if self.checkClass(path):
|
||||
cpath = self.username + "/" + cname
|
||||
data = {
|
||||
"name": cname,
|
||||
"repo": "",
|
||||
"path": cpath,
|
||||
"teacher": self.username,
|
||||
"owner":self.id
|
||||
"owner": self.id
|
||||
}
|
||||
#make class instance in db
|
||||
# make class instance in db
|
||||
postDB(data, 'http://127.0.0.1:8000/api/classes/')
|
||||
self.classes.append(cname)
|
||||
#add to instance
|
||||
#upate self.classes
|
||||
# add to instance
|
||||
# update self.classes
|
||||
data = {
|
||||
'classes':self.classes
|
||||
'classes': self.classes
|
||||
}
|
||||
print(self.username)
|
||||
print(patchDB(data, 'http://127.0.0.1:8000/api/teachers/' + self.username + "/"))
|
||||
|
||||
#make a new class from scratch
|
||||
#subject: string, assignments: list
|
||||
#class name must be: <subject>_<ion_user>
|
||||
# make a new class from scratch
|
||||
# subject: string, assignments: list
|
||||
# class name must be: <subject>_<ion_user>
|
||||
def makeClass(self, cname):
|
||||
#check if class exists
|
||||
# check if class exists
|
||||
path = self.username + "/" + cname
|
||||
isclass = False
|
||||
acourses = getDB("http://127.0.0.1:8000/api/classes/")['results']
|
||||
for c in acourses:
|
||||
if c['name'] == cname:
|
||||
isclass=True
|
||||
isclass = True
|
||||
break
|
||||
if(os.path.exists(path) or isclass):
|
||||
if os.path.exists(path) or isclass:
|
||||
print("Class already exists: " + cname)
|
||||
if(isclass):
|
||||
if isclass:
|
||||
print("Class already exists in Database")
|
||||
return
|
||||
else:
|
||||
if((("_" + self.username) in cname) == False):
|
||||
print("class name must be: "+ cname + "_" + self.username)
|
||||
if not (("_" + self.username) in cname):
|
||||
print("class name must be: " + cname + "_" + self.username)
|
||||
return
|
||||
cdir = os.getcwd()
|
||||
os.mkdir(path)
|
||||
f=open(path + "/README.md", "w")
|
||||
f = open(path + "/README.md", "w")
|
||||
f.close()
|
||||
#push to remote repo
|
||||
# push to remote repo
|
||||
# os.chdir(path)
|
||||
# for a in assignments:
|
||||
|
||||
|
||||
# os.mkdir(a)
|
||||
# f=open(a + "/instructions.txt", "w")
|
||||
# f.close()
|
||||
# os.chdir(cdir)
|
||||
|
||||
self.addClass(path)
|
||||
|
||||
|
||||
def deleteClass(self, path):
|
||||
if(os.path.exists(path) == False):
|
||||
if not os.path.exists(path):
|
||||
print(path + " does not exist locally.")
|
||||
resp = input("Do you want to delete " + path + " from the SkoolOS system? (y/N) ")
|
||||
if(resp != 'y'):
|
||||
if resp != 'y':
|
||||
return
|
||||
|
||||
cname = path.split("/")
|
||||
cname = cname[len(cname)-1]
|
||||
cname = cname[len(cname) - 1]
|
||||
repo = ''
|
||||
print("DELETE: " + self.classes[i]['name'])
|
||||
for i in range(len(self.classes)):
|
||||
c = self.classes[i]
|
||||
if(c == cname):
|
||||
if c == cname:
|
||||
del self.classes[i]
|
||||
# data={
|
||||
# 'classes':self.classes,
|
||||
|
@ -233,94 +274,95 @@ class Teacher:
|
|||
# print(patchDB(data, self.url))
|
||||
delDB("http://127.0.0.1:8000/api/classes/" + cname + "/")
|
||||
break
|
||||
|
||||
#remove locally
|
||||
|
||||
# remove locally
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
except:
|
||||
pass
|
||||
|
||||
#remove from student directories
|
||||
|
||||
# remove from student directories
|
||||
|
||||
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):
|
||||
r = requests.get(url="http://127.0.0.1:8000/api/students/" + student + "/",
|
||||
auth=('raffukhondaker', 'hackgroup1'))
|
||||
if r.status_code != 200:
|
||||
return False
|
||||
return True
|
||||
|
||||
def reqStudent(self, sname, cname):
|
||||
if(self.isStudent(sname) == False):
|
||||
if not self.isStudent(sname):
|
||||
print(sname + " does not exist.")
|
||||
return False
|
||||
course = getDB("http://127.0.0.1:8000/api/classes/" + cname)
|
||||
if(sname in str(course['unconfirmed'])):
|
||||
print (sname + " already requested.")
|
||||
if sname in str(course['unconfirmed']):
|
||||
print(sname + " already requested.")
|
||||
return True
|
||||
if(sname in str(course['confirmed'])):
|
||||
print (sname + " alredy enrolled.")
|
||||
if sname in str(course['confirmed']):
|
||||
print(sname + " already enrolled.")
|
||||
return False
|
||||
|
||||
|
||||
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
|
||||
try:
|
||||
if(student['added_to']==""):
|
||||
student['added_to']=course['name']
|
||||
if student['added_to'] == "":
|
||||
student['added_to'] = course['name']
|
||||
else:
|
||||
student['added_to']=student['added_to']+ "," + course['name']
|
||||
student['added_to'] = student['added_to'] + "," + course['name']
|
||||
except:
|
||||
print(sname + " does not exist.")
|
||||
return False
|
||||
print(student['added_to'])
|
||||
data={
|
||||
'added_to':student['added_to'],
|
||||
data = {
|
||||
'added_to': student['added_to'],
|
||||
}
|
||||
student = patchDB(data, "http://localhost:8000/api/students/" + student['ion_user'] + "/")
|
||||
student = getDB( "http://localhost:8000/api/students/" + (sname)+ "/")
|
||||
if(course['unconfirmed']==[]):
|
||||
course['unconfirmed']=student['ion_user']
|
||||
student = getDB("http://localhost:8000/api/students/" + sname + "/")
|
||||
if not course['unconfirmed']:
|
||||
course['unconfirmed'] = student['ion_user']
|
||||
else:
|
||||
course['unconfirmed']=course['unconfirmed'].append(student['ion_user'])
|
||||
course['unconfirmed'] = course['unconfirmed'].append(student['ion_user'])
|
||||
cinfo = {
|
||||
"unconfirmed": course['unconfirmed']
|
||||
}
|
||||
print(cinfo)
|
||||
patchDB(cinfo, "http://localhost:8000/api/classes/" + course['name'] + "/")
|
||||
return True
|
||||
|
||||
#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
|
||||
|
||||
# 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
|
||||
def addStudent(self, sname, cname):
|
||||
if(self.isStudent(sname) == False):
|
||||
if not self.isStudent(sname):
|
||||
print(sname + " does not exist.")
|
||||
return False
|
||||
|
||||
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
|
||||
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")
|
||||
return True
|
||||
if((cname in student['added_to']) == True or (cname in student['classes']) == False):
|
||||
print(student['ion_user']+ " has not confirmed class yet")
|
||||
if (cname in student['added_to']) or not (cname in student['classes']):
|
||||
print(student['ion_user'] + " has not confirmed class yet")
|
||||
return False
|
||||
if((student['ion_user'] in course['unconfirmed']) == False):
|
||||
if not (student['ion_user'] in 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
|
||||
|
||||
#git clone and make student/class directories
|
||||
|
||||
# git clone and make student/class directories
|
||||
cdir = os.getcwd()
|
||||
cpath = self.username + "/" + cname
|
||||
path = self.username + "/Students/" + cname
|
||||
spath = self.username + "/Students/" + cname + "/" + student['ion_user']
|
||||
if(os.path.isdir(path) == False):
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
if(os.path.isdir(spath) == False):
|
||||
if not os.path.isdir(spath):
|
||||
os.chdir(path)
|
||||
command("git clone " + student['repo'])
|
||||
os.chdir(cdir)
|
||||
|
||||
#push to git
|
||||
# push to git
|
||||
os.chdir(spath)
|
||||
command('git checkout ' + cname)
|
||||
command('git pull origin ' + cname)
|
||||
|
@ -332,15 +374,15 @@ class Teacher:
|
|||
command('git push -u origin ' + cname)
|
||||
os.chdir(cdir)
|
||||
|
||||
if(course['confirmed']==[]):
|
||||
course['confirmed']=student['ion_user']
|
||||
if not course['confirmed']:
|
||||
course['confirmed'] = student['ion_user']
|
||||
else:
|
||||
course['confirmed'].append(student['ion_user'])
|
||||
|
||||
#only 1 pereson on confirmeed
|
||||
if(len(course['unconfirmed']) == 1):
|
||||
course['unconfirmed']=[]
|
||||
#mutiple
|
||||
# only 1 pereson on confirmeed
|
||||
if len(course['unconfirmed']) == 1:
|
||||
course['unconfirmed'] = []
|
||||
# mutiple
|
||||
else:
|
||||
course['unconfirmed'].remove(student['ion_user'])
|
||||
|
||||
|
@ -351,34 +393,34 @@ class Teacher:
|
|||
print(putDB(course, "http://localhost:8000/api/classes/" + course['name'] + "/"))
|
||||
return True
|
||||
|
||||
#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):
|
||||
unconf = []
|
||||
for i in range(len(array)):
|
||||
a = array[i]
|
||||
if(self.addStudent(a, cname) == False):
|
||||
if not self.addStudent(a, cname):
|
||||
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):
|
||||
parts = path.split("/")
|
||||
aname = parts[len(parts)-1]
|
||||
oname = aname + "_" + course
|
||||
aname = parts[len(parts) - 1]
|
||||
oname = aname + "_" + course
|
||||
|
||||
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.")
|
||||
return False
|
||||
if((parts[1] in str(self.classes)) == False):
|
||||
if not (parts[1] in str(self.classes)):
|
||||
print("Not in valid class directory")
|
||||
return False
|
||||
#parts of assignment name (Essay1, APLit)
|
||||
# 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)
|
||||
for folder in ar:
|
||||
if len(folder) == 0:
|
||||
|
@ -393,25 +435,25 @@ class Teacher:
|
|||
except:
|
||||
print("Due-date format is incorrect")
|
||||
return False
|
||||
|
||||
|
||||
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.")
|
||||
return False
|
||||
print(course['assignments'])
|
||||
print(aname)
|
||||
#################### 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")
|
||||
return True
|
||||
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
|
||||
cdir = os.getcwd()
|
||||
for st in slist:
|
||||
if st in str(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)
|
||||
spath = os.path.join(os.getcwd() + "/" + self.username + "/Students/" + course['name'], st)
|
||||
if not os.path.exists(spath + "/" + aname):
|
||||
os.mkdir(spath + "/" + aname)
|
||||
print(st)
|
||||
print(copy_tree(path, spath + "/" + aname))
|
||||
os.chdir(spath)
|
||||
|
@ -423,20 +465,20 @@ class Teacher:
|
|||
os.chdir(cdir)
|
||||
else:
|
||||
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):
|
||||
|
||||
# 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': oname,
|
||||
'path':path,
|
||||
'classes':course['name'],
|
||||
'teacher':self.username,
|
||||
'due_date':due
|
||||
'path': path,
|
||||
'classes': course['name'],
|
||||
'teacher': self.username,
|
||||
'due_date': due
|
||||
}
|
||||
postDB(ass, 'http://127.0.0.1:8000/api/assignments/')
|
||||
course['assignments'].append(oname)
|
||||
|
||||
|
||||
cinfo = {
|
||||
"assignments": course['assignments'],
|
||||
}
|
||||
|
@ -445,21 +487,21 @@ class Teacher:
|
|||
else:
|
||||
print("Assignment already addedd")
|
||||
return True
|
||||
|
||||
#try to avoid
|
||||
#copy modified assignments to student directories
|
||||
|
||||
# try to avoid
|
||||
# copy modified assignments to student directories
|
||||
def updateAssignment(self, path, course, due):
|
||||
parts = path.split("/")
|
||||
aname = parts[len(parts)-1]
|
||||
oname=aname + "_" + course
|
||||
if(os.path.isdir(path) == False):
|
||||
aname = parts[len(parts) - 1]
|
||||
oname = aname + "_" + course
|
||||
if not os.path.isdir(path):
|
||||
print(path + " is not an assignment.")
|
||||
return
|
||||
try:
|
||||
if(due != None or due == ""):
|
||||
if due != None or due == "":
|
||||
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
|
||||
d = {
|
||||
'due_date':due,
|
||||
'due_date': due,
|
||||
}
|
||||
print(patchDB(d, 'http://localhost:8000/api/assignments/' + oname + "/"))
|
||||
print("Due-date changed " + due)
|
||||
|
@ -471,23 +513,23 @@ class Teacher:
|
|||
cdir = os.getcwd()
|
||||
for st in slist:
|
||||
if st in 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)
|
||||
print(st)
|
||||
print(copy_tree(path, spath + "/" + aname))
|
||||
os.chdir(spath)
|
||||
#command('git checkout ' + course['name'])
|
||||
# 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
|
||||
# pull student's work, no modifications
|
||||
def getStudents(self, course):
|
||||
if((course in self.sclass) == False):
|
||||
if not (course in self.sclass):
|
||||
print(course + " not a class.")
|
||||
return
|
||||
path = self.username + "/Students/" + course
|
||||
path = self.username + "/Students/" + course
|
||||
slist = os.listdir(path)
|
||||
cdir = os.getcwd()
|
||||
for st in slist:
|
||||
|
@ -499,7 +541,7 @@ class Teacher:
|
|||
def getCommits(self, student, course, commits):
|
||||
course = getDB("http://127.0.0.1:8000/api/classes/" + course)
|
||||
try:
|
||||
if((student in course['confirmed']) == False):
|
||||
if not (student in course['confirmed']):
|
||||
print("Student not in class")
|
||||
return
|
||||
except:
|
||||
|
@ -508,19 +550,20 @@ class Teacher:
|
|||
|
||||
cdir = os.getcwd()
|
||||
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
|
||||
process = subprocess.Popen(['git', 'log', '-' + str(commits), course['name']], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
p=process.poll()
|
||||
process = subprocess.Popen(['git', 'log', '-' + str(commits), course['name']], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
p = process.poll()
|
||||
output = process.communicate()[0].decode('utf-8').split('\n\n')
|
||||
months = ['Jan', 'Feb', 'Mar', "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
|
||||
fout = []
|
||||
for i in range(len(output)):
|
||||
if("Date" in output[i]):
|
||||
if "Date" in output[i]:
|
||||
c = output[i].split("\n")
|
||||
for k in range(len(c)):
|
||||
temp = []
|
||||
if('commit' in c[k]):
|
||||
if 'commit' in c[k]:
|
||||
c[k] = c[k].replace('commit', '').strip()
|
||||
elif('Date:' in c[k]):
|
||||
elif 'Date:' in c[k]:
|
||||
c[k] = c[k].replace('Date:', '').strip()
|
||||
date = c[2].split(" ")
|
||||
times = date[3].split(":")
|
||||
|
@ -529,38 +572,40 @@ class Teacher:
|
|||
if date[1] == months[m]:
|
||||
mon = m
|
||||
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')
|
||||
fout.append([c[0],d1])
|
||||
#output[i] = [c[0], d1]
|
||||
#print(output[i])
|
||||
# datetime1 = datetime.strptime('07/11/2019 02:45PM', '%m/%d/%Y %I:%M%p')
|
||||
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]
|
||||
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()
|
||||
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)
|
||||
|
||||
|
||||
'''
|
||||
assignment = {
|
||||
'name': English11_eharris1,
|
||||
'due_date': 2020-06-11 16:58:33.383124
|
||||
}
|
||||
'''
|
||||
#check if assignment changed after due date
|
||||
# check if assignment changed after due date
|
||||
|
||||
def afterSubmit(self, course, assignment, student):
|
||||
|
||||
|
||||
assignment = getDB("http://127.0.0.1:8000/api/assignments/" + assignment)
|
||||
# assignment = {
|
||||
# 'name': assignment,
|
||||
|
@ -573,14 +618,14 @@ class Teacher:
|
|||
cdir = os.getcwd()
|
||||
os.chdir(self.username + "/Students/" + course + "/" + student)
|
||||
for l in log:
|
||||
process = subprocess.Popen(['git', 'show', l[0]], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
p=process.poll()
|
||||
process = subprocess.Popen(['git', 'show', l[0]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = process.poll()
|
||||
output = process.communicate()[0].decode('utf-8')
|
||||
if(assignment['name'] in output):
|
||||
if assignment['name'] in output:
|
||||
print(l[1])
|
||||
print(assignment['due_date'])
|
||||
print("--------------")
|
||||
if(l[1] > assignment['due_date']):
|
||||
if l[1] > assignment['due_date']:
|
||||
print("LATE")
|
||||
os.chdir(cdir)
|
||||
return True
|
||||
|
@ -594,12 +639,12 @@ class Teacher:
|
|||
|
||||
# data = getTeacher("eharris1")
|
||||
# t = Teacher(data)
|
||||
#t.makeClass("APLit_eharris1")
|
||||
# t.makeClass("APLit_eharris1")
|
||||
# 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)
|
||||
#t.addStudent('2022rkhondak', 'APLit_eharris1')
|
||||
# ar = ['2022rkhondak','2022inafi','2023rumareti']
|
||||
# extra = t.reqAddStudentList(ar, "APLit_eharris1")
|
||||
# print(extra)
|
||||
# t.addStudent('2022rkhondak', 'APLit_eharris1')
|
||||
# t.getChanges('2022rkhondak','APLit_eharris1', 10)
|
||||
|
||||
'''
|
||||
|
@ -614,4 +659,3 @@ TO-DO
|
|||
- check differences between commits
|
||||
- check if student changes file after submissionn deadline
|
||||
'''
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user