diff options
author | ankitjavalkar | 2018-03-05 12:44:04 +0530 |
---|---|---|
committer | ankitjavalkar | 2018-03-21 18:23:44 +0530 |
commit | 3bcbd380376faa9f2415af271489a4b8439f5717 (patch) | |
tree | 95c72b371baac97a700a16b2d932b729f3d65552 /yaksh/management/commands/results2csv.py | |
parent | aa64e8db6456260bf6f29086eff5012c970e14f3 (diff) | |
download | online_test-3bcbd380376faa9f2415af271489a4b8439f5717.tar.gz online_test-3bcbd380376faa9f2415af271489a4b8439f5717.tar.bz2 online_test-3bcbd380376faa9f2415af271489a4b8439f5717.zip |
Deprecate multiple management commands
- dump_user_data deprecated
- load_exam deprecated
- load_question_xml deprecated
- results2csv deprecated
Diffstat (limited to 'yaksh/management/commands/results2csv.py')
-rw-r--r-- | yaksh/management/commands/results2csv.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/yaksh/management/commands/results2csv.py b/yaksh/management/commands/results2csv.py deleted file mode 100644 index 2644354..0000000 --- a/yaksh/management/commands/results2csv.py +++ /dev/null @@ -1,69 +0,0 @@ -# System library imports. -import sys -from os.path import basename - -# Django imports. -from django.core.management.base import BaseCommand -from django.template import Template, Context - -# Local imports. -from yaksh.models import Quiz, QuestionPaper - -result_template = Template('''\ -"name","username","rollno","email","answered","total","attempts","position",\ -"department","institute" -{% for paper in papers %}\ -"{{ paper.user.get_full_name.title }}",\ -"{{ paper.user.username }}",\ -"{{ paper.profile.roll_number }}",\ -"{{ paper.user.email }}",\ -"{{ paper.get_answered_str }}",\ -{{ paper.get_total_marks }},\ -{{ paper.answers.count }},\ -"{{ paper.profile.position }}",\ -"{{ paper.profile.department }}",\ -"{{ paper.profile.institute }}" -{% endfor %}\ -''') - -def results2csv(filename, stdout): - """Write exam data to a CSV file. It prompts the user to choose the - appropriate quiz. - """ - qs = Quiz.objects.all() - - if len(qs) > 1: - print "Select quiz to save:" - for q in qs: - stdout.write('%d. %s\n'%(q.id, q.description)) - quiz_id = int(raw_input("Please select quiz: ")) - try: - quiz = Quiz.objects.get(id=quiz_id) - except Quiz.DoesNotExist: - stdout.write("Sorry, quiz %d does not exist!\n"%quiz_id) - sys.exit(1) - else: - quiz = qs[0] - - papers = QuestionPaper.objects.filter(quiz=quiz, - user__profile__isnull=False) - stdout.write("Saving results of %s to %s ... "%(quiz.description, - basename(filename))) - # Render the data and write it out. - f = open(filename, 'w') - context = Context({'papers': papers}) - f.write(result_template.render(context)) - f.close() - - stdout.write('Done\n') - -class Command(BaseCommand): - args = '<results.csv>' - help = '''Writes out the results of a quiz to a CSV file. Prompt user - to select appropriate quiz if there are multiple. - ''' - - def handle(self, *args, **options): - """Handle the command.""" - # Save to file. - results2csv(args[0], self.stdout) |