{"id":14075,"date":"2024-07-08T08:49:06","date_gmt":"2024-07-08T06:49:06","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=14075"},"modified":"2024-07-08T08:49:06","modified_gmt":"2024-07-08T06:49:06","slug":"very-simple-sum-test","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/very-simple-sum-test\/","title":{"rendered":"Very simple sum Test"},"content":{"rendered":"\n<figure class=\"wp-block-video\"><video height=\"446\" style=\"aspect-ratio: 808 \/ 446;\" width=\"808\" controls src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2024\/07\/addizioni.mp4\"><\/video><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"><\/pre>\n\n\n\n<!DOCTYPE html>\n<html lang=\"it\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Test di Matematica<\/title>\n    <link href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.5.2\/css\/bootstrap.min.css\" rel=\"stylesheet\">\n    <style>\n        body {\n            font-size: 1.5rem;\n            margin: 20px;\n        }\n        .btn-lg {\n            font-size: 1.5rem;\n        }\n        .hidden {\n            display: none;\n        }\n        .progress {\n            height: 2rem;\n            font-size: 1rem;\n        }\n        .progress-bar-striped {\n      background-color: orange !important;\n}\n    <\/style>\n<\/head>\n<body class=\"text-center\">\n    <div class=\"container\">\n        <span id=\"result\">Clicca sulla soluzione<\/span>\n        <p style='font-size:12px'>Corrette<\/p>\n<div class=\"progress mb-4\">\n            <div id=\"progress-bar\" class=\"progress-bar\" role=\"progressbar\" style=\"width: 0%;\" aria-valuenow=\"0\" aria-valuemin=\"0\" aria-valuemax=\"100\">0\/10<\/div>\n<\/div><p style='font-size:12px'>Errori<\/p>\n<div class=\"progress mb-6\">\n            \n            <div id=\"progress-bar2\" class=\"progress-bar progress-bar-striped\" role=\"progressbar\" style=\"width: 0%;\" aria-valuenow=\"0\" aria-valuemin=\"0\" aria-valuemax=\"100\"><\/div>\n<\/div>\n        <div id=\"question-container\" class=\"mb-4\"><\/div>\n        <div id=\"answer-buttons\" class=\"btn-group mb-4\"><\/div>\n        <br>\n        <button id=\"next-button\" onclick=\"nextQuestion()\" class=\"btn btn-primary btn-lg hidden\">Prossima Domanda<\/button>\n        <button id=\"restart-button\" onclick=\"startTest()\" class=\"btn btn-secondary btn-lg hidden\">Ripeti Test<\/button>\n    <\/div>\n\n    <script>\n        let currentQuestionIndex = 0;\n        let score = 0;\n        let error = 0;\n        let level = 1;\n\n        function generateQuestion(level) {\n            const max = level * 8;\n            const max2 = level * 3;\n            \/\/ versione semplificata            \n\n            const num1 = Math.floor(Math.random() * max) + 1;\n            const num2 = Math.floor(Math.random() * max2) + 1;\n            const answer = num1 + num2;\n            const options = [answer];\n            while (options.length < 4) {\n                const option = Math.floor(Math.random() * (max * 2)) + 1;\n                if (!options.includes(option)) {\n                    options.push(option);\n                }\n            }\n            options.sort(() => Math.random() - 0.5);\n            return {\n                question: `${num1} + ${num2} = ?`,\n                options: options,\n                answer: answer\n            };\n        }\n\n        let questions = Array.from({ length: 10 }, () => generateQuestion(level));\n\n        function loadQuestion() {\n            if (currentQuestionIndex < questions.length) {\n                const questionContainer = document.getElementById('question-container');\n                const answerButtons = document.getElementById('answer-buttons');\n                const question = questions[currentQuestionIndex];\n                questionContainer.innerHTML = `<p>${question.question}<\/p>`;\n                answerButtons.innerHTML = '';\n                question.options.forEach(option => {\n                    const button = document.createElement('button');\n                    button.className = 'btn btn-outline-primary btn-lg mr-2';\n                    button.innerText = option;\n                    button.onclick = () => checkAnswer(option, button);\n                    answerButtons.appendChild(button);\n                });\n                document.getElementById('next-button').classList.add('hidden');\n                updateProgressBar();\n            } else {\n                showFinalResult();\n            }\n        }\n\n        function checkAnswer(selectedAnswer, button) {\n            const correctAnswer = questions[currentQuestionIndex].answer;\n            if (selectedAnswer === correctAnswer) {\n                score++;\n                button.className = 'btn btn-success btn-lg mr-2';\n                document.getElementById('result').textContent = 'Corretto!';\n            } else {\n                error += 1;\n                button.className = 'btn btn-danger btn-lg mr-2';\n                document.getElementById('result').textContent = `Sbagliato! La risposta corretta \u00e8 ${correctAnswer}.`;\n            }\n            document.querySelectorAll('#answer-buttons button').forEach(btn => btn.disabled = true);\n            currentQuestionIndex++;\n            document.getElementById('next-button').classList.remove('hidden');\n\n            nextQuestion()\n        }\n\n        function nextQuestion() {\n            document.getElementById('result').textContent = \"Livello: \" + level;\n            loadQuestion();\n        }\n\n        function showFinalResult() {\n            document.getElementById('question-container').innerHTML = '';\n            document.getElementById('answer-buttons').innerHTML = '';\n            document.getElementById('next-button').classList.add('hidden');\n            const resultMessage = `Hai risposto correttamente a ${score} domande su 10.`;\n            document.getElementById('result').textContent = resultMessage;\n            document.getElementById('restart-button').classList.remove('hidden');\n            if (score >= 7) {\n                level++;\n                errori = 0;\n                document.getElementById('result').textContent += ' Ottimo lavoro! Il prossimo test sar\u00e0 pi\u00f9 difficile.';\n            } else {\n                level = 1;\n            }\n        }\n\n        function startTest() {\n            currentQuestionIndex = 0;\n            score = 0;\n            document.getElementById('result').textContent = '';\n            document.getElementById('restart-button').classList.add('hidden');\n            questions = Array.from({ length: 10 }, () => generateQuestion(level));\n            document.getElementById('result').textContent = level;\n            loadQuestion();\n        }\n\n        function updateProgressBar() {\n            const progressBar = document.getElementById('progress-bar');\n            const progressBar2 = document.getElementById('progress-bar2');\n            \/\/ const progress = ((currentQuestionIndex) \/ questions.length) * 100;\n            const progress = (score\/10) * 100;\n            const progress2 = (error\/10) * 100;\n            progressBar.style.width = `${progress}%`;\n            progressBar2.style.width = `${progress2}%`;\n            progressBar.setAttribute('aria-valuenow', progress);\n            \n            progressBar.textContent = `${score}`;\n            progressBar2.textContent = `${error}`;\n            \n        }\n\n        window.onload = startTest;\n    <\/script>\n<\/body>\n<\/html>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!DOCTYPE html>\n&lt;html lang=\"it\">\n&lt;head>\n    &lt;meta charset=\"UTF-8\">\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    &lt;title>Test di Matematica&lt;\/title>\n    &lt;link href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.5.2\/css\/bootstrap.min.css\" rel=\"stylesheet\">\n    &lt;style>\n        body {\n            font-size: 1.5rem;\n            margin: 20px;\n        }\n        .btn-lg {\n            font-size: 1.5rem;\n        }\n        .hidden {\n            display: none;\n        }\n        .progress {\n            height: 2rem;\n            font-size: 1rem;\n        }\n        .progress-bar-striped {\n      background-color: orange !important;\n}\n    &lt;\/style>\n&lt;\/head>\n&lt;body class=\"text-center\">\n    &lt;div class=\"container\">\n        &lt;span id=\"result\">Clicca sulla soluzione&lt;\/span>\n        &lt;p style='font-size:12px'>Corrette&lt;\/p>\n&lt;div class=\"progress mb-4\">\n            &lt;div id=\"progress-bar\" class=\"progress-bar\" role=\"progressbar\" style=\"width: 0%;\" aria-valuenow=\"0\" aria-valuemin=\"0\" aria-valuemax=\"100\">0\/10&lt;\/div>\n&lt;\/div>&lt;p style='font-size:12px'>Errori&lt;\/p>\n&lt;div class=\"progress mb-6\">\n            \n            &lt;div id=\"progress-bar2\" class=\"progress-bar progress-bar-striped\" role=\"progressbar\" style=\"width: 0%;\" aria-valuenow=\"0\" aria-valuemin=\"0\" aria-valuemax=\"100\">&lt;\/div>\n&lt;\/div>\n        &lt;div id=\"question-container\" class=\"mb-4\">&lt;\/div>\n        &lt;div id=\"answer-buttons\" class=\"btn-group mb-4\">&lt;\/div>\n        &lt;br>\n        &lt;button id=\"next-button\" onclick=\"nextQuestion()\" class=\"btn btn-primary btn-lg hidden\">Prossima Domanda&lt;\/button>\n        &lt;button id=\"restart-button\" onclick=\"startTest()\" class=\"btn btn-secondary btn-lg hidden\">Ripeti Test&lt;\/button>\n    &lt;\/div>\n\n    &lt;script>\n        let currentQuestionIndex = 0;\n        let score = 0;\n        let error = 0;\n        let level = 1;\n\n        function generateQuestion(level) {\n            const max = level * 8;\n            const max2 = level * 3;\n            \/\/ versione semplificata            \n\n            const num1 = Math.floor(Math.random() * max) + 1;\n            const num2 = Math.floor(Math.random() * max2) + 1;\n            const answer = num1 + num2;\n            const options = [answer];\n            while (options.length &lt; 4) {\n                const option = Math.floor(Math.random() * (max * 2)) + 1;\n                if (!options.includes(option)) {\n                    options.push(option);\n                }\n            }\n            options.sort(() => Math.random() - 0.5);\n            return {\n                question: `${num1} + ${num2} = ?`,\n                options: options,\n                answer: answer\n            };\n        }\n\n        let questions = Array.from({ length: 10 }, () => generateQuestion(level));\n\n        function loadQuestion() {\n            if (currentQuestionIndex &lt; questions.length) {\n                const questionContainer = document.getElementById('question-container');\n                const answerButtons = document.getElementById('answer-buttons');\n                const question = questions[currentQuestionIndex];\n                questionContainer.innerHTML = `&lt;p>${question.question}&lt;\/p>`;\n                answerButtons.innerHTML = '';\n                question.options.forEach(option => {\n                    const button = document.createElement('button');\n                    button.className = 'btn btn-outline-primary btn-lg mr-2';\n                    button.innerText = option;\n                    button.onclick = () => checkAnswer(option, button);\n                    answerButtons.appendChild(button);\n                });\n                document.getElementById('next-button').classList.add('hidden');\n                updateProgressBar();\n            } else {\n                showFinalResult();\n            }\n        }\n\n        function checkAnswer(selectedAnswer, button) {\n            const correctAnswer = questions[currentQuestionIndex].answer;\n            if (selectedAnswer === correctAnswer) {\n                score++;\n                button.className = 'btn btn-success btn-lg mr-2';\n                document.getElementById('result').textContent = 'Corretto!';\n            } else {\n                error += 1;\n                button.className = 'btn btn-danger btn-lg mr-2';\n                document.getElementById('result').textContent = `Sbagliato! La risposta corretta \u00e8 ${correctAnswer}.`;\n            }\n            document.querySelectorAll('#answer-buttons button').forEach(btn => btn.disabled = true);\n            currentQuestionIndex++;\n            document.getElementById('next-button').classList.remove('hidden');\n\n            nextQuestion()\n        }\n\n        function nextQuestion() {\n            document.getElementById('result').textContent = \"Livello: \" + level;\n            loadQuestion();\n        }\n\n        function showFinalResult() {\n            document.getElementById('question-container').innerHTML = '';\n            document.getElementById('answer-buttons').innerHTML = '';\n            document.getElementById('next-button').classList.add('hidden');\n            const resultMessage = `Hai risposto correttamente a ${score} domande su 10.`;\n            document.getElementById('result').textContent = resultMessage;\n            document.getElementById('restart-button').classList.remove('hidden');\n            if (score >= 7) {\n                level++;\n                errori = 0;\n                document.getElementById('result').textContent += ' Ottimo lavoro! Il prossimo test sar\u00e0 pi\u00f9 difficile.';\n            } else {\n                level = 1;\n            }\n        }\n\n        function startTest() {\n            currentQuestionIndex = 0;\n            score = 0;\n            document.getElementById('result').textContent = '';\n            document.getElementById('restart-button').classList.add('hidden');\n            questions = Array.from({ length: 10 }, () => generateQuestion(level));\n            document.getElementById('result').textContent = level;\n            loadQuestion();\n        }\n\n        function updateProgressBar() {\n            const progressBar = document.getElementById('progress-bar');\n            const progressBar2 = document.getElementById('progress-bar2');\n            \/\/ const progress = ((currentQuestionIndex) \/ questions.length) * 100;\n            const progress = (score\/10) * 100;\n            const progress2 = (error\/10) * 100;\n            progressBar.style.width = `${progress}%`;\n            progressBar2.style.width = `${progress2}%`;\n            progressBar.setAttribute('aria-valuenow', progress);\n            \n            progressBar.textContent = `${score}`;\n            progressBar2.textContent = `${error}`;\n            \n        }\n\n        window.onload = startTest;\n    &lt;\/script>\n&lt;\/body>\n&lt;\/html><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[hoop name=&#8221;all&#8221;]<\/p>\n","protected":false},"excerpt":{"rendered":"Test di Matematica Clicca sulla soluzione Corrette 0\/10 Errori Prossima Domanda Ripeti Test [hoop name=&#8221;all&#8221;]\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/very-simple-sum-test\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":14077,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-14075","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-examples"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":true,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/14075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=14075"}],"version-history":[{"count":2,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/14075\/revisions"}],"predecessor-version":[{"id":14079,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/14075\/revisions\/14079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/14077"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=14075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=14075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=14075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}