I posted the following on the github page, and then I read a post where you don't check that too often. Therefore, I am posting it here.
Hi James -
I want to thank you again (probably done in the forum somewhere) for canvancements. I find them very useful. I need to figure out how to write these or browser extensions to attempt a few ideas on my own.
In any case, one of your old canvancements 95 years since last update: show_question_names
in the quizzes canvancement is not working properly for me. I figured you were suppose to see something like
Question 1: Find the current
where your script would pull the name I assigned to the first question which in this example would be "Find the current"
Instead what I see is Question 1: Question 1
If I am correct in that the script no longer works the way it was intended, it is because in 5 years Canvas has changed some internal naming that the script is no longer accessing correctly.
Just in case it matters, this is with Classic Quizzes and not New Quizzes.
Solved! Go to Solution.
Ron, you are correct that it no longer functions the way it was intended.
Canvas changed it so that the real question name is no longer delivered within a browser. My local version used for testing shows that I last tried to track down the issue about 2.5 years ago in September 2018.
What is happening is that if you make the call from outside a browser, Canvas will return the question name that you entered when you created the quiz, but if you make the call from within the browser, it just returns "Question 1".
Upon further investigation, it seems that it's not the JSON vs fetch that is causing the issue. If you get the questions for the quiz, it gives the real names. If you ask for the questions for a specific submission from a student, then it gives Question 1, Question 2.
I think I was asking for a specific submission to save time. I have one quiz that has (for example) 1000+ questions in it, but only 10 of them were delivered to the student (10 question groups of 100 questions each). Fetching all of the question names could introduce a noticeable delay and potentially run into throttling issues. At least Canvas returns a status that the questions haven't changed since the last time you asked for it (304 status code) and it should still be in the browser's cache, but it seems to take as long to do that as it does to fetch the data. We're now getting into the realm of optimization to make it go faster, where as the few people who would use it would probably just rather have it work.
Without asking for a specific submission, there may be problems getting the names when the questions come from question banks or if the quiz was changed between the time it was taken and the time you're looking at it. I can't remember 5 years ago, but I wonder if the change was because questions coming from a question bank cannot be delivered through just fetching the questions for the quiz (without a submission) or because they wanted to hide the question name for security purposes (so a student doesn't see the code when they look at their results).
Anyway, in preliminary testing, removing the parameters specific to the submission restored the functionality -- until I went to test it on a quiz that had a lot of question groups where not every question was asked. That's most likely a logic problem in my code as it seems to be getting the name data, but not changing it. That code was pretty inefficient, anyway.
I rewrote it to implement the changes I talked about and have updated the code on GitHub. Please see if this works better.
It forces the cache mode to make things a lot faster, but if you have stale data in the cache because you changed the question name after view
Were the items in the question group linked to a question bank or where they added to the question group directly?
If the items are linked to a question bank, getting the question names out is going to be nearly impossible because Canvas doesn't give you that information when you ask for the questions. Canvas has no API for accessing question banks directly like it does for quiz questions. One of the few ways to even get banks out of Canvas is to create a quiz where you copy the questions from the bank and then work with that quiz. Linking from a bank has other issues and I've never recommended it and don't do it myself because of the problems. Some people like it, but the problems were too many for me to use them. My problems may be different than other people's problems (mine include getting the information out of Canvas).
In my testing where the questions were part of the quiz, the names show up just fine. I did my testing on a quiz with one question group with 144 questions of which I picked 6. All of them were part of the question group, though, and not linked to the question bank.