'Run a reset task for one student, with several StudentModules for the problem defined.'

def _test_reset_with_student(self, use_email):

    num_students = 10
    initial_attempts = 3
    input_state = json.dumps({'attempts': initial_attempts})
    students = self._create_students_with_state(num_students, input_state)
    for student in students:
        module = StudentModule.objects.get(course_id=self.course.id, student=student, module_state_key=self.location)
        state = json.loads(module.state)
        self.assertEquals(state['attempts'], initial_attempts)
    if use_email:
        student_ident = students[3].email
    else:
        student_ident = students[3].username
    task_entry = self._create_input_entry(student_ident)
    status = self._run_task_with_mock_celery(reset_problem_attempts, task_entry.id, task_entry.task_id)
    self.assertEquals(status.get('attempted'), 1)
    self.assertEquals(status.get('succeeded'), 1)
    self.assertEquals(status.get('total'), 1)
    self.assertEquals(status.get('action_name'), 'reset')
    self.assertGreater(status.get('duration_ms'), 0)
    entry = InstructorTask.objects.get(id=task_entry.id)
    self.assertEquals(json.loads(entry.task_output), status)
    self.assertEquals(entry.task_state, SUCCESS)
    for (index, student) in enumerate(students):
        module = StudentModule.objects.get(course_id=self.course.id, student=student, module_state_key=self.location)
        state = json.loads(module.state)
        if (index == 3):
            self.assertEquals(state['attempts'], 0)
        else:
            self.assertEquals(state['attempts'], initial_attempts)
