File:
[LON-CAPA] /
loncom /
homework /
templates /
Rnumerical.problem
Revision
1.3:
download - view:
text,
annotated -
select for diffs
Mon Jul 6 17:12:47 2009 UTC (15 years, 7 months ago) by
bisitz
Branches:
MAIN
CVS tags:
version_2_9_99_0,
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,
version_2_10_0_RC2,
version_2_10_0_RC1,
version_2_10_0,
loncapaMITrelate_1,
language_hyphenation_merge,
language_hyphenation,
bz6209-base,
bz6209,
bz2851,
PRINT_INCOMPLETE_base,
PRINT_INCOMPLETE,
HEAD,
GCI_3,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse,
BZ4492-feature_Support_horizontal_radioresponse,
BZ4492-Support_horizontal_radioresponse
Consistent problem templates:
- New line after each tag (not for texts in foils)
- One empty row after each end tag and before new start tag for second level tags
- No indentation for second level tags, e.g. <script>
- Four white spaces as indentation for each further sub level
Exceptions:
-Content (mostly text) in separate line(s): no indentation
- Concept groups: same indentation as foilgroup
(allows to insert code from problems without concept groups without changing the indentation and vice versa)
- No new line at end of template
- Removed new lines from within the middle of default texts
- Added one blank each after "<m>$" and before "$</m>" to ensure no misinterpretation neither by human nor by machine (e.g. "<m>$x" is not "<m>$ $x")
- Replaced deprecated font tag in <instructorcomment> by CSS
- Removed dos line endings
- dos2unix conversion
(ClickImageExample.problem, RandomLabelExample.problem, SimpleMatching.problem)
1: <problem>
2:
3: <script type="loncapa/perl">
4: $seed=&random(1,500,1);
5: $n=&random(15,25,1);
6: $offset=&random(2,5,0.1);
7: $slope=&random(0.6,2.5,0.1);
8: # construct a data set using R
9: # dump is for debugging, print to screen to see data structure
10: ($data,$dump)=&cas_hashref('R',"set.seed($seed);x<-1:$n;w<-1+sqrt(x)/2;data.frame(x=x,y=$offset+$slope*x+rnorm(x)*w);");
11: @x=&cas_hashref_array($data,'x');
12: @y=&cas_hashref_array($data,'y');
13: $datax=join(',',@x);
14: $datay=join(',',@y);
15: # calculate the right answer using R
16: ($answerdata,$dump)=&cas_hashref('R',"x<-c($datax);y<-c($datay);dataset<-data.frame(x=x,y=y);fm<-lm(y~x,data=dataset);");
17: $answer=&cas_hashref_entry($answerdata,'coefficients','x').'*x+'.&cas_hashref_entry($answerdata,'coefficients','(Intercept)');
18: </script>
19:
20: <startouttext />
21: Consider the plotted data set.<br />
22: <endouttext />
23:
24: <gnuplot width="400" solid="0" plotcolor="monochrome" gridlayer="off" bmargin="default" font="9" alttag="dynamically generated plot" bgcolor="xffffff" texfont="22" transparent="off" plottype="Cartesian" rmargin="default" gridtype="Cartesian" minor_ticscale="0.5" fontface="sans-serif" grid="on" align="left" texwidth="93" height="300" border="on" samples="100" fgcolor="x000000" major_ticscale="1" tmargin="default" lmargin="default" fillstyle="empty">
25: <curve linestyle="points" linetype="solid" color="x000000" pointtype="3" limit="closed" pointsize="2" linewidth="1">
26: <data>@x</data>
27: <data>@y</data>
28: </curve>
29: </gnuplot>
30:
31: <startouttext />
32: <br />
33: Give a linear function approximating the data.<br />
34: <tt>y(x)=</tt>
35: <endouttext />
36:
37: <formularesponse id="11" answer="$answer" samples="x@1:$n#20">
38: <responseparam name="tol" default="2%" description="Numerical Tolerance" type="tolerance" />
39: <textline size="25" readonly="no" />
40: </formularesponse>
41:
42: </problem>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>