Copying Code Into a Canvas Essay Quiz Question

The Canvas essay quiz question response box enables test-takers to provide a free-response answer to a quiz question. This works fine most of the time, but if a test-taker uses an interactive development environment (e.g., BlueJ, Spyder, Jupyter) to write code and then tries to copy and paste the code into the response box, often times the indentation will not copy over. Here are two possible solutions to this problem.

Solution 1: Select the “Preformatted” style in the response box’s style combo box before copying over the text:

Then, the test-taker can paste in the code and the indentation should copy over:

The above worked on a Mac running OSX and Chrome. But sometimes this solution doesn’t work. If not, try the next idea.

Solution 2: This comes from a student who couldn’t get Solution 1 to work on a Windows machine running Chrome. (Below is the student’s text, with minor edits.)

  1. Select and Copy your code in your IDE environment.
  2. Paste the code into the Canvas response box (NOT “as plain text” – just use the Paste option). The code will copy over in Paragraph style, and no indentations will be visible until you do Step 3 below.
  3. Select the pasted code, then select “Preformatted” style in the response box’s style options. The code will change to Preformatted style, and indentations should then become visible.

The key difference: Selecting “Preformatted” before copying did not result in the desired formatting, but selecting the code after pasting into Canvas and then choosing the “Preformatted” style made the indentations viewable. So, clearly the indentations carried over in the copy/paste, but in my case they only became viewable after selecting the code and changing the style to “Preformatted.”

(Post last updated June 10, 2020.)