def moodle_backup(self):
        """
        Returns an archive of the course in zipped Moodle backup format

        """
        sections, activities = self.activities_for_export()
        backup = MoodleCourse(
            name=self.title,
            id=self.pk,
            sections=sections,
            activities=activities,
            version=self.version,
            backup_filename=self.moodle_file_name,
        )
        return backup.export()
예제 #2
0
def short_course():
    yield MoodleCourse(
        "Short course",
        9,
        sections=[{
            "id": 1,
            "sequence": [1, 2]
        }, {
            "id": 2,
            "sequence": [3]
        }],
        activities=[
            {
                "id": 1,
                "type": "page",
                "intro": "First slide",
                "content": "Hello world",
                "section": 1,
            },
            {
                "id": 2,
                "type": "page",
                "intro": "Intermission",
                "content": "Olé!",
                "section": 1,
            },
            {
                "id": 3,
                "type": "page",
                "intro": "Second section title",
                "content": "Second section description",
                "section": 2,
            },
        ],
    )
예제 #3
0
def test_backup_filename(empty_course, short_course):
    # specified
    assert empty_course.backup_filename == "empty.mbz"

    # default
    assert short_course.backup_filename == "orb-course.mbz"

    # Wrong extension
    with pytest.raises(ValueError):
        MoodleCourse("Error Course", 7, backup_filename="empty.zip")
예제 #4
0
def empty_course():
    yield MoodleCourse("Empty Course", 7, backup_filename="empty.mbz")