[LON-CAPA-users] comparing submitted answer with ..

Guy Albertelli II lon-capa-users@mail.lon-capa.org
Wed, 12 May 2004 09:13:35 -0400 (EDT)


--ELM1084367615-11433-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII

Hi Jim,

> Thanks for the question about &EXT and the added documentation.  This is 
> useful. 
> My question:  Is it possible to use the &EXT subroutine to set up a 
> conditional answer (i. e. if the first answer is A, the second and third 
> are B and C, but if the first answer is B, the second and third are C 
> and D?  --jim

Aye.

http://s10.lite.msu.edu/res/msu/albertel/submission_example.problem

Source is attached.

More complex example:
http://s10.lite.msu.edu/res/msu/albertel/molarvolume.problem

-- 
guy@albertelli.com  LON-CAPA Developer  0-7-4-3-

--ELM1084367615-11433-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
Content-Disposition: attachment; filename=submission_example.problem
Content-Description: 

<problem>
  <script type="loncapa/perl">

    #Enter the computations here
    $submission=&EXT('user.resource.resource.Enter_A_Number.1.submission');
    $status=&EXT('user.resource.resource.Enter_A_Number.solved');

    $randnum=&random(3,7,1);
    if (!$submission) {
        $anwer='UNANSWERABLE';
    } else {
        $answer=$submission*$randnum;
    }
  </script>
  <block condition="$status!~/^correct/">
    <part id="Enter_A_Number">
      <startouttext />Please enter a number between 1 and 10<endouttext />
      <numericalresponse id="1" answer="5.5">
        <responseparam description="Numerical Tolerance" default="4.5"
                       type="tolerance" name="tol" />	
	<textline />	
      </numericalresponse>
    </part>
  </block>

  <block condition="$status=~/^correct/">
    <part id="Find_The_Product">
      <startouttext />
         You entered $submission, calculate the product of $submission
         and $randnum.
      <endouttext />
      <numericalresponse id="2" answer="$answer">
        <textline />
      </numericalresponse>
    </part>
  </block>
</problem>

--ELM1084367615-11433-0_--