-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to the XMLRPC system to support UTF-8 encoded problems #956
Changes to the XMLRPC system to support UTF-8 encoded problems #956
Conversation
problems. Rendering works already. However, submitting UTF-8 encoded text which is not English (Latin1) as form values (in particular as answer) is not working yet. Due to this, the values set on the submit buttons are currently forced back into English. clients/sendXMLRPC.pl was extended to take a language setting as an argument. lib/WebworkClient.pm contains code to set the HTML language and text direction both at the level of the "page" and at the level of the DIV element enclosing a problem (based on data set in the PG file). lib/WeBWorK/Localize.pm received a new method getLangHandle() used by lib/WebworkClient.pm to get access to maketext. lib/WeBWorK/Utils/DetermineProblemLangAndDirection.pm was extended to allow forcing options not available via a request hash when the XMLRPC system is rendering problems. Small related changes and some cleanup work was done to several of the formats in lib/WebworkClient/ including changes to support UTF-8, to standardize the title setting, to the copyright dates. Additional settings were added to the <form> element and to the "problem-content" DIV element to be more similar to what is generated by the regular ContentGenerator system. "forcePortNumber" was added as a new hidden field. The value settings of the submit buttons are set by variables so they can get localized text. At present, this is not in active use as UTF-8 values render properly but then cause problems when the buttons are clicked and the non-English values are sent as form data. This PR also includes changes to allow forcing a port number to be used by the XMLRPC system. This is intended to help when using the XMLRPC system with a Docker container or a host which requires using a port number for the site_url and form_action_url. This is managed by setting the value of forcePortNumber in the credentials and/or in the address used to access html2xml. Ex: http://localhost:8080/webwork2/html2xml?&answersSubmitted=0&language=en&sourceFilePath=some_pg_file.pg&problemSeed=123567890&displayMode=MathJax&courseID=daemon_course&userID=daemon&course_password=daemon&outputformat=simple&forcePortNumber=8080
Pay attention to #955 and the workaround given there when trying to test the XMLRPC system with the 2.15 branch. |
Although this works fine (for rendering) - submitting answers with non-latin characters makes trouble. Since that would not have worked at all before the UTF-8 support was added, leaving that issue unresolved by this PR is still significant progress on getting XMLRPC working with foreign languages. |
Some thoughts on the issue with non-English characters in answers / form field data:
At present I see two error messages when submitting non-English in an answer (using the
If I hack the form to change to the form value for
I can see that the form data is in 3 locations:
In
|
outputing sensitive information when pretty_print_self is allowed. We block specific keys from CourseEnvironment as well as the entire expected seed_ce.
I added in a second commit to the PR code to sanitize the output of the
is uncommented. The code explicitly avoids all sorts of sensitive fields from any included CourseEnvironment from being output, and blocks the entire |
I see the following minor error messages when I run this:
I see you noticed these as well Tani. Can you fix them in your pull request? or would you like me to fix them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the following minor error messages when I run this:
Unknown PerlIO layer "uft8" at /Volumes/WW_test/opt/webwork/webwork2/../pg//lib/PGcore.pm line 34.
"our" variable @path_list redeclared at ./sendXMLRPC.pl line 406.
"my" variable $credentials_string masks earlier declaration in same scope at ./sendXMLRPC.pl line 408.
"our" variable $UNIT_TESTS_ON redeclared at ./sendXMLRPC.pl line 575.
home directory .
I see you noticed these as well Tani. Can you fix them in your pull request? or would you like me to fix them.
Otherwise this looks good.
…t.pm to fix the main problem reported in: openwebwork#955 as well as the warnings mentioned there, which were also mentioned in openwebwork#956 but which are not related to the main theme of that PR.
…t.pm to fix the main problem reported in: openwebwork#955 as well as the warnings mentioned there, which were also mentioned in openwebwork#956 but which are not related to the main theme of that PR.
The minor issues were just fixed in
Those PRs also fix #955 |
See: The issue about |
Changes to the XMLRPC system to allow it to handle UTF-8 encoded problems.
Rendering works already. However, submitting UTF-8 encoded text which is not English (Latin1) as form values (in particular as answer) is not working yet. Due to this, the values set on the submit buttons are currently forced back into English.
clients/sendXMLRPC.pl
was extended to take a language setting as an argument.A sample Hebrew UTF-8 problem was added as
clients/t/test-utf8-hebrew.pg
to allow testing. On my system, testing using./sendXMLRPC.pl -b -f simple t/test-utf8-hebrew.pg
./sendXMLRPC.pl -b -l heb -f simple t/test-utf8-hebrew.pg
both give reasonable behavior, so long as no special characters are used in the answers.
lib/WebworkClient.pm
contains code to set the HTML language and text direction both at the level of the "page" and at the level of the DIV element enclosing a problem (based on data set in the PG file).lib/WeBWorK/Localize.pm
received a new methodgetLangHandle()
used bylib/WebworkClient.pm
to get access to maketext.lib/WeBWorK/Utils/DetermineProblemLangAndDirection.pm
was extended to allow forcing options not available via a request hash when the XMLRPC system is rendering problems.Small related changes and some cleanup work was done to several of the formats in
element and to the "problem-content"lib/WebworkClient/
including changes to support UTF-8, to standardize the title setting, to the copyright dates. Additional settings were added to theDIV element to be more similar to what is generated by the regular ContentGenerator system.
forcePortNumber
was added as a new hidden field. The value settings of the submit buttons are set by variables so they can get localized text. At present, this is not in active use as UTF-8 values render properly but then cause problems when the buttons are clicked and the non-English values are sent as form data.This PR also includes changes to allow forcing a port number to be used by the XMLRPC system. This is intended to help when using the XMLRPC system with a Docker container or a host which requires using a port number for the site_url and form_action_url. This is managed by setting the value of
forcePortNumber
in the credentials and/or in the address used to accesshtml2xml
.Ex:
http://localhost:8080/webwork2/html2xml?&answersSubmitted=0&language=en&sourceFilePath=some_pg_file.pg&problemSeed=123567890&displayMode=MathJax&courseID=daemon_course&userID=daemon&course_password=daemon&outputformat=simple&forcePortNumber=8080