コード例 #1
0
ファイル: base.py プロジェクト: oplarshad/fun-apps
 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="******")
コード例 #2
0
ファイル: test_wiki.py プロジェクト: cuissai/fun-apps
    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)
コード例 #3
0
ファイル: test_wiki.py プロジェクト: oplarshad/fun-apps
    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)
コード例 #4
0
ファイル: test_youtube.py プロジェクト: openfun/fun-apps
    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}
        )
コード例 #5
0
    def test_teaser_public_id(self):
        """
        Tests that we always get a correct dailymotion 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)
コード例 #6
0
ファイル: test_youtube.py プロジェクト: oplarshad/fun-apps
    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
                                             })
コード例 #7
0
ファイル: test_utils.py プロジェクト: regisb/fun-apps
    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))
コード例 #8
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="******")
コード例 #9
0
ファイル: test_videoupload.py プロジェクト: openfun/fun-apps
 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="******")
コード例 #10
0
ファイル: test_views.py プロジェクト: nttks/edx-platform
    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)

        """