Kolorwanie:
Status:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Assessment</title>
    <style type="text/css" media="screen">
		@import url( style.css );
	</style>
	
    <script type="text/javascript">
    var QUESTION_TYPE_CHOICE = "choice";
    var QUESTION_TYPE_TF = "true-false";
    var QUESTION_TYPE_NUMERIC = "numeric";
    
    function Question(id, text, type, answers, correctAnswer, objectiveId){
        this.Id = id;
        this.Text = text;
        this.Type = type;
        this.Answers = answers;
        this.CorrectAnswer = correctAnswer;
        this.ObjectiveId = objectiveId;
    }

    function Test(questions){
        this.Questions = questions;
    }
    Test.prototype.AddQuestion = function(question)
    {
        this.Questions[this.Questions.length] = question;
    }
    
    var test = new Test(new Array());
</script>

<script type="text/javascript">
var queryString = new String(document.location.search);
queryString = queryString.replace("?", "");
var includeFiles = queryString.split("&");
for (var i=0; i<includeFiles.length; i++){
    var questionsFile = includeFiles[i].replace("questions=", "");
    document.write('<script src="../', questionsFile, '/questions.js" type="text/JavaScript"><\/script>');
}
</script>

<script type="text/javascript">
    function CheckNumeric(obj){
        var userText = new String(obj.value);
        var numbersRegEx = /[^0-9]/g;
        if (userText.search(numbersRegEx) >= 0){
            alert("Please enter only numeric values.");
            obj.value = userText.replace(numbersRegEx, "");
        }
    }
    function SubmitAnswers(){
        var correctCount = 0;
        var totalQuestions = test.Questions.length;
        
        var resultsSummary = "";
        
        for (var i in test.Questions){
            var question = test.Questions[i];
            
            var wasCorrect = false;
            var correctAnswer = null;
            var learnerResponse = "";
            
            switch (question.Type){
                case QUESTION_TYPE_CHOICE:

                    for (var answerIndex = 0; answerIndex < question.Answers.length; answerIndex++){
                        
                        if (question.CorrectAnswer == question.Answers[answerIndex]){
                            correctAnswer = answerIndex;
                        }
                        if (document.getElementById("question_" + question.Id + "_" + answerIndex).checked == true){
                            learnerResponse = answerIndex;
                        }
                    }
  
                break;
                
                case QUESTION_TYPE_TF:
                    
                    if (document.getElementById("question_" + question.Id + "_True").checked == true){
                        learnerResponse = "true";
                    }
                    if (document.getElementById("question_" + question.Id + "_False").checked == true){
                       learnerResponse = "false";
                    } 
                       
                    if (question.CorrectAnswer == true){
                        correctAnswer = "true";
                    }
                    else{
                        correctAnswer = "false"; 
                    }
                break;
                
                case QUESTION_TYPE_NUMERIC:
                    correctAnswer = question.CorrectAnswer;
                    learnerResponse = document.getElementById("question_" + question.Id + "_Text").value;
                break;
                
                default:
                    alert("invalid question type detected");
                break;
            }
            
            wasCorrect = (correctAnswer == learnerResponse);
            if (wasCorrect) {correctCount++;}
            
            if (parent.RecordQuestion){
                parent.RecordQuestion(test.Questions[i].Id, 
                                        test.Questions[i].Text, 
                                        test.Questions[i].Type, 
                                        learnerResponse, 
                                        correctAnswer, 
                                        wasCorrect, 
                                        test.Questions[i].ObjectiveId);
            }
            
            // resultsSummary += "<div class='questionResult'><h3>Question " + i + "</h3>";
            if (wasCorrect) {
                // resultsSummary += "<em>Correct</em><br>"
            }
            else{
                resultsSummary += "<em>Błąd/Incorrect</em><br>"
                resultsSummary += "Twoja odpowiedź: / Your answer: " + learnerResponse + "<br>"
                resultsSummary += "Prawidłowa odpowiedź / Correct answer: " + correctAnswer + "<br>"
            }
            resultsSummary += "</div>";
        }
        var score = Math.round(correctCount * 100 / totalQuestions);
        resultsSummary = "<h3>Wynik/Score: " + score + "</h3>" + resultsSummary;
        document.getElementById("test").innerHTML = resultsSummary;
        
        if (parent.RecordTest){
            parent.RecordTest(score);
        }
    }
    </script>
    <script type="text/javascript">
    function RenderTest(test){
        
        document.write ("<div id='test'><form id='frmTest' action='#'>");
        
        for (var i in test.Questions){
            var question = test.Questions[i];
            
            document.write ("<div id='question_" + question.Id + "' class='question'>");
            document.write (question.Text);
            
            switch (question.Type){
                case QUESTION_TYPE_CHOICE:
                    var ansIndex = 0;
                    for (var j in question.Answers){
                        var answer = question.Answers[j];
                        document.write("<div ");
                        if (question.CorrectAnswer == answer) {document.write("class='correctAnswer'");} else{document.write("class='answer'");}
                        document.write("><input type='radio' name='question_" + question.Id + "_choices' id='question_" + question.Id + "_" + ansIndex + "'/>" + answer + "</div>");
                        ansIndex++;
                    }
                break;
                
                case QUESTION_TYPE_TF:
                    
                    document.write("<div ");
                    if (question.CorrectAnswer == true) {document.write("class='correctAnswer'");}else{document.write("class='answer'");}
                    document.write("><input type='radio' name='question_" + question.Id + "_choices' id='question_" + question.Id + "_True'/>True</div>");
                    
                    document.write("<div ");
                    if (question.CorrectAnswer == false) {document.write("class='correctAnswer'");}else{document.write("class='answer'");}
                    document.write("><input type='radio' name='question_" + question.Id + "_choices' id='question_" + question.Id + "_False'/>False</div>");
                break;
                
                case QUESTION_TYPE_NUMERIC:
                    document.write("<div class='correctAnswer'><input type='text' value='' id='question_" + question.Id + "_Text' onchange='CheckNumeric(this)'/> (");
                    document.write(question.CorrectAnswer + ")</div>");
                break;
                
                default:
                    alert("invalid question type detected");
                break;
            }
            document.write ("</div>");      //close out question div
        }
        document.write("<input type='button' value='Wyślij/Send' onclick='SubmitAnswers();' />");
        document.write ("</form></div>");      //close out test div
    }
    </script>
    <script src="../shared/scormfunctions.js" type="text/javascript"></script>
</head>
<body>
<h1>Dziękujemy.</h1>
<script type="text/javascript">
RenderTest(test);
AddTagLine();
</script>
</body>
</html>


Copyrights 2014-2020 © Wklejaj.pl Wszelkie prawa zastrzeżone.