WeBWorK Main Forum

Are $prob_val and $prob_try automatically defined in homework code? Where?

Are $prob_val and $prob_try automatically defined in homework code? Where?

by Christian Seberino -
Number of replies: 1
I was looking at the code for homework problems in the CAPA library and I saw this in the answer part...

"wgt" => $prob_val,
"tries" => $prob_try,

I can guess that this defines the 'weight' of a problem and the # of allowed tries. What I'm confused about is that the code does NOT seem to define $prob_val or $prob_try anywhere.

Is that passed in somehow to ALL webwork homework code by default?

Thanks!

chris



In reply to Christian Seberino

Re: Are $prob_val and $prob_try automatically defined in homework code? Where?

by Michael Gage -
No.  Let's see if I can figure out what it does mean.   I wrote the interpreter 
that converted CAPA language problems to PG language somewhere 
around 1997 or 1998 so it's been a while.  Some of these problems have been 
rewritten and cleaned up by Frank Wolfs and his crew.  I wouldn't 
recommend using them as models for new problems (or learning a foreign 
language from Google translator :-) ).

......   some time later  ...........    ok -- here it is.



If you look in PG_CAPAmacros.pl where CAPA_ans() is defined you see that 
these options which had meaning for CAPA problems are ignored when they 
get translated into PG.

  http://webwork.maa.org/viewvc/system/trunk/pg/macros/PG_CAPAmacros.pl?view=markup

e.g. 


15
# explicitlty delete options which are meaningless to WeBWorK
   16     if (defined($options{'sig'})) { delete($options{'sig'}); }
   17     if (defined($options{'wgt'})) { delete($options{'wgt'}); }
   18     if (defined($options{'tries'})) { delete($options{'tries'});
 }   19 
   20 # $options{'allow_unknown_options'} = 1;  
## if uncommented, this is a fast and possibly dangerous 
21   ## way to prevent warning message about unknown options 
22 

Hope this helps.

Take care,