[LON-CAPA-dev] RFC: XML for <imageresponse> rewrite

Guy Albertelli II lon-capa-dev@mail.lon-capa.org
Mon, 10 Oct 2005 18:06:57 -0400 (EDT)


Hi All,

A design idea for the XML of a  multiclick/vector/line style problems.

I'm looking for opinions

Things that need support:

1) a way to specify multiple areas that need to be clicked on and
submitted as a single answer.

2) a ways to specfy vectors that
     a) need to point from something to something else
     b) need to have a certain angle/length

3) a way to spcify lines that connect something to something else

4) try to make it not exclude later extensions,

(This proposal ignores what the interface for specifying the correct
answer looks like, I'd like to get the XML design correct before the
pitched battle over how we get the student to specify what is correct
occurs)



It seems a wrapper tag of <answer> is at least needed, and some markup
about what style of answer is required should be added (<area>,
<vector>, <line>)



So the simplfied example template of:

<imageresponse max="1">
  <foilgroup>
    <foil name="foil1">
      <image>/res/adm/includes/templates/man1.jpg</image>
      <text>Click on an eye</text>
      <rectangle>(127,139)-(186,178)</rectangle>
      <rectangle>(242,139)-(306,183)</rectangle>
    </foil>
</imageresponse>


Should become:

<imageresponse max="1">
  <foilgroup>
    <foil name="foil1">
      <image>/res/adm/includes/templates/man1.jpg</image>
      <text>Click on an eye</text>
      <answer>
        <area>
          <rectangle>(127,139)-(186,178)</rectangle>
          <rectangle>(242,139)-(306,183)</rectangle>
        </area>
      </answer>
    </foil>
</imageresponse>

Thus specifying an answer of 1 click is needed (1 <area> exists), with
multiple locations of correctness (the 2 <rectangle>s)


Multiple clicks can be required by (2 <areas>, 1 of which has multiple
correct spots, 1 of which has only 1 correct spot):

<imageresponse max="1">
  <foilgroup>
    <foil>
      <image>/res/adm/includes/templates/man1.jpg</image>
      <text>Click on an eye and on the mouth</text>
      <answer>
        <area>
          <rectangle>(127,139)-(186,178)</rectangle>
          <rectangle>(242,139)-(306,183)</rectangle>
        </area>
        <area>
          <rectangle>(142,226)-(294,293)</rectangle>
       </area>
      </answer>
    </foil>
  </foilgroup>
</imageresponse>

We could also require the order of the clicks to matter (they must
make the first <area> 'click 1' and the second <area> 'click 2':

<answer ordered="yes">
  <area>
    <circle>(250,250,15)</circle>
  </area>
  <area>
    <circle>(500,500,15)</circle>
  </area>
</answer>


Onto vector answers, this example requires 3 vectors and 1 line as a
correct answer,

- vector 1 must origniate inside of the <from> <circle> and terminate
in the <to> circle

- vector 2 must originate in the <from> cirlce and terminate inside of
one of the <to> <circle>s

- line 1 must connect the <from> and <to> circles, but the order
doesn't matter

- vector 3 must exist and have a <angle> as specified (with a
tolerance of 3%) and a <length> as specified with a tolerance of 15
pixels


<answer ordered="yes">
  <vector type="location">
    <from>
      <circle>(250,250,15)</circle>
    </from>
    <to>
      <circle>(500,500,15)</circle>
    </to>
  </vector>
  <vector type="location">
    <from>
      <circle>(100,100,15)</circle>
    </from>
    <!-- either direction -->
    <to>
      <circle>(200,200,15)</circle>
      <circle>(0,0,15)</circle>
    </to>
  </vector>
  <!-- <line> uses <from> and <to> but doesn't actually care about
        order -->
  <line>
    <from>
      <circle>(100,100,15)</circle>
    </from>
    <to>
      <circle>(200,200,15)</circle>
    </to>
  </line>
  <vector type="locationless">
     <!-- radians also possible -->
     <angle unit="degrees" tolerance="3%">35</angle>
     <!-- other units % of image? If we go with the absolute
          measurement idea a unit of 'absolute' -->
     <length unit="pixel" tolerance="15">100</length>
  </vector>
</answer>


For simplying the amount typing, we could create a means to name
certain areas for easy reuse.

<answer>
  <hotspots>
    <circle name="circle1">(250,250,15)</circle>
    <rectangle name="rectangle1">(100,100)-(250,250)</rectangle>
    <polygon name="poly1">....</polygon>
  </hotspots>
  <vector>
    <from><hotspot>circle1</hotspot></from>
    <to><circle>(100,101,2)</circle></to>
  </vector>
  <area>
    <hotspot>poly1</hotspot>
  </area>
</answer>


I guess if I really want to go for the XML route it should be:
<circle>
  <x>250</x>
  <y>250</y>
  <radius>15</radius>
</circle>

etc for <rectangle> et al.


-- 
guy@albertelli.com   0-7-2-1-27,137