quiz/management/commands/seed_db.py
changeset 15 99af908a4174
child 22 fe197c0c9903
equal deleted inserted replaced
14:ea7d372bfbff 15:99af908a4174
       
     1 import sys
       
     2 from datetime import datetime
       
     3 
       
     4 from django.core.management.base import NoArgsCommand
       
     5 
       
     6 from offline.event.models import Event
       
     7 from offline.quiz.models import QuestionBank
       
     8 
       
     9 def seed_db():
       
    10     ev = Event()
       
    11     ev.title = "Some Workshop"
       
    12     ev.start_date = datetime.now()
       
    13     ev.stop_date = datetime.now()
       
    14     ev.quiz_status = '11'
       
    15     ev.save()
       
    16 
       
    17     q1 = QuestionBank()
       
    18     q1.quiz_num = "11"
       
    19     q1.description = "How do you combine two lists a and b"
       
    20     q1.type = 'S'
       
    21     q1.time_limit = 15
       
    22     q1.expected_ans = r"a + b"
       
    23     q1.save()
       
    24 
       
    25     q2 = QuestionBank()
       
    26     q2.quiz_num = '11'
       
    27     q2.description = "What IPython magic command would you use to obtain the code that you have already typed."
       
    28     q2.type = "S"
       
    29     q2.time_limit = 15
       
    30     q2.expected_ans = r"%hist"
       
    31     q2.save()
       
    32 
       
    33     q3 = QuestionBank()
       
    34     q3.quiz_num = "11"
       
    35     q3.description = "a = [1, 2, 5, 9]. How do you add 10 to end of this list."
       
    36     q3.type = "S"
       
    37     q3.time_limit = 30
       
    38     q3.expected_ans = r"a.append(10)"
       
    39     q3.save()
       
    40 
       
    41     
       
    42 class Command(NoArgsCommand):
       
    43     
       
    44     def handle_noargs(self, **options):
       
    45         """ Just copied the code from seed_db.py """
       
    46         
       
    47         seed_db()