[LON-CAPA-users] Any way to do this???

Gerd Kortemeyer korte at lite.msu.edu
Thu May 24 12:10:58 EDT 2012


Hi,

On May 24, 2012, at 9:59 AM, Mills, Douglas G wrote:
> 
> 
> if ($submission=~/\,/) { return 'EXTRA_ANSWER'; }

If there are multiple input fields within a response, then $submission is a pointer to an array, not a value.

I am attaching a little script that just checks if the input by the students is not too high. You can as well check against additional input fields within the same response.

- Gerd.

<part id="data">
<startouttext /><p>Find yourself a large area away from traffic, potholes and black holes, and try to determine your average walking speed (distance/time).</p><endouttext />
<customresponse id="mydata">
    <answer type="loncapa/perl">for ($i=0;$i<=5;$i++) {
    $height[$i]=$$submission[2*$i];
    unless ($height[$i]) { return 'MISSING_ANSWER'; }
    unless ($height[$i]=~/^[\d\.]+$/) { return 'WANTED_NUMERIC'; }
    $time[$i]=$$submission[2*$i+1];
    unless ($time[$i]) { return 'MISSING_ANSWER'; }
    unless ($time[$i]=~/^[\d\.]+$/) { return 'WANTED_NUMERIC'; }
}
for ($i=0;$i<=5;$i++) {
    if ($height[$i]/$time[$i]>3) { return 'INCORRECT'; }
}
return 'APPROX_ANS';</answer>
<startouttext /><table><tr><th>Distance [Meters]</th><th>Time [Seconds]</th></tr><endouttext />
<startouttext /><tr><td><endouttext /><textline readonly="no" /><startouttext />$height[0]</td><td><endouttext /><textline readonly="no" /><startouttext />$time[0]</td></tr><endouttext />
<startouttext /><tr><td><endouttext /><textline readonly="no" /><startouttext />$height[1]</td><td><endouttext /><textline readonly="no" /><startouttext />$time[1]</td></tr><endouttext />
<startouttext /><tr><td><endouttext /><textline readonly="no" /><startouttext />$height[2]</td><td><endouttext /><textline readonly="no" /><startouttext />$time[2]</td></tr><endouttext />
<startouttext /><tr><td><endouttext /><textline readonly="no" /><startouttext />$height[3]</td><td><endouttext /><textline readonly="no" /><startouttext />$time[3]</td></tr><endouttext />
<startouttext /><tr><td><endouttext /><textline readonly="no" /><startouttext />$height[4]</td><td><endouttext /><textline readonly="no" /><startouttext />$time[4]</td></tr><endouttext />
<startouttext /><tr><td><endouttext /><textline readonly="no" /><startouttext />$height[5]</td><td><endouttext /><textline readonly="no" /><startouttext />$time[5]</td></tr><endouttext />
<startouttext /></table><endouttext />
    
</customresponse>

</part>


More information about the LON-CAPA-users mailing list