Ejemplo n.º 1
0
 def create(cls, name, description, points, answer, unlocked=False,
            validator='static_pbkdf2'):
     challenge = cls()
     challenge.name = name
     challenge.description = description
     challenge.cid = utils.generate_id()
     challenge.points = points
     challenge.answer_hash = answer
     challenge.unlocked = unlocked
     challenge.validator = validator
     weight = db.session.query(db.func.max(Challenge.weight)).scalar()
     challenge.weight = (weight + 1) if weight else 1
     challenge.prerequisite = ''
     db.session.add(challenge)
     return challenge
Ejemplo n.º 2
0
 def create(cls, name, description, points, answer, unlocked=False,
            validator='static_pbkdf2'):
     challenge = cls()
     challenge.name = name
     challenge.description = description
     challenge.cid = utils.generate_id()
     challenge.points = points
     challenge.answer_hash = answer
     challenge.unlocked = unlocked
     challenge.validator = validator
     weight = db.session.query(db.func.max(Challenge.weight)).scalar()
     challenge.weight = (weight + 1) if weight else 1
     challenge.prerequisite = ''
     db.session.add(challenge)
     return challenge