forked from wispwisp/interactiveEducator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
populate.py
58 lines (47 loc) · 1.18 KB
/
populate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'interactiveEducator.settings')
import django
django.setup()
from iedu.models import Slide, Question, Choice, Theme
def populate():
ps = None
for i in range(1,20):
t = Theme(
theme='theme ' + str(i),
)
t.save()
q = Question(
theme=t,
text='question? ' + str(i),
)
q.save()
c = Choice(
question=q,
text='option1',
isCorrect=False,
)
c.save()
c = Choice(
question=q,
text='option2',
isCorrect=True,
)
c.save()
s = Slide(
headword='headword ' + str(i),
text='text ' + str(i),
question=Question.objects.get(id=q.id),
)
s.save()
if ps:
ps.nextSlide = s
ps.save()
ps = s
print("- {0}".format(str(s)), ", id: ", s.id)
lslide = Slide.objects.last()
fslide = Slide.objects.first()
lslide.nextSlide = fslide
lslide.save()
if __name__ == '__main__':
print("Starting population script...")
populate()