Annotation of loncom/homework/templates/answerdependent.problem, revision 1.1
1.1 ! www 1: <problem>
! 2:
! 3: <parameter name="ordered" type="string_yesno" description="Show Parts One-at-a-Time" default="yes" />
! 4:
! 5: <script type="loncapa/perl">
! 6: $lower=&random(3,10,1);
! 7: $higher=&random(15,20,1);
! 8: $answer=&random($lower,$higher,0.1);
! 9: $example='An example would be '.$answer;
! 10: # Get the entered answer. First argument is partID, second is responseID
! 11: $given=&submission(1,11);
! 12: if ($given=~/\d/) { $answer=$given; $example='You chose '.$given; }
! 13: $add=&random(3,6,0.1);
! 14: $result=$given+$add;
! 15: </script>
! 16:
! 17: <part id="1">
! 18: <startouttext />
! 19: Give a number between $lower and $higher.
! 20: <endouttext />
! 21: <customresponse answerdisplay="$example" id="11">
! 22: <answer type="loncapa/perl"># We do not want a vector
! 23: if ($submission=~/\,/) { return 'EXTRA_ANSWER'; }
! 24: # No units needed
! 25: if ($submission=~/^\d+\s+\w+$/) { return 'UNIT_NOTNEEDED'; }
! 26: # Need a numerical answer here
! 27: if ($submission!~/^[\d\.]+$/) { return 'WANTED_NUMERIC'; }
! 28: # is it correct?
! 29: if (($submission>=$lower) && ($submission<=$higher)) { return 'EXACT_ANS'; }
! 30: return 'INCORRECT';</answer>
! 31: <textline readonly="no" />
! 32: </customresponse>
! 33: </part>
! 34:
! 35: <part id="2">
! 36: <startouttext />
! 37: What do you get if you add $add to your number?
! 38: <endouttext />
! 39: <numericalresponse answer="$result">
! 40: <responseparam type="tolerance" default="1%" name="tol" description="Numerical Tolerance" />
! 41: <textline readonly="no" />
! 42: </numericalresponse>
! 43: </part>
! 44:
! 45: </problem>
! 46:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>