diff --git a/Assigment08.aux b/19.aux similarity index 100% rename from Assigment08.aux rename to 19.aux diff --git a/Assigment08.tex b/19.tex similarity index 100% rename from Assigment08.tex rename to 19.tex diff --git a/db.sqlite3 b/db.sqlite3 index 390809d..2d07582 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/website/migrations/0002_auto_20141115_1202.py b/website/migrations/0002_auto_20141115_1202.py new file mode 100644 index 0000000..022b43b --- /dev/null +++ b/website/migrations/0002_auto_20141115_1202.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('website', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='assignment', + name='points', + field=models.IntegerField(default=0), + preserve_default=False, + ), + migrations.AddField( + model_name='assignment', + name='received_submission', + field=models.BooleanField(default=True), + preserve_default=True, + ), + ] diff --git a/website/migrations/0003_auto_20141115_1229.py b/website/migrations/0003_auto_20141115_1229.py new file mode 100644 index 0000000..fa1d65b --- /dev/null +++ b/website/migrations/0003_auto_20141115_1229.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('website', '0002_auto_20141115_1202'), + ] + + operations = [ + migrations.AlterField( + model_name='assignment', + name='points', + field=models.IntegerField(null=True, blank=True), + preserve_default=True, + ), + ] diff --git a/website/migrations/0004_remove_submission_student.py b/website/migrations/0004_remove_submission_student.py new file mode 100644 index 0000000..c486e67 --- /dev/null +++ b/website/migrations/0004_remove_submission_student.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('website', '0003_auto_20141115_1229'), + ] + + operations = [ + migrations.RemoveField( + model_name='submission', + name='student', + ), + ] diff --git a/website/models.py b/website/models.py index dfbf6cd..20d1e7a 100644 --- a/website/models.py +++ b/website/models.py @@ -29,7 +29,6 @@ class Problem(models.Model): class Submission(models.Model): - student = models.ForeignKey(UserProfile) problem = models.ForeignKey(Problem) contents = models.TextField() score = models.IntegerField(null=True, blank=True) @@ -39,5 +38,5 @@ class Assignment(models.Model): name = models.CharField(max_length=CHARFIELD_MAX_LENGTH) due_date = models.DateTimeField() problems = models.ManyToManyField(Problem) - points = models.IntegerField() - received_submission = models.BooleanField(null=True, blank=True) \ No newline at end of file + points = models.IntegerField(null=True, blank=True) + received_submission = models.BooleanField(default=True) \ No newline at end of file diff --git a/Assigment08.pdf b/website/static/asgts/19.pdf similarity index 99% rename from Assigment08.pdf rename to website/static/asgts/19.pdf index 2731367..4a50d4e 100644 Binary files a/Assigment08.pdf and b/website/static/asgts/19.pdf differ diff --git a/website/templates/index.html b/website/templates/index.html index 2cd3c50..6d2a478 100644 --- a/website/templates/index.html +++ b/website/templates/index.html @@ -3,7 +3,7 @@ {% block title %}test{% endblock %} {% block content %} - +{{ success }} @@ -18,15 +18,16 @@ {% for assignment in assignments %} - {% if assignment.received_submission == "False" %} + - + - {% else if assignment.received_submission == "True"%} - - - - - - - - - {% else %} - - - - - - - Submitted on DATE - - - {% endif %} + {% endfor %}
{{assignment.due_date}} {{assignment.name}} Haven't started/{{assignment.points}}?/{{assignment.points}}
- + TeX + PDF
@@ -36,44 +37,16 @@ Select file Change - Remove +
{% csrf_token %} + {{ form.file }} + +
{{assignment.due_date}}{{assignment.name}}Submitted47/{{assignment.points}}
- -
-
- - Submitted on DATE -
11/16/1994Ramsey TheorySubmittedVALUE/50
- -
-
- - File sumitted on DATE -
diff --git a/website/templates/profbig.html b/website/templates/profbig.html index 429de2b..fb5da10 100644 --- a/website/templates/profbig.html +++ b/website/templates/profbig.html @@ -36,6 +36,7 @@
+ {{ success }}
{% csrf_token %}
diff --git a/website/urls.py b/website/urls.py index dfcbb8c..0a0a32b 100644 --- a/website/urls.py +++ b/website/urls.py @@ -7,5 +7,7 @@ # url(r'^register/$', views.register, name='register'), # url(r'^login/$', views.user_login, name='login'), # url(r'^logout/$', views.user_logout, name='logout'), - url(r'^professor/', views.professor, name='professor') + url(r'^professor/', views.professor, name='professor'), + url(r'^student/', views.student, name='student'), + url(r'^grader/', views.grader, name='grader'), ) diff --git a/website/views.py b/website/views.py index c30bd82..246715b 100644 --- a/website/views.py +++ b/website/views.py @@ -7,7 +7,7 @@ import re import os import aggregator -from website.models import Assignment, Problem +from website.models import Assignment, Problem, Submission import package_problems def professor(request): @@ -15,7 +15,7 @@ def professor(request): form = ProfessorUploadForm(request.POST, request.FILES) if form.is_valid(): process_prof_file(request.FILES['file']) - return HttpResponseRedirect('/success/url/') + return render(request, 'profbig.html', {'form': form, 'success': "Submitted"}) else: form = ProfessorUploadForm() return render(request, 'profbig.html', {'form': form}) @@ -25,11 +25,20 @@ def student(request): for a in Assignment.objects.all(): total_points = 0; - for p in a.problems: + for p in a.problems.all(): total_points += p.points a.points = total_points + a.save() - return render(request, "index.html", {'assignments': ass}) + if request.method == 'POST': + form = ProfessorUploadForm(request.POST, request.FILES) + if form.is_valid(): + # process_student_file(request.FILES['file']) + return render(request, 'index.html', {'assignments': ass, 'form': form, 'success': "Submitted"}) + else: + form = ProfessorUploadForm() + + return render(request, "index.html", {'assignments': ass, 'form': form}) def grader(request): ass = Assignment.objects.all() @@ -68,10 +77,11 @@ def process_prof_file(file): asgt.problems.add(p) strip_solutions(asgt) - os.system("pdflatex %s" % asgt.name.replace(" ", "") + aggregator.TEX_FILE) + os.system("pdflatex %s" % asgt.pk + aggregator.TEX_FILE) + os.system("mv ./%s.pdf ./website/static/asgts/" % asgt.pk) def strip_solutions(asgt): - problems_file = open(asgt.name.replace(" ", "") + aggregator.TEX_FILE, 'w') + problems_file = open(str(asgt.pk) + aggregator.TEX_FILE, 'w') aggregator.print_header(problems_file) print(r"\name{" + asgt.name + "}", file=problems_file) print(r"\duedate{" + asgt.due_date + "}", file=problems_file) @@ -83,3 +93,24 @@ def strip_solutions(asgt): print(r"\end{document}",file=problems_file) return problems_file + +def process_student_file(file): + data = file.read() + + problem_locs = [m.end() for m in re.finditer("begin{problem}", data)] + + for loc in problem_locs: + s = Submission() + m = re.search(r"\[([^]]*)\]", data[loc:]) + s.name = m.group(1) + n = re.search(r"\[([^]]*)\]", data[loc+m.end():]) + s.points = n.group(1) + o = re.search(r"([^]]*)\end{problem}", data[loc + m.end() + n.end():]) + q = re.search(r"begin{solution}([^]]*)\\end{solution}", data[loc + m.end() + n.end() + o.end():]) + s.contents = q.group(1) + p = Problem.objects.get(name=s.name) + s.problem = p + s.save() + + os.system("pdflatex %s" % asgt.pk + aggregator.TEX_FILE) + os.system("mv ./%s.pdf ./website/static/asgts/" % asgt.pk)