Skip to content

Commit

Permalink
added multiple lines support for quiz question content
Browse files Browse the repository at this point in the history
  • Loading branch information
Om Chauhan authored and Om Chauhan committed Jan 17, 2025
1 parent 12918cb commit ac60ad8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/assets/javascripts/training/components/quiz.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ const Quiz = (props) => {
);
});

const rawQuestionHtml = md.render(props.question);

return (
<form className="training__slide__quiz">
<h3>{props.question}</h3>
<h3 dangerouslySetInnerHTML={{ __html: rawQuestionHtml }} />
<fieldset>
<ul>
{answers}
Expand Down
12 changes: 8 additions & 4 deletions lib/training/wiki_slide_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ def module_hash(template, module_number)
end

def template_parameter_value(template, parameter)
# Extract value from something like:
# | parameter_name = value
match = template.match(/\|\s*#{parameter}\s*=\s*(?<value>.*)/)
match && match['value']
# Extract value from the template
match = template.match(/\|\s*#{parameter}\s*=\s*(?<value>.*?)(?=\||\Z)/m)

# Check if match is present and value is not nil
value = match && match['value']

# Remove undesired formatting and whitespace, only if value is not nil
value ? value.gsub(/(^:|''')/, '').strip : nil
end
end

0 comments on commit ac60ad8

Please sign in to comment.