cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dmg34
Community Contributor

Is there an easier way to duplicate & edit math questions with equations?

Jump to solution

The best way to ask this question is to explain what I'm trying to do. As an example, I am working on a question bank with absolute value inequality questions. I have 4 similar multiple choice questions, e.g.: "What is the solution set to the inequality: |x|>7" and then additional versions that use |x|<7, |x|<=7, |x|>=7. The first two versions have 8 identical answer choices (6 of which are sets involving a "7"), and the last 2 have the same answer choices, but with closed intervals instead of open. All of the expressions, both in the question and the answer, are done with equation editor.

Now, I want to load up the question bank with several more versions, where I just change the 7 to other numbers; e.g., duplicate these 4 questions maybe another 5-8 times. The only way I know how to do this is to:

1. copy each question into a temporary new bank (since I can't just "duplicate" a question in the same bank)

2. edit EVERY equation in each of the 4 questions and answers (approximately 28 edits, just for one new "set" of 4 questions)

3. move the questions from the temporary bank back to the "real" bank

4. lather, rinse, repeat 7 more times

Since all of the items that need to be edited are inside equation objects, I don't know if there is an easier way to do this. If there were a way to export the questions into some kind of text format, edit the text (even if it means editing the html for the equation objects??) using copy and paste, etc, and then import it BACK into Canvas, it would be SO much easier.

Alternatively, if there were a way to use variables inside equation objects (the way we can for formula questions), AND then use those same variables in multiple choice answer options, this would be a BREEZE. I have a feeling there is no breezy way to accomplish what I'm trying to do here.

We do have a campus license for Respondus, which I just recently downloaded and haven't really learned how to use yet. I hoped that it might be an easier way to create multiple questions like this, but since it also uses an equation editor for equation objects, I doubt that it will be much of a time/effort savings.

1 Solution

Accepted Solutions
James
Community Champion

As a followup -- we have moved from the realm of theoretical into proof of concept. It is possible to generate a quiz question involving equations using Excel, bring it into Respondus, and then export it into Canvas. Below are some of the details.


Here's what a sample quiz looks like:

215328_pastedImage_1.png

And here is what it looks like when you're editing the question.

215329_pastedImage_2.png

Here's a mostly useless snapshot of what I imported as a CSV.

215405_pastedImage_3.png

The question and choices are copied from another sheet where I did my scratch work. I can't have extra stuff on the sheet exported as a CSV.

215406_pastedImage_4.png

Columns E-M contain valid LaTeX markup.

Here are the formulas for some of the key spots

E2: ="(x"&IF(A2<0,"+","-")&ABS(A2)&")"

F2: ="(x"&IF(B2<0,"+","-")&ABS(B2)&")^2"

I2: ="f(x)=\frac{"&E2&F2&"}{"&G2&H2&"}"

J2: ="x="&A2

N2: ="<p>Where does the graph of the rational function "&CanvasEquation(I2)&" cross the x-axis?</p>"

P2: ="<p>"&CanvasEquation(J2)&"</p>"

Q2: ="<p>"&CanvasEquation(K2)&"</p>"

I wrote a helper function called CanvasEquation using VBA to generate the image link. It greatly simplified the process. 

To use the code, Press Alt-F11 in Excel, then go to Insert > Module and paste the code. Then, when you save the file, be sure to save it as an .xlsm (Macro-Enabled) file.  Don't make the mistake of only saving the CSV, you'll lose all your formulas. Save the whole spreadsheet and then save just the first sheet as a CSV. Go back to the full file before doing more editing.

It's not pretty, but it works for the elementary stuff. I didn't have to add img as a separate variable, but I did just in case I wanted to do something else with it later. I did minimal HTML entity escaping, although it looks like the only thing that had to be escaped were the ampersand the quote mark.

Function CanvasEquation(t As String) As String
    Dim url As String
    Dim s As String
    Dim img As String
    Let s = Replace(t, "&", "&amp;")
    Let s = Replace(s, """", "&quot;")
    Let s = Replace(s, "<", "&lt;")
    Let s = Replace(s, ">", "&gt;")
    Let url = WorksheetFunction.EncodeURL(t)
    Let img = "<img class=""equation_image""" _
        & " title=""" & s & """" _
        & " src=""/equation_images/" & url & """" _
        & " alt=""" & s & """ />"
    Let CanvasEquation = img
End Function

Then in Respondus, I did the CSV import as HTML. If you get an error that the CSV file can't be read, you might need to close the Excel file first.

I should probably do a write-up about this as a blog post, but hopefully it will give you enough information to get moving.

View solution in original post

10 Replies
James
Community Champion

Is there a reason it needs done with the equation editor?

It doesn't sound like you're doing anything that requires it as ≤ and ≥ can be entered directly (Fabulous Code Chart (ALT and HTML) for Math and Currency Symbols for PC ). There's also an infinity symbol ∞ if you're using interval notation.Those three can be typed directly from a PC keyboard using ALT+numpad codes.

What I would do is create a spreadsheet that has the questions and let the formula refer to the "7". Then copy/paste that down and bring it into Respondus as a CSV import and make it multiple choice questions. I've done that with other things and it's worked well.

Respondus will even import HTML this way, so if you do need something fancy like superscripts or subscripts, it still might be able to help.

siouxgeonz
Community Contributor

The spreadsheet solution's a good one but yes, there are many of us who wish copying were built in!   I weary of rinse, lather & repeat (respondus not an option, here).

Hey  @James ,

Is this another situation where something like PhraseExpress can save the day? I think you would be able to setup symbols (or more) to replace any custom text you decide to use? 

James
Community Champion

Can't say, I've never heard of it before now.

I would expect it to have problems because of the way Canvas names its input fields and that some answers are dynamically created (even if you create 8 answers, the next time you create a question, it defaults to 4 choices, so you have to click "Add another answer" 4 times and that does some JavaScript to add the fields to the page, so the inputs weren't there originally. But again, I've never heard of it, so that's pure conjecture. If you have Respondus, which  @dmg34 ‌ did, I'd definitely go that way.

The other way I've done it is to programmatically create problems through the API. That's definitely not for everyone (or even most people). But that's how I made up a quiz with 150 variations on a problem and 9 types of problems (could have used formula questions if there was better support). I readily admit that's overkill and Canvas really slows down when I go to edit it.

dmg34
Community Contributor

Thank you for the suggestion,  @James ‌! I will look into the spreadsheet approach. I did consider using plain text, and I found the infinity alt code. The main reason I prefer the equation editor for this particular question bank is aesthetic - I think that the formatting looks better and is easier to read. But I might be able to get by with text for some purposes.

However, from a more general point of view, I often need rational expressions and other formatting/symbols which would definitely require the equation editor, and I'd like to be able to do the same kind of editing with those question banks as well. (Or even better, be able to use variables more robustly - in equations and also in multiple choice solutions.)

On another note - do you know if there is an alt code for union and intersection symbols? I was originally trying to see if I could design another problem as a matching, and for that purpose, I was going to use text. I got hung up on needing the union and intersection symbols, and I could not find alt codes for them. I suppose I could get by with a "U" for the union, but not sure how I could do an intersection symbol.

James
Community Champion

I'm not a big fan of the way the equation editor works since it insists on generating graphics and that doesn't scale well without pixelating. But sometimes it is a necessary evil.

I was not aware of any way to automatically create those, but I hadn't looked into what's going on behind the scenes to try and figure it out either. I just now took a couple of minutes and it appears that the name of the file in the img src attribute is the LaTeX code that is displayed. I changed a formula in the src attribute and the alt attribute and then saved the page and it updated the image to match the src.

The src is URL encoded, though, so no spaces or certain special symbols.

SE=\frac{SD}{\sqrt{n}} becomes SE%3D%5Cfrac%7BSD%7D%7B%5Csqrt%7Bn%7D%7D

This is untested, but it looks like you might be able to get somewhere with Respondus if you manually create the src and alt tags (alt is required for accessibility, but the src is used to generate the image) and then import the CSV file as HTML rather than plaintext. What you might want to do is create one in Canvas and see what it comes out looking like and then play around. I did this in our beta instance.  Also, recent versions of Excel on Windows have a ENCODEURL() function that could help.

I still know what I did last summer -- it was add MathJaX to Canvas so that the equations rendered without the need to create an image. Then I added LaTeX to the page using \( and \) delimiters to avoid the issue with $ possibly appearing in text. I did this to a subaccount that I moved my classes into so that it didn't load for every page.

The only downside I experienced was that dynamically created content after the page had loaded didn't display until I refreshed the page. Not a big deal and there's ways to tell MathJaX to watch for that, I just didn't bother.

James
Community Champion

As a followup -- we have moved from the realm of theoretical into proof of concept. It is possible to generate a quiz question involving equations using Excel, bring it into Respondus, and then export it into Canvas. Below are some of the details.


Here's what a sample quiz looks like:

215328_pastedImage_1.png

And here is what it looks like when you're editing the question.

215329_pastedImage_2.png

Here's a mostly useless snapshot of what I imported as a CSV.

215405_pastedImage_3.png

The question and choices are copied from another sheet where I did my scratch work. I can't have extra stuff on the sheet exported as a CSV.

215406_pastedImage_4.png

Columns E-M contain valid LaTeX markup.

Here are the formulas for some of the key spots

E2: ="(x"&IF(A2<0,"+","-")&ABS(A2)&")"

F2: ="(x"&IF(B2<0,"+","-")&ABS(B2)&")^2"

I2: ="f(x)=\frac{"&E2&F2&"}{"&G2&H2&"}"

J2: ="x="&A2

N2: ="<p>Where does the graph of the rational function "&CanvasEquation(I2)&" cross the x-axis?</p>"

P2: ="<p>"&CanvasEquation(J2)&"</p>"

Q2: ="<p>"&CanvasEquation(K2)&"</p>"

I wrote a helper function called CanvasEquation using VBA to generate the image link. It greatly simplified the process. 

To use the code, Press Alt-F11 in Excel, then go to Insert > Module and paste the code. Then, when you save the file, be sure to save it as an .xlsm (Macro-Enabled) file.  Don't make the mistake of only saving the CSV, you'll lose all your formulas. Save the whole spreadsheet and then save just the first sheet as a CSV. Go back to the full file before doing more editing.

It's not pretty, but it works for the elementary stuff. I didn't have to add img as a separate variable, but I did just in case I wanted to do something else with it later. I did minimal HTML entity escaping, although it looks like the only thing that had to be escaped were the ampersand the quote mark.

Function CanvasEquation(t As String) As String
    Dim url As String
    Dim s As String
    Dim img As String
    Let s = Replace(t, "&", "&amp;")
    Let s = Replace(s, """", "&quot;")
    Let s = Replace(s, "<", "&lt;")
    Let s = Replace(s, ">", "&gt;")
    Let url = WorksheetFunction.EncodeURL(t)
    Let img = "<img class=""equation_image""" _
        & " title=""" & s & """" _
        & " src=""/equation_images/" & url & """" _
        & " alt=""" & s & """ />"
    Let CanvasEquation = img
End Function

Then in Respondus, I did the CSV import as HTML. If you get an error that the CSV file can't be read, you might need to close the Excel file first.

I should probably do a write-up about this as a blog post, but hopefully it will give you enough information to get moving.

View solution in original post

dmg34
Community Contributor

Wow.... this is extremely helpful! Please do let us know if you do a blog post. I will need to study this and take some time to understand it all, but I greatly appreciate your time and effort!

James
Community Champion

I've started it, but I'm making it a discussion rather than a blog since it might need revising multiple times. I finally gave up at 5:00 am and went to bed since I had to get up and teach today.

I've got the part through creating a function that will make the <img> tag. They're double encoding the URL and I'm not sure why, but it seems to work in my very limited testing without doing that.

I added code for Google Sheets in addition to Excel so the Mac users can use something.

Now I'm working on creating the rest of the spreadsheet to do the actual problem part in a way that you can import into Respondus.

Along the way, I had an idea of -- wouldn't it be awesome if you could add a button to the editor that would translate things like \(\frac{x}{2}\) into the corresponding equation image or back again. That way, someone who wants to just type it could and then convert the entire page all at once into Equation Objects. I'm pretty sure you could, but the question becomes of whether that's the best way to do it (two buttons take a lot of real estate on the toolbar).

The other issue, which I'm not going to try and address at all, is error checking to make sure someone enters valid LaTeX.