Fix edge checklist 500 error

EDUCATOR-3355
This commit is contained in:
Awais Jibran
2018-08-27 18:12:39 +05:00
parent 71161b8eda
commit 3bb34faa8f
8 changed files with 593 additions and 90 deletions

View File

@@ -125,6 +125,7 @@ class CourseQualityViewTest(SharedModuleStoreTestCase, APITestCase):
'total_visible': 1,
'total_number': 1,
'highlights_enabled': False,
'highlights_active_for_course': False,
},
'subsections': {
'num_with_one_block_type': 1,

View File

@@ -92,6 +92,7 @@ class CourseValidationViewTest(SharedModuleStoreTestCase, APITestCase):
'has_update': True,
},
'certificates': {
'is_enabled': True,
'is_activated': False,
'has_certificate': False,
},
@@ -101,5 +102,4 @@ class CourseValidationViewTest(SharedModuleStoreTestCase, APITestCase):
},
'is_self_paced': True,
}
self.assertDictEqual(resp.data, expected_data)

View File

@@ -5,6 +5,7 @@ from scipy import stats
from rest_framework.generics import GenericAPIView
from rest_framework.response import Response
from contentstore.views.item import highlights_setting
from edxval.api import get_videos_for_course
from openedx.core.djangoapps.request_cache.middleware import request_cached
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes
@@ -122,12 +123,13 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
def _sections_quality(self, course):
sections, visible_sections = self._get_sections(course)
sections_with_highlights = [s for s in visible_sections if s.highlights]
sections_with_highlights = [section for section in visible_sections if section.highlights]
return dict(
total_number=len(sections),
total_visible=len(visible_sections),
number_with_highlights=len(sections_with_highlights),
highlights_enabled=course.highlights_enabled_for_messaging,
highlights_active_for_course=course.highlights_enabled_for_messaging,
highlights_enabled=highlights_setting.is_enabled(),
)
def _subsections_quality(self, course, request):

View File

@@ -205,9 +205,11 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
def _certificates_validation(self, course):
is_activated, certificates = CertificateManager.is_activated(course)
certificates_enabled = certificates is not None
return dict(
is_activated=is_activated,
has_certificate=len(certificates) > 0,
has_certificate=certificates_enabled and len(certificates) > 0,
is_enabled=certificates_enabled,
)
def _updates_validation(self, course, request):