-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_data.py
39 lines (31 loc) · 1.5 KB
/
gen_data.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
from users.models import User, StudentToCourse
import courses.models as cmodels
import secrets
import random
nouns = ("puppy", "car", "rabbit", "girl", "monkey")
verbs = ("runs", "hits", "jumps", "drives", "barfs")
adv = ("crazily.", "dutifully.", "foolishly.", "merrily.", "occasionally.")
adj = ("adorable", "clueless", "dirty", "odd", "stupid")
for x in range(100):
user = User.objects.create(username=secrets.token_hex(20))
for x in range(3):
univ = cmodels.University.objects.create(name=secrets.token_hex(20))
for x in range(20):
unif = cmodels.University.objects.all().order_by('?').first()
faculty = cmodels.Faculty.objects.create(name=secrets.token_hex(20), university=unif)
for x in range(100):
faculty = cmodels.Faculty.objects.all().order_by('?').first()
random_num = random.randint(100, 500)
course = cmodels.Course.objects.create(name=f'INFO-F-{random_num}', faculty=faculty, ects=random.randint(1, 15))
description = f"{nouns[random.randrange(0,5)]} {verbs[random.randrange(0,5)]} {adv[random.randrange(0,5)]} {adj[random.randrange(0,5)]}"
course.description = description
course.save()
for user in User.objects.all():
for x in range(7):
course = cmodels.Course.objects.all().order_by('?').first()
user.courses.add(course)
s2c = StudentToCourse.objects.get(student=user, course=course)
s2c.grade = random.randint(0,20)
s2c.difficulty = random.randint(0,10)
s2c.study_time = random.randint(0,150)
s2c.save()