Skip to content
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

PG Text post processing #897

Merged
merged 3 commits into from
Oct 30, 2023
Merged

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Aug 3, 2023

Macros or problems can add a hook by calling add_content_post_processor with a subroutine that will be called after the translator has processed answers. For all display modes except TeX, the subroutine will be passed the problem text parsed into a Mojo::DOM object and a reference to the header text. For the TeX display mode a reference to the problem text is passed. The subroutine can then modify the problem DOM or text, and header text. The resulting Mojo::DOM object will be converted back to a string and the problem text reference returned by the translator set to point to that string.

The hidden MathQuill inputs for the latex string is added in this post processing stage (see the ENDDOCUMENT method in PG.pl).

The scaffold.pl macro is updated to use this post processing. This means that answers are no longer evaluated by the macro. Instead the scaffold sections are finalized after the answers are processed normally by the translator.

@drgrice1 drgrice1 force-pushed the post-process-text branch 22 times, most recently from 2cd5384 to dff345a Compare August 6, 2023 02:14
@pstaabp
Copy link
Member

pstaabp commented Aug 10, 2023

Saw that you updated with the scaffolding. Just played with one problem and there's an extra (unstyled) preview button:
image

@drgrice1
Copy link
Member Author

That doesn't exactly make sense. The submit buttons are not added by PG at all. They are added by webwork2 after PG finishes rendering the problem.

@drgrice1
Copy link
Member Author

@pstaabp: I am guessing that you have something else going on unrelated to this pull request. Perhaps you need to run generateAssets.js in the webwork2 htdocs location. I suspect that the visually-hidden-unfocusable class added in openwebwork/webwork2#2119 is not in your math4 css and the new hidden submit button is showing up.

@pstaabp
Copy link
Member

pstaabp commented Aug 10, 2023

You're right. It was doing this in develop and it was a problem with my custom theme--I had another issue with the fact that some of the files were copies and not links to the math4/ versions. All fixed now.

@drgrice1 drgrice1 force-pushed the post-process-text branch 14 times, most recently from 3ed91df to 299e247 Compare September 19, 2023 21:12
@drgrice1 drgrice1 force-pushed the post-process-text branch 3 times, most recently from dce4d1c to 1219e56 Compare October 1, 2023 19:02
@drgrice1 drgrice1 marked this pull request as ready for review October 2, 2023 20:08
@drgrice1 drgrice1 force-pushed the post-process-text branch 2 times, most recently from e6349e3 to cdf779d Compare October 6, 2023 10:29
@drgrice1 drgrice1 force-pushed the post-process-text branch 2 times, most recently from 6896524 to 16a8622 Compare October 11, 2023 21:44
Macros or problems can add a hook by calling
`add_content_post_processor` with a subroutine that will be called after
the translator has processed answers.  For all display modes except TeX,
the subroutine will be passed the problem text parsed into a Mojo::DOM
object and a reference to the header text.  For the TeX display mode a
reference to the problem text is passed.  The subroutine can then modify
the problem DOM or text, and header text.  The resulting Mojo::DOM
object will be converted back to a string and the problem text reference
returned by the translator set to point to that string.

Note that the `$PG_PROBLEM_TEXT_ARRAY_REF` has been removed from the
translator code.  It is never used and is redundant with the
`$PG_PROBLEM_TEXT_REF` which is all that is used.  It was becoming
annoying to maintain both in a compatible manner.

The hidden MathQuill inputs for the latex string is added in this post
processing stage (see the ENDDOCUMENT method in PG.pl).
This means that answers are no longer evaluated by the macro.  Instead
the scaffold sections are finalized after the answers are processed
normally by the translator.
This is so that the content post processor methods have access to the
full answer objects.  This gives this approach a whole lot more power
than the (soon to be eliminated) results table has.
@Alex-Jordan
Copy link
Contributor

Probably all is well now, but there is an extra button like the preview button here that is usually hidden. It is the button that is "clicked" if you hit enter from an input field. You can configure so that button might be check/submit instead. I'm guessing this is the button you saw.

@pstaabp pstaabp merged commit c01a16b into openwebwork:develop Oct 30, 2023
2 checks passed
@drgrice1 drgrice1 deleted the post-process-text branch October 30, 2023 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants