home *** CD-ROM | disk | FTP | other *** search
/ Beweegwijzer / beweegwijzer.iso / setup / _SETUP.1 / kennistest.js < prev    next >
Encoding:
Text File  |  2000-09-01  |  4.2 KB  |  121 lines

  1. var chosenVraag = -1;
  2. var vraagArray = new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
  3. var antwoordArray = new Array('','','','','','','','','','');
  4. var conclusieMode = 0;
  5.  
  6. var moduleData = new ActiveXObject("Microsoft.XMLDOM");
  7. moduleData.load("data/kennistest.xml");
  8. var moduleRoot = moduleData.documentElement;
  9.  
  10. function showPage() {
  11.   buildPage();
  12.   parent.goPage = 'kennistest.html';  
  13.   AppScreen.style.visibility = "visible";
  14.   }
  15.  
  16. function buildPage() {
  17.   styleRule = '<?xml version="1.0"?>';
  18.   styleRule += '<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">';
  19.   styleRule += '<xsl:template match="/">';
  20.   styleRule += '<xsl:apply-templates select="kennistest/text">';
  21.   styleRule += '<xsl:template>';
  22.   styleRule += '<xsl:copy>';
  23.   styleRule += '<xsl:apply-templates select="@* | * | comment() | pi() | text()"/>';
  24.   styleRule += '</xsl:copy>';
  25.   styleRule += '</xsl:template>';
  26.   styleRule += '</xsl:apply-templates>';
  27.   styleRule += '</xsl:template>';
  28.   styleRule += '</xsl:stylesheet>';
  29.  
  30.   style = new ActiveXObject("Microsoft.XMLDOM");
  31.   style.loadXML(styleRule);
  32.   
  33.   TextArea.innerHTML = moduleData.transformNode(style);
  34.   
  35.   Count = 0;
  36.   Aantal = moduleRoot.selectNodes("vraag").length-1;
  37.   while (Count < 10) {
  38.     theNumber = Math.round(Aantal * Math.random());
  39.     alreadyExists = false;
  40.     for (var i=0; i<Count; i++) {
  41.       if (vraagArray[i] == theNumber) alreadyExists = true;
  42.       }
  43.     if (alreadyExists != true) {
  44.       vraagArray[Count] = theNumber;
  45.       Count ++;
  46.       }
  47.     }
  48.  
  49.   vraagWriteString = '';
  50.   for (var i=0; i<vraagArray.length; i++) {
  51.     vraagWriteString += '<div id="VraagBtn" num="' + i + '" style="left:'+ (64+(i*50)) +'px">' + (i+1) + '</div>';
  52.     }
  53.   VraagBtnArea.innerHTML = vraagWriteString;  
  54.   }
  55.  
  56. function doVraag(n) {
  57.   chosenVraag = n;
  58.   TextArea.innerHTML = '<u>Vraag ' + (chosenVraag+1) + ' </u><p>' + moduleRoot.selectNodes("vraag")[(vraagArray[chosenVraag])].selectSingleNode("text").text;
  59.   if (antwoordArray[chosenVraag] == 'g') {
  60.     AntwoordBtn[0].src = 'images/bt_juist_2.bmp';
  61.     AntwoordBtn[1].src = 'images/bt_onjuist_0.bmp';
  62.     }
  63.   else if (antwoordArray[chosenVraag] == 'f') {
  64.     AntwoordBtn[0].src = 'images/bt_juist_0.bmp';
  65.     AntwoordBtn[1].src = 'images/bt_onjuist_2.bmp';
  66.     }
  67.   else {
  68.     AntwoordBtn[0].src = 'images/bt_juist_0.bmp';
  69.     AntwoordBtn[1].src = 'images/bt_onjuist_0.bmp';
  70.     }  
  71.   AntwoordBtn[0].style.visibility = 'inherit';
  72.   AntwoordBtn[1].style.visibility = 'inherit';  
  73.   }
  74.  
  75. function doAntwoord() {
  76.   styleRule = '<?xml version="1.0"?>';
  77.   styleRule += '<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">';
  78.   styleRule += '<xsl:template match="/">';
  79.   styleRule += '<xsl:apply-templates select="kennistest/vraag['+vraagArray[chosenVraag]+']/layout">';
  80.   styleRule += '<xsl:template>';
  81.   styleRule += '<xsl:copy>';
  82.   styleRule += '<xsl:apply-templates select="@* | * | comment() | pi() | text()"/>';
  83.   styleRule += '</xsl:copy>';
  84.   styleRule += '</xsl:template>';
  85.   styleRule += '</xsl:apply-templates>';
  86.   styleRule += '</xsl:template>';
  87.   styleRule += '</xsl:stylesheet>';    
  88.  
  89.   style = new ActiveXObject("Microsoft.XMLDOM");
  90.   style.loadXML(styleRule);
  91.   
  92.   FbkArea.innerHTML = '<p>' + ((antwoordArray[chosenVraag] == 'g')?'Goed geantwoord.</p>':'Fout geantwoord.</p>') + moduleData.transformNode(style);  
  93.   FbkArea.style.visibility = 'inherit';
  94.   FbkBtn.style.visibility = 'hidden';
  95.   
  96.   allesKlaar = true;
  97.   for (var i=0; i<antwoordArray.length; i++) {
  98.     if (antwoordArray[i] == '') allesKlaar = false;
  99.     }
  100.     
  101.   if (allesKlaar) {
  102.     FbkBtn.style.visibility = 'inherit';
  103.     conclusieMode = 1;
  104.     }
  105.   }
  106.   
  107. function doConclusie() {
  108.   foutCount = 0;
  109.   for (var i=0; i<antwoordArray.length; i++) {
  110.     if (antwoordArray[i] == 'f') foutCount ++;
  111.     }  
  112.   
  113.   for (var i=0; i<moduleRoot.selectNodes("fbk").length; i++) {
  114.     minCount = parseFloat(moduleRoot.selectNodes("fbk")[i].getAttribute("min"));
  115.     maxCount = parseFloat(moduleRoot.selectNodes("fbk")[i].getAttribute("max"));
  116.     if ((foutCount >= minCount) && (foutCount < maxCount)) {
  117.       FbkArea.innerHTML = moduleRoot.selectNodes("fbk")[i].text;
  118.       }
  119.     }  
  120.   conclusieMode = 2;
  121.   }