def test_user_not_yet_answered_required_survey(self): """ Assert that a new course which has a required survey but user has not answered it yet """ assert not check_survey_required_and_unanswered( self.student, self.course) temp_course = CourseFactory.create(course_survey_required=False) assert check_survey_required_and_unanswered(self.student, temp_course) temp_course = CourseFactory.create(course_survey_required=True, course_survey_name="NonExisting") assert check_survey_required_and_unanswered(self.student, temp_course)
def test_user_has_answered_required_survey(self): """ Assert that a new course which has a required survey and user has answers for it """ self.survey.save_user_answers(self.student, self.student_answers, None) self.assertTrue( check_survey_required_and_unanswered(self.student, self.course))
def _check_nonstaff_access(): # Below is a series of checks that must all pass for a user to be granted access # to a course. (Essentially check this AND check that AND...) # Also note: access_response (AccessResponse) objects are compared as booleans access_response = has_access(user, action, course, course.id) if not access_response: return access_response if check_if_authenticated: authentication_access_response = check_authentication(user, course) if not authentication_access_response: return authentication_access_response if check_if_enrolled: enrollment_access_response = check_enrollment(user, course) if not enrollment_access_response: return enrollment_access_response # Redirect if the user must answer a survey before entering the course. if check_survey_complete and action == 'load': survey_access_response = check_survey_required_and_unanswered( user, course) if not survey_access_response: return survey_access_response # This access_response will be ACCESS_GRANTED return access_response
def test_staff_must_answer_survey(self): """ Assert that someone with staff level permissions does not have to answer the survey """ self.assertTrue( check_survey_required_and_unanswered(self.staff, self.course))