def setup_students_and_grades(context):
 if context.course:
  context.student = student = UserFactory.create()
  CourseEnrollmentFactory.create(user=student, course_id=context.course.id)
  context.student2 = student2 = UserFactory.create()
  CourseEnrollmentFactory.create(user=student2, course_id=context.course.id)
  for chapter in context.course.get_children():
   for (i, section) in enumerate(chapter.get_children()):
    for (j, problem) in enumerate(section.get_children()):
     StudentModuleFactory.create(grade=(1 if (i < j) else 0), max_grade=1, student=context.student, course_id=context.course.id, module_state_key=problem.location)
     StudentModuleFactory.create(grade=(1 if (i > j) else 0), max_grade=1, student=context.student2, course_id=context.course.id, module_state_key=problem.location)

def setup_students_and_grades ( context ) : if context . course : context . student = student = UserFactory . create ( ) CourseEnrollmentFactory . create ( user = student , course_id = context . course . id ) context . student2 = student2 = UserFactory . create ( ) CourseEnrollmentFactory . create ( user = student2 , course_id = context . course . id ) for chapter in context . course . get_children ( ) : for ( i , section ) in enumerate ( chapter . get_children ( ) ) : for ( j , problem ) in enumerate ( section . get_children ( ) ) : StudentModuleFactory . create ( grade = ( 1 if ( i < j ) else 0 ) , max_grade = 1 , student = context . student , course_id = context . course . id , module_state_key = problem . location ) StudentModuleFactory . create ( grade = ( 1 if ( i > j ) else 0 ) , max_grade = 1 , student = context . student2 , course_id = context . course . id , module_state_key = problem . location )
create students and set their grades .