[LON-CAPA-users] Illegal division by zero

Lucas, Mark lucasm at ohio.edu
Fri May 29 13:30:35 EDT 2015


Bob,

As an aside, all the perl scripts should be run serverside, so it should hopefully be browser
independent. The bombs are created during processing of the problem on the server, not
as a return from the browser (unless it’s during the processing of a problem during a submission).

What LON-CAPA servers were the error messages from?

Mark


On May 29, 2015, at 1:01 PM, Rex Abert <ABERTR at tcc.fl.edu> wrote:

> Bob-
> 
> This might be a browser-specific phenomenon.  One popular browser is known to be non-compliant with W3C standards.  One thing that *might* help is to combine all your scripts into one script at the beginning of the problem.  The way it is written now, the variables $f1 and $ansa might not have values assigned to them in the second script, since there values were set in a different script---an issue with the scope of the variables.
> 
> It would be interesting to ask your students which browser was in use when the error occurred.
> 
> Rex Abert
> Associate Professor of Mathematics
> Tallahassee Community College
> ________________________________________
> From: lon-capa-users-bounces at mail.lon-capa.org [lon-capa-users-bounces at mail.lon-capa.org] on behalf of Bob Gonzales [rgonzal at binghamton.edu]
> Sent: Friday, May 29, 2015 12:21 PM
> To: Discussion list for LON-CAPA users
> Subject: Re: [LON-CAPA-users] Illegal division by zero
> 
> Rex,
> 
> Here's the code, I thought it might be easier to cut and paste it in construction space to make it easier to debug.  The problem works fine for me in construction space.   One student with $f1=1.0 and one student with $f1=6.0221e23 have gotten it correct so far.
> 
> <problem>
> <part id="t06p12a">
> <script type="loncapa/perl">
> $n1=&random(0.025,0.050,0.001);
> $t1=&random(1,2);
> $unit1=&choose($t1,"moles","molecules");
> $f1=&choose($t1,1.00,6.0221e23);
> $mw1=(12.011*20.0)+(1.008*24.0)+(15.999*2.0);
> $ansa= $n1 * 1e-3 * $f1/ $mw1;
> </script>
> 
> <startouttext />
> <p>A particular oral contraceptive contains &format($n1,'3f') mg of ethinyl estradiol
> in each pill. The formula of this compound is <chem>C20H24O2</chem>.
> How many $unit1 of ethinyl estradiol are there in one pill?  (give answer to 3 digits)</p>
> <endouttext />
> <numericalresponse format="3e" answer="$ansa" id="11">
> <responseparam name="tol" type="tolerance" default="5%" description="Numerical Tolerance" />
> <responseparam name="sig" type="int_range,0-16" default="3,4" description="Significant Figures" />
> <textline />
> <hintgroup>
> <startouttext /><endouttext />
> </hintgroup>
> </numericalresponse>
> </part>
> <part id="t06p12b">
> <script type="loncapa/perl">
> $t2=&random(1,3);
> $sub2=&choose($t2,"carbon","hydrogen","oxygen");
> $f2=&choose($t2,20.0,24.0,2.0);
> $ansb=($ansa/$f1)* $f2 * 6.0221e23;
> </script>
> 
> <startouttext />
> <p>How many $sub2 atoms are there in one of these pills (due to the presence
> of ethinyl estradiol)?  (give answer to 3 digits)</p>
> 
> <endouttext />
> <numericalresponse format="3e" answer="$ansb" id="12">
> <responseparam name="tol" type="tolerance" default="5%" description="Numerical Tolerance" />
> <responseparam name="sig" type="int_range,0-16" default="3,4" description="Significant Figures" />
> <textline />
> <hintgroup>
> <startouttext /><endouttext />
> </hintgroup>
> </numericalresponse>
> </part>
> 
> <part id="t06p12c">
> <script type="loncapa/perl">
> $mw3=&choose($t2,12.011,1.008,15.999);
> $ansc=$ansb*$mw3/6.0221e23;
> </script>
> 
> <startouttext />
> <p>What mass of $sub2 is this? (Enter the answer in grams.)</p>
> 
> <endouttext />
> <numericalresponse format="3e" answer="$ansc" id="13">
> <responseparam name="tol" type="tolerance" default="5%" description="Numerical Tolerance" />
> <responseparam name="sig" type="int_range,0-16" default="3,4" description="Significant Figures" />
> <textline />
> <hintgroup>
> <startouttext /><endouttext />
> </hintgroup>
> </numericalresponse>
> </part>
> </problem>
> 
> 
> 
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users at mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

-- 
Mark Lucas 								email: lucasm at ohiou.edu
252D Clippinger Lab						phone: (740)597-2984
Department of Physics and Astronomy		fax: (740)593-0433
Ohio University
Athens, OH 45701



More information about the LON-CAPA-users mailing list