mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
Merge branch 'development' of github.com:Rushilwiz/SkoolOS into development
This commit is contained in:
commit
989d165494
|
@ -1 +0,0 @@
|
|||
Subproject commit 8dca8b78c03fab721e9976a4675e2996802328a7
|
2
CLI/back.py
Normal file
2
CLI/back.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
import os
|
||||
os.spawnl(os.P_DETACH, 'some_long_running_command')
|
256
CLI/s-git-oldd.py
Normal file
256
CLI/s-git-oldd.py
Normal file
|
@ -0,0 +1,256 @@
|
|||
import subprocess
|
||||
import os
|
||||
import requests
|
||||
import webbrowser
|
||||
import pprint
|
||||
import json
|
||||
import shutil
|
||||
import time
|
||||
import pyperclip
|
||||
|
||||
#git clone student directory ==> <student-id>/classes/assignments
|
||||
|
||||
#get teacher info from api
|
||||
def getStudent(ion_user):
|
||||
URL = "http://127.0.0.1:8000/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'))
|
||||
print("GET:" + str(r.status_code))
|
||||
return(r.json())
|
||||
|
||||
def postDB(data, url):
|
||||
r = requests.post(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
print("POST:" + str(r.status_code))
|
||||
return(r.json())
|
||||
|
||||
def putDB(data, url):
|
||||
r = requests.put(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
print("PUT:" + str(r.status_code))
|
||||
return(r.json())
|
||||
|
||||
def delDB(url):
|
||||
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()
|
||||
output = process.communicate()[1]
|
||||
print(output.decode('utf-8'))
|
||||
|
||||
####################################################################################################################################
|
||||
|
||||
#public methods: deleteClass, makeClass, update
|
||||
class Student:
|
||||
def __init__(self, data):
|
||||
# teacher info already stored in API
|
||||
# intitialze fields after GET request
|
||||
self.first_name=data['first_name']
|
||||
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.email = data['email']
|
||||
self.grade = data['grade']
|
||||
self.student_id=data['student_id']
|
||||
self.completed = data['completed']
|
||||
#classes in id form (Example: 4,5)
|
||||
|
||||
#storing actual classes
|
||||
cid=data['classes'].split(",")
|
||||
try:
|
||||
cid.remove('')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cid.remove("")
|
||||
except:
|
||||
pass
|
||||
classes=[]
|
||||
for c in cid:
|
||||
url = "http://127.0.0.1:8000/classes/" + str(c) + "/"
|
||||
classes.append(getDB(url))
|
||||
|
||||
self.classes = classes
|
||||
self.sclass=str(data['classes'])
|
||||
|
||||
#storing added_to classes
|
||||
nid=data['added_to'].split(",")
|
||||
try:
|
||||
nid.remove('')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
nid.remove("")
|
||||
except:
|
||||
pass
|
||||
nclasses=[]
|
||||
for c in nid:
|
||||
url = "http://127.0.0.1:8000/classes/" + str(c) + "/"
|
||||
nclasses.append(getDB(url))
|
||||
|
||||
self.new = nclasses
|
||||
self.snew=str(data['added_to'])
|
||||
if(os.path.isdir(self.username)):
|
||||
print("Synced to " + self.username)
|
||||
else:
|
||||
os.mkdir(self.username)
|
||||
|
||||
|
||||
#update API and Github, all assignments / classes
|
||||
def update(self):
|
||||
#lists all classes
|
||||
ignore=['.DS_Store']
|
||||
classes = os.listdir(self.username)
|
||||
for i in ignore:
|
||||
try:
|
||||
classes.remove(i)
|
||||
except:
|
||||
pass
|
||||
|
||||
for i in range(len(classes)):
|
||||
c = classes[i]
|
||||
path = self.username + "/" + c
|
||||
#lists all assignments and default files
|
||||
#push to git
|
||||
isclass = False
|
||||
for d in os.listdir(path):
|
||||
if(d == '.git'):
|
||||
isclass=True
|
||||
break
|
||||
if(isclass):
|
||||
loc = os.getcwd()
|
||||
os.chdir(path)
|
||||
command('git fetch origin')
|
||||
command('git checkout ' + self.username)
|
||||
command('git add .')
|
||||
command('git commit -m ' + self.username + '-update')
|
||||
command('git push -u origin ' + self.username)
|
||||
command('git merge master')
|
||||
os.chdir(loc)
|
||||
print("Updated: " + c)
|
||||
else:
|
||||
print(d + " is not a class")
|
||||
|
||||
#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):
|
||||
print("Already enrolled in this class.")
|
||||
else:
|
||||
print("Not added by teacher yet.")
|
||||
return None
|
||||
data = getDB('http://127.0.0.1:8000/classes/'+cid)
|
||||
|
||||
#clone class repo and make student branch (branch name: username)
|
||||
os.chdir(self.username)
|
||||
command("git clone " + data['repo'])
|
||||
os.chdir(data['name'])
|
||||
command("git checkout " + self.username)
|
||||
command("git push -u origin " + self.username)
|
||||
|
||||
self.classes.append(data)
|
||||
if(len(self.sclass)==0):
|
||||
self.sclass = data['id']
|
||||
else:
|
||||
self.sclass = self.sclass + "," + str(data['id'])
|
||||
|
||||
#upddate self.new
|
||||
s=""
|
||||
nar = ''
|
||||
for i in range(len(self.new)):
|
||||
if(self.new[i]['id'] == int(data['id'])):
|
||||
print("DELETE: " + self.new[i]['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
|
||||
break
|
||||
|
||||
#update teacher instance in db, classes field
|
||||
data={
|
||||
'first_name':self.first_name,
|
||||
'last_name':self.last_name,
|
||||
'git':self.git,
|
||||
'ion_user':self.username,
|
||||
'student_id':self.student_id,
|
||||
'added_to':self.snew,
|
||||
'url':self.url,
|
||||
'classes':self.sclass,
|
||||
'email':self.email,
|
||||
'grade':self.grade,
|
||||
'completed':self.completed
|
||||
}
|
||||
print(self.url)
|
||||
print(putDB(data, self.url))
|
||||
return data
|
||||
|
||||
def submit(self, path):
|
||||
#2022rkhondak/English11_eharris1/Essay1
|
||||
#check if valid assignment
|
||||
parts = path.split("/")
|
||||
if(len(parts) != 3):
|
||||
print("Assignment path too short")
|
||||
return
|
||||
isclass = False
|
||||
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):
|
||||
print("Not valid assignment")
|
||||
return
|
||||
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'):
|
||||
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={
|
||||
'first_name':self.first_name,
|
||||
'last_name':self.last_name,
|
||||
'git':self.git,
|
||||
'ion_user':self.username,
|
||||
'student_id':self.student_id,
|
||||
'added_to':self.snew,
|
||||
'url':self.url,
|
||||
'classes':self.sclass,
|
||||
'email':self.email,
|
||||
'grade':self.grade,
|
||||
'completed':self.completed
|
||||
}
|
||||
#print(putDB(data, "http://127.0.0.1:8000/students/" + self.username + "/"))
|
||||
|
||||
data = getStudent("2022rkhondak")
|
||||
s = Student(data)
|
||||
s.update()
|
231
CLI/s-git.py
231
CLI/s-git.py
|
@ -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()
|
||||
|
@ -54,8 +54,9 @@ def command(command):
|
|||
ar.append(c)
|
||||
process = subprocess.Popen(ar, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
p=process.poll()
|
||||
output = process.communicate()[1]
|
||||
output = process.communicate()[0]
|
||||
print(output.decode('utf-8'))
|
||||
return output.decode('utf-8')
|
||||
|
||||
####################################################################################################################################
|
||||
|
||||
|
@ -68,13 +69,12 @@ 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']
|
||||
self.completed = data['completed']
|
||||
#classes in id form (Example: 4,5)
|
||||
|
||||
#storing actual classes
|
||||
cid=data['classes'].split(",")
|
||||
try:
|
||||
|
@ -87,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
|
||||
|
@ -105,91 +105,140 @@ 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
|
||||
self.snew=str(data['added_to'])
|
||||
if(os.path.isdir(self.username)):
|
||||
print("Synced to " + self.username)
|
||||
else:
|
||||
os.mkdir(self.username)
|
||||
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"
|
||||
print(url)
|
||||
os.system(url)
|
||||
cdir = os.getcwd()
|
||||
command('git clone https://github.com/' + self.git + '/' + self.username + '.git')
|
||||
os.chdir(self.username)
|
||||
command('git checkout master')
|
||||
command('touch README.md')
|
||||
command('git add README.md')
|
||||
command('git commit -m "Hello"')
|
||||
command('git push -u origin master')
|
||||
os.chdir(cdir)
|
||||
self.repo = 'https://github.com/' + self.git + '/' + self.username + '.git'
|
||||
data={
|
||||
'first_name':self.first_name,
|
||||
'last_name':self.last_name,
|
||||
'git':self.git,
|
||||
'ion_user':self.username,
|
||||
'student_id':self.student_id,
|
||||
'added_to':self.snew,
|
||||
'url':self.url,
|
||||
'classes':self.sclass,
|
||||
'email':self.email,
|
||||
'grade':self.grade,
|
||||
'completed':self.completed,
|
||||
'repo':self.repo
|
||||
}
|
||||
print(putDB(data, self.url))
|
||||
print("Synced to " + self.username)
|
||||
|
||||
|
||||
|
||||
#update API and Github, all assignments / classes
|
||||
def update(self):
|
||||
#lists all classes
|
||||
ignore=['.DS_Store']
|
||||
classes = os.listdir(self.username)
|
||||
for i in ignore:
|
||||
try:
|
||||
classes.remove(i)
|
||||
except:
|
||||
pass
|
||||
|
||||
for i in range(len(classes)):
|
||||
c = classes[i]
|
||||
path = self.username + "/" + c
|
||||
#lists all assignments and default files
|
||||
#push to git
|
||||
isclass = False
|
||||
for d in os.listdir(path):
|
||||
if(d == '.git'):
|
||||
isclass=True
|
||||
break
|
||||
if(isclass):
|
||||
loc = os.getcwd()
|
||||
os.chdir(path)
|
||||
command('git fetch origin')
|
||||
command('git checkout ' + self.username)
|
||||
command('git add .')
|
||||
command('git commit -m ' + self.username + '-update')
|
||||
command('git push -u origin ' + self.username)
|
||||
command('git merge master')
|
||||
os.chdir(loc)
|
||||
print("Updated: " + c)
|
||||
else:
|
||||
print(d + " is not a class")
|
||||
cdir = os.getcwd()
|
||||
os.chdir(self.username)
|
||||
for c in self.classes:
|
||||
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 pull origin " + data['name'])
|
||||
command("git push -u origin " + data['name'])
|
||||
command("git checkout master")
|
||||
os.chdir(cdir)
|
||||
for c in self.new:
|
||||
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):
|
||||
print("Already enrolled in this class.")
|
||||
else:
|
||||
print("Not added by teacher yet.")
|
||||
return None
|
||||
data = getDB('http://127.0.0.1:8000/classes/'+cid)
|
||||
|
||||
#clone class repo and make student branch (branch name: username)
|
||||
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):
|
||||
print("Not added by teacher yet.")
|
||||
return None
|
||||
|
||||
#add class teacher as cocllaborator to student repo
|
||||
print(os.getcwd())
|
||||
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 + "'"
|
||||
print(url)
|
||||
os.system(url)
|
||||
|
||||
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 clone " + data['repo'])
|
||||
os.chdir(data['name'])
|
||||
command("git checkout " + self.username)
|
||||
command("git push -u origin " + 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'
|
||||
user = self.git
|
||||
|
||||
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'])
|
||||
|
||||
#upddate self.new
|
||||
s=""
|
||||
nar = ''
|
||||
snew=""
|
||||
new = []
|
||||
for i in range(len(self.new)):
|
||||
if(self.new[i]['id'] == int(data['id'])):
|
||||
print("DELETE: " + self.new[i]['name'])
|
||||
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
|
||||
|
@ -249,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()
|
||||
|
|
574
CLI/t-git.py
Normal file
574
CLI/t-git.py
Normal file
|
@ -0,0 +1,574 @@
|
|||
import os
|
||||
import subprocess
|
||||
import requests
|
||||
import webbrowser
|
||||
import pprint
|
||||
import json
|
||||
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/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'))
|
||||
print("GET:" + str(r.status_code))
|
||||
return(r.json())
|
||||
|
||||
def postDB(data, url):
|
||||
r = requests.post(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
print("POST:" + str(r.status_code))
|
||||
return(r.json())
|
||||
|
||||
def putDB(data, url):
|
||||
r = requests.put(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
|
||||
print("PUT:" + str(r.status_code))
|
||||
return(r.json())
|
||||
|
||||
def delDB(url):
|
||||
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()
|
||||
output = process.communicate()[1]
|
||||
print(output.decode('utf-8'))
|
||||
|
||||
####################################################################################################################################
|
||||
|
||||
#public methods: deleteClass, makeClass, update
|
||||
class Teacher:
|
||||
def __init__(self, data):
|
||||
# teacher info already stored in API
|
||||
# intitialze fields after GET request
|
||||
self.first_name=data['first_name']
|
||||
self.last_name=data['last_name']
|
||||
self.git=data['git']
|
||||
self.username=data['ion_user']
|
||||
self.url= "http://127.0.0.1:8000/api/teachers/" + self.username + "/"
|
||||
self.email = data['email']
|
||||
#classes in id form (Example: 4,5)
|
||||
|
||||
cid=data['classes'].split(",")
|
||||
try:
|
||||
cid.remove('')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cid.remove("")
|
||||
except:
|
||||
pass
|
||||
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'])
|
||||
if(os.path.isdir(self.username + "/Students")):
|
||||
print("Synced to " + self.username)
|
||||
else:
|
||||
os.makedirs(self.username + "/Students")
|
||||
|
||||
#2020-05-11 12:25:00
|
||||
|
||||
|
||||
|
||||
#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):
|
||||
cname = path.split("/")
|
||||
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)
|
||||
return False
|
||||
dirs = os.listdir(path)
|
||||
#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)
|
||||
as_file = True
|
||||
as_bad = ""
|
||||
|
||||
for d in dirs:
|
||||
if(os.path.isfile(d)):
|
||||
deffile=True
|
||||
else:
|
||||
#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):
|
||||
as_bad = d
|
||||
break
|
||||
if(as_file==False):
|
||||
print("Assignment '" + as_bad + "' does not have a default file!")
|
||||
return False
|
||||
|
||||
if(deffile==False):
|
||||
print("Need a default file in the " + path + " Directory!")
|
||||
return False
|
||||
return True
|
||||
|
||||
def checkInDB(self, path):
|
||||
n = path.split("/")
|
||||
n = n[len(n)-1]
|
||||
for c in self.classes:
|
||||
if(n == c['name']):
|
||||
return True
|
||||
return False
|
||||
|
||||
#make class from existing directory, add to git and api
|
||||
def addClass(self, path):
|
||||
if (self.checkClass(path)):
|
||||
cname = path.split("/")
|
||||
cname = cname[len(cname)-1]
|
||||
cpath = self.username + "/" + cname[len(cname)-1]
|
||||
data = {
|
||||
"name": cname,
|
||||
"repo": "",
|
||||
"path": cpath,
|
||||
"teacher": self.username,
|
||||
"assignments": "",
|
||||
"default_file": "",
|
||||
"confirmed": "",
|
||||
"unconfirmed": ""
|
||||
}
|
||||
#make class instance in db
|
||||
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['name']
|
||||
else:
|
||||
self.sclass = self.sclass + "," + str(data['name'])
|
||||
|
||||
#update teacher instance in db, classes field
|
||||
teacher={
|
||||
'first_name':self.first_name,
|
||||
'last_name':self.last_name,
|
||||
'git':self.git,
|
||||
'ion_user':self.username,
|
||||
'url':self.url,
|
||||
'classes':self.sclass,
|
||||
'email':self.email
|
||||
}
|
||||
putDB(teacher, self.url)
|
||||
|
||||
return teacher
|
||||
|
||||
|
||||
#make a new class from scratch
|
||||
#subject: string, assignments: list
|
||||
#class name must be: <subject>_<ion_user>
|
||||
def makeClass(self, cname, assignments):
|
||||
#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
|
||||
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):
|
||||
print("class name must be: "+ cname + "_" + self.username)
|
||||
return
|
||||
cdir = os.getcwd()
|
||||
os.mkdir(path)
|
||||
f=open(path + "/README.md", "w")
|
||||
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)
|
||||
|
||||
data = self.addClass(path)
|
||||
return data
|
||||
|
||||
def deleteClass(self, path):
|
||||
if(os.path.exists(path) == False):
|
||||
print(path + " does not exist locally.")
|
||||
resp = input("Do you want to delete " + path + " from the SkoolOS system? (y/N) ")
|
||||
if(resp != 'y'):
|
||||
return
|
||||
|
||||
cname = path.split("/")
|
||||
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['name'] == cname):
|
||||
del self.classes[i]
|
||||
s=""
|
||||
#recreate sclass field, using ids
|
||||
for c in self.classes:
|
||||
s = s + str(c['name']) + ","
|
||||
print(s)
|
||||
s = s[:-1]
|
||||
print(s)
|
||||
data={
|
||||
'first_name':self.first_name,
|
||||
'last_name':self.last_name,
|
||||
'git':self.git,
|
||||
'ion_user':self.username,
|
||||
'url':self.url,
|
||||
'classes':s,
|
||||
'email':self.email
|
||||
}
|
||||
print(putDB(data, self.url))
|
||||
delDB("http://127.0.0.1:8000/api/classes/" + cname + "/")
|
||||
break
|
||||
|
||||
#remove locally
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
except:
|
||||
pass
|
||||
|
||||
#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):
|
||||
return False
|
||||
return True
|
||||
|
||||
def reqStudent(self, sname, cname):
|
||||
if(self.isStudent(sname) == False):
|
||||
print(sname + " does not exist.")
|
||||
return
|
||||
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
|
||||
|
||||
student = getDB("http://127.0.0.1:8000/api/students/" + sname)
|
||||
try:
|
||||
if(student['added_to']==""):
|
||||
student['added_to']=course['name']
|
||||
else:
|
||||
student['added_to']=student['added_to']+ "," + course['name']
|
||||
except:
|
||||
print(sname + " does not exist.")
|
||||
return
|
||||
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"]
|
||||
}
|
||||
student = putDB(s, student['url'])
|
||||
|
||||
if(course['unconfirmed']==""):
|
||||
course['unconfirmed']=student['ion_user']
|
||||
else:
|
||||
course['unconfirmed']=course['unconfirmed']+ "," + student['ion_user']
|
||||
cinfo = {
|
||||
"name": course['name'],
|
||||
"repo": "",
|
||||
"path": self.username + "/" + course['name'],
|
||||
"teacher": self.username,
|
||||
"assignments": "",
|
||||
"default_file": "",
|
||||
"confirmed": course["confirmed"],
|
||||
"unconfirmed": course['unconfirmed']
|
||||
}
|
||||
print(putDB(cinfo, course['url']))
|
||||
|
||||
#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
|
||||
|
||||
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()
|
||||
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)
|
||||
return output
|
||||
|
||||
'''
|
||||
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")
|
||||
|
||||
|
||||
data = getTeacher("eharris1")
|
||||
t = Teacher(data)
|
||||
t.getStudents("English11_eharris1")
|
16
CLI/test.py
16
CLI/test.py
|
@ -1,16 +0,0 @@
|
|||
import subprocess
|
||||
import os
|
||||
import time
|
||||
|
||||
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()
|
||||
output = process.communicate()[0]
|
||||
print(output)
|
||||
|
||||
command('echo hello')
|
||||
command('python runtest.py')
|
|
@ -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)),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
]
|
23
Website/api/migrations/0002_auto_20200612_0135.py
Normal file
23
Website/api/migrations/0002_auto_20200612_0135.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -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),
|
||||
),
|
||||
]
|
23
Website/api/migrations/0003_auto_20200612_0135.py
Normal file
23
Website/api/migrations/0003_auto_20200612_0135.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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=''),
|
||||
),
|
||||
]
|
|
@ -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,12 +19,14 @@ 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="")
|
||||
assignments=models.CharField(max_length=100, default="")
|
||||
default_file=models.CharField(max_length=100, default="")
|
||||
confirmed=models.TextField(default="", blank=True)
|
||||
unconfirmed=models.TextField(default="", blank=True)
|
||||
|
||||
# assignments = models.ManyToManyField(Assignment, default="")
|
||||
# default_file = models.ManyToManyField(DefFiles)
|
||||
|
@ -50,6 +52,7 @@ class Student(models.Model):
|
|||
email=models.CharField(max_length=100, default="", blank=True)
|
||||
grade = models.IntegerField()
|
||||
git=models.CharField(max_length=100)
|
||||
repo=models.URLField(default="", blank=True)
|
||||
classes=models.CharField(max_length=100, default="", blank=True)
|
||||
added_to=models.CharField(max_length=100, default="", blank=True)
|
||||
completed=models.TextField(default="", blank=True)
|
||||
|
|
|
@ -9,24 +9,24 @@ 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']
|
||||
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)
|
||||
class Meta:
|
||||
model = Student
|
||||
fields = ['url', 'first_name', 'last_name', 'grade','email','student_id', 'git','ion_user','classes','added_to','completed']
|
||||
fields = ['url', 'first_name', 'last_name', 'grade','email','student_id', 'git','ion_user','classes','added_to','completed', 'repo']
|
||||
|
||||
class TeacherSerializer(serializers.ModelSerializer):
|
||||
# classes = ClassesSerializer(many=True, read_only=True,allow_null=True)
|
||||
|
|
|
@ -15,8 +15,17 @@ router.register(r'files', views.DefFilesViewSet)
|
|||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
path('api/', include(router.urls)),
|
||||
path('api-auth/', include('rest_framework.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
]
|
||||
]
|
||||
'''
|
||||
{
|
||||
"name": "Entry1",
|
||||
"due_date": "2020-05-11 12:25:00",
|
||||
"path": "",
|
||||
"classes": "",
|
||||
"teacher": ""
|
||||
}
|
||||
'''
|
0
eharris1/English11_eharris1/README.md
Normal file
0
eharris1/English11_eharris1/README.md
Normal file
|
@ -9,13 +9,17 @@ djangorestframework==3.11.0
|
|||
idna==2.9
|
||||
oauthlib==3.1.0
|
||||
prompt-toolkit==1.0.14
|
||||
pyclipper==1.1.0.post3
|
||||
Pygments==2.6.1
|
||||
PyInquirer==1.0.3
|
||||
pyperclip==1.8.0
|
||||
pytz==2020.1
|
||||
regex==2020.5.14
|
||||
requests==2.23.0
|
||||
requests-oauthlib==1.3.0
|
||||
selenium==3.141.0
|
||||
six==1.15.0
|
||||
sqlparse==0.3.1
|
||||
urllib3==1.25.9
|
||||
wcwidth==0.2.3
|
||||
Werkzeug==1.0.1
|
||||
|
|
Loading…
Reference in New Issue
Block a user