Get all data and display the page

def page(self, course, msg="", error=False):
        """ Get all data and display the page """
        aggregations = OrderedDict()
        taskids = list(course.get_tasks().keys())

        for aggregation in self.user_manager.get_course_aggregations(course):
            aggregations[aggregation['_id']] = dict(list(aggregation.items()) +
                                                [("tried", 0),
                                                 ("done", 0),
                                                 ("url", self.submission_url_generator(aggregation['_id']))
                                                 ])

            data = list(self.database.submissions.aggregate(
                [
                    {
                        "$match":
                            {
                                "courseid": course.get_id(),
                                "taskid": {"$in": taskids},
                                "username": {"$in": aggregation["students"]}
                            }
                    },
                    {
                        "$group":
                            {
                                "_id": "$taskid",
                                "tried": {"$sum": 1},
                                "done": {"$sum": {"$cond": [{"$eq": ["$result", "success"]}, 1, 0]}}
                            }
                    },

                ]))

            for c in data:
                aggregations[aggregation['_id']]["tried"] += 1 if c["tried"] else 0
                aggregations[aggregation['_id']]["done"] += 1 if c["done"] else 0

        my_aggregations, other_aggregations = [], []
        for aggregation in aggregations.values():
            if self.user_manager.session_username() in aggregation["tutors"]:
                my_aggregations.append(aggregation)
            else:
                other_aggregations.append(aggregation)

        if "csv" in web.input():
            return make_csv(data)

        return self.template_helper.get_renderer().course_admin.aggregation_list(course, [my_aggregations, other_aggregations], msg, error)