def METHOD_NAME(request):
    testgroups = []
    for round in request.contest.round_set.all():
        pis = ProblemInstance.objects.filter(round=round)
        res = {'id': str(round.id), 'name': round.name, 'tasks': []}
        for pi in pis:
            task = {
                'name': pi.problem.name,
                'short_name': pi.short_name,
                'testgroups': [],
            }
            for test in Test.objects.filter(problem_instance=pi):
                if test.group not in task['testgroups']:
                    task['testgroups'].append(test.group)
            res['tasks'].append(task)
        testgroups.append(res)
    return testgroups