Exemplo n.º 1
0
def get_most_common_statistics(user):
    v = [h.hanzi for h in Leitner.objects.filter(user=user)]
    v = set(v)
    common = [c for (c, f) in MostCommonCharacter.get_all()]
    in_common = 0
    out_common = 0
    for h in v:
        if h in common:
            in_common += 1
        else:
            out_common += 1
    ret = dict(in_common=in_common, 
        out_common=out_common)
    return ret
Exemplo n.º 2
0
def get_new_from_500(request):
    '''
    HTTP GET /study/get_new_from_500?num=3
    Return
        [u0x2345, u0x1111, ...]
    '''
    ret = []
    if 'num' in request.GET:
        num = int(request.GET['num'])   
    else:
        num = 3
    common500 = [ch for (ch, f) in MostCommonCharacter.get_all()]

    for v in StudyHistory.objects.filter(user=request.user):
        if v.vocabulary in common500:
            common500.remove(v.vocabulary)
    ret = common500[:num]

    return HttpResponse(json.dumps(ret, cls=DjangoJSONEncoder))