[LON-CAPA-users] best way to include image?

Felicia Berryman lon-capa-users@mail.lon-capa.org
Wed, 05 Feb 2003 17:43:49 -0500


Here are some examples of what has been done here at MSU.

Code for 
res/msu/physicslib/msuphysicslib/02_Math_2_Trig/msu-prob04.problem is 
below (it probably should be a random plot problem, but I think it's a 
good example that incorporates the script with the random image).
------------------------------

<problem><font size="+1" color="#003399" />
<script type="loncapa/perl">#  by kashy@nscl.msu.edu no unauthorized 
commercial use
# /BEG prob_val=1
# /LET try_val=99
# Last checked 3-24-2002
# $k and $file choose what graph is outputted
$k=&random(1,14,1);
$file=&choose($k,'3p5x','4p5x','5p6x','6p2x','7p7x','8p6x','9p3x','m2p6x','m3p9x','m4p7x','m5p1x','m6p6x','m7p4x','m8p4x');
$ans15=&choose($k,3.5,4.5,5.6,6.2,7.7,8.6,9.3,-2.6,-3.9,-4.7,-5.1,-6.6,-7.4,-8.4);
$prob_val=1;
</script>

<startouttext />The graph below represents the function Y=aX. Make a 
careful determination of the value of a. <br /><img 
src="graphics/prob04_Y$file.gif" TeXwidth="92" /> <br />
<endouttext />


<numericalresponse id="11" answer="$ans15">
	<responseparam description="Significant Figures" type="int_range,0-12" 
default="2,4" name="sig" />
	<responseparam description="Numerical Tolerance" type="tolerance" 
default="7.0%" name="tol" />
	<textline />
<hintgroup>
	<hintpart on="default">
	<startouttext />You can pick a value for x, read the corresponding Y, 
and solve.
	<endouttext />
	</hintpart>
</hintgroup>

</numericalresponse>


<allow 
src="/res/msu/physicslib/msuphysicslib/02_Math_2_Trig/graphics/prob04_Y$file.gif" 
/>
<allow 
src="/res/msu/physicslib/msuphysicslib/02_Math_2_Trig/graphics/prob04_Y*.gif" 
/>
</problem>

-----------------------

a more standard problem is:
res/msu/physicslib/msuphysicslib/22_Rot4_Precession/msu-prob02.problem
-------------------------
<problem><font size="+1" color="#003399" />
<script type="loncapa/perl">
#By j. Brown and E Kashy
#kashy@nscl.msu.edu
#No unauthorized commercial use.
#Last updated 5-19-2002
$m=random(10.0,50.0,0.1);
$R=random(10.0,20.0,0.1);
$d=random(1.0,2.0,0.05);
$h=random(0.5,0.9,0.02);
$L=random(0.5,2.0,0.05)*sqrt(2.0*$m*9.81*$d*$h*$R);
$v=$R*$m*9.81*$d/(2*$L);
$L=roundto($L,1);
</script>
<startouttext />
<img 
src="/res/msu/physicslib/msuphysicslib/22_Rot4_Precession/graphics/prob02_cart_not.gif" 
TeXwidth="60" /><br />A flywheel of mass &format($m,"1f") kg is 
supported by an axle &format($d,"2f") m long, with two small wheels, as 
shown in the figure.  The axle's wheels roll on an elevated track, part 
of which has a curve of radius, R = &format($R,"1f") m. If the flywheel 
has angular momentum &format($L,"2f") kg&middot;m<sup>2</sup>/s, what is 
the maximum speed at which the system can take the curve without a wheel 
lifting from the track? <br />
<endouttext />
<numericalresponse format="3E" unit="m/s" id="11" answer="$v">
<responseparam description="Significant Figures" type="int_range,0-12" 
default="3,5" name="sig" />
<responseparam description="Numerical Tolerance" type="tolerance" 
default="6%" name="tol" />
<textline />
</numericalresponse>
<hintgroup>
	<hintpart on="default">
	<startouttext />
The rate at which the angular momentum must change going around the 
curve equals the maximum net torque which the weight of the flywheel can 
provide.
         <endouttext />
	</hintpart>
</hintgroup>


<allow 
src="/res/msu/physicslib/msuphysicslib/22_Rot4_Precession/graphics/prob02_cart_not.gif" 
/>
</problem>

-------------------------

Note that the two problems above have both a gif file and .eps/ps file 
already created in the graphics directory.

Felicia
-- 
Felicia Berryman
LON-CAPA Coordinator
Michigan State University
   Email:  felicia@lon-capa.org
   Phone:  (517)432-9866
http://www.lon-capa.org