[ww-devel] Issuing warning messages in PG

Gage, Michael michael.gage at rochester.edu
Tue Aug 26 15:45:36 EDT 2014


Hi Davor,

 Thanks much.  I won’t change the behavior at the moment. I think (or at least thought at the time) that it was
appropriate for the PG version to have more decorations, compatible with its specific use in problems.  I am wondering about changing
the name of the PG method for consistency but I think I’ll leave it alone for the moment.  Perhaps later.

Take care,

Mike

On Aug 26, 2014, at 3:32 PM, Davor Cubranic <cubranic at stat.ubc.ca<mailto:cubranic at stat.ubc.ca>> wrote:

Thanks for the clarification Mike. I fixed the call to the old name in ‘custom_problem_grader’ and the POD in PGcore.pm. The pull request is at pg/pull/155.

I’ll let you decide whether to make WARN_MESSAGE and PG->warning_message behave exactly the same.

Davor

On Aug 26, 2014, at 12:22 PM, Gage, Michael <michael.gage at rochester.edu<mailto:michael.gage at rochester.edu>> wrote:

Hi Davor,

Perhaps I should change the $PG->warning_message for consistency.
I changed the PG macro message to WARN_MESSAGE early on to make it more consistent with “warn”.  when it was warning_message I kept
mistyping it.

the reference in custom_problem_grader is a bug and should be fixed. I’ll submit it to bugzilla
along with a reference to the misleading comments in PGcore.pm

In any PG problem you should use WARN_MESSAGE.  In the macro files you may have to
use main::WARN_MESSAGE  particularly if you have declared a package name in the file.

In the .pm files you will not have easy access to WARN_MESSAGE but in most cases (when PGcore is a parent) you
will have access to the method in PGcore.

Both DEBUG_MESSAGE  and WARN_MESSAGE() are constructed by PG and are meant to allow a bit more
control over the error message.  It also allows the possibility of handling these messages differently when the problem is
rendered in a webservice or in a library than when it is rendered in a problem.

“warn” is a perl command.  It is still sometimes needed when DEBUG_MESSAGE doesn’t work, e.g. if there is a syntax error than
perl simply closes down and the messages in the DEBUG_MESSAGE pipeline are never delivered.

Take care,

Mike


On Aug 26, 2014, at 2:27 PM, Davor Cubranic <cubranic at stat.ubc.ca<mailto:cubranic at stat.ubc.ca>> wrote:

The current code and documentation seem to be a bit out of date about issuing warnings. For instance, in ‘lib/PGcore.pm’, there is the following POD:

There are three message channels
$PG->debug_message()   or in PG:  DEBUG_MESSAGE()
$PG->warning_message() or in PG:  WARNING_MESSAGE()
They behave the same way, it is simply convention as to how they are used.

But there is no macro WARNING_MESSAGE anywhere. There is, however, WARN_MESSAGE in ‘macros/PG.pl’. This one is not quite the same as just calling ‘$PG->warning_message()’, because it decorates the message with caller info and frames it with a line border.

‘lib/PGcore.pm’ also used to contain function “WARN”, but it was commented out in commit 92127e6 (in 2010). It is still used by the “custom_problem_grader_fluid” macro in ‘macro/PGgraders.pl’.

Question: what is the right thing to do? I’m seeing PG macros using mostly “WARN_MESSAGE”, with a few “warn” thrown in. Nobody calls $PG->warning_message directly.

Davor
_______________________________________________
webwork-devel mailing list
webwork-devel at webwork.maa.org<mailto:webwork-devel at webwork.maa.org>
https://urldefense.proofpoint.com/v1/url?u=http://webwork.maa.org/mailman/listinfo/webwork-devel&k=p4Ly7qpEBiYPBVenR9G2iQ%3D%3D%0A&r=enN3K%2BCUdz1bRKB01s3PUtIX0B0zjgWTYpo9pUAD9Ek%3D%0A&m=7xgj59c0UBM%2Bn%2FrwDGvWKZ1lz91orFG8G5RBKvtwerY%3D%0A&s=3a217f3a0041f9f60ff1b516878fd92a1b504eac049c756d511223567ed1ccac

_______________________________________________
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<mailto:webwork-devel at webwork.maa.org>
https://urldefense.proofpoint.com/v1/url?u=http://webwork.maa.org/mailman/listinfo/webwork-devel&k=p4Ly7qpEBiYPBVenR9G2iQ%3D%3D%0A&r=enN3K%2BCUdz1bRKB01s3PUtIX0B0zjgWTYpo9pUAD9Ek%3D%0A&m=Gqk0M99dCnNJIiPiMU19GBUvQy7ax0XJJOSUw%2B8rtSI%3D%0A&s=d577b794547fe6e85788111df90580af175a192f147a1a07cf06e55440bc96be

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


More information about the webwork-devel mailing list