15
|
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.time_limit = 15
|
|
21 |
q1.expected_ans = r"a + b"
|
|
22 |
q1.save()
|
|
23 |
|
|
24 |
q2 = QuestionBank()
|
|
25 |
q2.quiz_num = '11'
|
|
26 |
q2.description = "What IPython magic command would you use to obtain the code that you have already typed."
|
|
27 |
q2.time_limit = 15
|
|
28 |
q2.expected_ans = r"%hist"
|
|
29 |
q2.save()
|
|
30 |
|
|
31 |
q3 = QuestionBank()
|
|
32 |
q3.quiz_num = "11"
|
|
33 |
q3.description = "a = [1, 2, 5, 9]. How do you add 10 to end of this list."
|
|
34 |
q3.time_limit = 30
|
|
35 |
q3.expected_ans = r"a.append(10)"
|
|
36 |
q3.save()
|
|
37 |
|
|
38 |
|
|
39 |
class Command(NoArgsCommand):
|
|
40 |
|
|
41 |
def handle_noargs(self, **options):
|
|
42 |
""" Just copied the code from seed_db.py """
|
|
43 |
|
|
44 |
seed_db()
|