def METHOD_NAME(request, problem):
    # Why .order_by()? Just in case. More in the following link:
    # https://docs.djangoproject.com/en/dev/topics/db/
    #       aggregation/#interaction-with-default-ordering-or-order-by
    # Testreports for deleted tests remain in the database, 
    # we can't show them here.
    agg = (
        TestReport.objects.filter(
            submission_report__userresultforproblem__problem_instance=problem,
            test__isnull=False,
        )
        .values('test', 'test__order', 'test_name', 'status')
        .annotate(status_count=Count('status'))
        .order_by()
    )
    statuses = sorted(set(a['status'] for a in agg))
    tests = set((a['test'], a['test_name'], a['test__order']) for a in agg)
    tests = sorted(tests, key=lambda x: (x[2], x[1]))
    d = defaultdict(int)
    for a in agg:
        d[(a['status'], a['test'])] = a['status_count']
    data = [[d[(st, test)] for test, _x, _x in tests] for st in statuses]
    return {
        'plot_name': _("Test scores"),
        'data': data,
        'keys': [test_name for _x, test_name, _x in tests],
        'series': statuses,
    }