[LON-CAPA-users] Any way to do this???
Mills, Douglas G
dmills at illinois.edu
Thu May 24 18:05:03 EDT 2012
Hey Again,
So you have multiple <textline /> 's all within ONE <customresponse> within
one PART.
I have multiple <customresponse> 's all within one PART. Is the
$$submission[x] access limited to within in the <customresponse> tags OR is
it to all the submissions within the <part> ?
Thanks,
Doug
On 5/24/12 11:10 AM, "Gerd Kortemeyer" <korte at lite.msu.edu> wrote:
> 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>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users at mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
Doug
Douglas Mills
Director of Instructional Technologies
Department of Chemistry
University of Illinois
dmills at illinois.edu
(217) 244-5739
More information about the LON-CAPA-users
mailing list