mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
assignments
This commit is contained in:
parent
5332a32816
commit
444c5a94f0
90
CLI/t-git.py
90
CLI/t-git.py
|
@ -8,7 +8,7 @@ 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
|
||||
|
||||
|
@ -213,11 +213,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
|
||||
|
@ -382,7 +383,7 @@ class Teacher:
|
|||
}
|
||||
print(putDB(cinfo, course['url']))
|
||||
|
||||
def addAssignment(self, path, course):
|
||||
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:
|
||||
|
@ -397,6 +398,14 @@ class Teacher:
|
|||
if len(folder) == 0:
|
||||
print("Assignment is completely empty, need a file.")
|
||||
return
|
||||
|
||||
ass = {
|
||||
'name': parts[len(parts)-1],
|
||||
'path':path,
|
||||
'classes':course,
|
||||
'teacher':self.username,
|
||||
'due_date':due
|
||||
}
|
||||
course = getDB("http://127.0.0.1:8000/classes/" + course)
|
||||
slist = os.listdir(os.getcwd() + "/" + self.username + "/Students/" + course['name'])
|
||||
cdir = os.getcwd()
|
||||
|
@ -426,11 +435,70 @@ class Teacher:
|
|||
except:
|
||||
print("class does not exist")
|
||||
return
|
||||
|
||||
cdir = os.getcwd()
|
||||
os.chdir(self.username + "/Students/" + course['name'] + "/" + student)
|
||||
process = subprocess.Popen(['git', 'log', course['name']], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
process = subprocess.Popen(['git', 'log', '-30', course['name']], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
p=process.poll()
|
||||
output = process.communicate()[0].decode('utf-8')
|
||||
print(output)
|
||||
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")
|
||||
|
@ -440,4 +508,4 @@ class Teacher:
|
|||
|
||||
data = getTeacher("eharris1")
|
||||
t = Teacher(data)
|
||||
t.getHistory("2022rkhondak", "English11_eharris1")
|
||||
t.addAssignment("English11_eharris1", "Entry1", '2022rkhondak',"2020-05-11 12:25:00")
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
]
|
89
Website/api/migrations/0002_auto_20200612_0010.py
Normal file
89
Website/api/migrations/0002_auto_20200612_0010.py
Normal file
|
@ -0,0 +1,89 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-12 00:10
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='assignment',
|
||||
name='id',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='classes',
|
||||
name='id',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='student',
|
||||
name='webmail',
|
||||
),
|
||||
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='added_to',
|
||||
field=models.CharField(blank=True, default='', max_length=100),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='student',
|
||||
name='completed',
|
||||
field=models.TextField(blank=True, default=''),
|
||||
),
|
||||
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.AlterField(
|
||||
model_name='assignment',
|
||||
name='files',
|
||||
field=models.CharField(blank=True, default='', max_length=100),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='assignment',
|
||||
name='name',
|
||||
field=models.CharField(max_length=100, primary_key=True, serialize=False),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='classes',
|
||||
name='name',
|
||||
field=models.CharField(max_length=100, primary_key=True, serialize=False),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='student',
|
||||
name='classes',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='student',
|
||||
name='classes',
|
||||
field=models.CharField(blank=True, default='', max_length=100),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='student',
|
||||
name='repo',
|
||||
field=models.URLField(blank=True, default=''),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='teacher',
|
||||
name='classes',
|
||||
field=models.CharField(blank=True, default='', max_length=100),
|
||||
),
|
||||
]
|
|
@ -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),
|
||||
),
|
||||
]
|
24
Website/api/migrations/0003_auto_20200612_0012.py
Normal file
24
Website/api/migrations/0003_auto_20200612_0012.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-12 00:12
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0002_auto_20200612_0010'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='assignment',
|
||||
name='id',
|
||||
field=models.AutoField(auto_created=True, default=0, primary_key=True, serialize=False, verbose_name='ID'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='assignment',
|
||||
name='name',
|
||||
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=''),
|
||||
),
|
||||
]
|
|
@ -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=''),
|
||||
),
|
||||
]
|
|
@ -1,22 +0,0 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-11 08:31
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0006_auto_20200610_0631'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='classes',
|
||||
name='id',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='classes',
|
||||
name='name',
|
||||
field=models.CharField(max_length=100, primary_key=True, serialize=False),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
|
@ -9,11 +9,11 @@ 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)
|
||||
|
|
|
@ -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": ""
|
||||
}
|
||||
'''
|
Loading…
Reference in New Issue
Block a user