Example #1
0
    def setUp(self):
        """Create a course that is closed for enrollment, and sign in as a user."""
        super(EnrollmentClosedRedirectTest, self).setUp()
        course = CourseFixture(
            self.course_info['org'], self.course_info['number'],
            self.course_info['run'], self.course_info['display_name']
        )
        now = datetime.now(pytz.UTC)
        course.add_course_details({
            'enrollment_start': (now - timedelta(days=30)).isoformat(),
            'enrollment_end': (now - timedelta(days=1)).isoformat()
        })
        course.install()

        # Add an honor mode to the course
        ModeCreationPage(self.browser, self.course_id).visit()

        # Add a verified mode to the course
        ModeCreationPage(
            self.browser,
            self.course_id,
            mode_slug=u'verified',
            mode_display_name=u'Verified Certificate',
            min_price=10,
            suggested_prices='10,20'
        ).visit()
Example #2
0
    def setUp(self):
        """Create a course that is closed for enrollment, and sign in as a user."""
        super(EnrollmentClosedRedirectTest, self).setUp()
        course = CourseFixture(
            self.course_info['org'], self.course_info['number'],
            self.course_info['run'], self.course_info['display_name']
        )
        now = datetime.now(pytz.UTC)
        course.add_course_details({
            'enrollment_start': (now - timedelta(days=30)).isoformat(),
            'enrollment_end': (now - timedelta(days=1)).isoformat()
        })
        course.install()

        # Add an honor mode to the course
        ModeCreationPage(self.browser, self.course_id).visit()

        # Add a verified mode to the course
        ModeCreationPage(
            self.browser,
            self.course_id,
            mode_slug=u'verified',
            mode_display_name=u'Verified Certificate',
            min_price=10,
            suggested_prices='10,20'
        ).visit()
Example #3
0
class DragAndDropXblockWithMixinsTest(UniqueCourseTest):
    """
    Test Suite to verify various behaviors of DragAndDrop Xblock on the LMS.
    """

    def setUp(self):
        super(DragAndDropXblockWithMixinsTest, self).setUp()

        self.username = "******".format(uuid=self.unique_id[0:8])
        self.email = "{username}@example.com".format(username=self.username)
        self.password = "******"
        self.courseware_page = CoursewarePage(self.browser, self.course_id)

        # Install a course with a hierarchy and problems
        self.course_fixture = CourseFixture(
            self.course_info['org'], self.course_info['number'],
            self.course_info['run'], self.course_info['display_name'],
            start_date=datetime.now() + timedelta(days=10)
        )
        self.browser.set_window_size(1024, 1024)

    def setup_sequential(self, metadata):
        """
        Setup a sequential with DnD problem, alongwith the metadata provided.

        This method will allow to customize the sequential, such as changing the
        due date for individual tests.
        """
        problem = self.get_problem()
        sequential = self.get_sequential(metadata=metadata)
        self.course_fixture.add_children(
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                sequential.add_children(problem)
            )
        ).install()

        # Auto-auth register for the course.
        AutoAuthPage(
            self.browser,
            username=self.username,
            email=self.email,
            password=self.password,
            course_id=self.course_id,
            staff=True
        ).visit()

    def format_date(self, date_value):
        """
        Get the date in isoformat as this is required format to add date data
        in the sequential.
        """
        return date_value.isoformat()

    def get_problem(self):
        """
        Creating a DnD problem with assessment mode
        """
        return XBlockFixtureDesc('drag-and-drop-v2', 'DnD', metadata={'mode': "assessment"})

    def get_sequential(self, metadata=None):
        return XBlockFixtureDesc('sequential', 'Test Subsection', metadata=metadata)

    @ddt.data(
        (datetime.now(), True),
        (datetime.now() - timedelta(days=1), True),
        (datetime.now() + timedelta(days=1), False)
    )
    @ddt.unpack
    def test_submit_button_status_with_due_date(self, due_date, is_button_disabled):
        """
        Scenario: Test that DnD submit button will be enabled if section is not past due.

        Given I have a sequential in instructor-paced course
        And a DnD problem with assessment mode is present in the sequential
        When I visit the problem
        Then the submit button should be present
        And button should be disabled as some item needs to be on a zone
        When I drag an item to a zone
        Then submit button will be enabled if due date has not passed, else disabled
        """
        problem_page = DragAndDropPage(self.browser)
        self.setup_sequential(metadata={'due': self.format_date(due_date)})
        self.courseware_page.visit()
        self.assertTrue(problem_page.is_submit_button_present())
        self.assertTrue(problem_page.is_submit_disabled())
        problem_page.drag_item_to_zone(0, 'middle')
        self.assertEqual(is_button_disabled, problem_page.is_submit_disabled())

    def test_submit_button_when_pacing_change_self_paced(self):
        """
        Scenario: For a self-paced course, the submit button of DnD problems will be
        be enabled, regardless of the subsection due date.

        Given a DnD problem in a subsection with past due date
        And the course is instructor-paced
        Then the submit button will remain disabled after initial drag
        When the pacing is changed to self-paced
        Then the submit button is not disabled anymore
        """
        problem_page = DragAndDropPage(self.browser)
        self.setup_sequential(metadata={'due': self.format_date(datetime.now())})
        self.courseware_page.visit()
        problem_page.drag_item_to_zone(0, 'middle')
        self.assertTrue(problem_page.is_submit_disabled())
        self.course_fixture.add_course_details({'self_paced': True})
        self.course_fixture.configure_course()
        self.courseware_page.visit()
        self.assertFalse(problem_page.is_submit_disabled())