// zahlenordnen.js
// erstellt am 15. Juli 2006
// zuletzt geändert am 15. Juli 2006
// Autor: Andreas Meier, Weiden i.d.OPf.
// alle Rechte liegen beim Autor

var anzahl =0;
var score =0;
var geloest =0;
var gesucht =0;
var pfeila =0;var pfeill =0;var pfeilm =0;var pfeiln =0;var pfeilo =0;var pfeilw =0;


function reset()
{

document.Para.vx.value ="";
document.Para.xt1.value ="";
document.Para.wertung.value ="";
applet = document.applets[0];
applet.evalCommand("A = (-2,10)");
applet.evalCommand("L = (-2,9)");
applet.evalCommand("M = (-2,8)");
applet.evalCommand("N = (-2,7)");
applet.evalCommand("O = (-2,6)");
applet.evalCommand("W = (-2,5)");
applet.setVisible("A", true);
applet.setVisible("L", true);
applet.setVisible("M", true);
applet.setVisible("N", true);
applet.setVisible("O", true);
applet.setVisible("W", true);

}

function zufall(min, max, ohne) {
  var zufallszahl;
  do {
  zufallszahl = Math.round(min + Math.random() * (max - min));
  } while (zufallszahl == ohne);
  return zufallszahl;
}


function neueAufgabe() {
zahl = new Array();
for (i = 1; i<7 ; i++)  zahl[i] = 0;
wert = new Array();
for (i = 1; i<7 ; i++)  wert[i] = 0;

startzahl = Math.pow(10,zufall(4,6))+zufall(1,11)*Math.pow(10,zufall(2,3))+zufall(0,9);
divisor = Math.pow(10,zufall(1,2));

for (i = 1; i<7 ; i++) {
        vorzeichen = zufall(1,2);
        zahl[i] = zufall(2,20);
        if (vorzeichen == 1) zahl[i] = (startzahl - zahl[i])/divisor;
        else zahl[i] = (startzahl + zahl[i])/divisor;
}
for (i = 1; i<7; i++){
for (j =i+1; j<7;j++){
if (zahl[i] == zahl[j]) zahl [j] = zahl[j]+(zufall(1,3)*zufall(1,25))/10;
}
}

// Sortieren

        for (i = 1; i<=6; i++) {
                for (j = 6; j>=i; j--) {
                        if (zahl[j-1]>zahl[j]) {
                                x = zahl[j-1];
                                zahl[j-1] = zahl[j];
                                zahl[j] = x;
                        }
                }
        }

// ende Sortieren

einlegen = zufall (1,4)
if (einlegen == 1) {

applet.evalCommand("n = "+String(zahl[1]));
applet.evalCommand("i_1 = "+String(zahl[3]));
applet.evalCommand("l_1 = "+String(zahl[4]));
applet.evalCommand("m_1 = "+String(zahl[6]));
applet.evalCommand("n_1 = "+String(zahl[5]));
applet.evalCommand("o_1 = "+String(zahl[2]));
ax = 4; ay = 5;
lx = 4; ly = 7;
mx = 4; my = 8;
nx = 4; ny = 10;
ox = 4; oy = 9;
wx = 4; wy = 6;

}


if (einlegen == 2) {

applet.evalCommand("n = "+String(zahl[5]));
applet.evalCommand("i_1 = "+String(zahl[3]));
applet.evalCommand("l_1 = "+String(zahl[1]));
applet.evalCommand("m_1 = "+String(zahl[6]));
applet.evalCommand("n_1 = "+String(zahl[2]));
applet.evalCommand("o_1 = "+String(zahl[4]));
ax = 4; ay = 9;
lx = 4; ly = 7;
mx = 4; my = 5;
nx = 4; ny = 10;
ox = 4; oy = 6;
wx = 4; wy = 8;}


if (einlegen == 3) {

applet.evalCommand("n = "+String(zahl[3]));
applet.evalCommand("i_1 = "+String(zahl[2]));
applet.evalCommand("l_1 = "+String(zahl[4]));
applet.evalCommand("m_1 = "+String(zahl[1]));
applet.evalCommand("n_1 = "+String(zahl[6]));
applet.evalCommand("o_1 = "+String(zahl[5]));
ax = 4; ay = 7;
lx = 4; ly = 6;
mx = 4; my = 8;
nx = 4; ny = 5;
ox = 4; oy = 10;
wx = 4; wy = 9;}

if (einlegen == 4) {

applet.evalCommand("n = "+String(zahl[5]));
applet.evalCommand("i_1 = "+String(zahl[6]));
applet.evalCommand("l_1 = "+String(zahl[2]));
applet.evalCommand("m_1 = "+String(zahl[1]));
applet.evalCommand("n_1 = "+String(zahl[3]));
applet.evalCommand("o_1 = "+String(zahl[4]));
ax = 4; ay = 9;
lx = 4; ly = 10;
mx = 4; my = 6;
nx = 4; ny = 5;
ox = 4; oy = 7;
wx = 4; wy = 8;}


}


function schreibe()
     {

geloest = 0;
reset();
neueAufgabe();
document.Para.vx.value = "Ziehe den linken Pfeil an die richtige Stelle!";
document.Para.xt1.value ="Beachte, dass der . das , sein soll.";
pfeila =0;pfeill =0; pfeilm =0; pfeiln =0; pfeilo =0; pfeilw =0;
}

function pruefe()
{

applet = document.applets[0];

var yA = applet.getYcoord("A");
var yL = applet.getYcoord("L");
var yM= applet.getYcoord("M");
var yN = applet.getYcoord("N");
var yO = applet.getYcoord("O");
var yW = applet.getYcoord("W");
var xA = applet.getXcoord("A");
var xL = applet.getXcoord("L");
var xM= applet.getXcoord("M");
var xN = applet.getXcoord("N");
var xO = applet.getXcoord("O");
var xW = applet.getXcoord("W");




if (geloest ==0) {

if (ay == yA && xA == 4) {
    if (pfeila == 0) score = score + 5;
    pfeila = 1;
    applet.setVisible("A", false);}
else {
pfeila = 0; score = score - 10; if (score <0) score = 0;
applet.evalCommand("A = (-2,10)");
}

if (ly == yL && xL == 4) {
    if (pfeill == 0) score = score + 5;
    pfeill = 1;
    applet.setVisible("L", false);}
else {
pfeill = 0; score = score - 10; if (score <0) score = 0;
applet.evalCommand("L = (-2,9)");
}

if (my == yM && xM == 4) {
    if (pfeilm == 0) score = score + 5;
    pfeilm = 1;
    applet.setVisible("M", false);}
else {
pfeilm = 0; score = score - 10; if (score <0) score = 0;
applet.evalCommand("M = (-2,8)");
}

if (ny == yN && xN == 4) {
    if (pfeiln == 0) score = score + 5;
    pfeiln = 1;
    applet.setVisible("N", false);}
else {
pfeiln = 0; score = score - 10; if (score <0) score = 0;
applet.evalCommand("N = (-2,7)");
}

if (oy == yO && xO == 4) {
    if (pfeilo == 0) score = score + 5;
    pfeilo = 1;
    applet.setVisible("O", false);}
else {
pfeilo = 0; score = score - 10; if (score <0) score = 0;
applet.evalCommand("O = (-2,6)");
}

if (wy == yW && xW == 4) {
    if (pfeilw == 0) score = score + 5;
    pfeilw = 1; applet.setVisible("W", false);}
else {
pfeilw = 0; score = score - 10; if (score <0) score = 0;
applet.evalCommand("W = (-2,5)");
}


if (pfeila == 1 && pfeill == 1 && pfeilm == 1 &&
    pfeiln == 1 && pfeilo == 1 && pfeilw == 1)

{geloest =1;
loestext1 = "Ausgezeichnet! \nAlle Zahlen richtig geordnet!";
}
else loestext1 = "Nicht alle Zahlen sind richtig! \nVerbessere deine Anordnung!";
}
else
{
loestext1 = "Die Aufgabe war schon gelöst! \nSchwindeln geht nicht!";
score = score - 15; if (score <0) score = 0;
}



ausgabe = loestext1;
ausgabe = ausgabe+"\n Aktueller Stand: "+String(score)+" Punkte.";
document.Para.wertung.value = ausgabe;
}


function auswerten() {

var punkte = score;
if (punkte < 1) punkte = 1;
// Zurücksetzen der Punkte auf Ausgangswert


score =0;
geloest =1;
document.Para.vx.value ="";
document.Para.xt1.value ="";

text1 ="";
text2 ="Deine Punkte werden nun übertragen. \n";
text3 ="Damit werden sie hier gelöscht. \n";
text4="Du beginnst also wieder bei 0 Punkten.";
text5="";
text = text1+text2+text3+text4+text5;
document.Para.wertung.value = text;

/* Achtung muss für jede Datei manuell angepasst werden */
/*                     Anfang                           */
var aufgabenart="Dezimalzahlen ordnen";
var datnam= "highsqlpost67ww.php";
uebertrag = "<form name = 'eingabe' action ='../../../Mathematik/"+datnam+"' method ='post'>";
auswertung(aufgabenart,punkte,uebertrag);
/*                     Ende                           */
}


