Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
Rushil Umaretiya 2020-06-12 15:54:44 -04:00
commit 5592c29208
17 changed files with 506 additions and 364 deletions

2
CLI/back.py Normal file
View File

@ -0,0 +1,2 @@
import os
os.spawnl(os.P_DETACH, 'some_long_running_command')

View File

@ -12,7 +12,7 @@ import pyperclip
#get teacher info from api
def getStudent(ion_user):
URL = "http://127.0.0.1:8000/students/" + 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()
@ -56,6 +56,7 @@ def command(command):
p=process.poll()
output = process.communicate()[0]
print(output.decode('utf-8'))
return output.decode('utf-8')
####################################################################################################################################
@ -68,7 +69,7 @@ class Student:
self.last_name=data['last_name']
self.git=data['git']
self.username=data['ion_user']
self.url= "http://127.0.0.1:8000/students/" + self.username + "/"
self.url= "http://127.0.0.1:8000/api/students/" + self.username + "/"
self.email = data['email']
self.grade = data['grade']
self.student_id=data['student_id']
@ -86,7 +87,7 @@ class Student:
pass
classes=[]
for c in cid:
url = "http://127.0.0.1:8000/classes/" + str(c) + "/"
url = "http://127.0.0.1:8000/api/classes/" + str(c) + "/"
classes.append(getDB(url))
self.classes = classes
@ -104,7 +105,7 @@ class Student:
pass
nclasses=[]
for c in nid:
url = "http://127.0.0.1:8000/classes/" + str(c) + "/"
url = "http://127.0.0.1:8000/api/classes/" + str(c) + "/"
nclasses.append(getDB(url))
self.new = nclasses
@ -120,8 +121,6 @@ class Student:
print(url)
os.system(url)
cdir = os.getcwd()
os.mkdir(self.username)
os.chdir(self.username)
command('git clone https://github.com/' + self.git + '/' + self.username + '.git')
os.chdir(self.username)
command('git checkout master')
@ -148,45 +147,75 @@ class Student:
print(putDB(data, self.url))
print("Synced to " + self.username)
#update API and Github, all assignments / classes
def update(self):
cdir = os.getcwd()
os.chdir(self.username)
for c in self.classes:
data = getDB("http://127.0.0.1:8000/classes/" + str(c['id']))
os.chdir(self.username + "/" + data['name'])
command("git checkout -b " + data['name'])
command("git add " + data['name'])
print("UPDATING CLASS: " + str(c['name']))
data = getDB("http://127.0.0.1:8000/api/classes/" + str(c['name']))
# command("git checkout master")
command("git checkout " + data['name'])
command("git add .")
command("git commit -m " + data['name'])
command("git push -u origin " + data['name'])
command("git pull origin " + data['name'])
command("git push -u origin " + data['name'])
command("git checkout master")
os.chdir(cdir)
for c in self.new:
self.addClass(str(c['id']))
print("ADDING CLASS: " + str(c['name']))
self.addClass(str(c['name']))
command("git checkout master")
#class name format: <course-name>_<ion_user>
#add classes from 'new' field
def addClass(self, cid):
if((cid in self.snew) == False):
if((cid in self.sclass) == True):
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.")
else:
return None
if((cid in self.sclass) or (self.username in data['unconfirmed']) == False):
print("Not added by teacher yet.")
return None
data = getDB('http://127.0.0.1:8000/classes/'+ str(cid))
#add class teacher as cocllaborator to student repo
print(os.getcwd())
pwd= input("Enter Github password: ")
tgit = getDB("http://127.0.0.1:8000/teachers/" + data['teacher'] + "/")['git']
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 + "'"
print(url)
os.system(url)
data['unconfirmed'] = data['unconfirmed'].replace("," + self.username, "")
data['unconfirmed'] = data['unconfirmed'].replace(self.username, "")
data['confirmed'] = data['confirmed'] + "," + self.username
if(data['confirmed'][0] == ','):
data['confirmed'] = data['confirmed'][1:]
print(data['confirmed'])
print(putDB(data, 'http://127.0.0.1:8000/classes/'+ str(cid) + "/"))
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)
#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>
os.chdir(cdir)
# data['unconfirmed'] = data['unconfirmed'].replace("," + self.username, "")
# data['unconfirmed'] = data['unconfirmed'].replace(self.username, "")
# data['confirmed'] = data['confirmed'] + "," + self.username
# if(data['confirmed'][0] == ','):
# data['confirmed'] = data['confirmed'][1:]
# 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'
@ -194,40 +223,22 @@ class Student:
self.classes.append(data)
if(len(self.sclass)==0):
self.sclass = data['id']
self.sclass = data['name']
else:
self.sclass = self.sclass + "," + str(data['id'])
self.sclass = self.sclass + "," + str(data['name'])
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)
command("git checkout -b " + data['name'])
command("touch welcome.txt")
command("git add welcome.txt")
command("git commit -m initial")
command("git push origin " + data['name'])
#git clone --single-branch --branch <branchname> <remote-repo>
os.chdir(cdir)
shutil.move(path1, self.username + "/" + data['name'])
#upddate self.new
s=""
nar = ''
snew=""
new = []
for i in range(len(self.new)):
if(self.new[i]['id'] == int(data['id'])):
if(self.new[i]['name'] == data['name']):
del self.new[i]
#recreate sclass field, using ids
for c in self.new:
s = s + str(c['id']) + ","
nar.append(c)
self.snew=s
self.new=nar
snew = snew + str(c['name']) + ","
new.append(getDB("http://127.0.0.1:8000/api/classes/" + str(cid)))
self.snew=snew
self.new=new
break
#update teacher instance in db, classes field
@ -287,8 +298,54 @@ class Student:
'grade':self.grade,
'completed':self.completed
}
#print(putDB(data, "http://127.0.0.1:8000/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()
os.chdir(self.username)
for c in self.classes:
if c['name'] == courses:
command("git checkout " + courses)
print(os.listdir())
return
os.chdir(cdir)
print("Class not found")
return
def exitCLI(self):
self.update()
command("git checkout master")
def submit(self, course, assignment):
cdir = os.getcwd()
os.chdir(self.username)
print(os.getcwd())
command("git add .")
command("git commit -m update")
command('git checkout ' + course)
time.sleep(5)
ass = os.listdir()
inclass = False
for a in ass:
if a == assignment:
inclass = True
break
if(inclass == False):
print(assignment + " not an assignment of " + course)
command('git checkout master')
os.chdir(cdir)
return
command('touch ' + assignment + '/SUBMISSION')
command("git add .")
command("git commit -m submit")
command("git tag " + assignment + "-final")
command("git push -u origin " + course + " --tags")
command('git checkout master')
os.chdir(cdir)
data = getStudent("2022rkhondak")
s = Student(data)
#s.update()
# s.viewClass("English11_eharris1")
s.exitCLI()

View File

@ -1,5 +1,5 @@
import subprocess
import os
import subprocess
import requests
import webbrowser
import pprint
@ -8,13 +8,13 @@ import shutil
import time
import pyperclip
from distutils.dir_util import copy_tree
from datetime import datetime
#git clone student directory ==> <student-id>/classes/assignments
#get teacher info from api
def getTeacher(ion_user):
URL = "http://127.0.0.1:8000/teachers/" + 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()
@ -70,7 +70,7 @@ class Teacher:
self.last_name=data['last_name']
self.git=data['git']
self.username=data['ion_user']
self.url= "http://127.0.0.1:8000/teachers/" + self.username + "/"
self.url= "http://127.0.0.1:8000/api/teachers/" + self.username + "/"
self.email = data['email']
#classes in id form (Example: 4,5)
@ -85,64 +85,19 @@ class Teacher:
pass
classes=[]
for c in cid:
url = "http://127.0.0.1:8000/classes/" + str(c) + "/"
url = "http://127.0.0.1:8000/api/classes/" + str(c) + "/"
classes.append(getDB(url))
self.classes = classes
self.sclass=str(data['classes'])
if(os.path.isdir(self.username)):
if(os.path.isdir(self.username + "/Students")):
print("Synced to " + self.username)
else:
os.mkdir(self.username)
os.makedirs(self.username + "/Students")
#2020-05-11 12:25:00
#update API and Github, all assignments / classes
def update(self):
#lists all classes
ignore=['.git','.DS_Store']
classes = os.listdir(self.username)
for i in ignore:
try:
classes.remove(i)
except:
pass
#list of classes that have been deleted (not with deleteClass)
extra = []
for c in self.classes:
extra.append(c)
for i in range(len(extra)):
e = extra[i]['path']
extra[i] = e
print("Extra: "+str(extra))
print("Local:" + str(classes))
#checks all class directories first
for c in classes:
path = self.username + "/" + c
if(self.checkClass(path) == False):
return
extra.remove(path)
print("Current classes: " + path)
for e in extra:
self.deleteClass(e)
for i in range(len(classes)):
c = classes[i]
path = self.username + "/" + c
#lists all assignments and default files
#if no .git, directory not synced to git or API
if (self.checkInDB(path)==False):
self.addClass(path)
else:
#push to git
loc = os.getcwd()
os.chdir(path)
command('git fetch origin')
command('git pull origin master')
command('git add .')
command('git commit -m "Update"')
command('git push -u origin master')
os.chdir(loc)
#class name format: <course-name>_<ion_user>
@ -211,17 +166,17 @@ class Teacher:
"unconfirmed": ""
}
#make class instance in db
data = postDB(data, 'http://127.0.0.1:8000/classes/')
data = postDB(data, 'http://127.0.0.1:8000/api/classes/')
#add to instance
#upate self.classes
self.classes.append(data)
if(len(self.sclass)==0):
self.sclass = data['id']
self.sclass = data['name']
else:
self.sclass = self.sclass + "," + str(data['id'])
self.sclass = self.sclass + "," + str(data['name'])
#update teacher instance in db, classes field
data={
teacher={
'first_name':self.first_name,
'last_name':self.last_name,
'git':self.git,
@ -230,9 +185,9 @@ class Teacher:
'classes':self.sclass,
'email':self.email
}
putDB(data, self.url)
putDB(teacher, self.url)
return data
return teacher
#make a new class from scratch
@ -241,8 +196,16 @@ class Teacher:
def makeClass(self, cname, assignments):
#check if class exists
path = self.username + "/" + cname
if(os.path.exists(path)):
isclass = False
acourses = getDB("http://127.0.0.1:8000/api/classes/")['results']
for c in acourses:
if c['name'] == cname:
isclass=True
break
if(os.path.exists(path) or isclass):
print("Class already exists: " + cname)
if(isclass):
print("Class already exists in Database")
return
else:
if((("_" + self.username) in cname) == False):
@ -254,11 +217,12 @@ class Teacher:
f.close()
#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)
# for a in assignments:
# os.mkdir(a)
# f=open(a + "/instructions.txt", "w")
# f.close()
# os.chdir(cdir)
data = self.addClass(path)
return data
@ -272,22 +236,16 @@ class Teacher:
cname = path.split("/")
cname = cname[len(cname)-1]
cid = None
repo = ''
for c in self.classes:
if cname == c['name']:
cid = str(c['id'])
repo = c['repo']
#remove from api
for i in range(len(self.classes)):
if(self.classes[i]['id'] == int(cid)):
print("DELETE: " + self.classes[i]['name'])
for i in range(len(self.classes)):
c = self.classes[i]
if(c['name'] == cname):
del self.classes[i]
s=""
#recreate sclass field, using ids
for c in self.classes:
s = s + str(c['id']) + ","
s = s + str(c['name']) + ","
print(s)
s = s[:-1]
print(s)
@ -301,7 +259,7 @@ class Teacher:
'email':self.email
}
print(putDB(data, self.url))
delDB("http://127.0.0.1:8000/classes/" + cid + "/")
delDB("http://127.0.0.1:8000/api/classes/" + cname + "/")
break
#remove locally
@ -312,107 +270,305 @@ class Teacher:
#remove from student directories
#make student repo by student id
def reqStudent(self, student, classes):
cid = None
for c in self.classes:
print(c['name'])
if classes == c['name']:
cid = str(c['id'])
data1 = getDB("http://127.0.0.1:8000/classes/" + cid)
if(student in data1['unconfirmed']):
print (student + " already requested.")
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):
return False
return True
def reqStudent(self, sname, cname):
if(self.isStudent(sname) == False):
print(sname + " does not exist.")
return
if(student in data1['confirmed']):
print (student + " alredy enrolled.")
break
if(cid==None):
print(classes +" does not exist.")
course = getDB("http://127.0.0.1:8000/api/classes/" + cname)
if(sname in course['unconfirmed']):
print (sname + " already requested.")
return
if(sname in course['confirmed']):
print (sname + " alredy enrolled.")
return
data = getDB("http://127.0.0.1:8000/students/" + student)
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
try:
if(data['added_to']==""):
data['added_to']=cid
if(student['added_to']==""):
student['added_to']=course['name']
else:
data['added_to']=data['added_to']+ "," + cid
student['added_to']=student['added_to']+ "," + course['name']
except:
print(student + " does not exist.")
print(sname + " does not exist.")
return
print(data['added_to'])
d={
'first_name':data["first_name"],
'last_name':data["last_name"],
'git':data["git"],
'ion_user':data["ion_user"],
'student_id':data["student_id"],
'added_to':data['added_to'],
'classes':data["classes"],
'email':data["email"],
'grade':data["grade"],
'completed':data["completed"],
'repo':data["repo"]
print(student['added_to'])
s={
'first_name':student["first_name"],
'last_name':student["last_name"],
'git':student["git"],
'ion_user':student["ion_user"],
'student_id':student["student_id"],
'added_to':student['added_to'],
'classes':student["classes"],
'email':student["email"],
'grade':student["grade"],
'completed':student["completed"],
'repo':student["repo"]
}
print(putDB(d, data['url']))
data1 = getDB("http://127.0.0.1:8000/classes/" + cid)
if(data1['unconfirmed']==""):
data1['unconfirmed']=data['ion_user']
student = putDB(s, student['url'])
if(course['unconfirmed']==""):
course['unconfirmed']=student['ion_user']
else:
data1['unconfirmed']=data1['unconfirmed']+ "," + data['ion_user']
d = {
"name": classes,
course['unconfirmed']=course['unconfirmed']+ "," + student['ion_user']
cinfo = {
"name": course['name'],
"repo": "",
"path": self.username + "/" + classes,
"path": self.username + "/" + course['name'],
"teacher": self.username,
"assignments": "",
"default_file": "",
"confirmed": data1["confirmed"],
"unconfirmed": data1['unconfirmed']
"confirmed": course["confirmed"],
"unconfirmed": course['unconfirmed']
}
print(putDB(d, data1['url']))
print(putDB(cinfo, course['url']))
#confirmed students
def addStudent(self, student, classes):
for c in self.classes:
if(c['name'] == classes):
cid = c['id']
data = getDB("http://127.0.0.1:8000/classes/" + str(cid))
if(student in data['confirmed']):
print("Student already added to " + classes)
#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):
print(sname + " does not exist.")
return
if(student in data['unconfirmed']):
print("Student has been enrolled in " + classes)
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
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):
print("Student already added to class")
#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):
os.makedirs(path)
if(os.path.isdir(spath) == False):
os.chdir(path)
command("git clone " + student['repo'])
os.chdir(cdir)
#push to git
copy_tree(cpath, path + "/" + student['ion_user'])
os.chdir(spath)
command('git checkout ' + cname)
command('git pull origin ' + cname)
command('git add .')
command('git commit -m Hello')
command('git push -u origin ' + cname)
command('git checkout master')
if(course['confirmed']==""):
course['confirmed']=student['ion_user']
else:
course['confirmed']=course['confirmed']+ "," + student['ion_user']
cinfo = {
"name": course['name'],
"repo": "",
"path": course['path'],
"teacher": course['name'],
"assignments": "",
"default_file": "",
"confirmed": course["confirmed"],
"unconfirmed": course['unconfirmed']
}
print(putDB(cinfo, course['url']))
#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]
if(os.path.isdir(path) == 0 or len(parts) < 3) or aname in self.sclass:
print("Not valid path.")
return
if((parts[1] in self.sclass) == False):
print("Not in valid class directory")
return
ar = [x[2] for x in os.walk(path)]
print(ar)
for folder in ar:
if len(folder) == 0:
print("Assignment is completely empty, need a file.")
return
aname = parts[len(parts)-1]
p1 = course.split("_")[0]
if(p1 in aname == False):
print(aname + "incorrectly formated: must be " + aname + "_" + p1 + ".")
return
try:
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
except:
print("Due-date format is incorrect")
return
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)
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
cdir = os.getcwd()
for st in slist:
if st in course['confirmed']:
spath = os.path.join(os.getcwd() + "/" + self.username + "/Students/" + course['name'], st)
if(os.path.exists(spath + "/" + aname) == False):
os.mkdir(spath + "/" + aname)
print(st)
print(copy_tree(path, spath + "/" + aname))
os.chdir(spath)
command('git checkout ' + course['name'])
command('git pull origin ' + course['name'])
command('git add .')
command('git commit -m Hello')
command('git push -u origin ' + course['name'])
os.chdir(cdir)
else:
print(st + " already has assignment")
#try to avoid
#copy modified assignments to student directories
def updateAssignment(self, path, course, due):
if(os.path.isdir(path) == False):
print(path + " is not an assignment.")
return
try:
if(due != None or due == ""):
datetime.strptime(due, '%Y-%m-%d %H:%M:%S.%f')
except:
print("Due-date format is incorrect")
return
input()
parts = path.split("/")
aname = parts[len(parts)-1]
course = getDB("http://127.0.0.1:8000/api/classes/" + course)
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
cdir = os.getcwd()
for st in slist:
if st in course['confirmed']:
spath = os.path.join(os.getcwd() + "/" + self.username + "/Students/" + course['name'], st)
if(os.path.exists(spath + "/" + aname) == False):
os.mkdir(spath + "/" + aname)
print(st)
print(copy_tree(path, spath + "/" + aname))
os.chdir(spath)
command('git checkout ' + course['name'])
command('git pull origin ' + course['name'])
command('git add .')
command('git commit -m Hello')
command('git push -u origin ' + course['name'])
os.chdir(cdir)
else:
print(st + " already has assignment")
#pull student's work, no modifications
def getStudents(self, course):
if((course in self.sclass) == False):
print(course + " not a class.")
return
path = self.username + "/Students/" + course
slist = os.listdir(path)
cdir = os.getcwd()
for st in slist:
os.chdir(path + "/" + st)
command('git checkout ' + course)
command('git pull origin ' + course)
os.chdir(cdir)
def getHistory(self, student, course):
course = getDB("http://127.0.0.1:8000/api/classes/" + course)
try:
if((student in course['confirmed']) == False):
print("Student not in class")
return
except:
print("class does not exist")
return
cdir = os.getcwd()
cpath = self.username + "/" + classes
path = self.username + "/Students/" + classes
if(os.path.isdir(path) == False):
os.makedirs(path)
os.chdir(path)
student = getDB("http://127.0.0.1:8000/students/" + student)
command("git clone " + student['repo'])
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
process = subprocess.Popen(['git', 'log', '-30', 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"]
for i in range(len(output)):
if("Date" in output[i]):
c = output[i].split("\n")
for k in range(len(c)):
temp = []
if('commit' in c[k]):
c[k] = c[k].replace('commit', '').strip()
elif('Date:' in c[k]):
c[k] = c[k].replace('Date:', '').strip()
date = c[2].split(" ")
times = date[3].split(":")
mon = -1
for m in range(len(months)):
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')
output[i] = [c[0], d1]
os.chdir(cdir)
copy_tree(cpath, path + "/" + student['ion_user'])
os.chdir(self.username + "/Students/" + classes + "/" + student['ion_user'])
return output
command('git add .')
command('git checkout -b ' + classes)
command('git commit -m Hello')
command('git push -u origin ' + classes)
'''
assignment = {
'name': English11_eharris1,
'due_date': 2020-06-11 16:58:33.383124
}
'''
#check if assignment changed after due date
def afterSubmit(self, course, assignment, student):
'''
assignment = getDB()
'''
assignment = {
'name': assignment,
'due_date': "2020-04-11 16:58:33.383124",
'classes':course
}
log = self.getHistory(student, course)
assignment['due_date'] = datetime.strptime(assignment['due_date'], '%Y-%m-%d %H:%M:%S.%f')
late = False
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()
output = process.communicate()[0].decode('utf-8')
if(assignment['name'] in output):
print(l[1])
print(assignment['due_date'])
print("--------------")
if(l[1] > assignment['due_date']):
print("LATE")
os.chdir(cdir)
return True
print("On time")
os.chdir(cdir)
return False
def comment(self):
print("heheheh")
def addAssignment():
print()
def updateAssignnment():
print()
data = getTeacher("mlauerbach")
data = getTeacher("eharris1")
t = Teacher(data)
t.makeClass("Math5_mlauerbach", ["Week1_HW", "Test1"])
input()
t.reqStudent("2022rkhondak", "Math5_mlauerbach")
t.addStudent("2022rkhondak", "Math5_mlauerbach")
t.getStudents("English11_eharris1")

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.7 on 2020-06-09 02:03
# Generated by Django 3.0.7 on 2020-06-12 01:34
from django.db import migrations, models
@ -14,10 +14,9 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('name', models.CharField(max_length=100, primary_key=True, serialize=False)),
('due_date', models.DateTimeField()),
('files', models.CharField(max_length=100)),
('files', models.CharField(blank=True, default='', max_length=100)),
('path', models.CharField(max_length=100)),
('classes', models.CharField(max_length=100)),
('teacher', models.CharField(max_length=100)),
@ -26,13 +25,14 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Classes',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('name', models.CharField(max_length=100, primary_key=True, serialize=False)),
('repo', models.URLField(default='')),
('path', models.CharField(default='', max_length=100)),
('teacher', models.CharField(default='', max_length=100)),
('assignments', models.CharField(default='', max_length=100)),
('default_file', models.CharField(default='', max_length=100)),
('confirmed', models.TextField(blank=True, default='')),
('unconfirmed', models.TextField(blank=True, default='')),
],
),
migrations.CreateModel(
@ -46,17 +46,6 @@ class Migration(migrations.Migration):
('teacher', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='Teacher',
fields=[
('created', models.DateTimeField(auto_now_add=True)),
('first_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
('classes', models.CharField(default='', max_length=100)),
('ion_user', models.CharField(max_length=100, primary_key=True, serialize=False)),
('git', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='Student',
fields=[
@ -65,11 +54,25 @@ class Migration(migrations.Migration):
('last_name', models.CharField(max_length=100)),
('student_id', models.IntegerField()),
('ion_user', models.CharField(max_length=100, primary_key=True, serialize=False)),
('webmail', models.EmailField(blank=True, max_length=254)),
('email', models.CharField(blank=True, default='', max_length=100)),
('grade', models.IntegerField()),
('git', models.CharField(max_length=100)),
('repo', models.URLField(default='')),
('classes', models.ManyToManyField(default='', to='api.Classes')),
('repo', models.URLField(blank=True, default='')),
('classes', models.CharField(blank=True, default='', max_length=100)),
('added_to', models.CharField(blank=True, default='', max_length=100)),
('completed', models.TextField(blank=True, default='')),
],
),
migrations.CreateModel(
name='Teacher',
fields=[
('created', models.DateTimeField(auto_now_add=True)),
('first_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
('classes', models.CharField(blank=True, default='', max_length=100)),
('ion_user', models.CharField(max_length=100, primary_key=True, serialize=False)),
('git', models.CharField(max_length=100)),
('email', models.CharField(blank=True, default='', max_length=100)),
],
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 3.0.7 on 2020-06-09 03:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='teacher',
name='classes',
field=models.CharField(blank=True, default='', max_length=100),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.7 on 2020-06-12 01:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='name',
field=models.CharField(max_length=100),
),
migrations.AlterField(
model_name='assignment',
name='path',
field=models.CharField(max_length=100, primary_key=True, serialize=False),
),
]

View File

@ -1,40 +0,0 @@
# Generated by Django 3.0.7 on 2020-06-09 22:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_auto_20200609_0358'),
]
operations = [
migrations.RemoveField(
model_name='student',
name='repo',
),
migrations.RemoveField(
model_name='student',
name='webmail',
),
migrations.AddField(
model_name='student',
name='email',
field=models.CharField(blank=True, default='', max_length=100),
),
migrations.AddField(
model_name='teacher',
name='email',
field=models.CharField(blank=True, default='', max_length=100),
),
migrations.RemoveField(
model_name='student',
name='classes',
),
migrations.AddField(
model_name='student',
name='classes',
field=models.CharField(blank=True, default='', max_length=100),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.7 on 2020-06-12 01:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_auto_20200612_0135'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='name',
field=models.CharField(max_length=100, primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='assignment',
name='path',
field=models.CharField(max_length=100),
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 3.0.7 on 2020-06-09 22:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0003_auto_20200609_2206'),
]
operations = [
migrations.AddField(
model_name='student',
name='added_to',
field=models.CharField(blank=True, default='', max_length=100),
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 3.0.7 on 2020-06-10 01:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0004_student_added_to'),
]
operations = [
migrations.AddField(
model_name='student',
name='completed',
field=models.TextField(blank=True, default=''),
),
]

View File

@ -1,28 +0,0 @@
# Generated by Django 3.0.7 on 2020-06-10 06:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0005_student_completed'),
]
operations = [
migrations.AddField(
model_name='classes',
name='confirmed',
field=models.TextField(blank=True, default=''),
),
migrations.AddField(
model_name='classes',
name='unconfirmed',
field=models.TextField(blank=True, default=''),
),
migrations.AddField(
model_name='student',
name='repo',
field=models.URLField(blank=True, default=''),
),
]

View File

@ -8,10 +8,10 @@ class DefFiles(models.Model):
teacher=models.CharField(max_length=100)
class Assignment(models.Model):
name=models.CharField(max_length=100)
name=models.CharField(max_length=100, primary_key=True)
due_date=models.DateTimeField()
# files = models.ManyToManyField(DefFiles)
files=models.CharField(max_length=100)
files=models.CharField(max_length=100, default="", blank=True)
path=models.CharField(max_length=100)
classes=models.CharField(max_length=100)
teacher=models.CharField(max_length=100)
@ -19,7 +19,7 @@ class Assignment(models.Model):
return '%s' % (self.name)
class Classes(models.Model):
name = models.CharField(max_length=100)
name = models.CharField(primary_key=True, max_length=100)
repo=models.URLField(default="")
path=models.CharField(max_length=100, default="")
teacher=models.CharField(max_length=100, default="")

View File

@ -9,18 +9,18 @@ class DefFilesSerializer(serializers.HyperlinkedModelSerializer):
fields = ['name', 'path','assignment','classes', "teacher",'url', 'id']
class AssignmentSerializer(serializers.HyperlinkedModelSerializer):
permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
#permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
# files = DefFilesSerializer(many=True, read_only=True,allow_null=True)
class Meta:
model = Assignment
fields = ['name', 'due_date', 'url', 'path' , "classes","teacher",'files', 'id']
fields = ['url','name', 'due_date', 'path' , "classes","teacher"]
class ClassesSerializer(serializers.HyperlinkedModelSerializer):
# assignments = AssignmentSerializer(many=True, read_only=True,allow_null=True)
# default_file=DefFilesSerializer(many=True, read_only=True,allow_null=True)
class Meta:
model = Classes
fields = ['url', 'name', 'repo','path', "teacher",'assignments',"default_file",'id', 'confirmed', 'unconfirmed']
fields = ['url', 'name', 'repo','path', "teacher",'assignments',"default_file", 'confirmed', 'unconfirmed']
class StudentSerializer(serializers.HyperlinkedModelSerializer):
# classes = ClassesSerializer(many=True, read_only=True,allow_null=True)