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

create a pg to pgml convert script #882

Merged
merged 8 commits into from
Apr 3, 2024

Conversation

pstaabp
Copy link
Member

@pstaabp pstaabp commented Jul 24, 2023

This is a script to convert a PG problem to PGML format. Details are in the script file. Overall, to run this, it is

convert-to-pgml.pl file1.pg file2.pg

converts each of the files to PGML format and creates a .bak file.

@pstaabp pstaabp force-pushed the convert-to-pgml branch 2 times, most recently from 84e84e5 to b31394f Compare August 25, 2023 13:04
@pstaabp
Copy link
Member Author

pstaabp commented Aug 25, 2023

This is ready for testing. I've made the script more robust and improved documentation. If there are other features/conversions requested, happy to take those.

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a start, but there seem to be several things that aren't working very well.

I started with Library/UMN/calculusStewartCCC/s_2_3_12.pg

and got (I also manually deleted the comment lines):

DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', , 'PGcourse.pl');

Context("Numeric");

$a = list_random(-3,-2,-1,1,5);

$ans = Compute("(2*($a)^2+(4*$a)-5)/(($a)^2-(5*$a)+6)")->reduce;

BEGIN_PGML
Evaluate the limit, if it exists.  If a limit [$BITALIC] does not exist, [$EITALIC] type "DNE".
[``
\lim_{x \to [$a]} \frac{2x^2+4x-5}{x^2-5x+6}
``]

---

Limit: [_]{}{20}  
END_PGML

# ANS( $ans->cmp );

ENDDOCUMENT();

Observe the following:

  • There are now two consecutive commas in the loadMacros call.
  • The $BITALIC and $EITALIC did not get converted.
  • There is whitespace added at the end of the Limit: [_]{}{20} line.
  • The [``\lim ... ``] was initially in display style math mode with \[ ... \], but was converted to inline display style math mode. To get the same math mode it should be converted to use the three backtick version [```\lim ... ```].

Note that if you run the scrip on this file again, the two consecutive commas in the loadMacros call are turned into , '',. That is the empty string is added in between those two commas. This causes an error if the problem file is used (assuming you fix the answer).

Also, could you make the comments in the added files consistent. Some comments are capitalized and properly punctuated, but others are not.

lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
@pstaabp
Copy link
Member Author

pstaabp commented Sep 26, 2023

There is whitespace added at the end of the Limit: [_]{}{20} line.

This is added because there is a $BR at the end of the line and using the two spaces for a line break in PGML.

I think original $BR shouldn't be there.

Fixed these errors and added the removal of any lines with only comments on them.

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting to look closely at this. There is a lot of clean up needed in this.

bin/convert-to-pgml.pl Outdated Show resolved Hide resolved
bin/convert-to-pgml.pl Outdated Show resolved Hide resolved
bin/convert-to-pgml.pl Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will need some more tweaking, but this is a start.

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either the things commented on need to be fixed, or the help comments shown in the webwork2 problem editor for this need to be made much more far reaching. Clearly not only answer rules are not dealt with correctly.

lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
lib/WeBWorK/PG/ConvertToPGML.pm Outdated Show resolved Hide resolved
@pstaabp pstaabp force-pushed the convert-to-pgml branch 4 times, most recently from 152bfbb to 42131e6 Compare January 12, 2024 12:56
pstaabp added 8 commits March 27, 2024 17:40
improved ans_rule parsing, add $HR conversion, comment out ANS
improve the handling of the loadMacros block as well.
and added the removal of lines with only comments  on them.
Also, add additional conversion functionality.
* convert AnswerFormatHelp to helpLink
* remove AnswerFormatHelp from macro list
* better handling of HR
* better handling of code blocks inside of PGML.
* when wrapping variables in [], handle arrays, hashes better.
@drgrice1 drgrice1 merged commit 119626f into openwebwork:develop Apr 3, 2024
3 checks passed
@pstaabp pstaabp deleted the convert-to-pgml branch April 6, 2024 11:13
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.

2 participants