Beispiel #1
0
 def setUp(self):
     super(TestRenderRoles, self).setUp()
     InstructorFactory(course_key=self.course.id,
                       username='******')
     StaffFactory(course_key=self.course.id, username='******')
     InstructorFactory(course_key=self.course.id,
                       username='******')
Beispiel #2
0
def i_am_registered_for_the_course(coursenum, metadata, user='******'):
    # Create user
    if user == 'BetaTester':
        # Create the course
        now = datetime.datetime.now(pytz.UTC)
        tomorrow = now + datetime.timedelta(days=5)
        metadata.update({'days_early_for_beta': 5, 'start': tomorrow})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']
        course_location = world.scenario_dict['COURSE'].location

        # create beta tester
        user = BetaTesterFactory(course=course_location)
        normal_student = UserFactory()
        instructor = InstructorFactory(course=course_location)

        assert not has_access(normal_student, course_descriptor, 'load')
        assert has_access(user, course_descriptor, 'load')
        assert has_access(instructor, course_descriptor, 'load')
    else:
        metadata.update({'start': datetime.datetime(1970, 1, 1, tzinfo=UTC)})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']
        course_location = world.scenario_dict['COURSE'].location
        user = InstructorFactory(course=course_location)

    # Enroll the user in the course and log them in
    if has_access(user, course_descriptor, 'load'):
        world.enroll_user(user, course_id(coursenum))

    world.log_in(username=user.username, password='******')
Beispiel #3
0
    def create_staff_for_course(self, course):
        """Creates and returns users with instructor and staff access to course."""

        course_locator = loc_mapper().translate_location(course.id, course.location)
        return [
            InstructorFactory(course=course.location),  # Creates instructor_org/number/run role name
            StaffFactory(course=course.location),  # Creates staff_org/number/run role name
            InstructorFactory(course=course_locator),  # Creates instructor_org.number.run role name
            StaffFactory(course=course_locator),  # Creates staff_org.number.run role name
        ]
Beispiel #4
0
        def test_get_course_tabs_list_skipped_entrance_exam(self):
            """
            Tests tab list is not limited if user is allowed to skip entrance exam.
            """
            #create a user
            student = UserFactory()
            # login as instructor hit skip entrance exam api in instructor app
            instructor = InstructorFactory(course_key=self.course.id)
            self.client.logout()
            self.client.login(username=instructor.username, password='******')

            url = reverse('mark_student_can_skip_entrance_exam',
                          kwargs={'course_id': unicode(self.course.id)})
            response = self.client.post(
                url, {
                    'unique_student_identifier': student.email,
                })
            self.assertEqual(response.status_code, 200)

            # log in again as student
            self.client.logout()
            self.login(self.email, self.password)
            request = get_request_for_user(self.user)
            course_tab_list = get_course_tab_list(request, self.course)
            self.assertEqual(len(course_tab_list), 5)
Beispiel #5
0
 def setUp(self):
     """
     Fixtures.
     """
     self.course = CourseFactory.create()
     self.instructor = InstructorFactory(course_key=self.course.id)
     self.client.login(username=self.instructor.username, password='******')
    def test_skip_entrance_exame_gating(self):
        """
        Tests gating is disabled if skip entrance exam is set for a user.
        """
        # make sure toc is locked before allowing user to skip entrance exam
        locked_toc = toc_for_course(self.request, self.course,
                                    self.entrance_exam.url_name,
                                    self.exam_1.url_name,
                                    self.field_data_cache)
        for toc_section in self.expected_locked_toc:
            self.assertIn(toc_section, locked_toc)

        # hit skip entrance exam api in instructor app
        instructor = InstructorFactory(course_key=self.course.id)
        self.client.login(username=instructor.username, password='******')
        url = reverse('mark_student_can_skip_entrance_exam',
                      kwargs={'course_id': unicode(self.course.id)})
        response = self.client.post(
            url, {
                'unique_student_identifier': self.request.user.email,
            })
        self.assertEqual(response.status_code, 200)

        unlocked_toc = toc_for_course(self.request, self.course,
                                      self.entrance_exam.url_name,
                                      self.exam_1.url_name,
                                      self.field_data_cache)
        for toc_section in self.expected_unlocked_toc:
            self.assertIn(toc_section, unlocked_toc)
Beispiel #7
0
    def test_enrolled_students_features_keys_cohorted(self):
        course = CourseFactory.create(org="test", course="course1", display_name="run1")
        course.cohort_config = {'cohorted': True, 'auto_cohort': True, 'auto_cohort_groups': ['cohort']}
        self.store.update_item(course, self.instructor.id)
        cohorted_students = [UserFactory.create() for _ in range(10)]
        cohort = CohortFactory.create(name='cohort', course_id=course.id, users=cohorted_students)
        cohorted_usernames = [student.username for student in cohorted_students]
        non_cohorted_student = UserFactory.create()
        for student in cohorted_students:
            cohort.users.add(student)
            CourseEnrollment.enroll(student, course.id)
        CourseEnrollment.enroll(non_cohorted_student, course.id)
        instructor = InstructorFactory(course_key=course.id)
        self.client.login(username=instructor.username, password='******')

        query_features = ('username', 'cohort')
        # There should be a constant of 2 SQL queries when calling
        # enrolled_students_features.  The first query comes from the call to
        # User.objects.filter(...), and the second comes from
        # prefetch_related('course_groups').
        with self.assertNumQueries(2):
            userreports = enrolled_students_features(course.id, query_features)
        self.assertEqual(len([r for r in userreports if r['username'] in cohorted_usernames]), len(cohorted_students))
        self.assertEqual(len([r for r in userreports if r['username'] == non_cohorted_student.username]), 1)
        for report in userreports:
            self.assertEqual(set(report.keys()), set(query_features))
            if report['username'] in cohorted_usernames:
                self.assertEqual(report['cohort'], cohort.name)
            else:
                self.assertEqual(report['cohort'], '[unassigned]')
Beispiel #8
0
    def setUp(self):
        """
        Fixtures.
        """
        super(TestCourseRegistrationCodeAnalyticsBasic, self).setUp()
        self.course = CourseFactory.create()
        self.instructor = InstructorFactory(course_key=self.course.id)
        self.client.login(username=self.instructor.username, password='******')
        CourseSalesAdminRole(self.course.id).add_users(self.instructor)

        # Create a paid course mode.
        mode = CourseModeFactory.create(course_id=self.course.id, min_price=1)

        url = reverse('generate_registration_codes',
                      kwargs={'course_id': text_type(self.course.id)})

        data = {
            'total_registration_codes': 12, 'company_name': 'Test Group', 'unit_price': 122.45,
            'company_contact_name': 'TestName', 'company_contact_email': '*****@*****.**', 'recipient_name': 'Test123',
            'recipient_email': '*****@*****.**', 'address_line_1': 'Portland Street', 'address_line_2': '',
            'address_line_3': '', 'city': '', 'state': '', 'zip': '', 'country': '',
            'customer_reference_number': '123A23F', 'internal_reference': '', 'invoice': ''
        }

        response = self.client.post(url, data, **{'HTTP_HOST': 'localhost'})
        self.assertEqual(response.status_code, 200, response.content)
    def setUp(self):
        super(CertificateExceptionViewInstructorApiTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)
        self.user = UserFactory()
        self.user2 = UserFactory()
        CourseEnrollment.enroll(self.user, self.course.id)
        CourseEnrollment.enroll(self.user2, self.course.id)
        self.url = reverse('certificate_exception_view', kwargs={'course_id': unicode(self.course.id)})

        certificate_white_list_item = CertificateWhitelistFactory.create(
            user=self.user2,
            course_id=self.course.id,
        )

        self.certificate_exception = dict(
            created="",
            notes="Test Notes for Test Certificate Exception",
            user_email='',
            user_id='',
            user_name=unicode(self.user.username)
        )

        self.certificate_exception_in_db = dict(
            id=certificate_white_list_item.id,
            user_name=certificate_white_list_item.user.username,
            notes=certificate_white_list_item.notes,
            user_email=certificate_white_list_item.user.email,
            user_id=certificate_white_list_item.user.id,
        )

        # Enable certificate generation
        cache.clear()
        CertificateGenerationConfiguration.objects.create(enabled=True)
        self.client.login(username=self.global_staff.username, password='******')
Beispiel #10
0
    def create_staff_for_course(self, course):
        """Creates and returns users with instructor and staff access to course."""

        return [
            InstructorFactory(course_key=course.id),  # Creates instructor_org/number/run role name
            StaffFactory(course_key=course.id),  # Creates staff_org/number/run role name
        ]
Beispiel #11
0
    def test_instructor_level(self):
        """
        Ensure that an instructor member can access all endpoints.
        """
        inst = InstructorFactory(self.course)
        CourseEnrollment.enroll(inst, self.course.id)
        self.client.login(username=inst.username, password='******')

        for endpoint, args in self.staff_level_endpoints:
            # TODO: make these work
            if endpoint in [
                    'update_forum_role_membership', 'proxy_legacy_analytics'
            ]:
                continue
            self._access_endpoint(
                endpoint, args, 200,
                "Instructor should be allowed to access endpoint " + endpoint)

        for endpoint, args in self.instructor_level_endpoints:
            # TODO: make this work
            if endpoint in ['rescore_problem']:
                continue
            self._access_endpoint(
                endpoint, args, 200,
                "Instructor should be allowed to access endpoint " + endpoint)
Beispiel #12
0
    def test_long_course_display_name(self):
        """
        This test tests that courses with exorbitantly large display names
        can still send emails, since it appears that 320 appears to be the
        character length limit of from emails for Amazon SES.
        """
        test_email = {
            'action': 'Send email',
            'send_to': 'myself',
            'subject': 'test subject for self',
            'message': 'test message for self'
        }

        # make very long display_name for course
        long_name = u"x" * 321
        course = CourseFactory.create(display_name=long_name,
                                      number="bulk_email_course_name")
        instructor = InstructorFactory(course_key=course.id)

        self.login_as_user(instructor)
        send_mail_url = reverse('send_email',
                                kwargs={'course_id': unicode(course.id)})
        response = self.client.post(send_mail_url, test_email)
        self.assertTrue(json.loads(response.content)['success'])

        self.assertEqual(len(mail.outbox), 1)
        from_email = mail.outbox[0].from_email

        self.assertEqual(
            from_email,
            u'"{course_name}" Course Staff <{course_name}[email protected]>'
            .format(course_name=course.id.course))
        self.assertEqual(len(from_email), 83)
Beispiel #13
0
    def setUp(self):

        self.course = CourseFactory.create(number='999',
                                           display_name='Robot_Super_Course')
        self.overview_chapter = ItemFactory.create(display_name='Overview')
        self.courseware_chapter = ItemFactory.create(display_name='courseware')

        self.test_course = CourseFactory.create(
            number='666', display_name='Robot_Sub_Course')
        self.other_org_course = CourseFactory.create(org='Other_Org_Course')
        self.sub_courseware_chapter = ItemFactory.create(
            parent_location=self.test_course.location,
            display_name='courseware')
        self.sub_overview_chapter = ItemFactory.create(
            parent_location=self.sub_courseware_chapter.location,
            display_name='Overview')
        self.welcome_section = ItemFactory.create(
            parent_location=self.overview_chapter.location,
            display_name='Welcome')

        self.global_staff_user = GlobalStaffFactory()
        self.unenrolled_user = UserFactory(last_name="Unenrolled")

        self.enrolled_user = UserFactory(last_name="Enrolled")
        CourseEnrollmentFactory(user=self.enrolled_user,
                                course_id=self.course.id)
        CourseEnrollmentFactory(user=self.enrolled_user,
                                course_id=self.test_course.id)

        self.staff_user = StaffFactory(course=self.course.location)
        self.instructor_user = InstructorFactory(course=self.course.location)
        self.org_staff_user = OrgStaffFactory(course=self.course.location)
        self.org_instructor_user = OrgInstructorFactory(
            course=self.course.location)
Beispiel #14
0
 def setUp(self):
     self.course_key = SlashSeparatedCourseKey('robot', 'course', 'id')
     self.users = tuple(UserFactory() for _ in xrange(30))
     self.ces = tuple(
         CourseEnrollment.enroll(user, self.course_key)
         for user in self.users)
     self.instructor = InstructorFactory(course_key=self.course_key)
Beispiel #15
0
    def setUp(self):
        course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
        self.course = CourseFactory.create(display_name=course_title)

        self.instructor = InstructorFactory(course=self.course.location)

        # Create staff
        self.staff = [StaffFactory(course=self.course.location)
                      for _ in xrange(STAFF_COUNT)]

        # Create students
        self.students = [UserFactory() for _ in xrange(STUDENT_COUNT)]
        for student in self.students:
            CourseEnrollmentFactory.create(user=student, course_id=self.course.id)

        # load initial content (since we don't run migrations as part of tests):
        call_command("loaddata", "course_email_template.json")

        self.client.login(username=self.instructor.username, password="******")

        # Pull up email view on instructor dashboard
        self.url = reverse('instructor_dashboard', kwargs={'course_id': self.course.id})
        # Response loads the whole instructor dashboard, so no need to explicitly
        # navigate to a particular email section
        response = self.client.get(self.url)
        email_section = '<div class="vert-left send-email" id="section-send-email">'
        # If this fails, it is likely because ENABLE_INSTRUCTOR_EMAIL is set to False
        self.assertTrue(email_section in response.content)
        self.send_mail_url = reverse('send_email', kwargs={'course_id': self.course.id})
        self.success_content = {
            'course_id': self.course.id,
            'success': True,
        }
Beispiel #16
0
    def setUp(self):
        self.course = CourseFactory.create()

        self.instructor = InstructorFactory(self.course)

        # Create staff
        self.staff = [StaffFactory(self.course) for _ in xrange(STAFF_COUNT)]

        # Create students
        self.students = [UserFactory() for _ in xrange(STUDENT_COUNT)]
        for student in self.students:
            CourseEnrollmentFactory.create(user=student,
                                           course_id=self.course.id)

        # load initial content (since we don't run migrations as part of tests):
        call_command("loaddata", "course_email_template.json")

        self.client.login(username=self.instructor.username, password="******")

        # Pull up email view on instructor dashboard
        self.url = reverse('instructor_dashboard',
                           kwargs={'course_id': self.course.id})
        response = self.client.get(self.url)
        email_link = '<a href="#" onclick="goto(\'Email\')" class="None">Email</a>'
        # If this fails, it is likely because ENABLE_INSTRUCTOR_EMAIL is set to False
        self.assertTrue(email_link in response.content)

        # Select the Email view of the instructor dash
        session = self.client.session
        session['idash_mode'] = 'Email'
        session.save()
        response = self.client.get(self.url)
        selected_email_link = '<a href="#" onclick="goto(\'Email\')" class="selectedmode">Email</a>'
        self.assertTrue(selected_email_link in response.content)
Beispiel #17
0
    def setUp(self):
        """
        Fixtures.
        """
        self.course = CourseFactory.create()
        self.instructor = InstructorFactory(course_key=self.course.id)
        self.client.login(username=self.instructor.username, password='******')

        url = reverse(
            'generate_registration_codes',
            kwargs={'course_id': self.course.id.to_deprecated_string()})

        data = {
            'total_registration_codes': 12,
            'company_name': 'Test Group',
            'sale_price': 122.45,
            'company_contact_name': 'TestName',
            'company_contact_email': '*****@*****.**',
            'recipient_name': 'Test123',
            'recipient_email': '*****@*****.**',
            'address_line_1': 'Portland Street',
            'address_line_2': '',
            'address_line_3': '',
            'city': '',
            'state': '',
            'zip': '',
            'country': '',
            'customer_reference_number': '123A23F',
            'internal_reference': '',
            'invoice': ''
        }

        response = self.client.post(url, data, **{'HTTP_HOST': 'localhost'})
        self.assertEqual(response.status_code, 200, response.content)
 def setUp(self):
     self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
     self.anonymous_user = AnonymousUserFactory()
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course_key)
     self.course_instructor = InstructorFactory(course_key=self.course_key)
Beispiel #19
0
 def setUp(self):
     self.course = Location('i4x://edX/toy/course/2012_Fall')
     self.anonymous_user = AnonymousUserFactory()
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course=self.course)
     self.course_instructor = InstructorFactory(course=self.course)
Beispiel #20
0
 def setUp(self):
     """
     Fixtures.
     """
     super(TestCourseSaleRecordsAnalyticsBasic, self).setUp()
     self.course = CourseFactory.create()
     self.instructor = InstructorFactory(course_key=self.course.id)
     self.client.login(username=self.instructor.username, password='******')
Beispiel #21
0
    def setUp(self):
        self.course = CourseFactory.create()
        self.instructor = InstructorFactory(self.course)
        self.client.login(username=self.instructor.username, password='******')

        self.students = [UserFactory() for _ in xrange(6)]
        for student in self.students:
            CourseEnrollment.enroll(student, self.course.id)
Beispiel #22
0
 def setUp(self):
     super(BaseCourseDashboardTestCase, self).setUp(create_user=False)
     self.course = CourseFactory.create()
     self.problem_module = None
     self._generate_modules_tree(self.course, 'chapter', 'sequential',
                                 'vertical', 'problem')
     self.instructor = InstructorFactory.create(course_key=self.course.id)
     self.client.login(username=self.instructor.username, password="******")
Beispiel #23
0
    def setUp(self):
        super(CertificatesInstructorApiTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)

        # Enable certificate generation
        cache.clear()
        CertificateGenerationConfiguration.objects.create(enabled=True)
Beispiel #24
0
 def setUp(self):
     super(UserRoleTestCase, self).setUp()
     self.course_key = CourseLocator('edX', 'toy', '2012_Fall')
     self.anonymous_user = AnonymousUserFactory()
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course_key)
     self.course_instructor = InstructorFactory(course_key=self.course_key)
    def setUp(self):
        super(TestCourseRegistrationCodeStatus, self).setUp()
        CourseModeFactory.create(course_id=self.course.id, min_price=50)
        self.instructor = InstructorFactory(course_key=self.course.id)
        self.client.login(username=self.instructor.username, password='******')
        CourseSalesAdminRole(self.course.id).add_users(self.instructor)

        # create testing invoice
        self.sale_invoice = Invoice.objects.create(
            total_amount=1234.32,
            company_name='Test1',
            company_contact_name='TestName',
            company_contact_email='*****@*****.**',
            recipient_name='Testw',
            recipient_email='*****@*****.**',
            customer_reference_number='2Fwe23S',
            internal_reference="A",
            course_id=self.course.id,
            is_valid=True)
        self.invoice_item = CourseRegistrationCodeInvoiceItem.objects.create(
            invoice=self.sale_invoice,
            qty=1,
            unit_price=1234.32,
            course_id=self.course.id)
        self.lookup_code_url = reverse(
            'look_up_registration_code',
            kwargs={'course_id': unicode(self.course.id)})

        self.registration_code_detail_url = reverse(
            'registration_code_details',
            kwargs={'course_id': unicode(self.course.id)})

        url = reverse(
            'generate_registration_codes',
            kwargs={'course_id': self.course.id.to_deprecated_string()})

        data = {
            'total_registration_codes': 12,
            'company_name': 'Test Group',
            'company_contact_name': '*****@*****.**',
            'company_contact_email': '*****@*****.**',
            'unit_price': 122.45,
            'recipient_name': 'Test123',
            'recipient_email': '*****@*****.**',
            'address_line_1': 'Portland Street',
            'address_line_2': '',
            'address_line_3': '',
            'city': '',
            'state': '',
            'zip': '',
            'country': '',
            'customer_reference_number': '123A23F',
            'internal_reference': '',
            'invoice': ''
        }

        response = self.client.post(url, data)
        self.assertEqual(response.status_code, 200, response.content)
Beispiel #26
0
 def setUp(self):
     super(AccessTestCase, self).setUp()
     course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
     self.course = course_key.make_usage_key('course', course_key.run)
     self.anonymous_user = AnonymousUserFactory()
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course.course_key)
     self.course_instructor = InstructorFactory(course_key=self.course.course_key)
Beispiel #27
0
    def test_long_course_display_name(self):
        """
        This test tests that courses with exorbitantly large display names
        can still send emails, since it appears that 320 appears to be the
        character length limit of from emails for Amazon SES.
        """
        test_email = {
            'action': 'Send email',
            'send_to': '["myself", "staff", "learners"]',
            'subject': 'test subject for self',
            'message': 'test message for self'
        }

        # make display_name that's longer than 320 characters when encoded
        # to ascii and escaped, but shorter than 320 unicode characters
        long_name = u"Финансовое программирование и политика, часть 1: макроэкономические счета и анализ"

        course = CourseFactory.create(
            display_name=long_name,
            org="IMF",
            number="FPP.1x",
            run="2016",
        )
        instructor = InstructorFactory(course_key=course.id)

        unexpected_from_addr = _get_source_address(
            course.id, course.display_name, course_language=None, truncate=False
        )
        __, encoded_unexpected_from_addr = forbid_multi_line_headers(
            "from", unexpected_from_addr, 'utf-8'
        )
        escaped_encoded_unexpected_from_addr = escape(encoded_unexpected_from_addr)

        # it's shorter than 320 characters when just encoded
        self.assertEqual(len(encoded_unexpected_from_addr), 318)
        # escaping it brings it over that limit
        self.assertEqual(len(escaped_encoded_unexpected_from_addr), 324)
        # when not escaped or encoded, it's well below 320 characters
        self.assertEqual(len(unexpected_from_addr), 137)

        self.login_as_user(instructor)
        send_mail_url = reverse('send_email', kwargs={'course_id': six.text_type(course.id)})
        response = self.client.post(send_mail_url, test_email)
        self.assertTrue(json.loads(response.content.decode('utf-8'))['success'])

        self.assertEqual(len(mail.outbox), 1)
        from_email = mail.outbox[0].from_email

        expected_from_addr = (
            u'"{course_name}" Course Staff <{course_name}[email protected]>'
        ).format(course_name=course.id.course)

        self.assertEqual(
            from_email,
            expected_from_addr
        )
        self.assertEqual(len(from_email), 61)
Beispiel #28
0
 def setUp(self):
     super(RolesTestCase, self).setUp()
     self.course_key = CourseKey.from_string('edX/toy/2012_Fall')
     self.course_loc = self.course_key.make_usage_key('course', '2012_Fall')
     self.anonymous_user = AnonymousUserFactory()
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course_key)
     self.course_instructor = InstructorFactory(course_key=self.course_key)
Beispiel #29
0
    def setUp(self):
        super(CertificatesInstructorDashTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)

        # Need to clear the cache for model-based configuration
        cache.clear()

        # Enable the certificate generation feature
        CertificateGenerationConfiguration.objects.create(enabled=True)
Beispiel #30
0
 def setUp(self):
     super(AccessTestCase, self).setUp()
     self.course = CourseFactory.create(org='edX', course='toy', run='test_run')
     self.anonymous_user = AnonymousUserFactory()
     self.beta_user = BetaTesterFactory(course_key=self.course.id)
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course.id)
     self.course_instructor = InstructorFactory(course_key=self.course.id)
     self.staff = GlobalStaffFactory()
Beispiel #31
0
    def test(self):

        self.course = CourseFactory.create()
        self.wiki = get_or_create_root()

        wiki_page = self.create_urlpath(self.wiki, course_wiki_slug(self.course))
        wiki_page2 = self.create_urlpath(wiki_page, 'Child')
        wiki_page3 = self.create_urlpath(wiki_page2, 'Grandchild')

        instructor = InstructorFactory.create(course_key=self.course.id)
        self.client.login(username=instructor.username, password="******")

        response = self.client.get(reverse('course-dashboard:wiki-activity',
                kwargs={'course_id': self.course.id.to_deprecated_string()}))
        self.assertEqual(200, response.status_code)
Beispiel #32
0
    def test_get_activity(self):
        from course_wiki.views import get_or_create_root
        from course_wiki.utils import course_wiki_slug

        course = CourseFactory.create()
        wiki = get_or_create_root()

        wiki_page = self.create_urlpath(wiki, course_wiki_slug(course))
        wiki_page2 = self.create_urlpath(wiki_page, 'Child')
        _wiki_page3 = self.create_urlpath(wiki_page2, 'Grandchild')

        instructor = InstructorFactory.create(course_key=course.id)
        self.client.login(username=instructor.username, password="******")

        # TODO we should probably test something more here
        response = self.client.get(reverse('course-dashboard:wiki-activity',
                kwargs={'course_id': course.id.to_deprecated_string()}))
        self.assertEqual(200, response.status_code)
Beispiel #33
0
    def setUp(self):
        super(YoutubeCmsTests, self).setUp()
        self.create_credentials()
        self.instructor = InstructorFactory.create(course_key=self.course_id)
        self.client.login(username=self.instructor.username, password="******")

        self.subtitle_id = "subtitleid"
        self.youtube_client.auth.captions = mock_list_service({
            "items": [{
                "id": self.subtitle_id,
                "snippet": {
                    "language": "fr"
                }
            }]
        })
        self.subtitle_download_url = reverse(
            "youtube:download_subtitle",
            kwargs={'subtitle_id': self.subtitle_id, 'course_key_string': self.course_key_string}
        )
Beispiel #34
0
    def test_teaser_public_id(self):
        """
        Tests that we always get a correct dailmotion id from the about section.
        The public video id is store in Mongo surrounded by an iframe tag referencing youtube.
        As we use dailmotion we need to extract the id from the iframe and create a
        new one referencing dailymotion (see function get_teaser).
        """
        from contentstore.views.course import settings_handler

        course = CourseFactory.create()
        instructor = InstructorFactory.create(course_key=course.id)
        self.client.login(username=instructor.username, password="******")

        dm_code = 'x2an9mg'
        course_details = {'intro_video' : dm_code}
        self.client.post(reverse(settings_handler,
                                 args=[str(course.id)]),
                         json.dumps(course_details),
                         content_type='application/json',
                         HTTP_ACCEPT='application/json')
        video_tag_youtube = get_about_section(course, 'video')
        self.assertIn(dm_code, video_tag_youtube)
        video_tag_dailymotion = '<iframe id="course-teaser" frameborder="0" scrolling="no" allowfullscreen="" src="//www.dailymotion.com/embed/video/' + dm_code + '/?&api=postMessage"></iframe>'
        self.assertEqual(video_tag_dailymotion, get_teaser(course, video_tag_youtube))
Beispiel #35
0
    def setUp(self):
        self.output = StringIO.StringIO()
        self.gzipfile = StringIO.StringIO()
        self.course = CourseFactory.create(
            display_name=self.COURSE_NAME,
        )
        self.course.raw_grader = [{
            'drop_count': 0,
            'min_count': 1,
            'short_label': 'Final',
            'type': 'Final Exam',
            'weight': 1.0
        }]
        self.course.grade_cutoffs = {'Pass': 0.1}
        self.students = [
            UserFactory.create(username='******'),
            UserFactory.create(username='******'),
            UserFactory.create(username='******'),
            UserFactory.create(username='******'),
            UserFactory.create(username='******'),
            StaffFactory.create(username='******', course_key=self.course.id),
            InstructorFactory.create(username='******', course_key=self.course.id),
        ]
        UserStandingFactory.create(
            user=self.students[4],
            account_status=UserStanding.ACCOUNT_DISABLED,
            changed_by=self.students[6]
        )

        for user in self.students:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        self.pgreport = ProgressReport(self.course.id)
        self.pgreport2 = ProgressReport(self.course.id, lambda state: state)

        self.chapter = ItemFactory.create(
            parent_location=self.course.location,
            category="chapter",
            display_name="Week 1"
        )
        self.chapter.save()
        self.section = ItemFactory.create(
            parent_location=self.chapter.location,
            category="sequential",
            display_name="Lesson 1"
        )
        self.section.save()
        self.vertical = ItemFactory.create(
            parent_location=self.section.location,
            category="vertical",
            display_name="Unit1"
        )
        self.vertical.save()
        self.html = ItemFactory.create(
            parent_location=self.vertical.location,
            category="html",
            data={'data': "<html>foobar</html>"}
        )
        self.html.save()
        """
        course.children = [week1.location.url(), week2.location.url(),
                           week3.location.url()]
        """
        from capa.tests.response_xml_factory import OptionResponseXMLFactory
        self.problem_xml = OptionResponseXMLFactory().build_xml(
            question_text='The correct answer is Correct',
            num_inputs=2,
            weight=2,
            options=['Correct', 'Incorrect'],
            correct_option='Correct'
        )

        self.problems = []
        for num in xrange(1, 3):
            self.problems.append(ItemFactory.create(
                parent_location=self.vertical.location,
                category='problem',
                display_name='problem_' + str(num),
                metadata={'graded': True, 'format': 'Final Exam'},
                data=self.problem_xml
            ))
            self.problems[num - 1].save()

        for problem in self.problems:
            problem.correct_map = {
                unicode(problem.location) + "_2_1": {
                    "hint": "",
                    "hintmode": "",
                    "correctness": "correct",
                    "npoints": "",
                    "msg": "",
                    "queuestate": ""
                },
                unicode(problem.location) + "_2_2": {
                    "hint": "",
                    "hintmode": "",
                    "correctness": "incorrect",
                    "npoints": "",
                    "msg": "",
                    "queuestate": ""
                }
            }

            problem.student_answers = {
                unicode(problem.location) + "_2_1": "Correct",
                unicode(problem.location) + "_2_2": "Incorrect"
            }

            problem.input_state = {
                unicode(problem.location) + "_2_1": {},
                unicode(problem.location) + "_2_2": {}
            }

        self.course.save()

        patcher = patch('pgreport.views.logging')
        self.log_mock = patcher.start()
        self.addCleanup(patcher.stop)

        """
Beispiel #36
0
 def setUp(self):
     super(TestVideoUpload, self).setUp(create_user=False)
     self.course = CourseFactory.create()
     self.instructor = InstructorFactory.create(course_key=self.course.id)
     self.client.login(username=self.instructor.username, password="******")