byu-cpe / ComputingBootCamp

https://byu-cpe.github.io/ComputingBootCamp/
MIT License
8 stars 56 forks source link

Quiz Questions feature breaks whenever you use special characters that are used in HTML #98

Closed BYUComputingBootCampTests closed 3 years ago

BYUComputingBootCampTests commented 3 years ago

I've been trying to implement more quiz questions through the Computing Boot Camp, but I keep running into the same problem. It's pretty straightforward. This below is a normal quiz question format for the questions.yml file:

- id: 2
  prompt: Select the most appropriate pairs
  type: matching
  responses:
    - text: interpreted
      correct: python
    - text: compiled
      correct: c++
    - text: HDL
      correct: System Verilog

If I replace any of the inputs for "prompt:", "text:", "correct:" or "help:" with any special characters used in HTML, then it won't work and will break the page. For example, look at the following quiz question:

- id: 9
  prompt: Match the git log features on the left with it's corresponding functionality on the right
  type: matching
  help: Use git log --help
  responses:
    - text: -<number>
      correct: Limit the number of commits to output
    - text: --reverse
      correct: Output the commits chosen to be shown in reverse order
    - text: --parents
      correct: Print also the parents of the commit (in the form \"commit parent...\")

This results in this on the CBC website:

example

It would be nice if the text inputs for quiz questions could support special characters. Since our website specializes in software and electrical development, alot of the quiz questions are naturally going to want to include these special characters. For example, the quiz question above is one that I am writing, and I can't use it in the site.

xanjohns commented 3 years ago

It looks like liquid has a built in "escape" filter that we could add easily to handle special characters. In my testing so far though, it doesn't seem to work well with double quotes, so I'll check it out and see if there is a workaround.

xanjohns commented 3 years ago

This PR should resolve the problems. Ping me if you run into other cases that cause issues.

BYUComputingBootCampTests commented 3 years ago

Ooh, that sounds great! And if all of the other special characters work, then the double quotes shouldn't be an issue (it'll be easy to replace it with single quotes instead). Thanks!

xanjohns commented 3 years ago

With this fix, single and double quotes should work, along with all other special characters.