peer_grade.py 1.04 KB
Newer Older
1 2 3 4 5
"""
Students grade peer submissions.
"""

from bok_choy.page_object import PageObject
6
from bok_choy.promise import Promise
7 8 9 10 11 12 13 14 15 16


class PeerGradePage(PageObject):
    """
    Students grade peer submissions.
    """

    url = None

    def is_browser_on_page(self):
17 18 19 20 21 22 23 24
        def _is_correct_page():
            is_present = (
                self.q(css='div.peer-grading-tools').present or
                self.q(css='div.grading-panel.current-state').present
            )
            return is_present, is_present

        return Promise(_is_correct_page, 'On the peer grading page.').fulfill()
25 26 27 28 29 30

    @property
    def problem_list(self):
        """
        Return the list of available problems to peer grade.
        """
31
        return self.q(css='a.problem-button').text
32 33 34 35 36 37

    def select_problem(self, problem_name):
        """
        Choose the problem with `problem_name` to start grading or calibrating.
        """
        index = self.problem_list.index(problem_name) + 1
38
        self.q(css='a.problem-button:nth-of-type({})'.format(index)).first.click()