RunestoneInteractive / rs

A New Monorepo structure for Runestone
Other
43 stars 69 forks source link

InvalidCharacterError when creating a new activecode #572

Closed tc-kirby closed 2 weeks ago

tc-kirby commented 2 weeks ago

Please check the current issues Many bug reports are duplicates, this just creates more work for us. Searching the issues first may give you your answer or a workaround! If not adding new information to an existing report is much more helpful than a new report.

What Course are you in tky_y10_bluebook

What Page were you on https://runestone.academy/runestone/admin/assignments

What is your username tomkirby

Describe the bug When I click 'save and add' on my assignment, nothing happens and I get a JavaScript error - see below.

I can generate a preview, no problem. (Although the unittest code didn't run for some reason).

Javascript Errors Uncaught InvalidCharacterError: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range. at create_question (admin.js?v=1731114967:1790:19) at HTMLInputElement.onclick (assignments:876:119)

I have been creating an assignment to test basic Python programming, asking students to write a program that creates a "squirrel" or a "snake". The following examples show all unusual characters that are used:

"<^/\/\/\/\/\/\/\/\~" "<^.^>-.@@@@@@@@@@#######"

I have tried deleting all of these characters from the instructions, program and test code... but to no avail. I am not sure exactly what's wrong or how to find out which character is the problem.

bnmnetp commented 2 weeks ago

Hmmm, did you perhaps copy/paste part of the question from somewhere? I am able to create activecode questions without error. Can you provide me with the entire text of the question?

bnmnetp commented 2 weeks ago

The error message definitely indicates that you have some non-ascii character in the source for that question. btoa does not convert anything beyond the Latin-1 character set. But allowing for a more modern character set like utf8 can also lead to problems that will not appear until you run the program and get an invalid character error. Maybe that is better as the error message from python or whatever language is likely to be more specific about which character is bad.

I can have a fix in by next weekend, in the meantime I would say the workaround will be to type in the question and ensure you are just using Latin-1 characters.

bnmnetp commented 2 weeks ago

Actually, I think that I found a quick reliable fix and am pushing it out now. Should be live in about 15 minutes.

bnmnetp commented 2 weeks ago

Definitely live now, it would be helpful to hear from you or anyone who ran into this today that it is resolved.

I made a change to the way we submit some data last week for security purposes. So 1) I want to make sure it works! 2) I want to make sure that we are secure and not leaving ourselves open to attack. Thanks for your patience and help!

tc-kirby commented 2 weeks ago

Solved it. Thank you Brad! If my school wasn't struggling for funds I would definitely get them to donate. As it is, all I can do is offer my gratitude for your incredibly speedy support!

bnmnetp commented 2 weeks ago

closing, as this is fixed.