コード例 #1
0
class Module(Document):
    module_name = db.StringField(required=True, max_length=20, unique=True)
    details = db.StringField(max_length=500)
    number_of_words = db.IntField()
    parent = db.ObjectIdField()
    child = db.ObjectIdField()
    words = db.ListField(gj.FollowReferenceField(Dictionary))
    quiz = db.ListField(gj.FollowReferenceField(Quiz))
コード例 #2
0
class Quiz(Document):
    quiz_name = db.StringField(required=True, max_length=100)
    details = db.StringField(max_length=500, required=True)
    questions = db.ListField(
        gj.FollowReferenceField(Question, reverse_delete_rule=PULL))

    def error_checker(id):
        if not ObjectId.is_valid(id):
            return Response('Failed: invalid Id', 400)

        if not Quiz.objects(id=id):
            return Response('', 204)
コード例 #3
0
class Module(Document):
    module_name = db.StringField(required=True, max_length=100, unique=True)
    details = db.StringField(max_length=500)
    parent = db.ObjectIdField(default=None)
    words = db.ListField(
        gj.FollowReferenceField(Dictionary, reverse_delete_rule=PULL))
    quiz = db.ListField(gj.FollowReferenceField(Quiz,
                                                reverse_delete_rule=PULL))

    def error_checker(id):
        if not ObjectId.is_valid(id):
            return Response('Failed: invalid Id', 400)

        if not Module.objects(id=id):
            return Response('', 204)
コード例 #4
0
class User(db.Document, UserMixin):
    username = db.StringField(required=True, max_length=20)
    firstname = db.StringField(max_length=20)
    lastname = db.StringField(max_length=20)
    dob = db.DateTimeField(required=True)
    creation_date = db.DateTimeField()
    last_login = db.DateTimeField()
    email = db.EmailField(required=True)
    password = db.StringField(required=True)
    is_verified = db.BooleanField(default=False)
    completed_modules = db.ListField(
        db.EmbeddedDocumentField(Completed_Modules))

    def __init__(self, creation_date, username):
        self.creation_date = datetime.utcnow()
        self.username = username
コード例 #5
0
class Question(Document):
    question_text = db.StringField(max_length=500)
    word = gj.FollowReferenceField(Dictionary, reverse_delete_rule=CASCADE)

    def error_checker(id):
        if not ObjectId.is_valid(id):
            return Response('Failed: invalid Id', 400)

        if not Question.objects(id=id):
            return Response('', 204)
コード例 #6
0
class Dictionary(Document):
    word = db.StringField(required=True, unique=True)
    url = db.URLField()
    in_dictionary = db.BooleanField(default=False)
    times_requested = db.IntField()

    def error_checker(id):
        if not ObjectId.is_valid(id):
            return Response('Failed: invalid Id', 400)

        if not Dictionary.objects(id=id):
            return Response('', 204)
コード例 #7
0
class User(Document, UserMixin):
    username = db.StringField(required=True, max_length=20, unique=True)
    firstname = db.StringField(max_length=20)
    lastname = db.StringField(max_length=20)
    dob = db.DateTimeField(required=True)
    creation_date = db.DateTimeField()
    completed_modules = db.ListField(
        db.EmbeddedDocumentField(Completed_Modules))

    def __init__(self, *args, **kwargs):
        super(Document, self).__init__(*args, **kwargs)
        self.creation_date = datetime.now()

    def get_id(self):
        return str(self.id)

    def error_checker(id):
        if not ObjectId.is_valid(id):
            return Response('Failed: invalid Id', 400)

        if not User.objects(id=id):
            return Response('', 204)
コード例 #8
0
class Completed_Modules(db.EmbeddedDocument):
    module_id = db.LazyReferenceField(Module)
    module_name = db.StringField(max_length=100)
コード例 #9
0
class Dictionary(Document):
    word = db.StringField(required=True, unique=True)
    url = db.URLField(unique=True)
    in_dictionary = db.BooleanField(default=False)
    times_requested = db.IntField()
コード例 #10
0
class Question(Document):
    question_text = db.StringField(max_length=500)
    url = db.URLField()
    answer_bank = db.ListField(db.StringField(max_length=20))
    correct_index = db.IntField()
コード例 #11
0
class Quiz(Document):
    quiz_name = db.StringField(required=True, max_length=20)
    number_of_questions = db.IntField()
    details = db.StringField(max_length=500, required=True)
    questions = db.ListField(gj.FollowReferenceField('Question'))
コード例 #12
0
class UserAnswers(db.EmbeddedDocument):
    question_id = db.LazyReferenceField(Question, required=True)
    user_answer = db.StringField(required=True)
    correct_answer = db.StringField(required=True)