-
-
Notifications
You must be signed in to change notification settings - Fork 79
Switch applets from storing state via RECORD_FORM_LABEL to using the PERSISTENCE_HASH.
#1353
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
base: develop
Are you sure you want to change the base?
Conversation
6e5d210 to
80fea8f
Compare
80fea8f to
6c1289a
Compare
pstaabp
left a comment
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.
Couldn't get the correct answer with the given problem, but the problem state is now saving with this PR.
macros/graph/AppletObjects.pl
Outdated
| type => 'button', | ||
| class => 'btn btn-primary applet-reset-btn mt-3', | ||
| 'data-applet-name' => $appletName, | ||
| 'Return this question to its initial state' |
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.
I noticed that since the problem you provided was in French and the restore state button was in English, that we could wrap this line in a maketext.
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.
I added the maketext call here.
6c1289a to
9286e5a
Compare
9286e5a to
bed0143
Compare
…e `PERSISTENCE_HASH`. The applet state is not a "kept extra answer" which is what the `RECORD_FORM_LABEL` approach is for. The applet state isn't an answer at all. It is just extra problem data that needs to persist. So exactly what the `PERSISTENCE_HASH` is for. In addition, webwork2 stores the kept extra answers in the `last_answer` column which is type `TEXT` and thus limited to 64KB. The data in the `PERSISTENCE_HASH` is stored in the `problem_data` column which is of type `MEDIUMTEXT` and so can hold up to 16MB of data. The applet state can become larger than 64KB as is evidenced by the issue posted in the forums at https://forums.openwebwork.org/mod/forum/discuss.php?d=8785. There is also a litle clean up of the `insertAll` method of the `AppletObjects.pl` macro. It can take advantage of the `tag` method.
bed0143 to
114272f
Compare
…lers on the submit buttons. This makes applet problems work in the PG problem editor of webwork2. The PG problem editor uses click handlers on the submit buttons as well, but calls `preventDefault` on the event, and prevents the form submission from occuring. That prevents the current submit handler set in the ww_applet_support.js code from happening. Thus the answers for applets do not get submitted. By using the click handlers this gets in at the same point that the PG problem editor handlers are, and they still occur. All click handlers are executed even if one of them prevents default behavior.
114272f to
1374218
Compare
The applet state is not a "kept extra answer" which is what the
RECORD_FORM_LABELapproach is for. The applet state isn't an answer at all. It is just extra problem data that needs to persist. So exactly what thePERSISTENCE_HASHis for. In addition, webwork2 stores the kept extra answers in thelast_answercolumn which is typeTEXTand thus limited to 64KB. The data in thePERSISTENCE_HASHis stored in theproblem_datacolumn which is of typeMEDIUMTEXTand so can hold up to 16MB of data. The applet state can become larger than 64KB as is evidenced by the issue posted in the forums at https://forums.openwebwork.org/mod/forum/discuss.php?d=8785.This also removes a FIXME that has been in the code since 2010 that states that this should be done.
There is also a litle clean up of the
insertAllmethod of theAppletObjects.plmacro. It can take advantage of thetagmethod.Finally, switch ww_applet_support.js from using a submit handler to click handlers on the submit buttons. This makes applet problems work in the PG problem editor of webwork2. The PG problem editor uses click handlers on the submit buttons as well, but calls
preventDefaulton the event, and prevents the form submission from occuring. That prevents the current submit handler set in the ww_applet_support.js code from happening. Thus the answers for applets do not get submitted. By using the click handlers this gets in at the same point that the PG problem editor handlers are, and they still occur. All click handlers are executed even if one of them prevents default behavior.Note that to work correctly with problem randomization or with show me another problems, this depends on openwebwork/webwork2#2855.
The attached problem can be used to test this. That problem will not even work without this pull request because the state is to large for the
last_answercolumn.LogScale.pg.txt