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

Convert nondecimal base #22

Conversation

Alex-Jordan
Copy link

This has a few changes to the macro file. They can all be jettisoned if you don't like them. First though, I made my branch off of develop, with your branch merged in. So this PR looks very big. I suspect if you rebase off develop, the PR will only show the one file being worked on.

Separated by commit:

  • some light editing to the documentation.
  • I added some strings you can use for setBase. The most extreme is ...->setBase('base64') as a short way to declare the 64 digits for that base.
  • Since this is all integer stuff, I added a modulo operator %.
  • I changed the file name (and all the package naming etc) to BaseN instead of NonDecimalBase. If you want to keep that name, can just cut the last commit.

drgrice1 and others added 30 commits January 24, 2024 16:41
Technically this does not add an option, but changes how the existing
showCorrectAnswers option in the PG environment works.  Previously it
was purely boolean.  Now it is numeric.

If it is zero, then correct answers are not shown (as before).

If it is 1, then correct answers are shown but hidden, and a "Reveal"
button is shown at first. If that button is clicked, then the answer is
shown.

If set to 2, then correct answers are shown immediately.
Move a popover to the front when it first opens, if it is clicked in, or
if focus moves into it.  Other popovers are behind the "active" popover
in the order they appear in the DOM.
Each time a feedback popover is closed and the opened again, the correct
answer "Reveal" button is back again.  So this makes it so that once the
correct answer has been revealed once, each subsequent time the popover
is opened it is automatically revealed without needing to click the
reveal button again.  Note that a page reload will reset this behavior.
Basically, if the feedback popover is opened with the reveal button in a
graphtool problem, and the reveal button is not clicked before the
popover closes, then the graphtool timeout that is waiting for the
graphtool container to be shown errors out because it calls the
graphtool initialization method and there is no longer a graph container
in the DOM.  So just return if the graph container is not found.
This requires a change to webwork2 (or any other front end).  Basically,
the front end needs to let PG know if the problem has been graded or not
via the environment "needs_grading" flag.

The feedback processing in the ENDDOCUMENT method of PG.pl and
PGessaymacros.pl use this flag to show the correct messages for essay
answers.

Note that the methods in PG.pl now has more generic code for handling
answers like those from the PGessaymacros.pl macro instead of being
specifically for that macro.  This done with the `manuallyGraded` and
`needsGrading` options that can be set by a `feedback_options` method
for a custom answer type.

I think that the answer messages and feedback popover titles need
further examination.  I am not sold on using "Graded" and "Ungraded" for
manually graded problems.  I also don't like the messages that state
things like "All of the gradable answers are correct".  In reality all
questions are "gradable", it is just a matter of who or what does the
grading (and perhaps when that grading is done). I am open to
suggestions for improvements to these messages.
Change "All of the gradeable answers are correct" to
"All of the computer gradable answers are correct".
…yml.

Versions of Perl prior to 5.34 need this.  Otherwise warnings are issue
by the `BEGIN { strict->import }` approach now used in place of the old
`BEGIN { be_strict() }` approach.

Note that this is not used by webwork2, but the standalone renderer will
need this (if anyone runs that with an older perl version).  So the
standalone renderer will also need to update its distributed
pg_config.yml file.

Also change `Main` to `main` in the translator.  I can't resist fixing
this any longer.  The proper namespace is `main`.  This is also used
inconsistently in `Translator.pm`.  Other than these two instances
`main` is used everywhere else.
Not much explanation needed here.
  The MultiAnswer object addMessage method will add the given
  message to an array of single_ans_messages. If using singleResult,
  these messages are joined together and displayed for the whole
  result, not attached to any specific answer rule. In addition
  any specific answer rule messages are appended to the final message.
…s occur.

This addresses the issue found in openwebwork#990.  This issue occurs at least as
far back as PG 2.17 (but probably occured before that as well).

If an answer has an error that prevents it from being parsed into a
MathObject value, and yet the error `pos` is not set, then the answer is
not HTML escaped as it should be.  This can result in the answer in the
"You Entered" feedback entry (or the old attempts table "Entered"
column) not being displayed correctly.

You can test with the problem
```perl
DOCUMENT();

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

Context('Matrix');
$v = Vector(1, 0, 0);

BEGIN_PGML
Enter the vector [`[$v]`]: [_]{$v}
END_PGML

ENDDOCUMENT();
```

If you enter the answer `<x(1,0),0,0>`, then on the develop branch the
"You Entered" section of feedback will appear to be empty.  Using the
element inspector of the developer tools you will see that it is there.
With this pull request it will appear as it should.

Note that in the cases that the answer does parse into a MatHObject
value or the error `pos` is set, then the answer is HTML escaped
already.
Fix a typo in the "Entering Numbers" help file.
Co-authored-by: Glenn Rice <47527406+drgrice1@users.noreply.github.com>
num and den methods for Fraction objects
…r-html

Fix an issue with the `student_ans` not being HTML escaped when errors occur.
…essage-array

Create addMessage method for parserMultiAnswer.pl (alternative to openwebwork#999)
…itedRadical

add a convenience subroutine for getting a simplified radical expression
Add `strict` to modules shared to the PG safe zone in pg_config.dist.yml
Add an option to show the correct answer with a reveal button.
Don't always show "Ungraded" for essay problems.
handle nested braces in alignment specification
@Alex-Jordan Alex-Jordan force-pushed the convert-nondecimal-base branch from e60c5eb to 3a37179 Compare February 13, 2024 05:47
@Alex-Jordan
Copy link
Author

Note: I just did the perltidy and threw it in with the last commit that did the renaming. So if you remove that commit, it will need a perltidy run.

@Alex-Jordan Alex-Jordan force-pushed the convert-nondecimal-base branch from 3a37179 to 48de15d Compare February 13, 2024 05:53
@pstaabp
Copy link
Owner

pstaabp commented Feb 13, 2024

@Alex-Jordan, I think this all looks good. However, it seems like you branched from an old version of this before we merged in a bunch of PRs from develop. I'm going to try to cherry pick your commits and see if that will look cleaner.

@pstaabp
Copy link
Owner

pstaabp commented Feb 13, 2024

@Alex-Jordan Looks like cherry-picked worked well. I'll close this and push these new changes. I also need to update the test suite with both the name change and for the new functionality.

@pstaabp pstaabp closed this Feb 13, 2024
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.

5 participants