<commit_before># -*- coding: utf-8 -*-
"""
Instructor (2) dashboard page.
"""

from bok_choy.page_object import PageObject
from .course_page import CoursePage
import os
from bok_choy.promise import EmptyPromise, Promise
from ...tests.helpers import select_option_by_text, get_selected_option_text, get_options


class InstructorDashboardPage(CoursePage):
    """
    Instructor dashboard, where course staff can manage a course.
    """
    url_path = "instructor"

    def is_browser_on_page(self):
        return self.q(css='div.instructor-dashboard-wrapper-2').present

    def select_membership(self):
        """
        Selects the membership tab and returns the MembershipSection
        """
        self.q(css='a[data-section=membership]').first.click()
        membership_section = MembershipPage(self.browser)
        membership_section.wait_for_page()
        return membership_section

    def select_cohort_management(self):
        """
        Selects the cohort management tab and returns the CohortManagementSection
        """
        self.q(css='a[data-section=cohort_management]').first.click()
        cohort_management_section = CohortManagementSection(self.browser)
        # The first time cohort management is selected, an ajax call is made.
        cohort_management_section.wait_for_ajax()
        cohort_management_section.wait_for_page()
        return cohort_management_section

    def select_data_download(self):
        """
        Selects the data download tab and returns a DataDownloadPage.
        """
        self.q(css='a[data-section=data_download]').first.click()
        data_download_section = DataDownloadPage(self.browser)
        data_download_section.wait_for_page()
        return data_download_section

    def select_student_admin(self):
        """
        Selects the student admin tab and returns the MembershipSection
        """
        self.q(css='a[data-section=student_admin]').first.click()
        student_admin_section = StudentAdminPage(self.browser)
        student_admin_section.wait_for_page()
        return student_admin_section

    @staticmethod
    def get_asset_path(file_name):
        """
        Returns the full path of the file to upload.
        These files have been placed in edx-platform/common/test/data/uploads/
        """

        # Separate the list of folders in the path reaching to the current file,
        # e.g.  '... common/test/acceptance/pages/lms/instructor_dashboard.py' will result in
        #       [..., 'common', 'test', 'acceptance', 'pages', 'lms', 'instructor_dashboard.py']
        folders_list_in_path = __file__.split(os.sep)

        # Get rid of the last 4 elements: 'acceptance', 'pages', 'lms', and 'instructor_dashboard.py'
        # to point to the 'test' folder, a shared point in the path's tree.
        folders_list_in_path = folders_list_in_path[:-4]

        # Append the folders in the asset's path
        folders_list_in_path.extend(['data', 'uploads', file_name])

        # Return the joined path of the required asset.
        return os.sep.join(folders_list_in_path)


class MembershipPage(PageObject):
    """
    Membership section of the Instructor dashboard.
    """
    url = None

    def is_browser_on_page(self):
        return self.q(css='a[data-section=membership].active-section').present

    def select_auto_enroll_section(self):
        """
        Returns the MembershipPageAutoEnrollSection page object.
        """
        return MembershipPageAutoEnrollSection(self.browser)


class CohortManagementSection(PageObject):
    """
    The Cohort Management section of the Instructor dashboard.
    """
    url = None
    csv_browse_button_selector_css = '.csv-upload #file-upload-form-file'
    csv_upload_button_selector_css = '.csv-upload #file-upload-form-submit'
    content_group_selector_css = 'select.input-cohort-group-association'
    no_content_group_button_css = '.cohort-management-details-association-course input.radio-no'
    select_content_group_button_css = '.cohort-management-details-association-course input.radio-yes'
    assignment_type_buttons_css = '.cohort-management-assignment-type-settings input'
    discussion_form_selectors = {
        'course-wide': '.cohort-course-wide-discussions-form',
        'inline': '.cohort-inline-discussions-form'
    }

    def is_browser_on_page(self):
        """
        Cohorts management exists under one class; however, render time can be longer because of sub-classes
        that must be rendered beneath it. To determine if the browser is on the cohorts management page (and
        allow for it to fully-render), we need to consider three different states of the page:
        * When no cohorts have been added yet
        * When a new cohort is being added (a confirmation state)
        * When cohorts exist (the traditional management page)
        """
        cohorts_warning_title = '.message-warning .message-title'

        if self.q(css=cohorts_warning_title).visible:
            return self.q(css='.message-title').text[0] == u'You currently have no cohorts configured'
        # The page may be in either the traditional management state, or an 'add new cohort' state.
        # Confirm the CSS class is visible because the CSS class can exist on the page even in different states.
        return self.q(css='.cohort-management-nav').visible or self.q(css='.new-cohort-form').visible

    def _bounded_selector(self, selector):
        """<commit_msg>Look for a consistent css class.<commit_after># -*- coding: utf-8 -*-
"""
Instructor (2) dashboard page.
"""

from bok_choy.page_object import PageObject
from .course_page import CoursePage
import os
from bok_choy.promise import EmptyPromise, Promise
from ...tests.helpers import select_option_by_text, get_selected_option_text, get_options


class InstructorDashboardPage(CoursePage):
    """
    Instructor dashboard, where course staff can manage a course.
    """
    url_path = "instructor"

    def is_browser_on_page(self):
        return self.q(css='div.instructor-dashboard-wrapper-2').present

    def select_membership(self):
        """
        Selects the membership tab and returns the MembershipSection
        """
        self.q(css='a[data-section=membership]').first.click()
        membership_section = MembershipPage(self.browser)
        membership_section.wait_for_page()
        return membership_section

    def select_cohort_management(self):
        """
        Selects the cohort management tab and returns the CohortManagementSection
        """
        self.q(css='a[data-section=cohort_management]').first.click()
        cohort_management_section = CohortManagementSection(self.browser)
        # The first time cohort management is selected, an ajax call is made.
        cohort_management_section.wait_for_ajax()
        cohort_management_section.wait_for_page()
        return cohort_management_section

    def select_data_download(self):
        """
        Selects the data download tab and returns a DataDownloadPage.
        """
        self.q(css='a[data-section=data_download]').first.click()
        data_download_section = DataDownloadPage(self.browser)
        data_download_section.wait_for_page()
        return data_download_section

    def select_student_admin(self):
        """
        Selects the student admin tab and returns the MembershipSection
        """
        self.q(css='a[data-section=student_admin]').first.click()
        student_admin_section = StudentAdminPage(self.browser)
        student_admin_section.wait_for_page()
        return student_admin_section

    @staticmethod
    def get_asset_path(file_name):
        """
        Returns the full path of the file to upload.
        These files have been placed in edx-platform/common/test/data/uploads/
        """

        # Separate the list of folders in the path reaching to the current file,
        # e.g.  '... common/test/acceptance/pages/lms/instructor_dashboard.py' will result in
        #       [..., 'common', 'test', 'acceptance', 'pages', 'lms', 'instructor_dashboard.py']
        folders_list_in_path = __file__.split(os.sep)

        # Get rid of the last 4 elements: 'acceptance', 'pages', 'lms', and 'instructor_dashboard.py'
        # to point to the 'test' folder, a shared point in the path's tree.
        folders_list_in_path = folders_list_in_path[:-4]

        # Append the folders in the asset's path
        folders_list_in_path.extend(['data', 'uploads', file_name])

        # Return the joined path of the required asset.
        return os.sep.join(folders_list_in_path)


class MembershipPage(PageObject):
    """
    Membership section of the Instructor dashboard.
    """
    url = None

    def is_browser_on_page(self):
        return self.q(css='a[data-section=membership].active-section').present

    def select_auto_enroll_section(self):
        """
        Returns the MembershipPageAutoEnrollSection page object.
        """
        return MembershipPageAutoEnrollSection(self.browser)


class CohortManagementSection(PageObject):
    """
    The Cohort Management section of the Instructor dashboard.
    """
    url = None
    csv_browse_button_selector_css = '.csv-upload #file-upload-form-file'
    csv_upload_button_selector_css = '.csv-upload #file-upload-form-submit'
    content_group_selector_css = 'select.input-cohort-group-association'
    no_content_group_button_css = '.cohort-management-details-association-course input.radio-no'
    select_content_group_button_css = '.cohort-management-details-association-course input.radio-yes'
    assignment_type_buttons_css = '.cohort-management-assignment-type-settings input'
    discussion_form_selectors = {
        'course-wide': '.cohort-course-wide-discussions-form',
        'inline': '.cohort-inline-discussions-form'
    }

    def is_browser_on_page(self):
        """
        Cohorts management exists under one class; however, render time can be longer because of sub-classes
        that must be rendered beneath it. To determine if the browser is on the cohorts management page (and
        allow for it to fully-render), we need to consider three different states of the page:
        * When no cohorts have been added yet
        * When a new cohort is being added (a confirmation state)
        * When cohorts exist (the traditional management page)
        """
        cohorts_warning_title = '.message-warning .message-title'

        if self.q(css=cohorts_warning_title).visible:
            return self.q(css='.message-title').text[0] == u'You currently have no cohorts configured'
        # The page may be in either the traditional management state, or an 'add new cohort' state.
        # Confirm the CSS class is visible because the CSS class can exist on the page even in different states.
        return self.q(css='.cohorts-state-section').visible or self.q(css='.new-cohort-form').visible

    def _bounded_selector(self, selector):
        """
{'fraction_non_alphanumeric': 0.09274965800273598, 'fraction_numerical': 0.001094391244870041, 'mean_word_length': 3.1490730230798336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4150245', 'n_tokens_mistral': 3174, 'n_tokens_neox': 3039, 'n_words': 811}