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, 8 months ago) by
www
Branches:
MAIN
CVS tags:
version_2_12_X,
version_2_11_X,
version_2_11_6_msu,
version_2_11_6,
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
1: <problem>
2:
3: <script type="loncapa/perl">
4: #Enter the computations here
5: $idx=&random(0,2,1);
6: $season=('nice spring','hot summer','cool fall')[$idx];
7: $temp=273+(20,30,10)[$idx];
8:
9: sub abstemp {
10: my ($answer,$unit)=@_;
11: if ($unit=~/degC/) { $answer+=273; }
12: if ($unit=~/degF/) { $answer+=460; }
13: return $answer;
14: }
15: </script>
16:
17: <startouttext />
18: What is the temperature in Germany on a $season day?
19: <endouttext />
20:
21: <numericalresponse answer="$temp" id="11" preprocess="abstemp" unit="K">
22: <responseparam name="tol" type="tolerance" default="5" description="Numerical Tolerance" />
23: <textline readonly="no" />
24: </numericalresponse>
25: </problem>
26:
27:
28:
29:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>