[ww-devel] Making Perl modules available

Davide P. Cervone dpvc at union.edu
Mon Jun 29 14:20:40 EDT 2015


Actually, 

	\{ Data::Dumper::Dumper(@$matrix) \}

Might be more what you're after.

Davide


On Jun 29, 2015, at 2:13 PM, Davide P. Cervone wrote:

> Try 
> 
> 	\{ Data::Dumper->Dump(@$matrix) \}
> 
> and see if that works.
> 
> Davide
> 
> 
> On Jun 29, 2015, at 2:01 PM, Andrew Dabrowski wrote:
> 
>> 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 Edit3
>>  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
>>>> 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
>> 
>> _______________________________________________
>> webwork-devel mailing list
>> webwork-devel at webwork.maa.org
>> http://webwork.maa.org/mailman/listinfo/webwork-devel
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://webwork.maa.org/pipermail/webwork-devel/attachments/20150629/ad0e87a3/attachment-0001.html>


More information about the webwork-devel mailing list