Въпроси и отговори, времетраене и проверка на отговор

Post Reply
User avatar
Ticketa
Потребител
Потребител
Reactions: 4
Posts: 631
Joined: Mon Feb 27, 2012 1:54 pm
Answers: 24
Location: in /root
Contact:

Въпроси и отговори, времетраене и проверка на отговор

Post by Ticketa »

Търся такъв код/скрипт или някаква идея как да се направи

https://ecstest.net/#start-practice

Виждам, че сайта е задвижван на Wordpress, но не желая да го ползвам и търся подобен код. :think:
by anonimen » Fri Jul 09, 2021 3:30 pm
Най-грубо, така?

Code: Select all

QAs = [
    { q: "Question 1", ans: [ "Possible answer1", "Correct answer", "Possible answer 2"], correct: 1 }
    // ...
]

userResponses = {}

function selectAnswer(question, answer) {
    userResponses[question] = answer;
}

function checkAnswers() {
    correctAnswers = // calculate points based on userResponses
    alert(correctAnswers);
}

currentQuestion = 0

renderQuestion(QAs[currentQuestion], selectAnswer);

<a onclick="currentQuestion = currentQuestion - 1">Previous</a>
<a onclick="currentQuestion = currentQuestion + 1">Next</a>
<a onclick="checkAnswers()">I'm done!</a>
Go to full post
You do not have the required permissions to view the files attached to this post.
User avatar
anonimen
Web-tourist
Web-tourist
Reactions: 2
Posts: 1613
Joined: Mon Jun 11, 2012 6:07 pm
Answers: 167
Location: Parse error: unexpected "}" in /home/index.php on line 26

Re: Въпроси и отговори, времетраене и проверка на отговор

Post by anonimen »

Най-грубо, така?

Code: Select all

QAs = [
    { q: "Question 1", ans: [ "Possible answer1", "Correct answer", "Possible answer 2"], correct: 1 }
    // ...
]

userResponses = {}

function selectAnswer(question, answer) {
    userResponses[question] = answer;
}

function checkAnswers() {
    correctAnswers = // calculate points based on userResponses
    alert(correctAnswers);
}

currentQuestion = 0

renderQuestion(QAs[currentQuestion], selectAnswer);

<a onclick="currentQuestion = currentQuestion - 1">Previous</a>
<a onclick="currentQuestion = currentQuestion + 1">Next</a>
<a onclick="checkAnswers()">I'm done!</a>
Post Reply