diff options
author | Prabhu Ramachandran | 2017-01-21 11:04:11 +0530 |
---|---|---|
committer | GitHub | 2017-01-21 11:04:11 +0530 |
commit | bfc97a55dddb4e1c3b6c49cc0a0f963e9b8a744c (patch) | |
tree | 536e0dadf3c71acd656e6e18c0501be04af10e8f /yaksh | |
parent | 5ed80c15d3b6a006d94769a1c298256d6f921c6c (diff) | |
parent | f21bdb189c99572981bdeba9c6cdb54f1a7de3ea (diff) | |
download | online_test-bfc97a55dddb4e1c3b6c49cc0a0f963e9b8a744c.tar.gz online_test-bfc97a55dddb4e1c3b6c49cc0a0f963e9b8a744c.tar.bz2 online_test-bfc97a55dddb4e1c3b6c49cc0a0f963e9b8a744c.zip |
Merge pull request #183 from maheshgudi/mcq_bugfix
added more fields in course csv dump
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/views.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 1dc7ea2..c4e8b61 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -10,7 +10,7 @@ from django.contrib.auth import login, logout, authenticate from django.shortcuts import render_to_response, get_object_or_404, redirect from django.template import RequestContext from django.http import Http404 -from django.db.models import Sum, Max, Q +from django.db.models import Sum, Max, Q, F from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.decorators import login_required from django.contrib.auth.models import Group @@ -1290,7 +1290,13 @@ def download_course_csv(request, course_id): course = get_object_or_404(Course,pk=course_id) if not course.is_creator(user) and not course.is_teacher(user): raise Http404('The question paper does not belong to your course') - students = course.get_only_students().values("id", "first_name", "last_name") + students = course.get_only_students().annotate(roll_number=F('profile__roll_number'), + institute=F('profile__institute') + )\ + .values("id", "first_name", "last_name", + "email","institute", + "roll_number" + ) quizzes = Quiz.objects.filter(course=course, is_trial=False) for student in students: @@ -1310,8 +1316,8 @@ def download_course_csv(request, course_id): response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="{0}.csv"'.format( (course.name).lower().replace('.', '')) - header = ['first_name', 'last_name']+[quiz.description for quiz in quizzes]\ - + ['total_scored', 'out_of'] + header = ['first_name', 'last_name', "roll_number","email", "institute"]\ + +[quiz.description for quiz in quizzes] + ['total_scored', 'out_of'] writer = csv.DictWriter(response,fieldnames=header, extrasaction='ignore') writer.writeheader() for student in students: |