Beispiel #1
0
def set_learning_context(user, **d):
    """
    Update the learning context of the user.

    Keys: `card`, `unit`, `subject`
        `next`: `method` and `path`
    """

    context = get_learning_context(user)
    d = pick(d, ('card', 'unit', 'subject', 'next'))
    context.update(d)
    context = compact_dict(context)
    key = 'learning_context_{id}'.format(id=user['id'])
    redis.setex(key, 10 * 60, json.dumps(context, default=json_serial))
    return context
Beispiel #2
0
def set_learning_context(user, **d):
    """
    Update the learning context of the user.

    Keys: `card`, `unit`, `set`
        `next`: `method` and `path`
    """

    context = get_learning_context(user)
    d = pick(d, ('card', 'unit', 'set', 'next'))
    context.update(d)
    context = compact_dict(context)
    key = 'learning_context_{id}'.format(id=user['id'])
    redis.setex(key, 10 * 60, json.dumps(context, default=json_serial))
    return context
Beispiel #3
0
    def set_learning_context(self, **d):
        """
        Update the learning context of the user.

        Keys: `card`, `unit`, `set`
            `next`: `method` and `path`
        """

        context = self.get_learning_context()
        d = pick(d, ("card", "unit", "set", "next"))
        context.update(d)
        context = compact_dict(context)
        key = "learning_context_{id}".format(id=self["id"])
        redis.setex(key, 10 * 60, json.dumps(context, default=json_serial))
        return context
Beispiel #4
0
def test_compact_dict():
    d = {'a': 1, 'b': None}
    assert util.compact_dict(d) == {'a': 1}