Justin, Many thanks! I will give it a try! Grigory From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> On Behalf Of Justin Gray Sent: Thursday, November 21, 2019 2:28 PM To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org> Subject: Re: [LON-CAPA-users] Formula response won't recognize "pi"
You can evaluate the answer using Maxima and allow for a tolerance using mathresponse. In Maxima, the constant pi is written as %pi. Here is a possible coding for this problem, which will accept either %pi or a numerical approximation for pi: <problem> <script type="loncapa/perl"> $function = "1/sqrt(4*(%pi)^2*L*C)"; $answer=&xmlparse('The correct answer is <m eval="on">$\frac{1}{\sqrt{4\cdot\pi^{2} \cdot L\cdot C}}$</m>'); </script> <startouttext /> <p>Enter <m>$ \frac{1}{\sqrt{4\cdot\pi^{2} \cdot L\cdot C}} $</m></p> <endouttext /> <mathresponse answerdisplay="$answer" cas="maxima" args="$function"> <answer>is(abs((RESPONSE[1])/(LONCAPALIST[1]) - 1) < 0.01);</answer> <textline readonly="no" size="100" spellcheck="none" /> </mathresponse> </problem> You will probably want to give students some instruction for formatting their answer. Best, Justin -- Justin Gray Senior Lecturer | Department of Mathematics Simon Fraser University | SCK 10531 8888 University Dr., Burnaby, B.C. V5A 1S6 T: 778.782.4237 [https://www.sfu.ca/content/sfu/communicators-toolkit/tools/brand-tools/on-brand-templates/email-signature/jcr:content/main_content/image_0.img.1280.high.png/1527873607206.png] On Thu, Nov 21, 2019 at 11:14 AM H. K. Ng <h...@fsu.edu<mailto:h...@fsu.edu>> wrote: Hi, Formularesponse using cas with maxima works great. <problem> <script type="loncapa/perl"> $ansa = &cas('maxima','1/sqrt(4*pi^2*L*C)'); </script> <startouttext />What is formula for resonant frequency for an LC circuit? <endouttext /><br /> <startouttext /><m>$ \omega_{res} = $</m><endouttext /> <formularesponse answer="$ansa" id="12"> <textline readonly="no" /> </formularesponse> </problem> Regards, -hk On Thu, Nov 21, 2019 at 11:05 AM SIMIN, GRIGORY <si...@engr.sc.edu<mailto:si...@engr.sc.edu>> wrote: Hi all! I've found a strange issue in some problems requiring formula response. I have a simple question to enter the formula for the resonant frequency. An example of correct answer is (in other variations the formula could be a bit more complex than this one) 1/(2*pi*sqrt(L*C)) The correct solution is checked by sampling L and C values. When I am entering the answer, I can see that LON-CAPA recognizes it because it displays the formatted formula as I am entering it: [cid:image001.jpg@01D5A07B.3EF6C940] But when I press submit, I got the response: “unable to understand formula” By experimenting with this, I found that the issue happens because of “pi” being a part of the answer. If pi is replaced with 3.141, everything would work. But it feels weird asking students to enter 3.141 instead of pi; besides, I don’t even want to give them a hint that pi is a part of the answer. Why is this happening? Apparently LON-CAPA knows what “pi” means because it displays it correctly. Thanks! Grigory _______________________________________________ LON-CAPA-users mailing list LON-CAPA-users@mail.lon-capa.org<mailto:LON-CAPA-users@mail.lon-capa.org> https://urldefense.com/v3/__http://mail.lon-capa.org/mailman/listinfo/lon-capa-users__;!!PhOWcWs!npThfddABuFrPgPy2N5gLLGz_02Hs0mlKSiyGgd0QGK0jAvPgqAmVRpO7BG6$<https://protect2.fireeye.com/v1/url?k=6499aa89-3808573f-6499e448-ac1f6b0e677a-e27f754950e6e6ab&q=1&e=55c490c3-9646-4121-955b-613377a7fa5e&u=https%3A%2F%2Furldefense.com%2Fv3%2F__http%3A%2F%2Fmail.lon-capa.org%2Fmailman%2Flistinfo%2Flon-capa-users__%3B%21%21PhOWcWs%21npThfddABuFrPgPy2N5gLLGz_02Hs0mlKSiyGgd0QGK0jAvPgqAmVRpO7BG6%24>
_______________________________________________ LON-CAPA-users mailing list LON-CAPA-users@mail.lon-capa.org http://mail.lon-capa.org/mailman/listinfo/lon-capa-users