@user_required
def post(self, user):
    parser = reqparse.RequestParser()
    parser.add_argument('id', help='This answers cannot be blank', required=True)
    parser.add_argument('sid', help='This answers cannot be blank', required=True)
    parser.add_argument('answers', help='This answers cannot be blank', required=True, action='append')
    parser.add_argument('check', help='This answer_check cannot be blank', required=True, action='append')
    data = parser.parse_args()
    word_id = data['id']
    word = models.Word.objects(id=word_id).first()
    if (not word):
        return ({'message': 'word not exist'}, 404)
    sentence_id = data['sid']
    answers = data['answers']
    check = data['check']
    check_res = [hashlib.sha1(((a + sentence_id) + word_id).encode()).hexdigest() for a in answers]
    result = (check == check_res)
    slog = models.SentenceLog(sentence=sentence_id, result=result, time=datetime.utcnow())
    models.ExerciseLog.objects(user=user, word=word).update_one(push__sentences=slog, wordname=word.word, upsert=True)
    log = models.ExerciseLog.objects(user=user, word=word).first()
    log.calucate_review()
    log.save()
    return {'message': 'ok', 'result': result}
@user_required
def post(self, user):
    parser = reqparse.RequestParser()
    parser.add_argument('id', help='This answers cannot be blank', required=True)
    parser.add_argument('sid', help='This answers cannot be blank', required=True)
    parser.add_argument('answers', help='This answers cannot be blank', required=True, action='append')
    parser.add_argument('check', help='This answer_check cannot be blank', required=True, action='append')
    data = parser.parse_args()
    word_id = data['id']
    word = models.Word.objects(id=word_id).first()
    if (not word):
        return ({'message': 'word not exist'}, 404)
    sentence_id = data['sid']
    answers = data['answers']
    check = data['check']
    check_res = [hashlib.sha1(((a + sentence_id) + word_id).encode()).hexdigest() for a in answers]
    result = (check == check_res)
    slog = models.SentenceLog(sentence=sentence_id, result=result, time=datetime.utcnow())
    models.ExerciseLog.objects(user=user, word=word).update_one(push__sentences=slog, wordname=word.word, upsert=True)
    log = models.ExerciseLog.objects(user=user, word=word).first()
    log.calucate_review()
    log.save()
    return {'message': 'ok', 'result': result}