diff --git a/lms/djangoapps/courseware/tests/test_course_survey.py b/lms/djangoapps/courseware/tests/test_course_survey.py index ba79989f76..7a92a8e5f7 100644 --- a/lms/djangoapps/courseware/tests/test_course_survey.py +++ b/lms/djangoapps/courseware/tests/test_course_survey.py @@ -106,6 +106,20 @@ class SurveyViewsTests(LoginEnrollmentTestCase): """ self._assert_survey_redirect(self.course) + def test_anonymous_user_visiting_course_with_survey(self): + """ + Verifies that anonymous user going to the courseware info with an unanswered survey is not + redirected to survery and info page renders without server error. + """ + self.logout() + resp = self.client.get( + reverse( + 'info', + kwargs={'course_id': unicode(self.course.id)} + ) + ) + self.assertEquals(resp.status_code, 200) + def test_visiting_course_with_existing_answers(self): """ Verifies that going to the courseware with an answered survey, there is no redirect diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 5887aa6489..002dd5f51e 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -586,7 +586,7 @@ def course_info(request, course_id): # check to see if there is a required survey that must be taken before # the user can access the course. - if survey.utils.must_answer_survey(course, request.user): + if request.user.is_authenticated() and survey.utils.must_answer_survey(course, request.user): return redirect(reverse('course_survey', args=[unicode(course.id)])) staff_access = has_access(request.user, 'staff', course)