示例#1
0
def i_am_registered_for_the_course(coursenum, metadata, user='******'):
    # Create user
    if user == 'BetaTester':
        # Create the course
        now = datetime.datetime.now(pytz.UTC)
        tomorrow = now + datetime.timedelta(days=5)
        metadata.update({'days_early_for_beta': 5, 'start': tomorrow})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']
        course_location = world.scenario_dict['COURSE'].location

        # create beta tester
        user = BetaTesterFactory(course=course_location)
        normal_student = UserFactory()
        instructor = InstructorFactory(course=course_location)

        assert not has_access(normal_student, course_descriptor, 'load')
        assert has_access(user, course_descriptor, 'load')
        assert has_access(instructor, course_descriptor, 'load')
    else:
        metadata.update({'start': datetime.datetime(1970, 1, 1, tzinfo=UTC)})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']
        course_location = world.scenario_dict['COURSE'].location
        user = InstructorFactory(course=course_location)

    # Enroll the user in the course and log them in
    if has_access(user, course_descriptor, 'load'):
        world.enroll_user(user, course_id(coursenum))

    world.log_in(username=user.username, password='******')
示例#2
0
def i_am_registered_for_the_course(coursenum, metadata, user='******'):
    # Create user
    if user == 'BetaTester':
        # Create the course
        now = datetime.datetime.now(pytz.UTC)
        tomorrow = now + datetime.timedelta(days=5)
        metadata.update({'days_early_for_beta': 5, 'start': tomorrow})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']

        # create beta tester
        user = BetaTesterFactory(course_key=course_descriptor.id)
        normal_student = UserFactory()
        instructor = InstructorFactory(course_key=course_descriptor.id)

        assert not has_access(normal_student, 'load', course_descriptor)
        assert has_access(user, 'load', course_descriptor)
        assert has_access(instructor, 'load', course_descriptor)
    else:
        metadata.update({'start': datetime.datetime(1970, 1, 1, tzinfo=UTC)})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']
        user = InstructorFactory(course_key=course_descriptor.id)

    # Enroll the user in the course and log them in
    if has_access(user, 'load', course_descriptor):
        world.enroll_user(user, course_descriptor.id)

    world.log_in(username=user.username, password='******')
示例#3
0
def make_populated_course(step):  # pylint: disable=unused-argument
    ## This is different than the function defined in common.py because it enrolls
    ## a staff, instructor, and student member regardless of what `role` is, then
    ## logs `role` in. This is to ensure we have 3 class participants to email.

    # Clear existing courses to avoid conflicts
    world.clear_courses()

    # Create a new course
    course = world.CourseFactory.create(org="edx", number="888", display_name="Bulk Email Test Course")
    world.bulk_email_course_key = course.id

    try:
        # See if we've defined the instructor & staff user yet
        world.bulk_email_instructor
    except AttributeError:
        # Make & register an instructor for the course
        world.bulk_email_instructor = InstructorFactory(course_key=world.bulk_email_course_key)
        world.enroll_user(world.bulk_email_instructor, world.bulk_email_course_key)

        # Make & register a staff member
        world.bulk_email_staff = StaffFactory(course_key=course.id)
        world.enroll_user(world.bulk_email_staff, world.bulk_email_course_key)

    # Make & register a student
    world.register_by_course_key(course.id, username="******", password="******", is_staff=False)

    # Store the expected recipients
    # given each "send to" option
    staff_emails = [world.bulk_email_staff.email, world.bulk_email_instructor.email]
    world.expected_addresses = {
        "course staff": staff_emails,
        "students, staff, and instructors": staff_emails + ["*****@*****.**"],
    }
示例#4
0
def i_am_registered_for_the_course(course, metadata):
    # Create the course
    create_course(course, metadata)

    # Create an instructor
    instructor = InstructorFactory(course=world.scenario_dict['COURSE'].location)

    # Enroll the user in the course and log them in
    world.enroll_user(instructor, course_id(course))
    world.log_in(username=instructor.username, password='******')
示例#5
0
def i_am_registered_for_the_course(course, metadata):
    # Create the course
    create_course(course, metadata)

    # Create an instructor
    instructor = InstructorFactory(
        course=world.scenario_dict['COURSE'].location)

    # Enroll the user in the course and log them in
    world.enroll_user(instructor, course_id(course))
    world.log_in(username=instructor.username, password='******')
示例#6
0
def i_am_staff_or_instructor(step, role):  # pylint: disable=unused-argument
    ## In summary: makes a test course, makes a new Staff or Instructor user
    ## (depending on `role`), and logs that user in to the course

    # Store the role
    assert_in(role, ['instructor', 'staff'])

    # Clear existing courses to avoid conflicts
    world.clear_courses()

    # Create a new course
    course = world.CourseFactory.create(
        org='edx',
        number='999',
        display_name='Test Course'
    )

    world.course_key = course.id
    world.role = 'instructor'
    # Log in as the an instructor or staff for the course
    if role == 'instructor':
        # Make & register an instructor for the course
        world.instructor = InstructorFactory(course_key=world.course_key)
        world.enroll_user(world.instructor, world.course_key)

        world.log_in(
            username=world.instructor.username,
            password='******',
            email=world.instructor.email,
            name=world.instructor.profile.name
        )

    else:
        world.role = 'staff'
        # Make & register a staff member
        world.staff = StaffFactory(course_key=world.course_key)
        world.enroll_user(world.staff, world.course_key)

        world.log_in(
            username=world.staff.username,
            password='******',
            email=world.staff.email,
            name=world.staff.profile.name
        )
示例#7
0
文件: common.py 项目: gopinath81/vmss
def i_am_staff_or_instructor(step, role):  # pylint: disable=unused-argument
    ## In summary: makes a test course, makes a new Staff or Instructor user
    ## (depending on `role`), and logs that user in to the course

    # Store the role
    assert_in(role, ['instructor', 'staff'])

    # Clear existing courses to avoid conflicts
    world.clear_courses()

    # Create a new course
    course = world.CourseFactory.create(
        org='edx',
        number='999',
        display_name='Test Course'
    )

    world.course_key = course.id
    world.role = 'instructor'
    # Log in as the an instructor or staff for the course
    if role == 'instructor':
        # Make & register an instructor for the course
        world.instructor = InstructorFactory(course_key=world.course_key)
        world.enroll_user(world.instructor, world.course_key)

        world.log_in(
            username=world.instructor.username,
            password='******',
            email=world.instructor.email,
            name=world.instructor.profile.name
        )

    else:
        world.role = 'staff'
        # Make & register a staff member
        world.staff = StaffFactory(course_key=world.course_key)
        world.enroll_user(world.staff, world.course_key)

        world.log_in(
            username=world.staff.username,
            password='******',
            email=world.staff.email,
            name=world.staff.profile.name
        )
示例#8
0
def make_populated_course(step):  # pylint: disable=unused-argument
    ## This is different than the function defined in common.py because it enrolls
    ## a staff, instructor, and student member regardless of what `role` is, then
    ## logs `role` in. This is to ensure we have 3 class participants to email.

    # Clear existing courses to avoid conflicts
    world.clear_courses()

    # Create a new course
    course = world.CourseFactory.create(org='edx',
                                        number='888',
                                        display_name='Bulk Email Test Course')
    world.bulk_email_course_key = course.id

    try:
        # See if we've defined the instructor & staff user yet
        world.bulk_email_instructor
    except AttributeError:
        # Make & register an instructor for the course
        world.bulk_email_instructor = InstructorFactory(
            course_key=world.bulk_email_course_key)
        world.enroll_user(world.bulk_email_instructor,
                          world.bulk_email_course_key)

        # Make & register a staff member
        world.bulk_email_staff = StaffFactory(course_key=course.id)
        world.enroll_user(world.bulk_email_staff, world.bulk_email_course_key)

    # Make & register a student
    world.register_by_course_key(course.id,
                                 username='******',
                                 password='******',
                                 is_staff=False)

    # Store the expected recipients
    # given each "send to" option
    staff_emails = [
        world.bulk_email_staff.email, world.bulk_email_instructor.email
    ]
    world.expected_addresses = {
        'course staff': staff_emails,
        'students, staff, and instructors': staff_emails + ['*****@*****.**']
    }
示例#9
0
def i_am_staff_or_instructor(step, role):  # pylint: disable=unused-argument
    ## In summary: makes a test course, makes a new Staff or Instructor user
    ## (depending on `role`), and logs that user in to the course

    # Store the role
    assert_in(role, ["instructor", "staff"])

    # Clear existing courses to avoid conflicts
    world.clear_courses()

    # Create a new course
    course = world.CourseFactory.create(org="edx", number="999", display_name="Test Course")

    world.course_id = "edx/999/Test_Course"
    world.role = "instructor"
    # Log in as the an instructor or staff for the course
    if role == "instructor":
        # Make & register an instructor for the course
        world.instructor = InstructorFactory(course=course.location)
        world.enroll_user(world.instructor, world.course_id)

        world.log_in(
            username=world.instructor.username,
            password="******",
            email=world.instructor.email,
            name=world.instructor.profile.name,
        )

    else:
        world.role = "staff"
        # Make & register a staff member
        world.staff = StaffFactory(course=course.location)
        world.enroll_user(world.staff, world.course_id)

        world.log_in(
            username=world.staff.username, password="******", email=world.staff.email, name=world.staff.profile.name
        )
示例#10
0
def i_am_staff_or_instructor(step, role):  # pylint: disable=unused-argument
    ## In summary: makes a test course, makes a new Staff or Instructor user
    ## (depending on `role`), and logs that user in to the course

    # Store the role
    assert_in(role, ['instructor', 'staff'])

    # Clear existing courses to avoid conflicts
    delete_pgreport_csv("edx/999/Test_Course")
    world.clear_courses()

    # Create a new course
    world.scenario_dict['COURSE'] = world.CourseFactory.create(
        org='edx',
        number='999',
        display_name='Test Course'
    )
    section1 = world.ItemFactory.create(
        parent_location=world.scenario_dict['COURSE'].location,
        category='chapter',
        display_name="Test Section 1"
    )
    subsec1 = world.ItemFactory.create(
        parent_location=section1.location,
        category='sequential',
        display_name="Test Subsection 1"
    )
    vertical1 = world.ItemFactory.create(
        parent_location=subsec1.location,
        category='vertical',
        display_name="Test Vertical 1",
    )
    problem_xml = PROBLEM_DICT['drop down']['factory'].build_xml(
        **PROBLEM_DICT['drop down']['kwargs'])
    problem1 = world.ItemFactory.create(
        parent_location=vertical1.location,
        category='problem',
        display_name="Problem 1",
        data=problem_xml
    )

    world.course_id = world.scenario_dict['COURSE'].id

    if not ProgressModules.objects.filter(location=problem1.location).exists():
        world.pgmodule = world.ProgressModulesFactory.create(
            location=problem1.location,
            course_id=world.course_id,
            display_name="Problem 1"
        )

    world.role = 'instructor'
    # Log in as the an instructor or staff for the course
    if role == 'instructor':
        # Make & register an instructor for the course
        world.instructor = InstructorFactory(
            course_key=world.scenario_dict['COURSE'].course_key)
        world.enroll_user(world.instructor, world.course_key)

        world.log_in(
            username=world.instructor.username,
            password='******',
            email=world.instructor.email,
            name=world.instructor.profile.name
        )

    else:
        world.role = 'staff'
        # Make & register a staff member
        world.staff = StaffFactory(
            course_key=world.scenario_dict['COURSE'].course_key)
        world.enroll_user(world.staff, world.course_key)

        world.log_in(
            username=world.staff.username,
            password='******',
            email=world.staff.email,
            name=world.staff.profile.name
        )

    create_pgreport_csv(world.course_id)
示例#11
0
def i_am_staff_or_instructor(step, role):  # pylint: disable=unused-argument
    ## In summary: makes a test course, makes a new Staff or Instructor user
    ## (depending on `role`), and logs that user in to the course

    # Store the role
    assert_in(role, ['instructor', 'staff'])

    # Clear existing courses to avoid conflicts
    delete_pgreport_csv("edx/999/Test_Course")
    world.clear_courses()

    # Create a new course
    world.scenario_dict['COURSE'] = world.CourseFactory.create(
        org='edx', number='999', display_name='Test Course')
    section1 = world.ItemFactory.create(
        parent_location=world.scenario_dict['COURSE'].location,
        category='chapter',
        display_name="Test Section 1")
    subsec1 = world.ItemFactory.create(parent_location=section1.location,
                                       category='sequential',
                                       display_name="Test Subsection 1")
    vertical1 = world.ItemFactory.create(
        parent_location=subsec1.location,
        category='vertical',
        display_name="Test Vertical 1",
    )
    problem_xml = PROBLEM_DICT['drop down']['factory'].build_xml(
        **PROBLEM_DICT['drop down']['kwargs'])
    problem1 = world.ItemFactory.create(parent_location=vertical1.location,
                                        category='problem',
                                        display_name="Problem 1",
                                        data=problem_xml)

    world.course_id = world.scenario_dict['COURSE'].id

    if not ProgressModules.objects.filter(location=problem1.location).exists():
        world.pgmodule = world.ProgressModulesFactory.create(
            location=problem1.location,
            course_id=world.course_id,
            display_name="Problem 1")

    world.role = 'instructor'
    # Log in as the an instructor or staff for the course
    if role == 'instructor':
        # Make & register an instructor for the course
        world.instructor = InstructorFactory(
            course_key=world.scenario_dict['COURSE'].course_key)
        world.enroll_user(world.instructor, world.course_key)

        world.log_in(username=world.instructor.username,
                     password='******',
                     email=world.instructor.email,
                     name=world.instructor.profile.name)

    else:
        world.role = 'staff'
        # Make & register a staff member
        world.staff = StaffFactory(
            course_key=world.scenario_dict['COURSE'].course_key)
        world.enroll_user(world.staff, world.course_key)

        world.log_in(username=world.staff.username,
                     password='******',
                     email=world.staff.email,
                     name=world.staff.profile.name)

    create_pgreport_csv(world.course_id)