diff --git a/lms/djangoapps/learner_dashboard/api/v0/views.py b/lms/djangoapps/learner_dashboard/api/v0/views.py index 69a972d829..b3f43eaf83 100644 --- a/lms/djangoapps/learner_dashboard/api/v0/views.py +++ b/lms/djangoapps/learner_dashboard/api/v0/views.py @@ -1,6 +1,7 @@ """ API v0 views. """ from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication +from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser from enterprise.models import EnterpriseCourseEnrollment from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAuthenticated @@ -347,7 +348,7 @@ class CourseRecommendationApiView(APIView): GET api/dashboard/v0/recommendation/courses/ """ - authentication_classes = (JwtAuthentication, SessionAuthentication,) + authentication_classes = (JwtAuthentication, SessionAuthenticationAllowInactiveUser,) permission_classes = (IsAuthenticated,) def get(self, request): @@ -379,4 +380,5 @@ class CourseRecommendationApiView(APIView): }) else: return Response(status=400) + return Response({'courses': recommended_courses, 'is_personalized_recommendation': not is_control}, status=200) diff --git a/lms/static/js/learner_dashboard/RecommendationsPanel.jsx b/lms/static/js/learner_dashboard/RecommendationsPanel.jsx index a8f1739be9..dc9133bfb2 100644 --- a/lms/static/js/learner_dashboard/RecommendationsPanel.jsx +++ b/lms/static/js/learner_dashboard/RecommendationsPanel.jsx @@ -37,13 +37,15 @@ class RecommendationsPanel extends React.Component { getCourseList = async () => { const coursesRecommendationData = await fetch(`${this.props.lmsRootUrl}/api/dashboard/v0/recommendation/courses/`) .then(response => { - if (response.status === 400) { - return this.props.generalRecommendations; - } else { - return response.json(); - } + if (response.status === 400) { + return this.props.generalRecommendations; + } else { + return response.json(); } - ); + }).catch(() => { + return this.props.generalRecommendations; + }); + this.setState({ coursesList: coursesRecommendationData['courses'], isPersonalizedRecommendation: coursesRecommendationData['is_personalized_recommendation']