File:
[LON-CAPA] /
loncom /
homework /
templates /
sampleexternal.problem
Revision
1.3:
download - view:
text,
annotated -
select for diffs
Tue Dec 21 01:53:13 2010 UTC (13 years, 8 months ago) by
www
Branches:
MAIN
CVS tags:
version_2_10_X,
version_2_10_1,
version_2_10_0_RC2,
version_2_10_0,
loncapaMITrelate_1,
language_hyphenation_merge,
language_hyphenation,
HEAD,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse,
BZ4492-feature_Support_horizontal_radioresponse,
BZ4492-Support_horizontal_radioresponse
answerdisplay-attribute, like with the other custom-type responses
1: <problem>
2: <script type="loncapa/perl">
3: sub fact {
4: my $n=shift;
5: if ($n==1) {
6: return $n;
7: } else {
8: return $n*&fact($n-1);
9: }
10: }
11:
12: $testvalues='0=1';
13: foreach $i (1..3) {
14: $rand=&random(3,8,1);
15: $testvalues.=','.$rand.'='.&fact($rand);
16: }
17: </script>
18:
19:
20: <startouttext />Write a Perl subroutine called <tt>factorial</tt>, which returns the factorial of its argument, e.g. <tt>&factorial(17)=17!</tt>.
21: <instructorcomment>
22: Sample code for an evaluation script can be found <a href="/res/adm/includes/templates/sampleexternal.pl">here.</a></instructorcomment>
23: <endouttext />
24: <externalresponse url="http://localhost/cgi-bin/sampleexternal.pl" answer="$testvalues" answerdisplay="The most elegant (and dangerous) solution is recursive.">
25: <textfield />
26:
27: </externalresponse>
28: </problem>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>