cancel
Showing results for 
Search instead for 
Did you mean: 
Surveyor

Change text on "Take the Quiz" button?

Jump to solution

Hi,

I've been trying to mimic what was done in this discussion to change the text on the "Take the Quiz" button in a Canvas quiz. Many of our quizzes are not actual quizzes; rather, just assignments that are better suited to be delivered as a "quiz" in Canvas.

That being the case, I am looking to change the "Take the Quiz" text on the quiz button to say something different, like "Begin Assignment".

I am tech savvy, but a novice in JavaScript. I have admin access to be able to upload custom JavaScript files to Canvas. Our instance currently has custom JavaScript and CSS files included.

I've tried updating the code and reuploading the JavaScript file in the theme editor, but what I've tried hasn't worked. Either my code is wrong, or I'm adding it incorrectly to the JavaScript file. Code:

  1. $(document).ready(function(){  
  2.     $('a.btn.btn-primary.take_quiz_link').text('Begin');  
  3. });  

Can any of you point me in the right direction here? Any advice is much appreciated.

Thanks,

Jake

0 Kudos
2 Replies

Jeffrey,

Thanks for taking the time to answer. This worked like a charm. Really appreciate the help.

Best,

Jake

Explorer

Try this:

$("#take_quiz_link").text("Begin")

However, relying on CSS IDs is a bit risky with jQuery code is a bit risky as Instructure will at some time potentially change their UI such that the CSS ID could become no longer relevant someday down the road. It is the institutions responsibility if they make use of JS overrides for the Canvas UI to check each release for potential UI breakage.

You can also base it off of a jQuery filter by a URL pattern. The <a> element selector in jQuery syntax can use a pattern for the href property. The URL in the <a> element for the 'Take Quiz' button contains the string of 'take?' in it.  Since Canvas calls its own API, that's less likely to change than a UI/CSS change so this expression may last longer:

$('a[href*="take?"]').text("Begin")

Hope that helps.

View solution in original post