添加分数并提供分数描述的JavaScript

时间:2014-05-06 22:53:35

标签: javascript

当用户提交使用JavaScript创建的测验时,我正在尝试显示分数结果。我不知道该怎么做,这是我到目前为止所做的。谢谢你的帮助。

function getScore(form) {
    var score = 0;
    var currElt;
    var currSelection;

    for (i = 0; i < numQues; i++) {
        currElt = i * numChoi;
        for (j = 0; j < numChoi; j++) {
            currSelection = form.elements[currElt + j];
            if (currSelection.checked) {
                if (currSelection.value == answers[i]) {
                    score++;
                    break;
                }
            }
        }
    }

    score = Math.round(score / numQues * 100);
    form.percentage.value = score + "%";

    var correctAnswers = "";
    for (i = 1; i <= numQues; i++) {
        correctAnswers += i + ". " + answers[i - 1] + "\r\n";
    }
    <!--  form.solutions.value = correctAnswers;-->

}


if (correctAnswers <= 100) {
    {
        document.quiz.Answer.value = "Your score indicates that you know this subject.";
    }
} else if (correctAnswers >= 60 {
        {
            document.quiz.Answer.value = "Your score indicates you need to review.";
        }
    } else {
        {
            document.quiz.Answer.value = "Your score indicates you do not know this subject";
        }
    }

0 个答案:

没有答案