[LON-CAPA-users] customresponse / customhint

Christina möller christina.moeller at fh-stralsund.de
Thu Jul 25 07:05:56 EDT 2013


Great, thank you very much. :-)




Am 25.07.2013 12:26, schrieb Peter Dencker:
> Hi,
>
> the <answer> block of <customhint> can be used to define hints. It
> doesn't make sense to return 'INCORRECT'. This has to be done in the
> <answer> block of customresponse.
>
> I give a suggestion below.
>
> - Peter
>
> <problem>
>
> <script type = "loncapa/perl">
>
> $term = "2*a*(13*b*c-2*d)";
> $solution = &cas("maxima","ratexpand($term)");
> $term =~s/\*//g;
>
> $hint = '';
> </script>
>
> <part id = 'p0'>
> <customresponse id="p0r0">
>
> <startouttext />
> Expand <m eval = 'on'> \[$term.\] </m>
> <textline readonly="no" size="25" /><br />
> <endouttext />
>
> <answer type="loncapa/perl">
> if ($submission =~/[()]/) { return 'BAD_FORMULA' }
> $given = &implicit_multiplication($submission);
> $frommaxima = &cas('maxima',"is(rat($given - ($solution))=0)");
> if ($frommaxima eq 'true') { return 'EXACT_ANS';}
> if  ($frommaxima eq 'false') { return 'INCORRECT';}
> return 'BAD_FORMULA'
> </answer>
>
> <customhint id="p0r0h0">
>    <answer type="loncapa/perl">
>    if ($submission =~ /[()]/) {
>        $hint = "Expand, don't use parentheses!";
>    }
>    else {
>        $given = &implicit_multiplication($submission);
>        $frommaxima = &cas('maxima',"is(rat($given - ($solution))=0)");
>        if  ($frommaxima eq 'false') {
>            $hint = "A solution is an expression equivalent to $solution."
>        }
>    }
>    </answer>
> </customhint>
>
> </customresponse>
> </part>
>
> <startouttext />
> $hint <br /> <br />
> <endouttext />
>
> </problem>
>
> On 25.07.2013 09:13, Christina möller wrote:
>> Hello LC-Community,
>>
>> is there anyone, who has an example for <customhint>?
>> I try it like the <Egyptian Fraction>-example, but it doesn´t work.
>>
>> What am I doing wrong?
>>
>> Thanks.
>>
>> %<-------- my problem-code
>>
>> #$term = "2*a*(13*b*c-2*d)";
>> #$answer = &cas("maxima","ratsimp($term);");
>> #$term =~s/\*//g;
>>
>> <customresponse answerdisplay="$answer" id="11">
>>
>> <textline readonly="no" size="25"></textline>
>> <hintgroup showoncorrect="no">
>>
>> <answer type="loncapa/perl">
>> $frommaxima = &cas('maxima',"is($submission = $answer);");
>> if ($frommaxima=~/^\s*true\s*$/i){ return 'EXACT_ANS';}
>> if ($submission eq $answer) { return 'EXACT_ANS'; }
>> return 'INCORRECT';
>> </answer>
>>
>>
>> <customhint name="format" >
>> <answer type="loncapa/perl">
>> if ($submission=~/\(/) { return 'INCORRECT'; }
>> if ($submission==$term){ return 'INCORRECT'; }
>> return 'INCORRECT';
>> </answer>
>>
>> </customhint>
>>
>> <hintpart on="format">
>> <startouttext />
>> <p>Customhint format </p>
>> <endouttext />
>> </hintpart>
>>
>> </hintgroup>
>>
>> </customresponse>
>>
>> ---------->%
>>
>> _______________________________________________
>> LON-CAPA-users mailing list
>> LON-CAPA-users at mail.lon-capa.org
>> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users at mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users



More information about the LON-CAPA-users mailing list