[ww-devel] Making Perl modules available
Andrew Dabrowski
dabrowsa at indiana.edu
Mon Jun 29 14:01:16 EDT 2015
The Data prefix didn't help. Here's a minimal example.
PG file:
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGchoicemacros.pl",
"PGauxiliaryFunctions.pl",
"gameTheory.pl",
);
TEXT(beginproblem);
$matrix = [ [1,2], [3,4] ];
BEGIN_TEXT
\{ Data::Dumper @$matrix \}
END_TEXT
ENDDOCUMENT();
The output:
*Warning* -- there may be something wrong with this question. Please
inform your instructor including the warning messages below.
(0 pts) *Problems/GameTheory/datadumper.pg*
\{
*Data::Dumper ARRAY(0xdc49220)ARRAY(0xdc491f0) *
\}
Edit2
<http://127.0.0.1/webwork2/NewGenEd/instructor/pgProblemEditor2/Undefined_Set/1/?user=admin&effectiveUser=admin&theme=&sourceFilePath=Problems/GameTheory/datadumper.pg&key=wkYIunlmy0WTpNBSIN3BL6mEWC3gyeTY>
Edit3
<http://127.0.0.1/webwork2/NewGenEd/instructor/pgProblemEditor3/Undefined_Set/1/?effectiveUser=admin&theme=&user=admin&key=wkYIunlmy0WTpNBSIN3BL6mEWC3gyeTY&sourceFilePath=Problems/GameTheory/datadumper.pg>
Show correct answers
You have attempted this problem 2,000 times.
Your overall recorded score is 0%. (This problem will not count towards
your grade.)
You have unlimited attempts remaining.
WeBWorK Warnings
WeBWorK has encountered warnings while processing your request. If this
occured when viewing a problem, it was likely caused by an error or
ambiguity in that problem. Otherwise, it may indicate a problem with the
WeBWorK system itself. If you are a student, report these warnings to
your professor to have them corrected. If you are a professor, please
consult the warning output below for more information.
Warning messages
* |ERROR in old_safe_ev, PGbasicmacros.pl: <PRE>|
* |## There is an error occuring inside evaluation brackets \{
...code... \}|
* |## somewhere in an EV2 or EV3 or BEGIN_TEXT block.|
* |## Code evaluated:|
* |## Data::Dumper @$matrix |
* |##syntax error at line 2 of (eval 1261), near "Data::Dumper @"|
* |##</PRE><BR/>|
* |at (eval 1181) line 1671|
Request information
Time Mon Jun 29 13:54:07 2015
Method GET
URI /webwork2/NewGenEd/Undefined_Set/1/
In my defaults.config I have:
${pg}{modules} = [
[qw(HTML::Parser)],
[qw(HTML::Entities)],
[qw(DynaLoader)],
[qw(Exporter)],
[qw(GD)],
[qw(AlgParser AlgParserWithImplicitExpand Expr
ExprWithImplicitExpand utf8)],
[qw(AnswerHash AnswerEvaluator)],
[qw(WWPlot)], # required by Circle (and others)
[qw(Circle)],
[qw(Complex)],
[qw(Complex1)],
[qw(Distributions)],
[qw(Fraction)],
[qw(Fun)],
[qw(Hermite)],
[qw(Label)],
[qw(ChoiceList)],
[qw(Match)],
[qw(MatrixReal1)], # required by Matrix
[qw(Matrix)],
[qw(Multiple)],
[qw(PGrandom)],
[qw(Regression)],
[qw(MatrixWithElemOps MatrixReal1 Matrix)],
[qw(SysLinEq MatrixReal1 Matrix MatrixWithElemOps)],
[qw(Select)],
[qw(Units)],
[qw(VectorField)],
[qw(Parser Value)],
[qw(Parser::Legacy)],
[qw(Statistics)],
# [qw(SaveFile)],
[qw(Chromatic)], # for Northern Arizona graph problems
# # -- follow instructions at
libraries/nau_problib/lib/README to install
[qw(Applet FlashApplet JavaApplet CanvasApplet GeogebraWebApplet)],
[qw(PGcore PGalias PGresource PGloadfiles PGanswergroup
PGresponsegroup Tie::IxHash)],
[qw(Locale::Maketext)],
[qw(WeBWorK::Localize)],
[qw(JSON)],
[qw(Data::Dumper)]
];
On 06/29/2015 01:50 PM, Davide P. Cervone wrote:
> You will probably need to use the explicit namespace, since that is
> what is imported into the safe compartment:
>
> Data::Dumper @$socwelbest
>
> Give that a try. Of not, can you post the complete problem so that we
> can reproduce your situation? It is hard to tell without seeing what
> you are actually doing.
>
> Davide
>
>
> On Jun 29, 2015, at 1:39 PM, Andrew Dabrowski wrote:
>
>> I should to my earlier message that I did restart httpd. I'm running
>> Arch Linux.
>>
>>
>> I thought it would be handy to make Perl's Data::Dumper available for
>> debugging. So on my office computer I added the line
>>
>> [qw(Data::Dumper)]
>>
>> to ${pg}{modules} in defaults.config. But it didn't work, I still get
>> an error.
>>
>> This is the code in my pg file to display debugging info.
>>
>> BEGIN_TEXT
>>
>> \{ Dumper @$socwelbest \}
>>
>> END_TEXT
>>
>> The display is this.
>>
>> <Mail Attachment.png>
>>
>> Here's the error message.
>>
>>
>> Warning messages
>>
>> * |ERROR in old_safe_ev, PGbasicmacros.pl: <PRE>|
>> * |## There is an error occuring inside evaluation brackets \{
>> ...code... \}|
>> * |## somewhere in an EV2 or EV3 or BEGIN_TEXT block.|
>> * |## Code evaluated:|
>> * |## Dumper @$socwelbest |
>> * |##syntax error at line 2 of (eval 1132), near "Dumper @"|
>> * |##</PRE><BR/>|
>> * |at (eval 1051) line 1671|
>>
>>
>>
>> It actually works fine when I use my own dumper function, defined in
>> a pl file (apart from the fact that my dumper isn't as nice as Perl's).
>>
>> What's the correct way to do this, i.e. add a aPerl module to webwork?
>>
>>
>> --
>> Andrew Dabrowski || ...my suspicion is that the universe is
>> Indiana University || not only queerer than we suppose, but
>> Swain East 117 || queerer than we can suppose. -JBS Haldane
>>
>> _______________________________________________
>> webwork-devel mailing list
>> webwork-devel at webwork.maa.org <mailto:webwork-devel at webwork.maa.org>
>> http://webwork.maa.org/mailman/listinfo/webwork-devel
>
>
>
> _______________________________________________
> webwork-devel mailing list
> webwork-devel at webwork.maa.org
> http://webwork.maa.org/mailman/listinfo/webwork-devel
--
Andrew Dabrowski || ...my suspicion is that the universe is
Indiana University || not only queerer than we suppose, but
Swain East 117 || queerer than we can suppose. -JBS Haldane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://webwork.maa.org/pipermail/webwork-devel/attachments/20150629/4c5081cd/attachment-0001.html>
More information about the webwork-devel
mailing list