summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaheshgudi2017-01-20 17:05:38 +0530
committermaheshgudi2017-01-20 17:05:38 +0530
commitf21bdb189c99572981bdeba9c6cdb54f1a7de3ea (patch)
tree060acf84086dc6db2e37f27cadc29951e046aa27
parent1f66352c1f26eb0688ae0884781e6a6a66d43b18 (diff)
downloadonline_test-f21bdb189c99572981bdeba9c6cdb54f1a7de3ea.tar.gz
online_test-f21bdb189c99572981bdeba9c6cdb54f1a7de3ea.tar.bz2
online_test-f21bdb189c99572981bdeba9c6cdb54f1a7de3ea.zip
added more fields in course csv dump
Added the fields of institute, roll number and email id for students in course csv dump
-rw-r--r--yaksh/views.py14
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: