The next drawing details can be retreived:
-
point , send as "point=point_name:x=x_value:y=y_value \n"
-
line , y=slope*x+contant is send as "line=line_name:slope=a_number:constant=a_number:affine \n"
if the line is vertical is will be send as "line=line_name:x=a_number:vertical \n"
if the line is horizontal is will be send as "line=line_name:y=a_number:horizontal \n"
-
segment , send as "segment=segment_name:x=a_number:y=a_number:x=a_number:y=a_number:length=a_number \n"
-
fixedcircle , send as "fixedcircle=fixed_circle_name:x=a_number:y=a_number:r=a_number \n"
-
circle , send as "circle=circle_name:x=a_number:y=a_number:r=a_number \n"
-
angle , send as "angle=angle_name:value=a_number \n" [degrees or radians depending on appletparam]
-
area , send as "area=area_name:x=a_number:y=a_number..... :area=a_number \n"
-
function, send as "function= name : 4*x^2"
-
freehand_drawing, freehand_point:noname:x=a_number:y=a+number\n"
The three applets public_functions to communicate with javascript :
-
getConstruction() retreives the xml-construction string [original Zirkel]
- getDrawing("object","name_of_object");
or with multiple occurances of an object:getDrawing("object","name1,name2,name3,name4,...");
All objects must be named correctly by the student
Multiple Objects of the same type but non-requested name will be ignored.
If an object/name combination is not present, the student will receive an browser alert message.
- getAllObjects(); this function retreives all objects drawn in the construction,
except object with prefix "my_"...like in "my_circle1".
These example javascript code could be used to produce a working WIMS-exercises:
function ReadApplet_I(){
<!-- this array should be produced using WIMS variables... -->;
var list_of_objects=["freehand_drawing,"noname"","point,p1,p2,p3","line,l1,l2","function","area,poly1","angle,a1","circle","fixedcircle","segment"];
var count=0;var reply=new Array();var data;var tmp;
for(var p=0;p<list_of_objects.length;p++){
tmp=list_of_objects[p].split(',');
if(tmp[0].length>0){
for(var s=1;s<tmp.length;s++){
data=document.applets[0].getDrawing(tmp[0],tmp[s]);
if(data.indexOf("error")!=-1){
alert("Your answer will not be send...\nthe next object could not be detected in your drawing...\n\n:"+data); return;
}
else
{
reply[count]=data;
count++;
}
}
}
}
}
function ReadApplet_II(){
<!-- this function retreives all construction details -->
<!-- excluded objects with name prefix "my_" -->
var data=document.getElementById("CaR").getAllObjects().split(',');
var cnt=0;var reply=new Array();
for(var p=0;p<data.length;p++){
reply[cnt]=data[p].toString();
cnt++;
}
alert("the reply is:\n"+reply);
}