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
2 changes: 2 additions & 0 deletions le_utils/constants/exercises.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
SINGLE_SELECTION = "single_selection"
FREE_RESPONSE = "free_response"
PERSEUS_QUESTION = "perseus_question"
QTI = "QTI"

question_choices = (
(INPUT_QUESTION, "Input Question"),
(MULTIPLE_SELECTION, "Multiple Selection"),
(SINGLE_SELECTION, "Single Selection"),
(FREE_RESPONSE, "Free Response"),
(PERSEUS_QUESTION, "Perseus Question"),
(QTI, "QTI"),
)
7 changes: 7 additions & 0 deletions le_utils/constants/format_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,10 @@ def _initialize_preset_list():


PRESETLIST = list(_initialize_preset_list())

# Bit order for the File.included_presets renderable bitmask.
# Consumers compute the bit value as 2 ** RENDERABLE_PRESETS_ORDER.index(preset_id).
# APPEND-ONLY: never reorder or remove an existing entry — that would
# silently change the bit value of every preset after it and corrupt
# already-persisted bitmasks. Only append new preset ids at the end.
RENDERABLE_PRESETS_ORDER = [preset.id for preset in PRESETLIST if not preset.supplementary]
9 changes: 9 additions & 0 deletions tests/test_exercises.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from le_utils.constants import exercises


def test_QTI_is_in_question_choices():
assert exercises.QTI == "QTI"
assert (exercises.QTI, "QTI") in exercises.question_choices
20 changes: 20 additions & 0 deletions tests/test_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,23 @@ def test_format_presets_are_synced():

def test_PRESETLIST_exists():
assert format_presets.PRESETLIST, "PRESETLIST did not genereate properly"


def test_RENDERABLE_PRESETS_ORDER_matches_PRESETLIST_ids():
preset_ids = {preset.id for preset in format_presets.PRESETLIST if not preset.supplementary}
assert set(format_presets.RENDERABLE_PRESETS_ORDER) == preset_ids


def test_RENDERABLE_PRESETS_ORDER_excludes_supplementary_presets():
assert "video_thumbnail" not in format_presets.RENDERABLE_PRESETS_ORDER
assert "qti_thumbnail" not in format_presets.RENDERABLE_PRESETS_ORDER


def test_RENDERABLE_PRESETS_ORDER_index_is_stable():
# Pin known bit positions: reordering silently breaks Studio/Kolibri's
# already-persisted File.included_presets bitmask values.
assert format_presets.RENDERABLE_PRESETS_ORDER.index("high_res_video") == 0
assert format_presets.RENDERABLE_PRESETS_ORDER.index("low_res_video") == 1
assert format_presets.RENDERABLE_PRESETS_ORDER.index("video_dependency") == 2
assert format_presets.RENDERABLE_PRESETS_ORDER.index("qti") == 13
assert format_presets.RENDERABLE_PRESETS_ORDER.index("kpub") == 17
Loading