Subversion Repositories wimsdev

Rev

Rev 3658 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <html>
  2.     <body>
  3.         <font size="-2">
  4.         The next drawing details can be retreived:
  5.         <ul>
  6.             <li>
  7.                 point , send as "<tt>point=point_name:x=x_value:y=y_value \n</tt>"
  8.             </li>
  9.             <li>
  10.                 line  , <tt>y=slope*x+contant</tt> is send as "<tt>line=line_name:slope=a_number:constant=a_number:affine \n</tt>"
  11.                 <br> if the line is vertical is will be send as "<tt>line=line_name:x=a_number:vertical \n</tt>"
  12.                 <br> if the line is horizontal is will be send as "<tt>line=line_name:y=a_number:horizontal \n</tt>"
  13.             </li>
  14.             <li>
  15.                 segment , send as "<tt>segment=segment_name:x=a_number:y=a_number:x=a_number:y=a_number:length=a_number \n</tt>"
  16.             </li>
  17.             <li>
  18.                 fixedcircle , send as "<tt>fixedcircle=fixed_circle_name:x=a_number:y=a_number:r=a_number \n</tt>"
  19.             </li>
  20.             <li>
  21.                 circle , send as "<tt>circle=circle_name:x=a_number:y=a_number:r=a_number</tt> \n"
  22.             </li>
  23.             <li>
  24.                 angle , send as "<tt>angle=angle_name:value=a_number</tt> \n" [degrees or radians depending on appletparam]
  25.             </li>
  26.             <li>
  27.                 area , send as "<tt>area=area_name:x=a_number:y=a_number..... :area=a_number \n</tt>"
  28.             </li>
  29.             <li>
  30.                 function, send as "<tt>function= name : 4*x^2</tt>"
  31.             </li>
  32.             <li>
  33.                 freehand_drawing, freehand_point:noname:x=a_number:y=a+number\n</tt>"
  34.             </li>
  35.         </ul>
  36.         The three applets public_functions to communicate with javascript :
  37.         <ol>
  38.         <li>
  39.             <tt>getConstruction()</tt> retreives the xml-construction string [original Zirkel]
  40.         </li>
  41.         <li> <tt>getDrawing("object","name_of_object");</tt><br>
  42.         or with multiple occurances of an object:<tt>getDrawing("object","name1,name2,name3,name4,...");</tt>
  43.         <br>All objects <u>must be named correctly</u> by the student<br>
  44.         Multiple Objects of the same type but non-requested name will be ignored.<br>
  45.         If an object/name combination is not present, the student will receive an browser alert message.
  46.         </li><li> <tt>getAllObjects();</tt> this function retreives all objects drawn in the construction,<br>
  47.         except object with prefix "my_"...like in "my_circle1".
  48.         </ol>
  49.         <hr>
  50.         These example javascript code could be used to produce a working WIMS-exercises:<p>
  51.         <pre><tt>
  52.             function ReadApplet_I(){
  53.                 &lt;!-- this array should be produced using WIMS variables... --&gt;;
  54.                 var list_of_objects=["freehand_drawing,"noname"","point,p1,p2,p3","line,l1,l2","function","area,poly1","angle,a1","circle","fixedcircle","segment"];
  55.                 var count=0;var reply=new Array();var data;var tmp;
  56.                 for(var p=0;p&lt;list_of_objects.length;p++){
  57.                     tmp=list_of_objects[p].split(',');
  58.                     if(tmp[0].length&gt;0){
  59.                         for(var s=1;s&lt;tmp.length;s++){
  60.                             data=document.applets[0].getDrawing(tmp[0],tmp[s]);
  61.                             if(data.indexOf("error")!=-1){
  62.                                 alert("Your answer will not be send...\nthe next object could not be detected in your drawing...\n\n:"+data); return;
  63.                             }
  64.                             else
  65.                             {
  66.                                 reply[count]=data;
  67.                                 count++;
  68.                             }
  69.                         }
  70.                     }
  71.                 }
  72.             }
  73.         <hr>
  74.             function ReadApplet_II(){                                                                                                      
  75.                &lt;!-- this function retreives all construction details --&gt;                                                                  
  76.                &lt;!-- excluded objects with name prefix "my_"        --&gt;                                                                  
  77.                var data=document.getElementById("CaR").getAllObjects().split(',');                                                        
  78.                var cnt=0;var reply=new Array();                                                                                          
  79.                for(var p=0;p&lt;data.length;p++){                                                                                            
  80.                    reply[cnt]=data[p].toString();                                                                                        
  81.                    cnt++;                                                                                                                
  82.                }                                                                                                                          
  83.                alert("the reply is:\n"+reply);                                                                                            
  84.            }                                                                                                                              
  85.  
  86.         </tt>
  87.         </pre>
  88.         </font>
  89.         <script language="javascript" type="text/javascript">
  90.             function ReadApplet_I(){
  91.                 <!-- this example array could be filled by WIMS -->
  92.                 var list_of_objects=["point,p1,p2,p3","line,l1,l2","function","area,poly1","angle,a1","circle","fixedcircle","segment"];
  93.                 var count=0;var reply=new Array();var data;var tmp;
  94.  
  95.                 for(var p=0;p<list_of_objects.length;p++){
  96.                     tmp=list_of_objects[p].split(',');
  97.                     if(tmp[0].length>0){
  98.                         for(var s=1;s<tmp.length;s++){
  99.                             <!-- the applet function : getDrawing("string","strings") -->
  100.                             <!-- the applet function : getDrawing("object","name_of_object") -->
  101.                             <!-- or with multiple occurances of an object -->
  102.                             <!--  getDrawing("object","name1,name2,name3,name4,...") -->
  103.                             data=document.getElementById("CaR").getDrawing(tmp[0],tmp[s]);
  104.                             if(data.indexOf("error")!=-1){
  105.                                 alert("Your answer will not be send...\nthe next object could not be detected in your drawing...\n\n:"+data); return;
  106.                             }
  107.                             else
  108.                             {
  109.                                 reply[count]=data;
  110.                                 count++;
  111.                             }
  112.                         }
  113.                     }
  114.                    
  115.                
  116.                 }
  117.                 alert("the reply is:\n"+reply);
  118.             }                                                                                                                                          
  119.  
  120.            function ReadApplet_II(){                                                                                                      
  121.                <!-- this function retreives all construction details -->                                                                  
  122.                <!-- excluded objects with name prefix "my_"          -->                                                                  
  123.                var data=document.getElementById("CaR").getAllObjects().split(',');                                                        
  124.                var cnt=0;var reply=new Array();                                                                                          
  125.                for(var p=0;p<data.length;p++){                                                                                            
  126.                    reply[cnt]=data[p].toString();                                                                                        
  127.                    cnt++;                                                                                                                
  128.                }                                                                                                                          
  129.                alert("the reply is:\n"+reply);                                                                                            
  130.            }    
  131.            
  132.             function ReadApplet_III(){
  133.                 <!-- this is the original getConstruction() of Zirkel -->
  134.                 var data=document.getElementById("CaR").getConstruction();
  135.                 alert(data.toString());
  136.             }  
  137.         </script>
  138.         <table>
  139.             <tr>
  140.             <td>
  141.                 Get all objects in the drawing:<br>
  142.                 <input type="button" onclick="javascript:ReadApplet_II()" name="TEST_II" value="getAllObjects();">
  143.                 <hr>
  144.                 or ...
  145.                 Get the xml-string from the original public function:<br>
  146.                 <input type="button" onclick="javascript:ReadApplet_III()" name="TEST_II" value="getConstruction();">
  147.                 <hr>
  148.                 or ...
  149.                 <ol>
  150.                     <li>Draw 3 points named p1,p2,p3</li>
  151.                     <li>Draw 2 lines named l1,l2</li>
  152.                     <li>Draw an area named poly1</li>
  153.                     <li>Draw an angel named a1</li>
  154.                 </ol>
  155.                 <br>
  156.                 <input type="button" onclick="javascript:ReadApplet_I()" name="TEST_I" value="getDrawing();">
  157.             </td>
  158.             <td>
  159.                 <applet id="CaR" codebase="dist" archive="zirkel.jar" code="rene.zirkel.ZirkelApplet.class" WIDTH="400" HEIGHT="400" ALIGN="CENTER" MAYSCRIPT>
  160.                     <!-- <param name="file" value="http://localhost/1.zir"> -->
  161.                     <!-- <param name="background_image" value="http://localhost/test.jpg"> -->
  162.                     <param name="language" value="fr">
  163.                     <!-- if axes/grid is activated -->
  164.                     <param name="x_axis_text" value="my x-axis"><!-- default "x-axis" ; unicodesymbols allowed (if OS permits) &#8594; &#8660; -->
  165.                     <param name="y_axis_text" value="this is my y-axis text"><!-- default "y-axis" -->
  166.                     <param name="y_axis_text_vertical" value="true"><!-- default "false" -->
  167.                     <param name="decimals" value="2"><!-- precision in answer send to WIMS ;useful in large constructuons...to limit query string -->                                                                                                  
  168.                    
  169.                     <!-- some more params ;there are many more defined -->
  170.                     <param name="nomousezoom" value="false">
  171.                     <param name="minfontsize" value="14">
  172.                     <param name="smallicons" value="what_ever"> <!-- size 32 ; remove param-tag for lager icons  size 64 -->
  173.                     <param name="grid" value="what_ever"> <!-- if grid param-tag is present, show grid ;value is non-important  -->
  174.                     <param name="snap" value="yes"> <!-- yes/true : if grid is present, snap to grid [left side oriented]  -->                                                                                          
  175.                     <param name="editdigits" value="2">                                                                                                  
  176.                     <param name="displaydigits" value="2">                                                                                                  
  177.                     <param name="angledigits" value="3">                                                                                                  
  178.                     <param name="color" value="255,255,255">                                                                                                  
  179.                     <param name="tools" value="line point area angle circle segment function ray">                                                                
  180.                     <param name="options" value="back grid delete mouse">                                                                                                      
  181.                     <param name="style" value="full">
  182.                     No java
  183.                 </applet>
  184.             </td>
  185.             </tr>
  186.         </table>    
  187.    </body>
  188. </html>
  189.