peer_calibrate.py 1.49 KB
Newer Older
1 2 3 4 5 6
"""
Page that allows the student to grade calibration essays
(requirement for being allowed to grade peers).
"""

from bok_choy.page_object import PageObject
7
from bok_choy.promise import Promise
8 9 10 11 12 13 14 15 16 17 18
from .rubric import RubricPage


class PeerCalibratePage(PageObject):
    """
    Grade calibration essays.
    """

    url = None

    def is_browser_on_page(self):
19 20 21 22 23 24 25 26 27

        def _is_correct_page():
            is_present = (
                self.q(css='div.peer-grading-tools').present or
                self.q(css='div.calibration-panel.current-state').present
            )
            return is_present, is_present

        return Promise(_is_correct_page, 'On the peer grading calibration page.').fulfill()
28 29 30 31 32

    def continue_to_grading(self):
        """
        Continue to peer grading after completing calibration.
        """
33
        self.q(css='input.calibration-feedback-button').first.click()
34 35 36 37 38 39 40 41

    @property
    def rubric(self):
        """
        Return a `RubricPage` for the calibration essay.
        If no rubric is available, raises a `BrokenPromise` exception.
        """
        rubric = RubricPage(self.browser)
42
        rubric.wait_for_page(timeout=60)
43 44 45 46 47 48 49
        return rubric

    @property
    def message(self):
        """
        Return a message shown to the user, or None if no message is available.
        """
50
        messages = self.q(css='div.peer-grading-tools > div.message-container > p').text
51 52 53 54
        if len(messages) < 1:
            return None
        else:
            return messages[0]