-
-
Notifications
You must be signed in to change notification settings - Fork 166
Add the capability in the pg problem editor to pg perltidy code. #2098
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
Conversation
bc4ac7f to
7aecd36
Compare
|
Haven't tried this out yet, but was thinking that we should add some documentation to the PGEditor help page for this. |
|
Yeah. I will add that. |
7aecd36 to
4932df7
Compare
|
I added a section about the new tab to the help file. Although, I didn't have anything else to say other than what the tab already says. |
4932df7 to
597103b
Compare
|
I decided that that lengthy explanation should only be in the help, and not directly on the tab. So the tab now simply say "Reformat the code using perltidy." |
|
I am at commit 651fa85 on |
|
I added Perl::Tidy to |
|
@Alex-Jordan: I suspect that not having Perl::Tidy installed is your problem. |
|
That wasn't it. II have The webwork2 error long has: Not sure what to make of that. Install |
|
I had |
|
OK, I see quite a bit about this after Googling the error message, for instance here: https://rt.cpan.org/Public/Bug/Display.html?id=77916 |
|
Both This issue happens for you with this branch, but not with the WeBWorK-2.18 branch? Also, this doesn't happen when you view a problem in a set in the usual way? |
|
I have them installed and don't have this issue except with this branch.
Did you see my later post that points to a known perl bug?
…On Sun, Jul 2, 2023, 3:42 AM Glenn Rice ***@***.***> wrote:
Both Safe and WWSafe use Tie::Hash::NamedCapture. Safe is in
check_modules.pl, although both Safe and Tie::Hash::NamedCapture are core
perl modules. If you have perl installed on your system, you should have
both of those.
This issue happens for you with this branch, but not with the WeBWorK-2.18
branch? Also, this doesn't happen when you view a problem in a set in the
usual way?
—
Reply to this email directly, view it on GitHub
<https://protect2.fireeye.com/v1/url?k=31323334-501cfaeb-3132feb7-454455535732-1667f6b60b096065&q=1&e=dd40cee6-e016-4957-a267-80d5b9a3f2bf&u=https%3A%2F%2Fgithub.com%2Fopenwebwork%2Fwebwork2%2Fpull%2F2098%23issuecomment-1616590040>,
or unsubscribe
<https://protect2.fireeye.com/v1/url?k=31323334-501cfaeb-3132feb7-454455535732-86bd7f120c7e1c5a&q=1&e=dd40cee6-e016-4957-a267-80d5b9a3f2bf&u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABEDOAAB37IHK43ATGXD4B3XOFGCHANCNFSM6AAAAAAZ2B5ADI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I saw that, but I don't see how that has anything to do with this pull request. This pull request doesn't change anything with the |
|
I also can not reproduce the issue on any of my systems. |
|
It may intersect with this flavor of OS (Oracle 8). I will try some things
based on what people have posted. Seems to be about English.pm that is a
dependency.
…On Sun, Jul 2, 2023, 9:41 AM Glenn Rice ***@***.***> wrote:
I also can not reproduce the issue on any of my systems.
—
Reply to this email directly, view it on GitHub
<https://protect2.fireeye.com/v1/url?k=31323334-501cfaeb-3132feb7-454455535732-3d1fdabdc7c3b2ac&q=1&e=4d3f8dc7-0c2a-4b83-86c6-0e68f2411f21&u=https%3A%2F%2Fgithub.com%2Fopenwebwork%2Fwebwork2%2Fpull%2F2098%23issuecomment-1616727304>,
or unsubscribe
<https://protect2.fireeye.com/v1/url?k=31323334-501cfaeb-3132feb7-454455535732-2e4ff72c86d7fb59&q=1&e=4d3f8dc7-0c2a-4b83-86c6-0e68f2411f21&u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABEDOABHWURNTGECZCTQW2DXOGQDJANCNFSM6AAAAAAZ2B5ADI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
I followed the suggestion from that link, putting Now that I can test the feature, it works! |
This adds a new tab to the PG problem editor (unless editing a course configuration file). The tab contains basic information about what it does, but if the "Tidy Code" button is pressed it perltidies the code in the CodeMirror editor window. The tidied code is also saved to the temprorary file. The actual tidying is done by a new webwork webservice action (not a form submission). If errors occur, they are shown in the renderer window. The webwork webwservice depends on a new PG module defined in a corresponding PG pull request (see openwebwork/pg#868).
The version needs to be at least 20220613. Newer versions than that should be okay for this, although those cause reformatting of webwork2 and pg code from the 20220613.
172df44 to
9f48f13
Compare
the code in the editor window.
|
I added a small tweak this. If there are no changes to the code when perltidy runs, then the code in the editor window is not updated, and the toast just says "There were no changes to the code." @Alex-Jordan: I am not sure what to do about the |
I would say yes, but I would like to know what that command even does first. If we know what that does, we can at least think about if it could have potential bad side effects. (Knowing how it "fixes" the issue I encountered would be nice, but not as important imho.) I am not a perl monk and I wouldn't have even guessed that was a legal command. It's been a challenge to Google about it given the nature of that character string. |
|
OK, I sort of understand now. Maybe 85%.
Anyway I tested that it is enough on my system to access |
|
@Alex-Jordan I added |
Alex-Jordan
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.
Just did a fresh test and it's working well.
| sub tidyPGCode { | ||
| my ($invocant, $self, $params) = @_; | ||
|
|
||
| debug('in tidyPGCode'); |
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.
Remove this line?
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.
This has been the standard in the WebworkWebservice action, particularly in this file. Each method calls debug('in thismethod');. So I just followed suit. Most of the other WebworkWebservice modules also do this, although not as consistently as this file. I would certainly be fine with removing all of those. That was probably more meaningful with the old XML pipeline that this was inside of. Now it is probably just clutter.
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.
Looks great.
| # The following line is a work around for a bug that occurs on some systems. See | ||
| # https://rt.cpan.org/Public/Bug/Display.html?id=77916 and | ||
| # https://github.com/openwebwork/webwork2/pull/2098#issuecomment-1619812699. | ||
| %+; |
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.
@Alex-Jordan: This is not right. I didn't notice this when I added this before. This is causing a warning every time the webwork2 app starts about the useless use of a variable in void context. This needs further investigation.
…ork#2098 This just assigns the result of calling `%+` to a dummy variable to avoid the warning that perl gives stating that this is a useless use of a variable in void context.
…ork#2098 This just assigns the result of calling `%+` to a dummy variable to avoid the warning that perl gives stating that this is a useless use of a variable in void context.
Fix a warning that is being emitted due to the hack added in #2098
This just assigns the result of calling `%+` to a dummy variable to avoid the warning that perl gives stating that this is a useless use of a variable in void context.
This was missed in openwebwork#2098.

This adds a new tab to the PG problem editor (unless editing a course configuration file). The tab contains basic information about what it does, but if the "Tidy Code" button is pressed it perltidies the code in the CodeMirror editor window. The tidied code is also saved to the temprorary file.
The actual tidying is done by a new webwork webservice action (not a form submission). If errors occur, they are shown in the renderer window.
The webwork webwservice depends on a new PG module defined in a corresponding PG pull request (see openwebwork/pg#868).