Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a getSampleProblemCode method to SampleProblemParser.pm. #1198

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Feb 19, 2025

This method is much more efficient than calling parseSampleProblem to obtain the code as it does not parse documentation, does not require that the sample problem metadata be parsed first, and it does not need macro POD information. Note that to obtain the code via the parseSampleProblem method, 253 files need to be read and parsed (all sample problems and all macros). The getSampleProblemCode method only needs to read 1 file, and the parsing of that is more efficient as well. It should be used if all you want is the code as it does not return the documentation and other data returned by the parseSampleProblem method.

Also remove the unused $macro_locations argument to the parseMetadata method.

These changes are used to implement sample problem editing in the PG problem editor for webwork2 in openwebwork/webwork2#2677.

This method is much more efficient than calling `parseSampleProblem` to
obtain the code as it does not parse documentation, does not require
that the sample problem metadata be parsed first, and it does not need
macro POD information.  Note that to obtain the code via the
`parseSampleProblem` method, 253 files need to be read and parsed (all
sample problems and all macros). The `getSampleProblemCode` method only
needs to read 1 file, and the parsing of that is more efficient as well.
It should be used if all you want is the code as it does not return the
documentation and other data returned by the `parseSampleProblem`
method.

Also remove the unused `$macro_locations` argument to the
`parseMetadata` method.

These changes are used to implement sample problem editing in the PG
problem editor for webwork2 in a corresponding pull request.
@drgrice1 drgrice1 force-pushed the sample-problem-get-code branch from a5428ee to 1e1695a Compare February 20, 2025 10:50
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant