Пример #1
0
    def get(self):
        """List student stats.

        """
        self.staff_required()
        cursor_key = self.request.GET.get('cursor')
        topic = self.request.GET.get('topic')
        sort_by = self.request.GET.get('sortBy')
        if topic == 'all':
            topic = None

        sort_by_options = {
            'performance': 'performance',
            'percentageComplete': 'percentage_complete'
        }
        sort_by = sort_by_options.get(sort_by)

        try:
            limit = int(self.request.GET.get('limit'))
        except (
                ValueError,
                TypeError,
        ):
            limit = None

        try:
            residents = self.request.GET.get('residents')
            if residents == 'all':
                residents = None
            else:
                residents = int(residents)
        except (
                ValueError,
                TypeError,
        ):
            residents = None

        stats, cursor = RoshReviewUserStats.get_stats(cursor_key=cursor_key,
                                                      limit=limit,
                                                      year=residents,
                                                      topic=topic,
                                                      sort_by=sort_by)
        self.render_json({
            'stats': [s.summary() for s in stats],
            'cursor': cursor if cursor else ''
        })
Пример #2
0
    def get(self):
        """List student stats.

        """
        self.staff_required()
        cursor_key = self.request.GET.get('cursor')
        topic = self.request.GET.get('topic')
        sort_by = self.request.GET.get('sortBy')
        if topic == 'all':
            topic = None

        sort_by_options = {
            'performance': 'performance',
            'percentageComplete': 'percentage_complete'
        }
        sort_by = sort_by_options.get(sort_by)

        try:
            limit = int(self.request.GET.get('limit'))
        except (ValueError, TypeError,):
            limit = None

        try:
            residents = self.request.GET.get('residents')
            if residents == 'all':
                residents = None
            else:
                residents = int(residents)
        except (ValueError, TypeError,):
            residents = None

        stats, cursor = RoshReviewUserStats.get_stats(
            cursor_key=cursor_key,
            limit=limit,
            year=residents,
            topic=topic,
            sort_by=sort_by
        )
        self.render_json({
            'stats': [s.summary() for s in stats],
            'cursor': cursor if cursor else ''
        })