Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def handle(self, *args, **options):
message = f'{file_name} loaded successfully'
self.stdout.write(self.style.SUCCESS(message))
except FileNotFoundError as exc:
message = f"Learning package file {file_name} not found"
message = f"Learning package file {file_name} not found: {exc}"
raise CommandError(message) from exc
except Exception as e:
message = f"Failed to load '{file_name}': {e}"
Expand Down
26 changes: 26 additions & 0 deletions test_utils/zip_file_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Utility functions for working with in-memory zip files from folders."""

import io
import zipfile
from pathlib import Path


def folder_to_inmemory_zip(folder_path: str) -> zipfile.ZipFile:
"""
Reads the contents of a folder and returns an in-memory ZipFile object.

Args:
folder_path (str): Path to the folder to zip.

Returns:
zipfile.ZipFile: An in-memory ZipFile containing the folder's contents.
"""
buffer = io.BytesIO()
folder = Path(folder_path)
with zipfile.ZipFile(buffer, "w", compression=zipfile.ZIP_DEFLATED) as zipf:
for file_path in folder.rglob("*"):
if file_path.is_file():
arcname = file_path.relative_to(folder)
zipf.write(file_path, arcname=str(arcname))
buffer.seek(0)
return zipfile.ZipFile(buffer, "r")
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[collection]
title = "Collection test1"
key = "collection-test"
description = ""
created = 2025-08-19T04:25:27.754968Z
entities = [
"xblock.v1:html:e32d5479-9492-41f6-9222-550a7346bc37",
"xblock.v1:problem:256739e8-c2df-4ced-bd10-8156f6cfa90b",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[entity]
uuid = "0df28dac-aa13-473c-8c41-2f27e10362da"
can_stand_alone = true
key = "section1-8ca126"
created = 2025-09-04T22:51:40.919872Z

[entity.draft]
version_num = 2

[entity.published]
# unpublished: no published_version_num

[entity.container.section]

# ### Versions

[[version]]
title = "Section1"
uuid = "60756ba1-231a-4014-9602-1fba48678674"
version_num = 2

[version.container]
children = ["subsection1-48afa3"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[entity]
uuid = "0b52444b-0604-4510-be71-960251e7343d"
can_stand_alone = true
key = "subsection1-48afa3"
created = 2025-09-04T22:51:52.824941Z

[entity.draft]
version_num = 2

[entity.published]
# unpublished: no published_version_num

[entity.container.subsection]

# ### Versions

[[version]]
title = "Subsection1"
uuid = "46642bce-0861-4e22-8b37-3cd897c99239"
version_num = 2

[version.container]
children = ["unit1-b7eafb"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[entity]
uuid = "c1a69936-ac68-4e1d-843a-0708fa7c755b"
can_stand_alone = true
key = "unit1-b7eafb"
created = 2025-09-04T22:51:59.271334Z

[entity.draft]
version_num = 2

[entity.published]
# unpublished: no published_version_num

[entity.container.unit]

# ### Versions

[[version]]
title = "Unit1"
uuid = "f8aa4b20-8271-4838-bbe6-e0164d616c13"
version_num = 2

[version.container]
children = ["xblock.v1:video:22601ebd-9da8-430b-9778-cfe059a98568"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[entity]
uuid = "a919094d-1fd0-40bb-9fe2-66284a80effb"
can_stand_alone = true
key = "xblock.v1:drag-and-drop-v2:4d1b2fac-8b30-42fb-872d-6b10ab580b27"
created = 2025-09-04T22:39:37.001432Z

[entity.draft]
version_num = 2

[entity.published]
# unpublished: no published_version_num

# ### Versions

[[version]]
title = "Drag and Drop"
uuid = "136f72d0-a793-4993-b0b1-8515e0c21e64"
version_num = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<drag-and-drop-v2 xblock-family="xblock.v1" data="{&#10; &quot;explanation&quot;: &quot;&quot;,&#10; &quot;feedback&quot;: {&#10; &quot;finish&quot;: &quot;Good work! You have completed this drag and drop problem.&quot;,&#10; &quot;start&quot;: &quot;Drag the items onto the image above.&quot;&#10; },&#10; &quot;items&quot;: [&#10; {&#10; &quot;displayName&quot;: &quot;Goes to the top&quot;,&#10; &quot;feedback&quot;: {&#10; &quot;correct&quot;: &quot;Correct! This one belongs to The Top Zone.&quot;,&#10; &quot;incorrect&quot;: &quot;No, this item does not belong here. Try again.&quot;&#10; },&#10; &quot;id&quot;: 0,&#10; &quot;imageDescription&quot;: &quot;&quot;,&#10; &quot;imageURL&quot;: &quot;&quot;,&#10; &quot;noPadding&quot;: false,&#10; &quot;zones&quot;: [&#10; &quot;top&quot;&#10; ]&#10; },&#10; {&#10; &quot;displayName&quot;: &quot;Goes to the middle&quot;,&#10; &quot;feedback&quot;: {&#10; &quot;correct&quot;: &quot;Correct! This one belongs to The Middle Zone.&quot;,&#10; &quot;incorrect&quot;: &quot;No, this item does not belong here. Try again.&quot;&#10; },&#10; &quot;id&quot;: 1,&#10; &quot;imageDescription&quot;: &quot;&quot;,&#10; &quot;imageURL&quot;: &quot;&quot;,&#10; &quot;noPadding&quot;: false,&#10; &quot;zones&quot;: [&#10; &quot;middle&quot;&#10; ]&#10; },&#10; {&#10; &quot;displayName&quot;: &quot;Goes to the bottom&quot;,&#10; &quot;feedback&quot;: {&#10; &quot;correct&quot;: &quot;Correct! This one belongs to The Bottom Zone.&quot;,&#10; &quot;incorrect&quot;: &quot;No, this item does not belong here. Try again.&quot;&#10; },&#10; &quot;id&quot;: 2,&#10; &quot;imageDescription&quot;: &quot;&quot;,&#10; &quot;imageURL&quot;: &quot;&quot;,&#10; &quot;noPadding&quot;: false,&#10; &quot;zones&quot;: [&#10; &quot;bottom&quot;&#10; ]&#10; },&#10; {&#10; &quot;displayName&quot;: &quot;Goes anywhere&quot;,&#10; &quot;feedback&quot;: {&#10; &quot;correct&quot;: &quot;Of course it goes here! It goes anywhere!&quot;,&#10; &quot;incorrect&quot;: &quot;&quot;&#10; },&#10; &quot;id&quot;: 3,&#10; &quot;imageDescription&quot;: &quot;&quot;,&#10; &quot;imageURL&quot;: &quot;&quot;,&#10; &quot;noPadding&quot;: false,&#10; &quot;zones&quot;: [&#10; &quot;top&quot;,&#10; &quot;middle&quot;,&#10; &quot;bottom&quot;&#10; ]&#10; },&#10; {&#10; &quot;displayName&quot;: &quot;I don't belong anywhere&quot;,&#10; &quot;feedback&quot;: {&#10; &quot;correct&quot;: &quot;&quot;,&#10; &quot;incorrect&quot;: &quot;You silly, there are no zones for this one.&quot;&#10; },&#10; &quot;id&quot;: 4,&#10; &quot;imageDescription&quot;: &quot;&quot;,&#10; &quot;imageURL&quot;: &quot;&quot;,&#10; &quot;noPadding&quot;: false,&#10; &quot;zones&quot;: []&#10; }&#10; ],&#10; &quot;targetImgDescription&quot;: &quot;An isosceles triangle with three layers of similar height. It is shown upright, so the widest layer is located at the bottom, and the narrowest layer is located at the top.&quot;,&#10; &quot;zones&quot;: [&#10; {&#10; &quot;align&quot;: &quot;center&quot;,&#10; &quot;description&quot;: &quot;Use this zone to associate an item with the top layer of the triangle.&quot;,&#10; &quot;height&quot;: 178,&#10; &quot;title&quot;: &quot;The Top Zone&quot;,&#10; &quot;uid&quot;: &quot;top&quot;,&#10; &quot;width&quot;: 196,&#10; &quot;x&quot;: 160,&#10; &quot;y&quot;: 30&#10; },&#10; {&#10; &quot;align&quot;: &quot;center&quot;,&#10; &quot;description&quot;: &quot;Use this zone to associate an item with the middle layer of the triangle.&quot;,&#10; &quot;height&quot;: 138,&#10; &quot;title&quot;: &quot;The Middle Zone&quot;,&#10; &quot;uid&quot;: &quot;middle&quot;,&#10; &quot;width&quot;: 340,&#10; &quot;x&quot;: 86,&#10; &quot;y&quot;: 210&#10; },&#10; {&#10; &quot;align&quot;: &quot;center&quot;,&#10; &quot;description&quot;: &quot;Use this zone to associate an item with the bottom layer of the triangle.&quot;,&#10; &quot;height&quot;: 135,&#10; &quot;title&quot;: &quot;The Bottom Zone&quot;,&#10; &quot;uid&quot;: &quot;bottom&quot;,&#10; &quot;width&quot;: 485,&#10; &quot;x&quot;: 15,&#10; &quot;y&quot;: 350&#10; }&#10; ]&#10;}" display_name="Drag and Drop" item_background_color="" item_text_color="" max_attempts="null" max_items_per_zone="null" mode="standard" question_text="test example" show_question_header="true" show_title="true" weight="1.0"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[entity]
uuid = "1e5e93ef-c34b-4061-aae2-fbca91db6bcc"
can_stand_alone = true
key = "xblock.v1:html:e32d5479-9492-41f6-9222-550a7346bc37"
created = 2025-08-19T04:25:43.685529Z

[entity.draft]
version_num = 5

[entity.published]
version_num = 4

# ### Versions

[[version]]
title = "Text"
uuid = "23dec9b0-0b2c-4706-9288-6ef4f3c888ea"
version_num = 5

[[version]]
title = "Text"
uuid = "f6ccd316-d603-45ef-ab96-86cf9d3645ae"
version_num = 4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html display_name="Text"><![CDATA[<p>Test<img src="/static/me.png" alt="Me" width="500" height="579" /></p>]]></html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<html display_name="Text"><![CDATA[<p>Test modified</p>
<p><img src="/static/me.png" alt="Me" width="500" height="579" /></p>]]></html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[entity]
uuid = "50dfd1e2-dac7-46b7-94b3-8a36c39cd8a1"
can_stand_alone = true
key = "xblock.v1:openassessment:1ee38208-a585-4455-a27e-4930aa541f53"
created = 2025-09-04T22:38:05.382684Z

[entity.draft]
version_num = 2

[entity.published]
# unpublished: no published_version_num

# ### Versions

[[version]]
title = "Open Response Assessment"
uuid = "8f3c5e83-c1bf-49ba-96dc-5ee8e8b79b83"
version_num = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<openassessment submission_start="2001-01-01T00:00:00+00:00" submission_due="2029-01-01T00:00:00+00:00" text_response="required" text_response_editor="text" allow_multiple_files="True" allow_latex="False" allow_learner_resubmissions="False" display_name="Open Response Assessment" prompts_type="html" teams_enabled="False" selected_teamset_id="" show_rubric_during_response="False">
<title>Open Response Assessment</title>
<assessments>
<assessment name="student-training" enable_flexible_grading="False" grading_strategy="median">
<example>
<answer>
<part>Replace this text with your own sample response for this assignment. Then, under Response Score to the right, select an option for each criterion. Learners practice performing peer assessments by assessing this response and comparing the options that they select in the rubric with the options that you specified.</part>
</answer>
<select criterion="Ideas" option="Fair"/>
<select criterion="Content" option="Good"/>
</example>
<example>
<answer>
<part>Replace this text with another sample response, and then specify the options that you would select for this response.</part>
</answer>
<select criterion="Ideas" option="Poor"/>
<select criterion="Content" option="Good"/>
</example>
</assessment>
<assessment name="peer-assessment" must_grade="5" must_be_graded_by="3" enable_flexible_grading="False" grading_strategy="median" start="2001-01-01T00:00:00+00:00" due="2029-01-01T00:00:00+00:00"/>
<assessment name="self-assessment" enable_flexible_grading="False" grading_strategy="median" start="2001-01-01T00:00:00+00:00" due="2029-01-01T00:00:00+00:00"/>
</assessments>
<prompts>
<prompt>
<description>&lt;p&gt;You are a math specialist and need to evaluate his answer&lt;/p&gt;</description>
</prompt>
</prompts>
<rubric>
<criterion feedback="optional">
<name>Ideas</name>
<label>Ideas</label>
<prompt>Determine if there is a unifying theme or main idea.</prompt>
<option points="0">
<name>Poor</name>
<label>Poor</label>
<explanation>Difficult for the reader to discern the main idea. Too brief or too repetitive to establish or maintain a focus.</explanation>
</option>
<option points="3">
<name>Fair</name>
<label>Fair</label>
<explanation>Presents a unifying theme or main idea, but may include minor tangents. Stays somewhat focused on topic and task.</explanation>
</option>
<option points="5">
<name>Good</name>
<label>Good</label>
<explanation>Presents a unifying theme or main idea without going off on tangents. Stays completely focused on topic and task.</explanation>
</option>
</criterion>
<criterion>
<name>Content</name>
<label>Content</label>
<prompt>Assess the content of the submission</prompt>
<option points="0">
<name>Poor</name>
<label>Poor</label>
<explanation>Includes little information with few or no details or unrelated details. Unsuccessful in attempts to explore any facets of the topic.</explanation>
</option>
<option points="1">
<name>Fair</name>
<label>Fair</label>
<explanation>Includes little information and few or no details. Explores only one or two facets of the topic.</explanation>
</option>
<option points="3">
<name>Good</name>
<label>Good</label>
<explanation>Includes sufficient information and supporting details. (Details may not be fully developed; ideas may be listed.) Explores some facets of the topic.</explanation>
</option>
<option points="5">
<name>Excellent</name>
<label>Excellent</label>
<explanation>Includes in-depth information and exceptional supporting details that are fully developed. Explores all facets of the topic.</explanation>
</option>
</criterion>
<feedbackprompt>(Optional) What aspects of this response stood out to you? What did it do well? How could it be improved?
</feedbackprompt>
<feedback_default_text>I think that this response...
</feedback_default_text>
</rubric>
</openassessment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[entity]
uuid = "c5240e01-0810-4904-bd8e-5ac0d3d8370c"
can_stand_alone = true
key = "xblock.v1:problem:256739e8-c2df-4ced-bd10-8156f6cfa90b"
created = 2025-09-04T22:37:24.780718Z

[entity.draft]
version_num = 2

[entity.published]
# unpublished: no published_version_num

# ### Versions

[[version]]
title = "Single select"
uuid = "a5bcdf80-f69b-4ee5-a980-e1a93c61ad03"
version_num = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<problem display_name="Single select" markdown_edited="false" weight="1.0"><multiplechoiceresponse>
<div>Single select question</div><choicegroup><choice correct="true"><div>1</div></choice><choice correct="false"><div>2</div></choice><choice correct="false"><div>3</div></choice></choicegroup></multiplechoiceresponse>
</problem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[entity]
uuid = "3c41aa22-998e-4161-bec8-8c28ccf4f006"
can_stand_alone = true
key = "xblock.v1:survey:6681da3f-b056-4c6e-a8f9-040967907471"
created = 2025-09-04T22:41:02.788509Z

[entity.draft]
version_num = 1

[entity.published]
# unpublished: no published_version_num

# ### Versions

[[version]]
title = "Survey"
uuid = "0bdcaf29-ca6b-47f2-8b16-86a900d1c837"
version_num = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<survey />
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[entity]
uuid = "5e8d8ec3-5adf-4a09-a81e-b4a86f78cbe6"
can_stand_alone = true
key = "xblock.v1:video:22601ebd-9da8-430b-9778-cfe059a98568"
created = 2025-09-04T22:40:23.526816Z

[entity.draft]
version_num = 3

[entity.published]
# unpublished: no published_version_num

# ### Versions

[[version]]
title = "Video"
uuid = "fcd566b9-5cb4-4228-85b6-ce2b1a0bafff"
version_num = 3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<video youtube="1.00:PT6cKHsMzSQ" display_name="Video" edx_video_id="" end_time="00:00:00" html5_sources="[]" start_time="00:00:00" track="" youtube_id_1_0="PT6cKHsMzSQ"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Datetime of the export: 2025-09-24 18:00:38.451670+00:00

[learning_package]
title = "Library test"
key = "lib:WGU:LIB_C001"
description = ""
created = 2025-08-19T04:25:10.988166Z
updated = 2025-08-19T04:25:10.988166Z
Loading