File:  [LON-CAPA] / loncom / homework / templates / numPrePro.problem
Revision 1.1: download - view: text, annotated - select for diffs
Wed Jun 8 20:38:53 2011 UTC (13 years, 5 months ago) by www
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, HEAD, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
Bug #2020: pre-processing of numerical, formula, and string response
Bug #5100: degrees Fahrenheit, etc

<problem>

<script type="loncapa/perl">
#Enter the computations here
$idx=&random(0,2,1);
$season=('nice spring','hot summer','cool fall')[$idx];
$temp=273+(20,30,10)[$idx];

sub abstemp {
    my ($answer,$unit)=@_;
    if ($unit=~/degC/) { $answer+=273; }
    if ($unit=~/degF/) { $answer+=460; }
    return $answer;
}
</script>

<startouttext />
What is the temperature in Germany on a $season day?
<endouttext />

<numericalresponse answer="$temp" id="11" preprocess="abstemp" unit="K">
    <responseparam name="tol" type="tolerance" default="5" description="Numerical Tolerance" />
    <textline readonly="no" />
</numericalresponse>
</problem>





FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>