Annotation of loncom/homework/templates/sampleexternal.problem, revision 1.1

1.1     ! www         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: for ($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>&amp;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">
        !            25: <textfield />
        !            26: 
        !            27: </externalresponse>
        !            28: </problem>

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