'Run rescore scenario on custom problem that uses randomize'

def test_rescoring_randomized_problem(self):

    problem_url_name = 'H1P1'
    self.define_randomized_custom_response_problem(problem_url_name)
    location = InstructorTaskModuleTestCase.problem_location(problem_url_name)
    descriptor = self.module_store.get_item(location)
    for user in self.users:
        self.render_problem(user.username, problem_url_name)
        dummy_answer = '1000'
        self.submit_student_answer(user.username, problem_url_name, [dummy_answer, dummy_answer])
        self.check_state(user, descriptor, 0, 1, expected_attempts=1)
        module = self.get_student_module(user.username, descriptor)
        state = json.loads(module.state)
        correct_map = state['correct_map']
        log.info('Correct    Map:    %s', correct_map)
        answer = correct_map.values()[0]['msg']
        self.submit_student_answer(user.username, problem_url_name, [answer, answer])
        self.check_state(user, descriptor, 1, 1, expected_attempts=2)
    self.define_randomized_custom_response_problem(problem_url_name, redefine=True)
    self.render_problem('u1', problem_url_name)
    self.check_state(self.user1, descriptor, 1, 1, expected_attempts=2)
    self.submit_rescore_one_student_answer('instructor', problem_url_name, User.objects.get(username='u1'))
    for user in self.users:
        expected_score = (0 if (user.username == 'u1') else 1)
        self.check_state(user, descriptor, expected_score, 1, expected_attempts=2)
    self.submit_rescore_all_student_answers('instructor', problem_url_name)
    for user in self.users:
        self.check_state(user, descriptor, 0, 1, expected_attempts=2)
