www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25

Thread: JavaScript Quiz works in IE, FF, Chrome but not Safari

  1. #16
    Join Date
    Apr 2012
    Location
    Porstmouth, NH
    Posts
    20
    lol, in my book plumbers are experts and make a nice living!

    You have been generous with your time and I appreciate it. This function is very close to working and I believe the "parse" is causing an issue because it is an actual JavaScript method so perhaps the JS engine is Safari is upset that it is being declared as a variable in this function.

    Plus, the actual debugging error in Safari says "Can't find variable: parse"

    So I tried changing the name (to "parced" and "place" but it still says it can't find that variable.

    I then declared it as a variable, var parsed; (undefined), but same result.

  2. #17
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    try this one (no coockie engaged):
    Attached Files Attached Files
    Last edited by Padonak; 05-01-2012 at 01:44 PM.

  3. #18
    Join Date
    Apr 2012
    Location
    Porstmouth, NH
    Posts
    20

    Thumbs up

    You are a master Plumber! That worked wonderfully on Safari as well as on the iPad! Fantastic!

    You made my week! As geeky as this may sound, I am going to spend the rest of the afternoon studying what you have done and hopefully start my JavaScript apprenticeship in the shadow of such a great plumber (yes, I am actually this corny in real life!).

    And no cookie is used? That's a lot for me to learn!

    Thank you Padonak!

    . . . and as for your English, it's pretty darn good, better than many of my co-workers (I am french canadian but went to English schools).

    I'd love to buy you a beer! subquark at gmail

  4. #19
    Join Date
    Apr 2012
    Location
    Porstmouth, NH
    Posts
    20
    lol on the "burn in hell!" =D

  5. #20
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    lol )) i can explain every line to you there's no need to waste time on it )) so wait for the explanations <wink>

    p.s. i do not drink at all ))))))))))

  6. #21
    Join Date
    Apr 2012
    Location
    Porstmouth, NH
    Posts
    20
    That would be great! And what a neat JavaScript trick you did for the images! =)

    I gave up drinking two years ago, the only thing I miss is the ritual of having a vodka martini on a Friday evening but it's all good! And I sleep much better too!

    Thanks again, and if you do write up an explanation, I'd love it.

    If you have a blog, I think you'd get traffic over this one - we do eLearning and have left Flash behind. We needed some form of low level assessment and can't count on having any server-side scripting available, so this simple quiz was okay for us. Separating the answers into a separate JS file was good enough because if our users figured that out, they should do well on the quizzes! =)

    I searched for a good week on something like this - JS, XML, AJAX, JQuery, anything at all and most solutions were poor. Plus it has to be HTML5 for us and work on almost anything.

    Your code allows for that and I think many other corporate eLearning departments are in the same boat.

    Not able to use SQL or a scripting language really limits this for us (on my own time I do a bit in MySQL, Apache, PHP for http://simonastick.com ).

    Thanks again Padonak, you are truly appreciated.

  7. #22
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    check mail ))

    by the way, i think it is possible to build the first array (correct answers) so that it will not be easily seen in the code to confuse cheaters
    Last edited by Padonak; 05-01-2012 at 04:56 PM.

  8. #23
    Join Date
    Apr 2012
    Location
    Porstmouth, NH
    Posts
    20
    A secret way to build the array? Now you have aroused my curiosity! This could be handy if it doesn't confuse me as how to assign those right answers!

    wow, I just searched JavaScript obfuscation and holy cow! Lots of tools out there! I will exoplore some and see what I find, thanks!
    Last edited by subQuark; 05-03-2012 at 10:27 AM. Reason: added info

  9. #24
    Join Date
    Apr 2012
    Location
    Porstmouth, NH
    Posts
    20
    I think I may just do the following which will be a little confusing but not hard.

    Our target audience is pretty good about not cheating and this quizzing does not impact their job and is offered as a self-guidance tool.

    Making two arrays of odd and even answers and concatenating them will work for us (latin terms for odd and even used):

    var impar = new Array('a','c','b','b','b');
    var etiam = new Array('a','a','b','d','a');
    var answers = impar.concat(etiam);

  10. #25
    Join Date
    Feb 2014
    Posts
    1

    Red face How can I remove the alert message with counting the w's and r's

    Hi Padonak,

    your help for subQuark helped me also a lot with my quiz.
    Everything works fine,a lso on Safari etc. but I can't get out your alerts. If I remove it the script doesn't work.

    Here is my code:
    Code:
    <script type="text/javascript">
    // src="scripts/quizconfig.js"
    // JavaScript Document
    
    // answers to each
    var correct=['c','a','c','b','a','c','c','b','b','b'];
    var answers=[];
    ///////////////////////////////
    // quiz function
    ///////////////////////////////
    function gradeit(){
    answers.length=0;
    for(var i=0;i<correct.length;i++){
    var radios=eval("document.myquiz.question"+(i+1)),current='';
    for(var k=0;k<radios.length;k++){
    if(radios[k].checked==true){
    var val=radios[k].value;
    current=(val==correct[i])?'r':'w';
    }
    else{continue;}
    }
    if(current==''){current='w';}
    answers.push(current);
    }
    
    var r=0,w=0,ratio=0;
    for(var z=0;z<answers.length;z++){
    if(answers[z]=='r'){r++;}
    else{w++;}
    }
    ratio=r*100/answers.length;
    if(ratio<1){alert('Sie haben noch keine Frage richtig beantwortet! Bitte machen Sie das Quiz noch einmal!');}
    else{
    var str='?a='+answers+'&r='+ratio; 
    location.href='results.htm'+str;
    }
    }
    </script>
    
    
    </head>
    
    <body>
    
    <!--Comments on configuring quiz script-->
    <!--Change the questions below any way you want, but make note of the following:-->
    <!--1) Perserve the <FORM> tags -->
    <!--2a) Inside each radio button, use the VALUE attribute to denote each question's choices: "a", "b", "c" etc.-->
    <!--2b) Inside each radio button, use the NAME attribute to denote which question the button belongs to ("question1", "question2" etc-->
    <!--3) Script supports unlmited # of questions. Be sure to edit .js file to enter corresponding solutions-->
    
    <div>
    <form method="POST" name="myquiz">
      <h2>Datenschutz Online Test</h2><br>
    
      <div class="qheader">Frage 1: Wer oder was schütz der Datenschutz?</div>
    <div>
    <input type="radio" value="a" name="question1">&nbsp;&nbsp;Elektronisch gespeicherte Daten<br>
    <input type="radio" value="b" name="question1">&nbsp;&nbsp;Stellen vor dem Zugriff von Hackern<br>
    <input type="radio" value="c" name="question1">&nbsp;&nbsp;Persönlichkeitsrechte<br>
    </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 2: Über die Verwendung der eigenen Daten bestimmt ...</div>
    <div>
    <input type="radio" value="a" name="question2">&nbsp;&nbsp;der oder die Betroffene.<br>
    <input type="radio" value="b" name="question2">&nbsp;&nbsp;die verantwortliche Leitung der Stelle (Amt, Diakonische Einrichtung, Firma), die die Daten gespeichert hat. <br>
    <input type="radio" value="c" name="question2">&nbsp;&nbsp;je nach Sachlage der oder die Betroffene bzw. die verantwortliche Stelle. <br>
    </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 3: Anschriften ... </div>
    <div>
    <input type="radio" value="a" name="question3">&nbsp;&nbsp;sind freie Daten. <br>
    <input type="radio" value="b" name="question3">&nbsp;&nbsp;sind Daten, über deren Verwendung datenverarbeitende Stellen nach sorgfältiger Prüfung selbst bestimmen dürfen.<br>
    <input type="radio" value="c" name="question3">&nbsp;&nbsp;unterliegen wie alle anderen Daten ebenso den Datenschutzbestimmungen. <br>
    </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 4: Datensicherheit ...</div>
    <div>
    <input type="radio" value="a" name="question4">&nbsp;&nbsp;wird ausschließlich durch von der Stelle zu treffende technische Maßnahmen hergestellt. <br>
    <input type="radio" value="b" name="question4">&nbsp;&nbsp;muss auch von der Mitarbeiterschaft umgesetzt werden. <br>
    <input type="radio" value="c" name="question4">&nbsp;&nbsp;ist Sache der auf der Stelle eingesetzten Programmen. <br>
    </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 5: Wenn vorhandene personenbezogene Daten für andere Zwecke verwendet werden sollen, ... </div>
    <div>
    <input type="radio" value="a" name="question5">&nbsp;&nbsp;muss geprüft werden, ob es dazu eine Rechtsgrundlage gibt. <br>
    <input type="radio" value="b" name="question5">&nbsp;&nbsp;muss immer eine Einwilligung eingeholt werden. <br>
    <input type="radio" value="c" name="question5">&nbsp;&nbsp;ist dies zulässig, wenn sie rechtmäßig erhoben und gespeichert wurden. <br>
    </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 6: Maßnahmen zum Datenschutz müssen getroffen werden, ... </div>
    <div>
    <input type="radio" value="a" name="question6">&nbsp;&nbsp;wenn ein Risiko für die Betroffenen absehbar ist. <br>
    <input type="radio" value="b" name="question6">&nbsp;&nbsp;wenn Betroffene ein Risiko geltend gemacht haben, von dem sie betroffen sind. <br>
    <input type="radio" value="c" name="question6">&nbsp;&nbsp;egal ob Risiken erkennbar sind oder nicht. <br>
    </div>
    
    <br><br>
    <div class="qheader">
    Frage 7: Wofür besteht Auskunftsrecht? </div>
    <div>
    <input type="radio" value="a" name="question7">&nbsp;&nbsp;Es gilt nur für Daten in Akten. <br>
    <input type="radio" value="b" name="question7">&nbsp;&nbsp;Es gilt nur für elektronisch gespeicherte Daten. <br>
    <input type="radio" value="c" name="question7">&nbsp;&nbsp;Es gilt für beides.<br>
    </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 8: Nicht geschäftsfähige Personen (Kinder, geistig Behinderte) ... </div>
    <div>
    <input type="radio" value="a" name="question8">&nbsp;&nbsp;haben kein Selbstbestimmungsrecht hinsichtlich der Verwendung ihrer Daten. <br>
    <input type="radio" value="b" name="question8">&nbsp;&nbsp;haben dieses Recht in soweit, wie sie Einsicht in die Folgen haben. <br>
    <input type="radio" value="c" name="question8">&nbsp;&nbsp;haben zwar Anspruch auf Datenschutz, es entscheidet aber der Betreuer, die Betreuerin.
    </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 9: Ist eine Person durch eine Datenverarbeitung geschädigt worden und erhebt Schadensersatzforderungen ... </div>
    <div>
    <input type="radio" value="a" name="question9">&nbsp;&nbsp;muss sie einigermaßen plausibel darlegen, dass die verarbeitende Stelle einen Fehler gemacht hat. <br>
    <input type="radio" value="b" name="question9">&nbsp;&nbsp;muss die datenverarbeitende Stelle nachweisen, dass sie keinen Fehler gemacht hat. <br>
    <input type="radio" value="c" name="question9">&nbsp;&nbsp;stellt ein Gericht fest, wer inwieweit verantwortlich ist. Die Gerichtskosten trägt dabei die verarbeitende Stelle. </div>
    
    <br><br>
    
    <div class="qheader">
    Frage 10: Wenn in Vertretungsfällen Daten zugänglich gemacht werden müssen ... </div>
    <div>
    <input type="radio" value="a" name="question10">&nbsp;&nbsp;können Passworte weitergegeben werden, wenn die Empfänger verpflichtet werden, diese nicht mißbräuchlich zu verwenden. <br>
    <input type="radio" value="b" name="question10">&nbsp;&nbsp;müssen die Berechtigungen des Berechtigungssystems entsprechend geändert werden. <br>
    <input type="radio" value="c" name="question10">&nbsp;&nbsp;können sowohl das Berechtigungssystem geändert als auch Passworte weitergegeben werden. <br>
    </form>
    <br> <br>
    <form>
    <div>
    <input type="button" value="Auswertung" name="B1" onClick="gradeit()"> 
    <input type="button" value="Auswahl zurücksetzen" name="B2" onClick="document.myquiz.reset()">
    </div>
    </form>
    </div>
    I want to remove the alert: 'Sie haben noch keine Frage richtig beantwortet! Bitte machen Sie das Quiz noch einmal!'
    and this counting of the w's and r's which come when you click on "Auswertung" (engl: results)
    I don't want to have any alert messages.

    May you can help me.
    thanks a lot
    Sabine

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles