예제 #1
0
 def test_ressource_odf_import(self):
     course = create_model('Course')
     section = create_model('Section')
     course.append(section)
     # Second presentation
     build_model(TestODPCourseImport._documents[1], section)
     self.assertEqual("Section 1 / Titre 1", course[0].title)
     self.assertEqual("Section 2 / Titre 2", course[1].title)
 def test_course_create_content_file(self):
     with open('./data/ressources/cat.jpg', 'rb') as f:
         file = create_model('BinaryFile', stream=f)
         file.name = 'CatFile.png'
         file.path = '/img/'
         self._basic_course.append(create_model('Section'))
         self._basic_course[0].append(file)
         self.assertEqual(self._basic_course[0][0].name, 'CatFile.png')
         file.title = 'Cat Picture'
         self.assertEqual(self._basic_course[0][0].name, 'CatFile.png')
예제 #3
0
 def test_course_imscc_export(self):
     self._basic_course.append(create_model('Section', title='Section 1'))
     self._basic_course[0].append(
         create_model('Label',
                      title='Label Title',
                      description='Label Descripton'))
     stream = self._basic_course.imscc_meta
     # We know that it is a stringio that is returned but it should not be assumed
     currentvalue = stream.getvalue()
     replaceident = re.compile(r'identifier="(\w+)"')
     currentvalue = replaceident.sub('identifier="AAAAAAA"', currentvalue)
     self.assertEqual(currentvalue, BASIC_IMS_CONTENT)
 def test_course_create_content_question(self):
     question1 = create_model('MultipleChoice',
                              title='Multiple choice 1',
                              description='Multiple choice description',
                              intro='Select is the best LMS?',
                              choices=dict([('A', 'Moodle'), ('B', 'edX'),
                                            ('C', 'Other')]),
                              rightanswers=['A', 'B'])
     assessment = create_model('Assessment',
                               title='Assessment',
                               items=[question1])
     self._basic_course.append(create_model('Section'))
     self._basic_course[0].append(assessment)
예제 #5
0
 def setUp(self):
     self._basic_course = create_model(
         'Course',
         languages=['en'],
         title='Course Title',
         description='Course Description <span> Span</span>',
         keywords=['tag1', 'tag2'])
def assessment_builder(odpdocument, assessmentmodel, **kwargs):
    assessmentmodel.title = kwargs.get('title')
    # Now try to find  the config for this quiz in the note
    quizcontent = ""
    quizformat = ""
    tomlconfig, embedded = kwargs.get('noteparams')
    if tomlconfig.get('quiz'):
        quizindex = 0
        for quizdef in tomlconfig.get('quiz'):
            if tomlconfig['quiz'][quizdef].get('name',
                                               None) == kwargs.get('title'):
                quizformat = tomlconfig['quiz'][quizdef].get('type')
                quizcontent = embedded[quizindex]
    if quizcontent and quizformat:
        # TODO manage more formats
        if quizformat == "aiken":
            questions = parse_aiken_quiz(quizcontent +
                                         "\n")  # We add an LF so we are sure
            # there is at least one
            items = [
                create_model('MultipleChoice',
                             title=q.intro,
                             intro=q.intro,
                             choices=q.choices,
                             rightanswers=q.rightanswers) for q in questions
            ]
            assessmentmodel.extend(items)
예제 #7
0
 def test_course_simple_odf_import(self):
     course = create_model('Course')
     # First presentation
     build_model(TestODPCourseImport._documents[0], course)
     self.assertEqual("Mon cours 1", course.title)
     self.assertEqual(
         "Description Courte du cours….  Autre description détaillée du cours",
         course.description.rstrip("\n").rstrip())
    def test_course_create_content_question(self):
        course = create_model(
            'Course',
            languages=['en'],
            title='Course Title',
            description='Course Description <span> Span</span>',
            keywords=['tag1', 'tag2'])

        file = create_model('BinaryFile')
        with open('./data/ressources/cat.jpg', 'rb') as f:
            file.stream = f

        file.name = 'CatFile.png'
        file.path = '/img/'
        course.append(create_model('Section'))
        course[0].append(file)
        self.assertTrue(isinstance(course[0][0], BinaryFile))
 def test_file_create(self):
     with open('./data/ressources/cat.jpg', 'rb') as f:
         file = create_model('BinaryFile', stream=f)
     file.name = 'cat.jpg'
     file.path = '/myressource/'
     self.assertEqual('/myressource/', file.path)
     self.assertEqual('cat.jpg', file.name)
     self.assertTrue(file.stream, IOBase)
예제 #10
0
 def test_course_simple_odf_import(self):
     course = create_model('Course')
     with open('./data/cours1/plandecours.odp', 'rb') as f:
         course.load(f, 'odpcourse')
     self.assertEqual("Mon cours 1", course.title)
     self.assertEqual("Description Courte du cours….  Autre description détaillée du cours",
                      course.description.rstrip("\n").rstrip())
     self.assertEqual(['fr', 'en'], course.languages)
     self.assertEqual(['Tag1', 'Tags2', 'Tag 3'], course.keywords)
예제 #11
0
 def test_course__odf_import(self):
     course = create_model('Course')
     with open('./data/cours2/plandecours.odp', 'rb') as f:
         course.load(f, 'odpcourse')
     self.assertEqual("Mon cours 1", course.title)
     self.assertEqual("Description courte du cours….\nAutre description détaillée",
                      course.description.rstrip("\n").rstrip())
     self.assertEqual("Section 1 /Titre 1", course[0].title)
     self.assertEqual("Section 2/ Titre 2", course[1].title)
예제 #12
0
 def setUp(self):
     self._basic_course = create_model(
         'Course',
         languages=['en'],
         title='Course Title',
         description='Course Description <span> Span</span>',
         keywords=['tag1', 'tag2'])
     question1 = create_model('MultipleChoice',
                              title='Multiple choice 1',
                              description='Multiple choice description',
                              intro='Select what is the best LMS?',
                              choices=dict([('A', 'Moodle'), ('B', 'edX'),
                                            ('C', 'Other')]),
                              rightanswers=['A', 'B'])
     assessment = create_model('Assessment',
                               title='Assessment',
                               items=[question1])
     section = create_model('Section', items=[assessment])
     self._basic_course.append(section)
 def test_course_create(self):
     course = create_model(
         'Course',
         languages=['en'],
         title='Course Title',
         description='Course Description <span> Span</span>',
         keywords=['tag1', 'tag2'],
         items=[])
     self.assertEqual(course.title, 'Course Title')
     self.assertEqual(course.description,
                      'Course Description <span> Span</span>')
    def test_course_create_with_section(self):
        section1 = create_model('Section',
                                title='Section 1 Title',
                                description='Section 1 Description')

        section2 = create_model('Section',
                                title='Section 2 Title',
                                description='Section 2 Description')
        course = create_model(
            'Course',
            languages=['en'],
            title='Course Title',
            description='Course Description <span> Span</span>',
            keywords=['tag1', 'tag2'],
            items=[section1, section2])

        self.assertEqual("Course Title", course.title)
        self.assertEqual("Course Description <span> Span</span>",
                         course.description)
        self.assertEqual("Section 1 Title", course[0].title)
        self.assertEqual("Section 2 Title", course[1].title)
예제 #15
0
def course_builder(odpdocument, coursemodel, **kwargs):
    firstslide = odpdocument.body.children[0]
    if not firstslide:
        raise ImportationError('odpcourse', 'Course', 'no first slide')
    coursetitle, coursedesc, langs, tags = _get_course_information(firstslide)

    coursemodel.title = coursetitle
    coursemodel.description = coursedesc
    coursemodel.languages = langs
    coursemodel.keywords = tags

    slideindex = 0
    for slide in odpdocument.body.children[1:]:
        if slide.__class__ is DrawPage:
            try:
                section = coursemodel[slideindex]
            except IndexError:
                section = create_model('Section')
                coursemodel.insert(slideindex, section)
            ezdisteach.lib.odf.build_model(odpdocument, section, slide=slide)
            slideindex += 1
예제 #16
0
def section_builder(odpdocument, section, **kwargs):
    # Treat the childen [0] for info
    currentslide = kwargs.get('slide', None)
    if currentslide is None:
        raise NotImplementedError()
    sectiontitle = ""
    sectiondoc = currentslide.children[0]
    pclass = sectiondoc.attributes.get('presentation:class', None)
    if pclass:
        sectiontitle = sectiondoc.text_content

    section.title = sectiontitle

    presentationnotes = currentslide.children[-1]

    tomlconfig, embedded = parse_note_slide_toml(
        presentationnotes.text_content)
    # We should have
    # draw:frame
    #   draw:text-box
    #       text:list
    #
    bulletindex = 0
    for frame in currentslide.children[1:-1]:
        # we look for the bullets /text:list
        bullets = frame.get_elements('draw:text-box/text:list/text:list-item')
        for bullet in bullets:
            # Here we recreate the item as it can be anything from label to assignment
            content = normalize_text(bullet.text_content)
            if content:
                type, args = get_item_from_instruction(content, "fr")
                if type:
                    item = create_model(type)
                    section.insert(bulletindex, item)
                    args['noteparams'] = (tomlconfig, embedded)
                    builder = ezdisteach.lib.odf.build_model(
                        odpdocument, item, **args)
 def test_section_create(self):
     section = create_model('Section',
                            title='Section Title',
                            description='Section Description')
     self.assertEqual(section.title, 'Section Title')
     self.assertEqual(section.description, 'Section Description')