summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyc/grader/models.py4
-rw-r--r--pyc/grader/views.py8
-rw-r--r--pyc/templates/base.html10
-rw-r--r--pyc/templates/index.html19
-rw-r--r--pyc/templates/lab.html20
-rw-r--r--pyc/urls.py4
6 files changed, 51 insertions, 14 deletions
diff --git a/pyc/grader/models.py b/pyc/grader/models.py
index 651ba6e..bf92598 100644
--- a/pyc/grader/models.py
+++ b/pyc/grader/models.py
@@ -12,5 +12,7 @@ class Submission(models.Model):
user = models.ForeignKey(User)
time = models.DateTimeField()
grade = models.IntegerField()
+ class Meta:
+ unique_together = (('lab', 'user'),)
def __unicode__(self):
- return "%d, %s" % (self.lab, self.user)
+ return "%d, %s" % (self.lab.id, self.user)
diff --git a/pyc/grader/views.py b/pyc/grader/views.py
index 35dba57..bba6b8f 100644
--- a/pyc/grader/views.py
+++ b/pyc/grader/views.py
@@ -1,4 +1,10 @@
from django.shortcuts import render_to_response
+from grader.models import Lab
def index(request):
- return render_to_response('index.html')
+ return render_to_response('index.html', {'labs' : Lab.objects.all()})
+
+def lab(request, lab_id):
+ lab = Lab.objects.get(pk=lab_id)
+ submissions = lab.submission_set.filter(user__is_staff=False).order_by('-grade', '-time')
+ return render_to_response('lab.html', {'lab' : lab, 'submissions' : submissions})
diff --git a/pyc/templates/base.html b/pyc/templates/base.html
new file mode 100644
index 0000000..65aa2f2
--- /dev/null
+++ b/pyc/templates/base.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <title>pyc</title>
+</head>
+<body>
+{% block body %}{% endblock %}
+</body>
+</html>
diff --git a/pyc/templates/index.html b/pyc/templates/index.html
index 87bb880..6707fca 100644
--- a/pyc/templates/index.html
+++ b/pyc/templates/index.html
@@ -1,10 +1,9 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="UTF-8">
- <title>pyc</title>
-</head>
-<body>
-woo
-</body>
-</html>
+{% extends 'base.html' %}
+{% block body %}
+Labs:
+<ol>
+{% for lab in labs %}
+ <li><a href="/lab/{{ lab.id }}/">{{ lab.name }}</a></li>
+{% endfor %}
+</ol>
+{% endblock %}
diff --git a/pyc/templates/lab.html b/pyc/templates/lab.html
new file mode 100644
index 0000000..f07a082
--- /dev/null
+++ b/pyc/templates/lab.html
@@ -0,0 +1,20 @@
+{% extends 'base.html' %}
+{% block body %}
+Lab {{ lab.id }} due {{ lab.due }} at 11:59:59 PDT (UTC-7):
+<br>{{ lab.name }}
+
+<table>
+<tr>
+ <th>User</th>
+ <th>Grade</th>
+ <th>Time</th>
+</tr>
+{% for s in submissions %}
+ <tr>
+ <td>{{ s.user }}</td>
+ <td>{{ s.grade }}</td>
+ <td>{{ s.time }}</td>
+ </tr>
+{% endfor %}
+</table>
+{% endblock %}
diff --git a/pyc/urls.py b/pyc/urls.py
index 92c79c9..b65970e 100644
--- a/pyc/urls.py
+++ b/pyc/urls.py
@@ -4,8 +4,8 @@ from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
- url(r'^$', 'pyc.grader.views.index', name='index'),
- # url(r'^pyc/', include('pyc.foo.urls')),
+ url(r'^$', 'grader.views.index', name='index'),
+ url(r'^lab/(?P<lab_id>\d+)/$', 'grader.views.lab'),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),