Repository navigation
Conversation
|
Is the reason to put the metadata in a comment block just to make parsing easier to find start/end of the block and and bail if encountering a non blank/non commented out line? To me not having to include those extra |
|
The reason it is in a comment block is so that it is valid Perl. Using a |
|
Furthermore, there are quite a lot of things that would need to be reworked to add an invalid YAML block in the code (the codemirror editor, pg perltidy, pg critic, and probably many other things). Using a Perl comment block already works with everything. |
|
It is also consistent with the current tagging setup. |
|
Ahh, I keep overlooking it needed to valid perl, since it was being stripped from the file, forgot to consider that. |
cda9087 to
d463212
Compare
|
I was trying to convert some of my problems over. It seems that if there is anything after either the last Note: I had commented out the |
8608c82 to
0ca035c
Compare
0ca035c to
22ae451
Compare
22ae451 to
1e7d80a
Compare
This sets up a new style of coding problems. These problems must contain a Perl comment block which is essentially a commented out YAML document that has first line `## ---` (spacing is ignored) and whose next line declares the `pgAuthoringVersion`, and is followed by other supported metadata tag values. For example, ``` ## --- ## pgAuthoringVersion: 1 ## macros: ## - parserMultiAnswer.pl ## - contextFraction.pl ## --- ``` That block must occur before any line of code, but can be preceded by any number of comment lines or lines consisting entirely of whitespace (so the OPL tags can preceded this block). The keys in this YAML block are case insensitive. So ``` ##--- ## pgauthoringversion: 1 ## MACROS: [parserPopUp.pl] ##--- ``` will also work. Note that alternate way of giving a YAML array for declaring the macros used by the file. Problems coded in this new style are not allowed to call `DOCUMENT`, `ENDDOCUMENT`, or `loadMacros`. The problem code is assumed to start at the beginning of the file, and end at the end of the file. The actual `DOCUMENT` and `ENDDOCUMENT` calls are added in the `WeBWorK::PG::Translator::translate` method when the problem code is evaluated. Furthermore, the metadata is passed to the `DOCUMENT` call. At the end of the `DOCUMENT` call `loadMacros` is called and loads the macros `PGbasicmacros.pl`, `PGauxiliaryFunctions.pl`, `PGML.pl`, any macros declared in the `macros` metadata, and finally the `PGcourse.pl` macro. So clearly problems should not list `PGbasicmacros.pl`, `PGauxiliaryFunctions.pl`, or `PGML.pl` in the `macros` metadata (although it would not be an error to do so). This means that basic problems that do not use any non-core macros will only need to have ``` ## --- ## pgAuthoringVersion: 1 ## --- ``` which is the minimal requirement to signify that this is a problem coded in the new style. At this point the only valid `pgAuthoringVersion` is 1, and passing any other version is an error. Of course, the point of a version here is that we can add new authoring versions in the future as authoring coding expectations change, and old versions of problems can continue to work. At this point any problem that does not contain this Perl comment block YAML document with the `pgAuthoringVersion` declared will continue to work with the old authoring requirements (`DOCUMENT` and `ENDDOCUMENT` must be called, and any macros that are needed, including core macros such as `PGbasicmacros.pl`, loaded via `loadMacros`). At this point the only supported metadata keys are `pgAuthoringVersion` and `macros`, and it is an error to add anything else. More keys can be added as needed.
73e3a6c to
4f31666
Compare
This sets up a new style of coding problems. These problems must contain a Perl comment block which is essentially a commented out YAML document that has first line
## ---(spacing is ignored) and whose next line declares thepgAuthoringVersion, and is followed by other supported metadata tag values. For example,That block must occur before any line of code, but can be preceded by any number of comment lines or lines consisting entirely of whitespace (so the OPL tags can preceded this block). The keys in this YAML block are case insensitive. So
will also work. Note that alternate way of giving a YAML array for declaring the macros used by the file.
Problems coded in this new style are not allowed to call
DOCUMENT,ENDDOCUMENT, orloadMacros. The problem code is assumed to start at the beginning of the file, and end at the end of the file. The actualDOCUMENTandENDDOCUMENTcalls are added in theWeBWorK::PG::Translator::translatemethod when the problem code is evaluated. Furthermore, the metadata is passed to theDOCUMENTcall. At the end of theDOCUMENTcallloadMacrosis called and loads the macrosPGbasicmacros.pl,PGauxiliaryFunctions.pl,PGML.pl, any macros declared in themacrosmetadata, and finally thePGcourse.plmacro. So clearly problems should not listPGbasicmacros.pl,PGauxiliaryFunctions.pl, orPGML.plin themacrosmetadata (although it would not be an error to do so).This means that basic problems that do not use any non-core macros will only need to have
which is the minimal requirement to signify that this is a problem coded in the new style.
At this point the only valid
pgAuthoringVersionis 1, and passing any other version is an error. Of course, the point of a version here is that we can add new authoring versions in the future as authoring coding expectations change, and old versions of problems can continue to work. At this point any problem that does not contain this Perl comment block YAML document with thepgAuthoringVersiondeclared will continue to work with the old authoring requirements (DOCUMENTandENDDOCUMENTmust be called, and any macros that are needed, including core macros such asPGbasicmacros.pl, loaded vialoadMacros).At this point the only supported metadata keys are
pgAuthoringVersionandmacros, and it is an error to add anything else. More keys can be added as needed.Note that this depends on #1548.