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 (14 years, 3 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
<problem>
<script type="loncapa/perl">
sub fact {
my $n=shift;
if ($n==1) {
return $n;
} else {
return $n*&fact($n-1);
}
}
$testvalues='0=1';
foreach $i (1..3) {
$rand=&random(3,8,1);
$testvalues.=','.$rand.'='.&fact($rand);
}
</script>
<startouttext />Write a Perl subroutine called <tt>factorial</tt>, which returns the factorial of its argument, e.g. <tt>&factorial(17)=17!</tt>.
<instructorcomment>
Sample code for an evaluation script can be found <a href="/res/adm/includes/templates/sampleexternal.pl">here.</a></instructorcomment>
<endouttext />
<externalresponse url="http://localhost/cgi-bin/sampleexternal.pl" answer="$testvalues" answerdisplay="The most elegant (and dangerous) solution is recursive.">
<textfield />
</externalresponse>
</problem>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>