New course cannot be started till web certificate is active
fixed broken test changes based on feedback on 6/24 fixed broken unit test after feedback changes added more checks and updated tests fixed broken bok choy test Fixed pylint quality error trying to fix pylint quality error
This commit is contained in:
@@ -52,6 +52,7 @@ class CourseDetailsTestCase(CourseTestCase):
|
||||
self.assertIsNone(details.intro_video, "intro_video somehow initialized" + str(details.intro_video))
|
||||
self.assertIsNone(details.effort, "effort somehow initialized" + str(details.effort))
|
||||
self.assertIsNone(details.language, "language somehow initialized" + str(details.language))
|
||||
self.assertIsNone(details.has_cert_config)
|
||||
|
||||
def test_encoder(self):
|
||||
details = CourseDetails.fetch(self.course.id)
|
||||
@@ -1008,6 +1009,41 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
tab_list.append(self.notes_tab)
|
||||
self.assertEqual(tab_list, course.tabs)
|
||||
|
||||
@override_settings(FEATURES={'CERTIFICATES_HTML_VIEW': True})
|
||||
def test_web_view_certifcate_configuration_settings(self):
|
||||
"""
|
||||
Test that has_cert_config is updated based on cert_html_view_enabled setting.
|
||||
"""
|
||||
test_model = CourseMetadata.update_from_json(
|
||||
self.course,
|
||||
{
|
||||
"cert_html_view_enabled": {"value": "true"}
|
||||
},
|
||||
user=self.user
|
||||
)
|
||||
self.assertIn('cert_html_view_enabled', test_model)
|
||||
url = get_url(self.course.id)
|
||||
response = self.client.get_json(url)
|
||||
course_detail_json = json.loads(response.content)
|
||||
self.assertFalse(course_detail_json['has_cert_config'])
|
||||
|
||||
# Now add a certificate configuration
|
||||
certificates = [
|
||||
{
|
||||
'id': 1,
|
||||
'name': 'Certificate Config Name',
|
||||
'course_title': 'Title override',
|
||||
'org_logo_path': '/c4x/test/CSS101/asset/org_logo.png',
|
||||
'signatories': [],
|
||||
'is_active': True
|
||||
}
|
||||
]
|
||||
self.course.certificates = {'certificates': certificates}
|
||||
modulestore().update_item(self.course, self.user.id)
|
||||
response = self.client.get_json(url)
|
||||
course_detail_json = json.loads(response.content)
|
||||
self.assertTrue(course_detail_json['has_cert_config'])
|
||||
|
||||
|
||||
class CourseGraderUpdatesTest(CourseTestCase):
|
||||
"""
|
||||
|
||||
@@ -310,3 +310,22 @@ def reverse_usage_url(handler_name, usage_key, kwargs=None):
|
||||
Creates the URL for handlers that use usage_keys as URL parameters.
|
||||
"""
|
||||
return reverse_url(handler_name, 'usage_key_string', usage_key, kwargs)
|
||||
|
||||
|
||||
def has_active_web_certificate(course):
|
||||
"""
|
||||
Returns True if given course has active web certificate configuration.
|
||||
If given course has no active web certificate configuration returns False.
|
||||
Returns None If `CERTIFICATES_HTML_VIEW` is not enabled of course has not enabled
|
||||
`cert_html_view_enabled` settings.
|
||||
"""
|
||||
cert_config = None
|
||||
if settings.FEATURES.get('CERTIFICATES_HTML_VIEW', False) and course.cert_html_view_enabled:
|
||||
cert_config = False
|
||||
certificates = getattr(course, 'certificates', {})
|
||||
configurations = certificates.get('certificates', [])
|
||||
for config in configurations:
|
||||
if config.get('is_active'):
|
||||
cert_config = True
|
||||
break
|
||||
return cert_config
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.conf import settings
|
||||
|
||||
from opaque_keys.edx.locations import Location
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
from contentstore.utils import course_image_url
|
||||
from contentstore.utils import course_image_url, has_active_web_certificate
|
||||
from models.settings import course_grading
|
||||
from xmodule.fields import Date
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -52,7 +52,8 @@ class CourseDetails(object):
|
||||
self.entrance_exam_minimum_score_pct = settings.FEATURES.get(
|
||||
'ENTRANCE_EXAM_MIN_SCORE_PCT',
|
||||
'50'
|
||||
) # minimum passing score for entrance exam content module/tree
|
||||
) # minimum passing score for entrance exam content module/tree,
|
||||
self.has_cert_config = None # course has active certificate configuration
|
||||
|
||||
@classmethod
|
||||
def _fetch_about_attribute(cls, course_key, attribute):
|
||||
@@ -84,6 +85,7 @@ class CourseDetails(object):
|
||||
course_details.language = descriptor.language
|
||||
# Default course license is "All Rights Reserved"
|
||||
course_details.license = getattr(descriptor, "license", "all-rights-reserved")
|
||||
course_details.has_cert_config = has_active_web_certificate(descriptor)
|
||||
|
||||
for attribute in ABOUT_ATTRIBUTES:
|
||||
value = cls._fetch_about_attribute(course_key, attribute)
|
||||
|
||||
Reference in New Issue
Block a user