Esempio n. 1
0
def new_attestation_for_solution(request, solution_id, force_create=False):
    if not (request.user.is_tutor or request.user.is_trainer
            or request.user.is_superuser):
        return access_denied(request)

    solution = get_object_or_404(Solution, pk=solution_id)

    attestations = Attestation.objects.filter(solution=solution)
    if ((not force_create) and attestations):
        return render_to_response(
            "attestation/attestation_already_exists_for_solution.html", {
                'task': solution.task,
                'attestations': attestations,
                'solution': solution,
                'show_author': not get_settings().anonymous_attestation
            },
            context_instance=RequestContext(request))

    attest = Attestation(solution=solution, author=request.user)
    attest.save()
    for solutionFile in solution.solutionfile_set.filter(
            mime_type__startswith='text'):
        annotatedFile = AnnotatedSolutionFile(attestation=attest,
                                              solution_file=solutionFile,
                                              content=solutionFile.content())
        annotatedFile.save()
    for rating in solution.task.rating_set.all():
        ratingResult = RatingResult(attestation=attest, rating=rating)
        ratingResult.save()
    return HttpResponseRedirect(reverse('edit_attestation', args=[attest.id]))
Esempio n. 2
0
def new_attestation_for_solution(request, solution_id):
	if not (in_group(request.user,'Tutor,Trainer') or request.user.is_superuser):
		return access_denied(request)
	
	solution = get_object_or_404(Solution, pk=solution_id)
			
	attest = Attestation(solution = solution, author = request.user)
	attest.save()
	for solutionFile in  solution.solutionfile_set.filter(mime_type__startswith='text'):
		annotatedFile = AnnotatedSolutionFile(attestation = attest, solution_file=solutionFile, content=solutionFile.content())
		annotatedFile.save()
	for rating in solution.task.rating_set.all():
		ratingResult = RatingResult(attestation = attest, rating=rating)
		ratingResult.save()
	return HttpResponseRedirect(reverse('edit_attestation', args=[attest.id]))
Esempio n. 3
0
def new_attestation_for_solution(request, solution_id, force_create = False):
    if not (request.user.is_tutor or request.user.is_trainer or request.user.is_superuser):
        return access_denied(request)

    solution = get_object_or_404(Solution, pk=solution_id)

    attestations = Attestation.objects.filter(solution = solution)
    if ((not force_create) and attestations):
        return render(request, "attestation/attestation_already_exists_for_solution.html", { 'task' : solution.task, 'attestations' : attestations, 'solution' : solution, 'show_author': not get_settings().anonymous_attestation })

    attest = Attestation(solution = solution, author = request.user)
    attest.save()
    for solutionFile in  solution.solutionfile_set.filter(mime_type__startswith='text'):
        annotatedFile = AnnotatedSolutionFile(attestation = attest, solution_file=solutionFile, content=solutionFile.content())
        annotatedFile.save()
    for rating in solution.task.rating_set.all():
        ratingResult = RatingResult(attestation = attest, rating=rating)
        ratingResult.save()
    return HttpResponseRedirect(reverse('edit_attestation', args=[attest.id]))
Esempio n. 4
0
def new_attestation_for_solution(request, solution_id):
    if not (in_group(request.user, 'Tutor,Trainer')
            or request.user.is_superuser):
        return access_denied(request)

    solution = get_object_or_404(Solution, pk=solution_id)

    attest = Attestation(solution=solution, author=request.user)
    attest.save()
    for solutionFile in solution.solutionfile_set.filter(
            mime_type__startswith='text'):
        annotatedFile = AnnotatedSolutionFile(attestation=attest,
                                              solution_file=solutionFile,
                                              content=solutionFile.content())
        annotatedFile.save()
    for rating in solution.task.rating_set.all():
        ratingResult = RatingResult(attestation=attest, rating=rating)
        ratingResult.save()
    return HttpResponseRedirect(reverse('edit_attestation', args=[attest.id]))