Skip to content

Commit

Permalink
division with modulo (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jniznan committed Sep 15, 2014
1 parent 517af54 commit c433e2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions model/migrations/0002_populate_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def forwards(self, orm):
total = a * b
orm.Skill(name='%s/%s' % (total, b), parent=d1, level=4,
note='%s/%s' % (total, b)).save()
dm = orm.Skill(name='division modulo', parent=division, level=3,
note=u'Dělení se zbytkem')
dm.save()
# update children
#-----------------
for s in orm.Skill.objects.all():
pk = s.pk
list = ",".join([str(s.pk) for s in get_children(s)])
Expand Down
17 changes: 14 additions & 3 deletions questions/migrations/0002_populate_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,20 @@ def forwards(self, orm):
orm.Question(
type='c', skill=skill, player=fillin,
data='{"pre": "%s ÷ ", "answer": "%s", "post": " = %s"}' % (total, b, a)).save()



skill = orm['model.Skill'].objects.get(name='division modulo')
for a in range(1, 21):
for b in range(1, 11):
r = a / b
m = a % b
orm.Question(
type='c', skill=skill, player=fillin,
data=json.dumps({"pre": "%s ÷ %s = " % (a, b),
"answer": str(r),
"post": ", zbytek %s" % m})).save()
orm.Question(
type='c', skill=skill, player=fillin,
data=json.dumps({"pre": "%s ÷ %s = %s, zbytek " % (a, b, r),
"answer": str(m), "post": ""})).save()

def backwards(self, orm):
"Write your backwards methods here."
Expand Down

0 comments on commit c433e2e

Please sign in to comment.