<!DOCTYPE html><html><head><title></title><style type="text/css">
p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div style="font-family:Arial;">Hi<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">(Sorry for miswriting Justin's name in my previous message.)<br></div><div style="font-family:Arial;">I finally was able to get a working minimal example (see below).<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">This modest success bring up a few follow-up questions that I hope that list members could answer.<br></div><div style="font-family:Arial;">1. How to test responder's input, e.g., for non-numeric submission?<br></div><div style="font-family:Arial;">    Should I use the $submission variable with the initial <script> block?<br></div><div style="font-family:Arial;">2. If the test should be done inside R : how to deliver the test results to LC?<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">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'.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">I would like to be able to give a more granular feedback to the students, in the spirit of the original ME.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Thanks<br></div><div style="font-family:Arial;">Itay<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><problem><br></div><div style="font-family:Arial;">  <script type="loncapa/perl"><br></div><div style="font-family:Arial;">    $ax = &random(1.0, 10, 0.1); # Coordinates of \vec{a}<br></div><div style="font-family:Arial;">    $ay = &random(1.0, 10, 0.1);<br></div><div style="font-family:Arial;">    @avec = ($ax, $ay);<br></div><div style="font-family:Arial;">    $answer="Chose b such that the scalar product with a is zero.";<br></div><div style="font-family:Arial;">  </script><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">  <startouttext /><br></div><div style="font-family:Arial;">  Consider a vector <m eval="on">\( \vec{a} = $ax\hat{x} + $ay\hat{y} \)</m>'.<br></div><div style="font-family:Arial;">  Provide a vector <m>\( \vec{b} \)</m>, orthogonal to <m>\( \vec{a} \)</m>.<br></div><div style="font-family:Arial;">  <br /><br></div><div style="font-family:Arial;">  <endouttext /><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><mathresponse answerdisplay="$answer" cas="R" args="@avec"><br></div><div style="font-family:Arial;">    <answer><br></div><div style="font-family:Arial;">        a <- c(LONCAPALIST[1],LONCAPALIST[2]);<br></div><div style="font-family:Arial;">        b <- c(RESPONSE[1],RESPONSE[2]) ;<br></div><div style="font-family:Arial;">         abs(sum(a*b))<0.001<br></div><div style="font-family:Arial;">    </answer><br></div><div style="font-family:Arial;">    <textline readonly="no" size="20" /><br></div><div style="font-family:Arial;"></mathresponse><br></div><div style="font-family:Arial;"></problem><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div>On Sat, 24 Oct 2020, at 13:35, Itay wrote:<br></div><blockquote type="cite" id="qt" style=""><div style="font-family:Arial;">Just,<br></div><div style="font-family:Arial;">Thank you for your reply.<br></div><div style="font-family:Arial;">Following your suggestion I tried to create a minimal example based on the template<br></div><div style="font-family:Arial;text-align:center;" class="qt-align-center">Math Response using Computer Algebra System R<br></div><div style="font-family:Arial;">Here, too, I am having difficulties.<br></div><div style="font-family:Arial;">The minimal example is enclosed below.<br></div><div style="font-family:Arial;">Typing the correct answer for vector b (ay, -ax)<br></div><div style="font-family:Arial;">provokes the response<br></div><div style="font-family:Arial;text-align:center;" class="qt-align-center">Unable to understand formula.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Note : the command delegated to R was tested directly with R.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Thank you<br></div><div style="font-family:Arial;">Itay<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><problem><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">  <script type="loncapa/perl"><br></div><div style="font-family:Arial;">    $ax = &random(1.0, 10, 0.1); # Coordinates of \vec{a}<br></div><div style="font-family:Arial;">    $ay = &random(1.0, 10, 0.1);<br></div><div style="font-family:Arial;">    @avec = ($ax, $ay);<br></div><div style="font-family:Arial;">    $answer="Chose b such that the scalar product with a is zero.";<br></div><div style="font-family:Arial;">  </script><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">  <startouttext /><br></div><div style="font-family:Arial;">  Consider a vector <m eval="on">\( \vec{a} = $ax\hat{x} + $ay\hat{y} \)</m>'.<br></div><div style="font-family:Arial;">  Provide a vector <m>\( \vec{b} \)</m>, orthogonal to <m>\( \vec{a} \)</m>.<br></div><div style="font-family:Arial;">  <br /><br></div><div style="font-family:Arial;">  <endouttext /><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><mathresponse answerdisplay="$answer" cas="R" args="@avec"><br></div><div style="font-family:Arial;">    <answer><br></div><div style="font-family:Arial;">    abs(sum(LONCAPALIST * RESPONSE))<0.001<br></div><div style="font-family:Arial;">    </answer><br></div><div style="font-family:Arial;">    <textline readonly="no" size="20" /><br></div><div style="font-family:Arial;"></mathresponse><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"></problem><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div>On Fri, 23 Oct 2020, at 23:36, Justin Gray wrote:<br></div><blockquote type="cite" id="qt-qt" style=""><div dir="ltr"><div>I'm afraid I do not have an answer to your question, but have you considered coding this problem as a mathresponse problem?<br></div><div><br></div><div>Best regards,<br></div><div><div>Justin<br></div><div><div dir="ltr" class="qt-qt-gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="border-top-color:currentcolor;border-top-style:none;border-top-width:0px;border-right-color:currentcolor;border-right-style:none;border-right-width:0px;border-bottom-color:currentcolor;border-bottom-style:none;border-bottom-width:0px;border-left-color:currentcolor;border-left-style:none;border-left-width:0px;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;"><div style="border-top-color:currentcolor;border-top-style:none;border-top-width:0px;border-right-color:currentcolor;border-right-style:none;border-right-width:0px;border-bottom-color:currentcolor;border-bottom-style:none;border-bottom-width:0px;border-left-color:currentcolor;border-left-style:none;border-left-width:0px;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;"><h3 style="border-top-color:currentcolor;border-top-style:none;border-top-width:0px;border-right-color:currentcolor;border-right-style:none;border-right-width:0px;border-bottom-color:currentcolor;border-bottom-style:none;border-bottom-width:0px;border-left-color:currentcolor;border-left-style:none;border-left-width:0px;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;margin-top:1.5rem;margin-right:0px;margin-bottom:1.5rem;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;"><div style="color:rgb(0, 0, 0);font-family:"Source Serif Pro", sans-serif;font-size:16px;border-top-color:currentcolor;border-top-style:none;border-top-width:0px;border-right-color:currentcolor;border-right-style:none;border-right-width:0px;border-bottom-color:currentcolor;border-bottom-style:none;border-bottom-width:0px;border-left-color:currentcolor;border-left-style:none;border-left-width:0px;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;"><div style="border-top-color:currentcolor;border-top-style:none;border-top-width:0px;border-right-color:currentcolor;border-right-style:none;border-right-width:0px;border-bottom-color:currentcolor;border-bottom-style:none;border-bottom-width:0px;border-left-color:currentcolor;border-left-style:none;border-left-width:0px;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;"><p style="border-top-color:currentcolor;border-top-style:none;border-top-width:0px;border-right-color:currentcolor;border-right-style:none;border-right-width:0px;border-bottom-color:currentcolor;border-bottom-style:none;border-bottom-width:0px;border-left-color:currentcolor;border-left-style:none;border-left-width:0px;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;margin-top:1rem;margin-right:0px;margin-bottom:1.5rem;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;font-stretch:normal;font-size:12px;line-height:18px;font-family:Arial, Helvetica, sans-serif;"><span style="font-weight:normal;">--</span><br></p><p style="font-weight:100;border-top-color:currentcolor;border-top-style:none;border-top-width:0px;border-right-color:currentcolor;border-right-style:none;border-right-width:0px;border-bottom-color:currentcolor;border-bottom-style:none;border-bottom-width:0px;border-left-color:currentcolor;border-left-style:none;border-left-width:0px;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;margin-top:1rem;margin-right:0px;margin-bottom:1.5rem;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;font-stretch:normal;font-size:12px;line-height:18px;font-family:Arial, Helvetica, sans-serif;"><br></p><div><b>Justin Gray</b><br></div><div>Senior Lecturer | Department of Mathematics<br></div><div>Simon Fraser University | SCK 10531<br></div><div>8888 University Dr., Burnaby, B.C. V5A 1S6<br></div><div>Canada<br></div><p><br></p></div></div><div><span style="font-weight:normal;"><span class="qt-size" style=""><span class="size" style="font-size:10px;">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</span></span></span><br></div></h3></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><div><br></div></div></div><div><br></div><div class="qt-qt-gmail_quote"><div dir="ltr" class="qt-qt-gmail_attr">On Fri, Oct 23, 2020 at 1:18 PM Itay <<a href="mailto:itayf@nospammail.net">itayf@nospammail.net</a>> wrote:<br></div><blockquote class="qt-qt-gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div><u></u><br></div><div><div style="font-family:Arial;">Hi<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">I am trying to develop a custom response problem in which the student submission is a vector.<br></div><div style="font-family:Arial;">A minimal example is provided below.<br></div><div style="font-family:Arial;">Regardless of what I typed in the either of the two input fields I get the response:<br></div><div style="font-family:Arial;">'This question expects a numeric answer.'<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Please advise what am I doing wrong?<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Thanks in advance.<br></div><div style="font-family:Arial;">Itay<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><problem>  <!-- begin minimal --><br></div><div style="font-family:Arial;">  <script type="loncapa/perl"><br></div><div style="font-family:Arial;">    $ax = &random(1.0, 10, 0.1); # Coordinates of \vec{a}<br></div><div style="font-family:Arial;">    $ay = &random(1.0, 10, 0.1);<br></div><div style="font-family:Arial;">  </script><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">  <startouttext /><br></div><div style="font-family:Arial;">  Consider a vector <m eval="on">\( \vec{a} = $ax\hat{x} + $ay\hat{y} \)</m>'.<br></div><div style="font-family:Arial;">  Provide a vector <m>\( \vec{b} \)</m>, orthogonal to <m>\( \vec{a} \)</m>.<br></div><div style="font-family:Arial;">  <br /><br></div><div style="font-family:Arial;">  <endouttext /><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">  <customresponse id="dotProd"><br></div><div style="font-family:Arial;">    <answer type="loncapa/perl"><br></div><div style="font-family:Arial;">      for ($i=0; $i<2; $i++) {                # Test input sanity.<br></div><div style="font-family:Arial;">        if ($submission[i] =~ /^\d+\s+\w+$/) { return 'UNIT_NOTNEEDED'; }<br></div><div style="font-family:Arial;">        if ($submission[i] !~ /^[\d\.]+$/)   { return 'WANTED_NUMERIC'; }<br></div><div style="font-family:Arial;">      }<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">      # Is submission correct?<br></div><div style="font-family:Arial;">      $dotProd = $ax * $submission[0] + $ay * $submission[1];<br></div><div style="font-family:Arial;">      if (abs($dotProd) < 1.0e-3) { return 'APPROX_ANS'; }  # Can't expect EXACT_ANS.<br></div><div style="font-family:Arial;">      return 'INCORRECT';<br></div><div style="font-family:Arial;">    </answer><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">    <startouttext /><m>\( b_x = \)</m><endouttext /><br></div><div style="font-family:Arial;">    <textline size="10" readonly="no" spellcheck="none" /><br></div><div style="font-family:Arial;">    <startouttext /><br /><endouttext /><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">    <startouttext /><m>\( b_y = \)</m><endouttext /><br></div><div style="font-family:Arial;">    <textline size="10" readonly="no" spellcheck="none" /><br></div><div style="font-family:Arial;">    <startouttext /><br /><endouttext /><br></div><div style="font-family:Arial;">  </customresponse><br></div><div style="font-family:Arial;"></problem>  <!-- end minimal --><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div></div></blockquote></div><div>_______________________________________________<br></div><div>LON-CAPA-users mailing list<br></div><div><a href="mailto:LON-CAPA-users@mail.lon-capa.org">LON-CAPA-users@mail.lon-capa.org</a><br></div><div><a href="http://mail.lon-capa.org/mailman/listinfo/lon-capa-users">http://mail.lon-capa.org/mailman/listinfo/lon-capa-users</a><br></div><div><br></div></blockquote><div style="font-family:Arial;"><br></div><div>_______________________________________________<br></div><div>LON-CAPA-users mailing list<br></div><div><a href="mailto:LON-CAPA-users@mail.lon-capa.org">LON-CAPA-users@mail.lon-capa.org</a><br></div><div><a href="http://mail.lon-capa.org/mailman/listinfo/lon-capa-users">http://mail.lon-capa.org/mailman/listinfo/lon-capa-users</a><br></div><div><br></div></blockquote><div style="font-family:Arial;"><br></div></body></html>