def test_review_problem_urls(self, num_desired): """ Verify that the URLs returned from the Review xBlock are valid and correct URLs for the problems the learner has seen. """ self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_actual) self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_review) # Loading problems so the learner has enough problems in the CSM self.client.get(reverse( 'courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section1_actual.location.block_id, } )) self.client.get(reverse( 'courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section2_actual.location.block_id, } )) self.client.get(reverse( 'courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section3_actual.location.block_id, } )) user = User.objects.get(email=self.STUDENTS[0]['email']) crum.set_current_user(user) result_urls = get_review_ids.get_problems(num_desired, self.course_actual.id) expected_urls = [ (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_5', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0) ] # Since the problems are randomly selected, we have to check # the correct number of urls are returned. count = 0 for url in expected_urls: if url in result_urls: count += 1 self.assertEqual(count, num_desired)
def test_review_problem_urls(self, num_desired): """ Verify that the URLs returned from the Review xBlock are valid and correct URLs for the problems the learner has seen. """ self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_actual) self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_review) # Loading problems so the learner has enough problems in the CSM self.client.get( reverse('courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section1_actual.location.block_id, })) self.client.get( reverse('courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section2_actual.location.block_id, })) self.client.get( reverse('courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section3_actual.location.block_id, })) user = User.objects.get(email=self.STUDENTS[0]['email']) crum.set_current_user(user) result_urls = get_review_ids.get_problems(num_desired, self.course_actual.id) expected_urls = [ (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_5', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0) ] # Since the problems are randomly selected, we have to check # the correct number of urls are returned. count = 0 for url in expected_urls: if url in result_urls: count += 1 self.assertEqual(count, num_desired)
def test_review_problem_urls_unique_problem(self, num_desired): """ Verify that the URLs returned from the Review xBlock are valid and correct URLs for the problems the learner has seen. This test will give a unique problem to a learner and verify only that learner sees it as a review. It will also ensure that if a learner has not loaded a problem, it should never show up as a review problem """ self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_actual) self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_review) # Loading problems so the learner has enough problems in the CSM self.client.get( reverse('courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section1_actual.location.block_id, })) self.client.get( reverse('courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section3_actual.location.block_id, })) user = User.objects.get(email=self.STUDENTS[0]['email']) crum.set_current_user(user) result_urls = get_review_ids.get_problems(num_desired, self.course_actual.id) expected_urls = [ (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0), # This is the unique problem when num_desired == 5 (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0) ] expected_not_loaded_problem = (self.URL_BEGINNING + 'problem+block@Problem_5', True, 0) # Since the problems are randomly selected, we have to check # the correct number of urls are returned. count = 0 for url in expected_urls: if url in result_urls: count += 1 self.assertEqual(count, num_desired) self.assertNotIn(expected_not_loaded_problem, result_urls)
def test_review_problem_urls_unique_problem(self, num_desired): """ Verify that the URLs returned from the Review xBlock are valid and correct URLs for the problems the learner has seen. This test will give a unique problem to a learner and verify only that learner sees it as a review. It will also ensure that if a learner has not loaded a problem, it should never show up as a review problem """ self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_actual) self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_review) # Loading problems so the learner has enough problems in the CSM self.client.get(reverse( 'courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section1_actual.location.block_id, } )) self.client.get(reverse( 'courseware_section', kwargs={ 'course_id': self.course_actual.id, 'chapter': self.chapter_actual.location.block_id, 'section': self.section3_actual.location.block_id, } )) user = User.objects.get(email=self.STUDENTS[0]['email']) crum.set_current_user(user) result_urls = get_review_ids.get_problems(num_desired, self.course_actual.id) expected_urls = [ (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0), (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0), # This is the unique problem when num_desired == 5 (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0) ] expected_not_loaded_problem = (self.URL_BEGINNING + 'problem+block@Problem_5', True, 0) # Since the problems are randomly selected, we have to check # the correct number of urls are returned. count = 0 for url in expected_urls: if url in result_urls: count += 1 self.assertEqual(count, num_desired) self.assertNotIn(expected_not_loaded_problem, result_urls)