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

Gerd Kortemeyer lon-capa-dev@mail.lon-capa.org
Tue, 11 Oct 2005 17:21:26 -0400


Hi,

On Oct 10, 2005, at 6:06 PM, Guy Albertelli II wrote:
>
> 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>


- so, this would not be compatible with old content?

> 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>


I like this a lot - but it needs to accept leaving out <answer> if  
there is only one because of existing content.

I assume that all of these can be variable, e.g.,

<answer ordered="yes">
   <area>
     <circle>($x,$y,$r)</circle>
   </area>
   <area>
     <circle>(@circle)</circle>
   </area>
</answer>

- where @circle has all three.

>
>
> 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


Okay, I don't understand why this is tied to other objects. I would  
suggest

<vector>
<xlength unit="pixels">40</xlength>
<ylength unit="pixels">80</ylength>
</vector>

or

<vector>
<length unit="pixels">50</length>
<angle unit="radians">.34</angle>
</vector>

for vectors in cartesian or polar coordinates.

You might then add an origin if you want to tie to a certain location:

<vector>
<xinitial unit="pixels">30</xinitial>
<yinitialunit="pixels">60</yinitial>
<xlength unit="pixels">40</xlength>
<ylength unit="pixels">80</ylength>
</vector>

<vector>
<xinitial unit="pixels">30</xinitial>
<yinitial unit="pixels">30</yinitial>
<length unit="pixels">50</length>
<angle unit="radians">.34</angle>
</vector>

Finally, you could get the vector by giving its end point:

<vector>
<xinitial unit="pixels">30</xinitial>
<yinitial unit="pixels">60</yinitial>
<xfinal unit="pixels">80</xfinal>
<yfinal unit="pixels">90</yfinal>
</vector>


- as a physicist, I would actually like this less verbose XML-y, so I  
can plug in arrays:

<vector>
<initial unit="pixels">30,60</xinitial>
<final unit="pixels">@final</final>
</vector>

Or

<vector>
<length unit="pixels">40,$height</length>
</vector>



>   <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>


I don't like the tolerance being packaged like that. We should use  
response parameters, just like with numerical.

>
> 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 like, but again, I don't see the idea of tying this to objects.

How about named coordinates, which are internally treated like  
cartesian vectors:

>
>
> 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>


Hmmm ... I would like to plug in arrays.

- Gerd.