feat: add course waffle flag for learner assistant (#32657)

This commit is contained in:
alangsto
2023-07-06 10:19:58 -04:00
committed by GitHub
parent a68a1ed434
commit 6f00f63da6
4 changed files with 42 additions and 1 deletions

View File

@@ -114,6 +114,7 @@ class CourseInfoSerializer(serializers.Serializer): # pylint: disable=abstract-
linkedin_add_to_profile_url = serializers.URLField()
is_integrity_signature_enabled = serializers.BooleanField()
user_needs_integrity_signature = serializers.BooleanField()
learning_assistant_launch_url = serializers.CharField()
def __init__(self, *args, **kwargs):
"""

View File

@@ -32,6 +32,7 @@ from lms.djangoapps.courseware.models import LastSeenCoursewareTimezone
from lms.djangoapps.courseware.tabs import ExternalLinkCourseTab
from lms.djangoapps.courseware.tests.helpers import MasqueradeMixin
from lms.djangoapps.courseware.toggles import (
COURSEWARE_LEARNING_ASSISTANT,
COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES,
COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES_STREAK_CELEBRATION,
)
@@ -429,6 +430,19 @@ class CourseApiTestViews(BaseCoursewareTests, MasqueradeMixin):
assert 'can_access_proctored_exams' in courseware_data
assert courseware_data['can_access_proctored_exams'] == result
@ddt.data(
True,
False
)
def test_learning_assistant_launch_url(self, enabled):
with override_waffle_flag(COURSEWARE_LEARNING_ASSISTANT, active=enabled):
response = self.client.get(self.url)
launch_url = response.json()['learning_assistant_launch_url']
if enabled:
assert launch_url == ""
else:
assert launch_url is None
@ddt.ddt
class SequenceApiTestViews(MasqueradeMixin, BaseCoursewareTests):

View File

@@ -41,7 +41,7 @@ from lms.djangoapps.courseware.masquerade import (
)
from lms.djangoapps.courseware.models import LastSeenCoursewareTimezone
from lms.djangoapps.courseware.block_render import get_block_by_usage_id
from lms.djangoapps.courseware.toggles import course_exit_page_is_active
from lms.djangoapps.courseware.toggles import course_exit_page_is_active, learning_assistant_is_active
from lms.djangoapps.courseware.views.views import get_cert_data
from lms.djangoapps.gating.api import get_entrance_exam_score, get_entrance_exam_usage_key
from lms.djangoapps.grades.api import CourseGradeFactory
@@ -359,6 +359,15 @@ class CoursewareMeta:
enrollment_active = self.enrollment['is_active']
return enrollment_active and CourseMode.is_eligible_for_certificate(enrollment_mode)
@property
def learning_assistant_launch_url(self):
"""
Returns a URL for the learning assistant LTI launch if applicable, otherwise None
"""
if learning_assistant_is_active(self.course_key):
return "" # TODO: replace empty string with LTI launch URL as part of MST-1975
return None
class CoursewareInformation(RetrieveAPIView):
"""
@@ -448,6 +457,7 @@ class CoursewareInformation(RetrieveAPIView):
verified mode. Will update to reverify URL if necessary.
* linkedin_add_to_profile_url: URL to add the effective user's certificate to a LinkedIn Profile.
* user_needs_integrity_signature: Whether the user needs to sign the integrity agreement for the course
* learning_assistant_launch_url: URL for the LTI launch of a learning assistant
**Parameters:**