Skip to content

Commit

Permalink
allow students to submit "test submissions", which cannot ever become…
Browse files Browse the repository at this point in the history
… final solutions.

This is rarely useful, and hence not linked to from the praktomat site.
It does, however, provide somewhat of a workaround to issue #219
  • Loading branch information
mhecker committed Nov 20, 2015
1 parent 186f9d2 commit 4e250c9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/solutions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Solution(models.Model):
author = models.ForeignKey(User, verbose_name="solution author")
creation_date = models.DateTimeField(auto_now_add=True)

testupload = models.BooleanField( default = False, help_text = _('Indicates whether this solution is a test upload by a trainer or tutor.'))
testupload = models.BooleanField( default = False, help_text = _('Indicates whether this solution is a test upload.'))
accepted = models.BooleanField( default = False, help_text = _('Indicates whether the solution has passed all public and required tests.'))
warnings = models.BooleanField( default = False, help_text = _('Indicates whether the solution has at least failed one public and not required tests.'))
plagiarism = models.BooleanField( default = False, help_text = _('Indicates whether the solution is a rip-off of another one.'))
Expand Down
23 changes: 23 additions & 0 deletions src/solutions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ def test_upload(request, task_id):
{"formset": formset, "task":task},
context_instance=RequestContext(request))

@login_required
def test_upload_student(request, task_id):

task = get_object_or_404(Task,pk=task_id)
if task.publication_date >= datetime.now():
raise Http404

if request.method == "POST":
solution = Solution(task = task, author=request.user, testupload = True)
formset = SolutionFormSet(request.POST, request.FILES, instance=solution)
if formset.is_valid():
solution.save()
formset.save()
solution.check_solution(run_secret = False)

return HttpResponseRedirect(reverse('solution_detail', args=[solution.id]))
else:
formset = SolutionFormSet()

return render_to_response("solutions/solution_test_upload.html",
{"formset": formset, "task":task},
context_instance=RequestContext(request))

@login_required
def solution_detail(request,solution_id,full):
solution = get_object_or_404(Solution, pk=solution_id)
Expand Down
5 changes: 3 additions & 2 deletions src/templates/solutions/solution_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ <h1>{{solution.task.title}}</h1>

<p>
{% if solution.testupload %}
This is a test submission by a tutor or trainer, and otherwise ignored.
{% elif solution.final %}
This is a test submission, and otherwise ignored.
{% endif %}
{% if solution.final %}
This is your current final solution.
{% else %}
This is NOT your current final solution.
Expand Down
1 change: 1 addition & 0 deletions src/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
url(r'^tasks/(?P<task_id>\d+)/solutionupload/$', 'solutions.views.solution_list', name='solution_list'),
url(r'^tasks/(?P<task_id>\d+)/solutionupload/user/(?P<user_id>\d+)$', 'solutions.views.solution_list', name='solution_list'),
url(r'^tasks/(?P<task_id>\d+)/solutionupload/test/$', 'solutions.views.test_upload', name='upload_test_solution'),
url(r'^tasks/(?P<task_id>\d+)/solutionupload/test/student/$', 'solutions.views.test_upload_student', name='upload_test_solution_student'),

#Attestation
url(r'^tasks/(?P<task_id>\d+)/attestation/statistics$', 'attestation.views.statistics', name='statistics'),
Expand Down

0 comments on commit 4e250c9

Please sign in to comment.