File: geogebra.input

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (268 lines) | stat: -rw-r--r-- 8,688 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
!!"list_of_things": object types treated by wims (to increase ? )
!!dans reply$i: objects list and formal condition in the order of the
!!construction...

!set anstype=yes
!set anstyle=dprompt
!set ans_require=geogebra,pari
!if $wims_read_parm=def
  !exit
!endif
!set ggblang=!getopt language in $(replyoption$i)
!default ggblang=$lang_choice
!default ggblang=$module_language
!set replyoption$i=!replace internal true by yes in $(replyoption$i)
!set noclue=!getopt idontknow in $(replyoption$i)
!set oef_js_submit=geogebra2wims()

!!! let the following tabulation
!set oef_applet_option=!replace internal $	$ by $\
$ in $inputsize
!set oef_applet_option=!replace internal ; by $\
$ in $oef_applet_option
!set oef_applet_option=!nonempty lines $oef_applet_option
!set Inputsize=!line 1 of $oef_applet_option
!set Inputsize=!replace internal x by , in $Inputsize
!set oef_applet_option=!line 2 to -1 of $oef_applet_option
!if width notin $oef_applet_option
  !set oef_applet_option=$oef_applet_option\
width=$(Inputsize[1])
!endif
!if height notin $oef_applet_option
  !set oef_applet_option=$oef_applet_option\
height=$(Inputsize[2])
!endif

!if enable3d isin $oef_applet_option
  !set enable3d=!getopt enable3d in $oef_applet_option
!endif

!set datapoint=data=thing+'='+it+','+x+','+y;
!set 3dcnt=4
!if $enable3d iswordof true yes
  !set coordz= z=mygbb.getZcoord(thing);\
z=(Math.round(z*Math.pow(10,prec)))/(Math.pow(10,prec));
  !set datapoint=data=thing+'='+it+','+x+','+y+','+z;
  !set 3dcnt=5
!endif

!read lang/geogebra.phtml.$ggblang

!set oef_applet_option=$oef_applet_option\
language=$ggblang

!set oef_answer_option$i=$oef_applet_option
!set number=!getopt number in $oef_applet_option
!default number=0

!readproc slib/geo2D/geogebra $oef_applet_option
!set out_applet=$slib_out

!readproc slib/geo2D/geogebracommand
!set oef_applet_command=$slib_out
!readproc slib/geo2D/geogebra $oef_applet_option
!readproc slib/geo2D/geogebraoption

!set oef_applet_option=$slib_out

!set maxobjects=!getopt max in $(replyoption$i)
!default maxobjects=10

!set precisionn=!getopt precision in $(replyoption$i)
!default precisionn=18

!set igno=!getopt ignore in $(replyoption$i)
!set igno=!replace internal & by , in $igno
!set igno=!makelist x:"1" for x in $igno
!set igno={$igno}

!! only objects beginning by the prefix given in the option "object_analysis"
!! will be analyzed
!set Ny_=!getopt object_analysis in $(replyoption$i)
!set Ny_=!nospace $Ny_
!if $Ny_!=$empty
  !set ny_=!charcnt $Ny_
  !set Ny=data.substr(0,$ny_)=="$Ny_"
!endif
!default Ny=data.substr(0,3)!="My_"
!default ny_=0
!! before it was data.indexOf('_') != 2
<script>
/*<![CDATA[*/
function dontknow(){
  var q='?';
  q=encodeURIComponent(q);
  var URL = '$wims_ref_name?session=$session&+module=$module&+cmd=reply&+reply$i='+q ;
  document.location.href = URL;
}

!!ici on ne peut prendre document.getElementById("applet$i")
!set mygbb=ggbApplet$number

window.onload = function() {
  preventSubmission('$mygbb');
}

/* Intercept the event 'keydown' on 'return' to avoid submitting the form. */
function preventSubmission(elementId){
  document.getElementById(elementId).addEventListener('keydown',function(e){
    var evt = e || window.event;
    //console.log(evt);
    if(evt.keyCode==13||evt.keyCode==10){
      evt.preventDefault();
    }
  });
}

function geogebra2wims() {
  var mygbb=$mygbb;
  var tot='';
  var ignore=$igno;
  var cond='';
  var test,test2,nbre;
  var a,b,c,d,e,f,g,h,n,x,y,p,max,r,s,t,i,it,whatisit,thing,listcnt,def,name,prec;
  var list_of_things = new Array();
  var debug=0;

  !!!!!!! WIMS !!!!!!!
  prec=$precisionn;
  ch=new String($mygbb.getXML());
  arr1=new String('<decimals val=\"'+prec+'\"');
  for ( i=0 ; i < 18 ; i++){
    dep1=new String('<decimals val=\"'+i+'\"');
    ch=ch.replace(dep1,arr1);
  }
  mygbb.setXML(ch);

  var data = new Array();
  var grec = new Array();

  !if $list_of_things=$empty
    !! look for all possible object names
    list_of_things=['point','line','ray','circle','segment','function','polynomial','conic','ellipse','hyperbola','parabola','vector','angle','conicpart','numeric','text','polygon','triangle','quadrilateral','pentagon','hexagon','boolean'];
  !endif
  !if $list_of_things=$empty and $enable3d==true
    list_of_things=['point'];
  !endif
  listcnt=list_of_things.length;

  grec=['alpha','beta','gamma','delta','epsilon','zeta','eta','theta',\
    'iota','kappa','lambda','mu','nu','xi','omicron','pi','rho','sigmaf',\
    'sigma','tau','upsilon','phi','khi','psi','omega'];

  var totalobject_count = 0;
  nbre=mygbb.getObjectNumber();
  for ( i=0 ; i < nbre ; i++){
    thing=mygbb.getObjectName(i);

    if (!(thing in ignore)) {
      whatisit=mygbb.getObjectType(thing);
      !!return the command in english because of the boolean
      def=mygbb.getCommandString(thing,false);
      if (def=='') {def=whatisit};
      /*alert('getobjetname='+thing+'||getObjettype='+whatisit+'||command='+def+'||valuestring='+mygbb.getValueString(thing));*/
      !!replace the greek names of the angles
      test=encodeURIComponent(thing);
      test=decodeURIComponent(test);
      if(test.substr(0,$ny_)=="$Ny_"){name=test.charCodeAt($ny_);}else{name=test.charCodeAt(0);}
      if (name>944){
        name=name-945;
        test='$Ny_'+grec[name];
      }
      for ( p=0 ; p < listcnt ; p++){
        !! walk trough the selection of objects we are interested in
        !! defined in Wimsvariable $list_of_things='point','circle','polygon'

        it=list_of_things[p];
        if (whatisit==it){
          data=mygbb.getValueString(thing);
          data=encodeURIComponent(data);
          data=data.replace(/%C2%B/g,'^');
          data= decodeURIComponent(data);
          !! back to normal...
          if ($Ny){
            !! check e.g. no special tags like My_A My_B used to mask a *.ggb objects
            !! or Ny_ used to analyse the *.gbb objects
            totalobject_count=totalobject_count + 1;
            if (it=='point'||it=='vector'){
              x=mygbb.getXcoord(thing);
              x=(Math.round(x*Math.pow(10,prec)))/(Math.pow(10,prec));
              y=mygbb.getYcoord(thing);
              y=(Math.round(y*Math.pow(10,prec)))/(Math.pow(10,prec));
              $coordz
              $datapoint
            }
            else if (it=='circle'||it=='line'||it=='polynomial'||it=='conic'||it=='parabola'||it=='ellipse'||it=='hyperbola'||it=='ray')
            !! c:(x - 5.73)^2 + (y - 1.53)^2 = 16,
            {
              t=data.length;
              c=data.indexOf(':');
              d=data.indexOf('=');
              e=data.substring(c+1,d-1);
              f=data.substring(d+1,t);
              data=thing+'='+it+','+e+'-(('+f+'))';
            }
            else if (it=='angle'){
              !!  on enleve le 'degre' ('^0')
              data=encodeURIComponent(data);
              data=data.replace(/%5E0/g,'');
              data=decodeURIComponent(data);
              !!on ecrit les noms grecs en toutes lettres
              if($Ny){na=data.charCodeAt($ny_);}else{na=data.charCodeAt(0);}
              data=data.split('=');
              name=data[0];
              data=data[1];
              if(na>944){
                na=na-945;
                name='$Ny_'+grec[na];
              }
              data=name+'='+it+','+data;
            }
            else if (it=='text'||it=='numeric'||it=='segment'||it=='function'||it=='conicpart'||it=='boolean'){
              data=data.split('=');
              name=data[0];
              data=data[1];
              data=name+'='+it+','+data;
            }
            else if (it=='polygon'||it=='triangle'||it=='quadrilateral'||it=='pentagon'||it=='hexagon'){
              data=data.split('=');
              name=data[0];
              data=data[1];
              data=name+'=polygon,'+data;
            }
            !! here we produce the URL string 'tot'
            tot=tot + data + '&&' ;
            cond=cond+test+'='+def+'&&';
          }
        }
      }
    }
  }
  t=tot.length;
  tot=tot.substr(0,t-2);
  t=cond.length;
  cond=cond.substr(0,t-2);
  tot=tot+';'+cond;
  !! use encoding on math '+' signs
  tot=tot.replace(/undefined/g, '');
  !!    tot= encodeURIComponent( tot );
  !! replace the strange unicode for ^2
  tot=tot.replace(/%C2%B/g,'^');

  if (totalobject_count == 0){
  }
  else if ( totalobject_count > $maxobjects )
  {
    alert('$inp0 '+ $maxobjects +' $inp1');
  }
  else
  {
    if (debug=='1') {alert('You are about to send a reply:'+tot);}
    document.getElementById('reply$i').value = tot;
  }
}

/*]]>*/
</script>
<input type="hidden" name="reply$i" id="reply$i" value="">
$out_applet