Comments (8)
Actually, looking closer it seems that this is due to #518, and not #526. The branch of code that is called when the currency set
method is called is there. Since $update = 1
is set here and thus the SUPER
update method is called, perhaps the correct fix is to remove line 339 of contextCurrency.pl.
from pg.
I have my suspicions that this arises from changes made to Value::Context::Data::set
in #526
Currency::set
calls SUPER::set
(Value::Context::Data::set
) and follows with Currency::update
, but by the time we get to Currency::update
, the old operator has already been removed since Value::Context::Data::set
now sets $update = 1
. We then get this error from Currency::update
attempting to redefine an operator that's already been removed.
from pg.
Commenting out line 339 of contextCurrency.pl (the update
call in the Currency::Context::currency::set
method) fixes the problem. Probably not in a proper way though, but the problem works then. This seems to confirm that @drdrew42 is correct in his assessment.
from pg.
No, I think the solution should be the removal of these lines from Currency::update
$operators->redefine($data->{symbol}, from => $context, using => $self->{symbol});
$operators->remove($self->{symbol});
perhaps even removing that entire conditional, since we can trust the parent to handle the symbol updates.
Edit: I agree with pointing at #518 as the culprit, but not the means of redress.
from pg.
Testing this it seems that my suggestion of removing line 339 (which means the entire set
override method should be removed) works. Testing the suggestion to remove lines 385 and 386 of the update
method does not. Test with the following MWE modified from @Alex-Jordan's previous example:
DOCUMENT();
loadMacros(qw(PGstandard.pl PGML.pl contextCurrency.pl));
Context('Currency')->currency->set(symbol => '!');
$a = Currency(1000);
BEGIN_PGML
Enter [`[$a]`].
[_]{$a}
END_PGML
ENDDOCUMENT();
Although the problem loads with both changes without error, student answers do not work correctly with @drdrew42's suggestion. If you enter !1000
with my proposed change, the answer is marked correct and displayed in the preview as !1000
. However, with @drdrew42's suggestion it is marked incorrect. If you enter $1000
with my proposed change, it is marked incorrect and displayed in the preview as $1000
as it should be. However, with @drdrew42's proposal, it is marked correct and it is displayed in the preview as !1000
.
from pg.
Confirmed, thanks for digging deeper -- I ran out of time to keep going on this yesterday. Here is what I've found with the removal of line 339.
As described in the POD for this context:
Context()->currency->set(symbol=>'euro'); # accepts '12 euro'
The associativity does not get set to "right" during this transaction, and so "12 euro" is incorrect with message: "There should be a number after 'euro'", and the Currency object is rendered as "euro 12". (Looking at the code, it seems that this never worked as described in the POD.)
Context()->currency->set(symbol=>'euro', associativity => "right")
does set the associativity (for both display and submitted answers) so perhaps it is reasonable to update the POD rather than fix the implementation.
However (again following the POD):
Context()->currency->set(symbol=>'euro');
Context()->currency->setSymbol(euro=>{associativity=>"right"});
does accept "12 euro" as correct, and "euro 12" as incorrect, but does not set the display of "euro" to the right and instead displays "euro 12".
from pg.
I saw that with the "euro" symbol as well. I am not sure if that ever worked or not, but that also needs to be fixed. I don't think it is related to this issue though.
from pg.
Fixed with #839
from pg.
Related Issues (20)
- Using upToConstant with complex numbers HOT 4
- keyboard issue with GraphTool HOT 8
- inconsistency in multiple choice macros HOT 4
- run-perltidy deletes .bak files
- Error answers now are escaped when they shouldn't be. HOT 1
- Cropping from pgfplots is not always working for final SVG output HOT 13
- variables declared with `my` lead to errors HOT 1
- student answers get spaces normalized
- iframeResizer, feedback popover, and mqeditor HOT 16
- Updating AnswerFormatHelp.pl HOT 5
- Viewing all correct answers at the same time HOT 4
- PTX "image" tag getting changed to "img" HOT 5
- error with brace and x HOT 9
- PG editor not decoding as expecting HOT 1
- macros/graph/PGnauGraphics.pl doesn't use unique name, which can break tests. HOT 1
- securtiy issues with braces HOT 2
- braces around math HOT 3
- Number with units in MathObject List doesn't work. HOT 9
- GraphTool not marking correct answers as correct HOT 2
- Feature request, show green checkmarks in feedback when partial feedback is hidden but answers are all correct. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg.