This was in reply to your R example. I have just read your most recent message. I am not sure how to provide more detailed feedback on the answer input without using customresponse. My approach is usually to just provide clear instructions to students on what is expected.
Best, Justin -- *Justin Gray* Senior Lecturer | Department of Mathematics Simon Fraser University | SCK 10531 8888 University Dr., Burnaby, B.C. V5A 1S6 Canada Simon Fraser University is located on the Unceded Coast Salish Territories of the xʷməθkʷəy̓əm (Musqueam), Səl̓ílwətaʔ/Selilwitulh (Tsleil-Waututh), Kwikwitlem, and Skwxwú7mesh Úxwumixw (Squamish) Peoples On Tue, Oct 27, 2020 at 11:49 AM Justin Gray <jg...@math.sfu.ca> wrote: > Perhaps you could do something with this: > > <problem> > <script type="loncapa/perl">$ax=&random(1.0,10,0.1); > $ay=&random(1.0,10,0.1); > @args = ($ax, $ay); > $answer = "Many answers are possible"; > </script> > <startouttext /> > <p>Consider a vector <m eval="on">\( \vec{a} = $ax\hat{x} + $ay\hat{y} > \)</m>'. > Provide a vector <m>\( \vec{b} \)</m>, orthogonal to <m>\( \vec{a} > \)</m>. > </p> > Enter the coordinates of <m>\( \vec{b} \)</m> separated by a comma. That > is, answer in the form <font color="red"> <m>\( b_x, b_y \)</m></font>: > <endouttext /> > <mathresponse cas="maxima" answerdisplay="$answer" args="@args"> > > <answer>is(abs([LONCAPALIST[1],LONCAPALIST[2]].[RESPONSE[1],RESPONSE[2]]) < > 0.001);</answer> > <textline readonly="no" spellcheck="none" /> > </mathresponse> > </problem> > > Best, > Justin > > -- > > *Justin Gray* > Senior Lecturer | Department of Mathematics > Simon Fraser University | SCK 10531 > 8888 University Dr., Burnaby, B.C. V5A 1S6 > Canada > Simon Fraser University is located on the Unceded Coast Salish Territories > of the xʷməθkʷəy̓əm (Musqueam), Səl̓ílwətaʔ/Selilwitulh (Tsleil-Waututh), > Kwikwitlem, and Skwxwú7mesh Úxwumixw (Squamish) Peoples > > > On Sat, Oct 24, 2020 at 4:15 AM Itay <it...@nospammail.net> wrote: > >> Hi >> >> (Sorry for miswriting Justin's name in my previous message.) >> I finally was able to get a working minimal example (see below). >> >> This modest success bring up a few follow-up questions that I hope that >> list members could answer. >> 1. How to test responder's input, e.g., for non-numeric submission? >> Should I use the $submission variable with the initial <script> block? >> 2. If the test should be done inside R : how to deliver the test results >> to LC? >> >> I ask this because when I tested the ME below with various inputs that do >> not follow the expected format (non-numeric values, missing input, etc.) I >> got only one kind of warning 'Unable to understand formula'. >> >> I would like to be able to give a more granular feedback to the students, >> in the spirit of the original ME. >> >> Thanks >> Itay >> >> <problem> >> <script type="loncapa/perl"> >> $ax = &random(1.0, 10, 0.1); # Coordinates of \vec{a} >> $ay = &random(1.0, 10, 0.1); >> @avec = ($ax, $ay); >> $answer="Chose b such that the scalar product with a is zero."; >> </script> >> >> <startouttext /> >> Consider a vector <m eval="on">\( \vec{a} = $ax\hat{x} + $ay\hat{y} >> \)</m>'. >> Provide a vector <m>\( \vec{b} \)</m>, orthogonal to <m>\( \vec{a} >> \)</m>. >> <br /> >> <endouttext /> >> >> <mathresponse answerdisplay="$answer" cas="R" args="@avec"> >> <answer> >> a <- c(LONCAPALIST[1],LONCAPALIST[2]); >> b <- c(RESPONSE[1],RESPONSE[2]) ; >> abs(sum(a*b))<0.001 >> </answer> >> <textline readonly="no" size="20" /> >> </mathresponse> >> </problem> >> >> >> >> >> On Sat, 24 Oct 2020, at 13:35, Itay wrote: >> >> Just, >> Thank you for your reply. >> Following your suggestion I tried to create a minimal example based on >> the template >> Math Response using Computer Algebra System R >> Here, too, I am having difficulties. >> The minimal example is enclosed below. >> Typing the correct answer for vector b (ay, -ax) >> provokes the response >> Unable to understand formula. >> >> Note : the command delegated to R was tested directly with R. >> >> Thank you >> Itay >> >> >> <problem> >> >> <script type="loncapa/perl"> >> $ax = &random(1.0, 10, 0.1); # Coordinates of \vec{a} >> $ay = &random(1.0, 10, 0.1); >> @avec = ($ax, $ay); >> $answer="Chose b such that the scalar product with a is zero."; >> </script> >> >> >> <startouttext /> >> Consider a vector <m eval="on">\( \vec{a} = $ax\hat{x} + $ay\hat{y} >> \)</m>'. >> Provide a vector <m>\( \vec{b} \)</m>, orthogonal to <m>\( \vec{a} >> \)</m>. >> <br /> >> <endouttext /> >> >> <mathresponse answerdisplay="$answer" cas="R" args="@avec"> >> <answer> >> abs(sum(LONCAPALIST * RESPONSE))<0.001 >> </answer> >> <textline readonly="no" size="20" /> >> </mathresponse> >> >> </problem> >> >> >> >> >> On Fri, 23 Oct 2020, at 23:36, Justin Gray wrote: >> >> I'm afraid I do not have an answer to your question, but have you >> considered coding this problem as a mathresponse problem? >> >> Best regards, >> Justin >> >> -- >> >> >> *Justin Gray* >> Senior Lecturer | Department of Mathematics >> Simon Fraser University | SCK 10531 >> 8888 University Dr., Burnaby, B.C. V5A 1S6 >> Canada >> >> >> Simon Fraser University is located on the Unceded Coast Salish >> Territories of the xʷməθkʷəy̓əm (Musqueam), Səl̓ílwətaʔ/Selilwitulh >> (Tsleil-Waututh), Kwikwitlem, and Skwxwú7mesh Úxwumixw (Squamish) Peoples >> >> >> On Fri, Oct 23, 2020 at 1:18 PM Itay <it...@nospammail.net> wrote: >> >> >> Hi >> >> I am trying to develop a custom response problem in which the student >> submission is a vector. >> A minimal example is provided below. >> Regardless of what I typed in the either of the two input fields I get >> the response: >> 'This question expects a numeric answer.' >> >> Please advise what am I doing wrong? >> >> Thanks in advance. >> Itay >> >> >> <problem> <!-- begin minimal --> >> <script type="loncapa/perl"> >> $ax = &random(1.0, 10, 0.1); # Coordinates of \vec{a} >> $ay = &random(1.0, 10, 0.1); >> </script> >> >> <startouttext /> >> Consider a vector <m eval="on">\( \vec{a} = $ax\hat{x} + $ay\hat{y} >> \)</m>'. >> Provide a vector <m>\( \vec{b} \)</m>, orthogonal to <m>\( \vec{a} >> \)</m>. >> <br /> >> <endouttext /> >> >> <customresponse id="dotProd"> >> <answer type="loncapa/perl"> >> for ($i=0; $i<2; $i++) { # Test input sanity. >> if ($submission[i] =~ /^\d+\s+\w+$/) { return 'UNIT_NOTNEEDED'; } >> if ($submission[i] !~ /^[\d\.]+$/) { return 'WANTED_NUMERIC'; } >> } >> >> # Is submission correct? >> $dotProd = $ax * $submission[0] + $ay * $submission[1]; >> if (abs($dotProd) < 1.0e-3) { return 'APPROX_ANS'; } # Can't >> expect EXACT_ANS. >> return 'INCORRECT'; >> </answer> >> >> <startouttext /><m>\( b_x = \)</m><endouttext /> >> <textline size="10" readonly="no" spellcheck="none" /> >> <startouttext /><br /><endouttext /> >> >> <startouttext /><m>\( b_y = \)</m><endouttext /> >> <textline size="10" readonly="no" spellcheck="none" /> >> <startouttext /><br /><endouttext /> >> </customresponse> >> </problem> <!-- end minimal --> >> >> >> _______________________________________________ >> LON-CAPA-users mailing list >> LON-CAPA-users@mail.lon-capa.org >> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users >> >> >> _______________________________________________ >> LON-CAPA-users mailing list >> LON-CAPA-users@mail.lon-capa.org >> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users >> >> >>
_______________________________________________ LON-CAPA-users mailing list LON-CAPA-users@mail.lon-capa.org http://mail.lon-capa.org/mailman/listinfo/lon-capa-users