A couple of thoughts.
How about encoding the number so it minimally protects their IDs if shared but is easily recoverable?
Going with your example (and making up UserID and QuizID), you might have a string like this:
12345-6932451-652003-718368
Base64 encoding makes it look totally random, but is long and hard to type.
MTIzNDUtNjkzMjQ1MS02NTIwMDMtNzE4MzY4
Converting each ID to a hexadecimal number makes it look like a code you might type into a product key.
3039-69C7E3-9F2E3-AF620
You could obfuscate those even more by applying a transform to them before encoding. Take the quiz number, for example, and then use it to modify the other numbers. Then none of the numbers would stay the same for each student and it would look more random.
Hexadecimal will save you space over straight decimal, so the code is smaller. You may not even need the random digit at the end, perhaps incorporating the course ID would be nice since looking up quizzes by ID requires the course ID.
Since this is all done through JavaScript, nothing is secure. This shouldn't be used to encode confidential information, but there are ways to make it look random without blatantly divulging information.
I set up MathJax on a subaccount in preparation for my fall calculus courses. How that pertains here is that I made it run on select pages only and it did run on the Mobile apps. That means that should be able to parse the location to grab the quiz ID. That said, the mobile apps may pull in the data for a quiz completely differently. There is a form element that contains the quiz ID if we cannot get it from the location. It might be easier to get it from the form#submit_quiz_form element as the action attribute contains the course number, quiz number, and user ID all in one spot.
I also reconfirmed my suspicion that JavaScript you specify for a browser is automatically loaded in the mobile apps as well, so if you write the code well, it should only have to be inserted in the one spot.
CSS selectors will make it difficult to match on an ID of question_652003_question_text where the number really needs to be a wildcard. I would look for .quiz_sortable.question_holder because that's the holder for the whole question. I am not sure how it works for delivered quizzes, but in editing them, there is a phantom question on the page that you might need to watch out for.
Alternatively, you could use document.queryAllSelector('.quiz_sortable.question_holder .text > .question_text.user_content') to get all of the texts. That includes the question number in the id and we already have the user ID and quiz ID from somewhere else.