Skip to content

Commit 5cfaa68

Browse files
committed
Conditional publishing of QTI archives instead of perseus.
1 parent 79743c9 commit 5cfaa68

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

contentcuration/contentcuration/utils/publish.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from contentcuration import models as ccmodels
4545
from contentcuration.decorators import delay_user_storage_calculation
4646
from contentcuration.utils.assessment.perseus import PerseusExerciseGenerator
47+
from contentcuration.utils.assessment.qti.archive import QTIExerciseGenerator
4748
from contentcuration.utils.cache import delete_public_channel_cache_keys
4849
from contentcuration.utils.files import create_thumbnail_from_base64
4950
from contentcuration.utils.files import get_thumbnail_encoding
@@ -320,12 +321,21 @@ def recurse_nodes(self, node, inherited_fields): # noqa C901
320321

321322
if node.kind_id == content_kinds.EXERCISE:
322323
exercise_data = process_assessment_metadata(node, kolibrinode)
324+
any_free_response = any(
325+
t == exercises.FREE_RESPONSE
326+
for t in exercise_data["assessment_mapping"].values()
327+
)
328+
generator_class = (
329+
QTIExerciseGenerator
330+
if any_free_response
331+
else PerseusExerciseGenerator
332+
)
323333
if (
324334
self.force_exercises
325335
or node.changed
326-
or not node.files.filter(preset_id=format_presets.EXERCISE).exists()
336+
or not node.files.filter(preset_id=generator_class.preset).exists()
327337
):
328-
generator = PerseusExerciseGenerator(
338+
generator = generator_class(
329339
node,
330340
exercise_data,
331341
self.channel_id,

0 commit comments

Comments
 (0)