cancel
Showing results for 
Search instead for 
Did you mean: 
bowmanr
Adventurer III

canvancement show_question_names issue

Jump to solution

@James 

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.
Ron

Labels (2)
0 Kudos
4 Solutions

Accepted Solutions
James
Navigator

@bowmanr 

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".

I just now did some testing. I wrote that script a long time ago with some jQuery code and have been trying to move away from that for a few years to a pure JavaScript solution when possible. Now I'm using fetch() that is built into the browser instead of jquery's getJSON(). I just tested it with fetch() and it returned the actual question name. In other words, it looks like it can be fixed with a rewrite of the script.

View solution in original post

0 Kudos

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.

View solution in original post

James
Navigator

@bowmanr 

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

View solution in original post

@bowmanr 

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.

View solution in original post

8 Replies
James
Navigator

@bowmanr 

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".

I just now did some testing. I wrote that script a long time ago with some jQuery code and have been trying to move away from that for a few years to a pure JavaScript solution when possible. Now I'm using fetch() that is built into the browser instead of jquery's getJSON(). I just tested it with fetch() and it returned the actual question name. In other words, it looks like it can be fixed with a rewrite of the script.

View solution in original post

0 Kudos
bowmanr
Adventurer III

@James 

James -
Thanks for the quick response.  I did not expect a reply over the weekend, but it is good to know that there might be a fix.

Ron

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.

View solution in original post

James
Navigator

@bowmanr 

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

View solution in original post

bowmanr
Adventurer III

@James 

James -

Everything works good now.  I had to reload the pages, and then I forgot that I had turned it off in tampermonkey.

It now is working as I expected.

Thanks again for all of your work with Canvancements.

Ron

@James 

James -

It looks like I spoke too soon.  it works provided the quiz question is not in a question group where you pick 4  of the 8 in there.  I was going to show someone this feature and it was not working.  I then went to an exam where I just had the questions added directly or from a question bank (but not part of a group) and the question name shows up.  

Ron

@bowmanr 

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.

View solution in original post

bowmanr
Adventurer III

@James 

James you answered my question.  My group questions came from a question bank.  I can add questions as individual ones from a question bank and it works - I guess because it duplicates the question or something like that.  i find the entire quiz bank setup in Canvas to be rather confusing and a bit of a pain.  My logic does not seem to process the information in the way that Canvas does with quiz banks.

In any case, it works as well as it can due to Canvas limitations - which is better than nothing.

Thanks again

Ron