Skip to content

Commit

Permalink
using arrays for keywods (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
babz007 authored Mar 22, 2024
1 parent 8f400a6 commit 10a6e8b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/controllers/export_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ def index
end
end

# Handle keywords split by either commas or semicolons, return as comma-separated
# using array for keywords
keywords = if matching_avmetadata && (matching_avmetadata[:satisfies] || matching_avmetadata[:topic] || matching_avmetadata[:keyword])
combined_keywords = [matching_avmetadata[:satisfies], matching_avmetadata[:topic], matching_avmetadata[:keyword]].compact.join('; ')
combined_keywords.split(/[,;]\s*/).join(', ') # Split by both commas and semicolons, then join with commas
[matching_avmetadata[:satisfies], matching_avmetadata[:topic], matching_avmetadata[:keyword]].compact.flat_map { |k| k.split(/[,;]\s*/) }
elsif matching_chapter
matching_chapter # Use the chapter name if there are no specific keywords
[matching_chapter] # Use the chapter name if there are no specific keywords
else
exercise.name # or fallback to using the exercise's name as the keyword, if there are no specific keywords
[exercise.name] # Fallback to using the exercise's name as the keyword, if there are no specific keywords
end

{
Expand All @@ -42,7 +41,7 @@ def index
"description": exercise.description,
"author": "Cliff Shaffer",
"institution": "Virginia Tech",
"keywords": keywords,
"keywords": keywords,
"exercise_name": exercise.name,
"iframe_url": exercise.embed_url(host_url),
"lti_url": "#{host_url}/lti/launch?custom_ex_short_name=#{exercise.short_name}"
Expand Down

0 comments on commit 10a6e8b

Please sign in to comment.