Beispiel #1
0
 def setUp(self):
     """Set up a course, coach, ccx and user"""
     super().setUp()
     self.course = CourseFactory.create()
     coach = self.coach = AdminFactory.create()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(coach)
Beispiel #2
0
 def setUp(self):
     super().setUp()
     coach = AdminFactory.create()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(coach)
     self.ccx = CcxFactory(course_id=self.course.id, coach=coach)
     self.course_key = CCXLocator.from_course_locator(self.course.id, self.ccx.id)
Beispiel #3
0
    def setUp(self):
        """
        Set up courses and enrollments.
        """
        super().setUp()

        # Create a Draft Mongo and a Split Mongo course and enroll a student user in them.
        self.student_password = "******"
        self.student = UserFactory.create(username="******", password=self.student_password, is_staff=False)
        self.draft_course = SampleCourseFactory.create(default_store=ModuleStoreEnum.Type.mongo)
        self.split_course = SampleCourseFactory.create(default_store=ModuleStoreEnum.Type.split)
        CourseEnrollment.enroll(self.student, self.draft_course.id)
        CourseEnrollment.enroll(self.student, self.split_course.id)

        # Create a CCX coach.
        self.coach = AdminFactory.create()
        role = CourseCcxCoachRole(self.split_course.id)
        role.add_users(self.coach)

        # Create a CCX course and enroll the user in it.
        self.ccx = CcxFactory(course_id=self.split_course.id, coach=self.coach)
        last_week = datetime.datetime.now(UTC) - datetime.timedelta(days=7)
        override_field_for_ccx(self.ccx, self.split_course, 'start', last_week)  # Required by self.ccx.has_started().
        self.ccx_course_key = CCXLocator.from_course_locator(self.split_course.id, self.ccx.id)
        CourseEnrollment.enroll(self.student, self.ccx_course_key)
Beispiel #4
0
 def setUp(self):
     super().setUp()
     self.user = UserFactory.create()
     for course in [self.ccx_enabled_course, self.ccx_disabled_course]:
         CourseEnrollmentFactory.create(user=self.user, course_id=course.id)
         role = CourseCcxCoachRole(course.id)
         role.add_users(self.user)
Beispiel #5
0
 def setUp(self):
     """Set up a course, coach, ccx and user"""
     super(TestGetCCXFromCCXLocator, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.course = CourseFactory.create()
     coach = self.coach = AdminFactory.create()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(coach)
Beispiel #6
0
 def setUp(self):
     super(TestRenderMessageToString, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     coach = AdminFactory.create()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(coach)
     self.ccx = CcxFactory(course_id=self.course.id, coach=coach)
     self.course_key = CCXLocator.from_course_locator(
         self.course.id, self.ccx.id)
Beispiel #7
0
 def setUp(self):
     """common setup for all tests"""
     super(TestCCX, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.course = CourseFactory.create()
     self.coach = AdminFactory.create()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(self.coach)
     self.ccx = CcxFactory(course_id=self.course.id, coach=self.coach)
Beispiel #8
0
 def setUp(self):
     """common setup for all tests"""
     super(TestCCX, self).setUp()
     self.course = CourseFactory.create()
     self.coach = AdminFactory.create()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(self.coach)
     self.ccx = CcxFactory(course_id=self.course.id, coach=self.coach)
Beispiel #9
0
 def test_ccx_tab_visibility_for_instructor_when_coach_master_course(self):
     """
     Instructor can view ccx coach dashboard only if he is coach on master course.
     """
     instructor = self.make_instructor()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(instructor)
     assert self.check_ccx_tab(self.course, instructor)
Beispiel #10
0
 def test_ccx_tab_visibility_for_staff_when_coach_master_course(self):
     """
     Staff can view ccx coach dashboard only if he is coach on master course.
     """
     staff = self.make_staff()
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(staff)
     assert self.check_ccx_tab(self.course, staff)
Beispiel #11
0
def make_user_coach(user, master_course_key):
    """
    Makes an user coach on the master course.
    This function is needed because an user cannot become a coach of the CCX if s/he is not
    coach on the master course.

    Args:
        user (User): User object
        master_course_key (CourseKey): Key locator object for the course
    """
    coach_role_on_master_course = CourseCcxCoachRole(master_course_key)
    coach_role_on_master_course.add_users(user)
Beispiel #12
0
    def setUp(self):
        """
        Set up tests
        """
        super().setUp()

        # Create ccx coach account
        self.coach = AdminFactory.create(password="******")
        self.client.login(username=self.coach.username, password="******")

        # assign role to coach
        role = CourseCcxCoachRole(self.course.id)
        role.add_users(self.coach)
        self.request_factory = RequestFactory()
Beispiel #13
0
    def setUp(self):
        """
        Set up tests
        """
        super(CoachAccessTestCaseCCX, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments

        # Create ccx coach account
        self.coach = AdminFactory.create(password="******")
        self.client.login(username=self.coach.username, password="******")

        # assign role to coach
        role = CourseCcxCoachRole(self.course.id)
        role.add_users(self.coach)
        self.request_factory = RequestFactory()
Beispiel #14
0
 def setUp(self):
     """
     Set up tests
     """
     super(TestSendCCXCoursePublished, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     course = self.course = CourseFactory.create(org="edX", course="999", display_name="Run 666")
     course2 = self.course2 = CourseFactory.create(org="edX", course="999a", display_name="Run 667")
     coach = AdminFactory.create()
     role = CourseCcxCoachRole(course.id)
     role.add_users(coach)
     self.ccx = CcxFactory(course_id=course.id, coach=coach)
     self.ccx2 = CcxFactory(course_id=course.id, coach=coach)
     self.ccx3 = CcxFactory(course_id=course.id, coach=coach)
     self.ccx4 = CcxFactory(course_id=course2.id, coach=coach)
Beispiel #15
0
    def setUp(self):
        super(TestGetEmailParamsCCX, self).setUp()
        self.coach = AdminFactory.create()
        role = CourseCcxCoachRole(self.course.id)
        role.add_users(self.coach)
        self.ccx = CcxFactory(course_id=self.course.id, coach=self.coach)
        self.course_key = CCXLocator.from_course_locator(
            self.course.id, self.ccx.id)

        # Explicitly construct what we expect the course URLs to be
        site = settings.SITE_NAME
        self.course_url = u'https://{}/courses/{}/'.format(
            site, self.course_key)
        self.course_about_url = self.course_url + 'about'
        self.registration_url = u'https://{}/register'.format(site)
Beispiel #16
0
    def make_ccx(self):
        """
        create ccx
        """
        ccx = CustomCourseForEdX(course_id=self.course.id,
                                 coach=self.coach,
                                 display_name="Test CCX")
        ccx.save()

        ccx_locator = CCXLocator.from_course_locator(self.course.id,
                                                     str(ccx.id))
        role = CourseCcxCoachRole(ccx_locator)
        role.add_users(self.coach)
        CourseEnrollment.enroll(self.coach, ccx_locator)
        return ccx_locator
Beispiel #17
0
    def setUp(self):
        """
        Set up tests
        """
        super().setUp()

        # Create instructor account
        self.coach = coach = AdminFactory.create()
        self.client.login(username=coach.username, password="******")

        # Create CCX
        role = CourseCcxCoachRole(self._course.id)
        role.add_users(coach)
        ccx = CcxFactory(course_id=self._course.id, coach=self.coach)

        # override course grading policy and make last section invisible to students
        override_field_for_ccx(ccx, self._course, 'grading_policy', {
            'GRADER': [
                {'drop_count': 0,
                 'min_count': 2,
                 'short_label': 'HW',
                 'type': 'Homework',
                 'weight': 1}
            ],
            'GRADE_CUTOFFS': {'Pass': 0.75},
        })
        override_field_for_ccx(
            ccx, self.sections[-1], 'visible_to_staff_only', True
        )

        # create a ccx locator and retrieve the course structure using that key
        # which emulates how a student would get access.
        self.ccx_key = CCXLocator.from_course_locator(self._course.id, str(ccx.id))
        self.course = get_course_by_id(self.ccx_key, depth=None)
        CourseOverview.load_from_module_store(self.course.id)
        setup_students_and_grades(self)
        self.client.login(username=coach.username, password="******")
        self.addCleanup(RequestCache.clear_all_namespaces)
        from xmodule.modulestore.django import SignalHandler

        # using CCX object as sender here.
        SignalHandler.course_published.send(
            sender=ccx,
            course_key=self.ccx_key
        )
Beispiel #18
0
    def test_create_ccx_with_ccx_connector_set(self):
        """
        Assert that coach cannot create ccx when ``ccx_connector`` url is set.
        """
        role = CourseCcxCoachRole(self.course_with_ccx_connect_set.id)
        role.add_users(self.coach)

        url = reverse(
            'create_ccx',
            kwargs={'course_id': str(self.course_with_ccx_connect_set.id)})

        response = self.client.get(url)
        assert response.status_code == 200
        error_message = _(
            "A CCX can only be created on this course through an external service."
            " Contact a course admin to give you access."
        )
        assert re.search(error_message, response.content.decode('utf-8'))
Beispiel #19
0
 def setUp(self):
     """
     Set up tests
     """
     super().setUp()
     course = self.course = CourseFactory.create(org="edX",
                                                 course="999",
                                                 display_name="Run 666")
     course2 = self.course2 = CourseFactory.create(org="edX",
                                                   course="999a",
                                                   display_name="Run 667")
     coach = AdminFactory.create()
     role = CourseCcxCoachRole(course.id)
     role.add_users(coach)
     self.ccx = CcxFactory(course_id=course.id, coach=coach)
     self.ccx2 = CcxFactory(course_id=course.id, coach=coach)
     self.ccx3 = CcxFactory(course_id=course.id, coach=coach)
     self.ccx4 = CcxFactory(course_id=course2.id, coach=coach)
Beispiel #20
0
 def make_coach(self):
     """
     create coach user
     """
     role = CourseCcxCoachRole(self.course.id)
     role.add_users(self.coach)