Skip to content

Commit

Permalink
Tweaks to ensure proper parsing of language codes and keywords.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Feb 25, 2024
1 parent e78463e commit b324108
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ricecooker/utils/SCORM_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from le_utils.constants.labels import learning_activities
from le_utils.constants.labels import needs
from le_utils.constants.labels import resource_type
from le_utils.constants.languages import getlang


imscp_metadata_keys = {
Expand Down Expand Up @@ -155,9 +156,16 @@ def infer_beginner_level_from_difficulty(metadata_dict):
def update_node_from_metadata(node, metadata_dict):
# Update the node with the general metadata
node.description = metadata_dict.get("description") or node.description
if metadata_dict.get("language"):
node.set_language(metadata_dict.get("language"))
node.tags = node.tags + metadata_dict.get("keyword", [])
lang_code = metadata_dict.get("language", "")
lang_code = (
lang_code.split("-")[0].lower() if getlang(lang_code) is None else lang_code
)
if getlang(lang_code):
node.set_language(lang_code)
keyword = metadata_dict.get("keyword", [])
if keyword and isinstance(keyword, str):
keyword = [keyword]
node.tags = node.tags + keyword

# Update the node with the educational metadata
node.learning_activities = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ example of proper metadata element usage.
<description>
<string language="en-US">Explore the fascinating world of hummingbirds, their unique characteristics and behaviors.</string>
</description>
<language>en-US</language>
</general>
</lom>
</metadata>
Expand Down

0 comments on commit b324108

Please sign in to comment.