One drawback that I hear from our math department is the inability of Canvas to self-grade equations. I have played around with different options, but I think I may have a possible solution. I am not a coder by any stretch, but I have worked on this issue and I would like some help making the code more efficient. What I have now is derived from mathquil. It allows a student to enter an equation as the answer.

It will grade it based on the latex code of the answer ...

It seems to work well, but I wanted someone to look at the code to see if there is a better way to construct it.
Here is the code that I use:
css
#mqBtn :hover {background:lightpink;}
#mq-math-field {max-width:100%;min-width:200px;padding:10px;}
#mqBtn > td {border: 1px solid black;}
#mqBtn > td > p {margin:5px;}
#mq-latex {display:none;}
javascript
if (/https:\/\/<<canvas web address>>\/courses\/<<course number>>\/quizzes\/*/.test(document.location)) {
if (document.getElementById('mq-equation-question')) {
var quesName = document.getElementsByClassName("display_question question short_answer_question")[0].id;
document.getElementsByName(quesName)[1].style.display = "none";
var q2 = '';
var q3 = '';
var q4 = '';
var q5 = '';
var q6 = '√x
';
var q7 = '½
';
var q8 = 'xy
';
var q9 = '';
var q10 = '';
var q11 = '';
var q12 = 'Type equation in box below
';
var q13 = '
';
var q15 = '
';
var q16 = '';
var q17 = 'var mathFieldSpan = document.getElementById("mq-math-field");';
var q18 = 'var latexSpan = document.getElementById("mq-latex");';
var q19 = 'var MQ = MathQuill.getInterface(2);';
var q20 = 'var mathField = MQ.MathField(mathFieldSpan, {spaceBehavesLikeTab: true, handlers: {edit: function() {latexSpan.textContent = mathField.latex();$("input.question_input").val(latexSpan.textContent);$("#list_'+quesName+'").attr("class","list_question answered seen current_question");}}});';
var q21 = '';
var q22 = '';
var q23 = '';
var q24 = '$("#sqrtbtn").click(function () {mathField.cmd("\\\\sqrt");mathField.focus();});';
var q25 = '$("#fracbtn").click(function () {mathField.cmd("\\\\frac");mathField.focus();});';
var q26 = '$("#sqbtn").click(function () {mathField.cmd("^");mathField.focus();});';
var q28 = '';
var question = q2.concat(q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q15,q16,q17,q18,q19,q20,q21,q22,q23,q24,q25,q26,q28);
var appendQuest ="#"+quesName+"_question_text";
$(appendQuest).append(question);
}}
Thanks for the help