{"id":7821,"date":"2020-12-10T11:12:57","date_gmt":"2020-12-10T10:12:57","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=7821"},"modified":"2020-12-10T11:35:36","modified_gmt":"2020-12-10T10:35:36","slug":"pydarm-python-to-generate-tests-in-html","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/pydarm-python-to-generate-tests-in-html\/","title":{"rendered":"Pydarm &#8211; Python to generate tests in html"},"content":{"rendered":"<p>How to generate a test in html through python easily.<\/p>\n<h2>Here is the full code in a github repository<\/h2>\n<p><a href=\"https:\/\/github.com\/formazione\/pydarm\">Github repository<\/a><\/p>\n<pre class=\"lang:default decode:true\"># in darm 2 ho fatto in modo che si possa usare l'apostrofo (codice 18-21)\r\n\r\nimport glob\r\nfrom random import choice\r\nfrom files.createfile import createfile\r\nfrom files.darm_start import *\r\nfrom files.darm_end import *\r\n# from dati.browser3 import *\r\n\r\n\r\nclass Start:\r\n\r\n\tdef __init__(self):\r\n\t\t\"a menu to choose a file in the directory 'dati'\"\r\n\t\tself.images()\r\n\t\tself.show_files()\r\n\t\tself.inputfilename() # self.filename contains the txt file with questions you choose\r\n\t\tself.create_list_of_dict(self.filename)\r\n\t\tself.create_test()\r\n\r\n\tdef images(self):\r\n\t\tself.imgslist = [\r\n\t\t\t\"https:\/\/picsum.photos\/200\"\r\n\t\t\t]\r\n\r\n\tdef create_list_of_dict(self, filename):\r\n\t\t\"takes the data from filename and convert them into a dictonary\"\r\n\r\n\t\t'''\r\n\t\tfrom\r\n\r\n\t\twhat is...\r\n\t\tis ...\r\n\t\tis ...\r\n\t\tis ...\r\n\t\t\r\n\t\tto this\r\n\r\n\t\t{\r\n\t\tquestion = \"What is....\",\r\n\t\timage = \"\",\r\n\t\tchoice = [\"is...\", \"is...\", \"is...\"],\r\n\t\tcorrect = \"\",\r\n\t\texplation = \"\"\r\n\t\t}\r\n\r\n\r\n\t\t'''\r\n\r\n\t\tqdic = {}\r\n\t\tflist = []\r\n\t\tdef list_of_questions():\r\n\t\t\t# read the file and splits every qna in a string\r\n\t\t\t# file is a list of strings each with a qna\r\n\t\t\twith open(filename, 'r', encoding='utf-8') as file:\r\n\t\t\t\tfile = file.read()\r\n\t\t\t\tfile = file.split(\"\\n\\n\")\r\n\t\t\t# every string in the list becomes a list with [q,a,a...]\r\n\t\t\treturn file\r\n\r\n\t\tdef list_of_list_with_qna(file):\r\n\t\t\tfor eachstring in file:\r\n\t\t\t\tflist.append(eachstring.split(\"\\n\"))\r\n\r\n\t\tdef delete_empty_items(): \r\n\t\t\tfor eachsublist in flist:\r\n\t\t\t\tfor e in eachsublist:\r\n\t\t\t\t\tif e == '':\r\n\t\t\t\t\t\teachsublist.pop(eachsublist.index(e))\r\n\t\t\t\tquestion = eachsublist[0]\r\n\t\t\t\teachsublist.pop(0)\r\n\t\t\t\tqdic[question] = eachsublist\r\n\t\tfile = list_of_questions()\r\n\t\tlist_of_list_with_qna (file)\r\n\t\tdelete_empty_items()\r\n\r\n\t\tself.qdic = qdic\r\n\r\n\tdef show_files(self):\r\n\t\ttext = \"File di testo nella cartella: dati\"\r\n\t\ttext += \"------------------------------------\"\r\n\t\tfor number,eachfile in enumerate(glob.glob(\"dati\/*.txt\")):\r\n\t\t\tprint(number, eachfile.replace(\"dati\\\\\",\"\"))\r\n\t\ttext += \"------------------------------------\"\r\n\t\tprint(text)\r\n\r\n\tdef inputfilename(self):\r\n\t\tfile_number = int(input(\"Scegli il numero del file? &gt; \"))\r\n\t\tself.filename = glob.glob(\"dati\/*.txt\")[file_number]\r\n\r\n\tdef convert_for_template(self, question, answers):\r\n\t\thtml = f\"\"\"{{\r\n\t\t\t\"question\"      :   \"{question}\",\r\n\t\t\t\"image\"         :   \"{choice(self.imgslist)}\",\r\n\t\t\t\"choices\"       :   {answers},\r\n\t\t\t\"correct\"       :   \"{answers[0]}\",\r\n\t\t\t\"explanation\"   :   \"\", }},\"\"\"\r\n\t\treturn html\r\n\r\n\tdef create_test(self):\r\n\t\tglobal htmlpage\r\n\r\n\t\tfor question in self.qdic:\r\n\t\t\tanswers = self.qdic[question]\r\n\t\t\thtmlpage += self.convert_for_template(question, answers)\r\n\t\thtmlpage += endpage\r\n\t\tfilename = f\"{input('nome del file: ')}.html\"\r\n\t\tcreatefile(filename, htmlpage)\r\n\r\n\r\n\r\ntest = Start()\r\n\r\n<\/pre>\n<h2>Example<\/h2>\n<!DOCTYPE html>\r\n<html>\r\n<head>\r\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\r\n    <meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\">\r\n\t<meta name=\"viewport\" content=\"initial-scale=1.0\">\r\n    <title>Quiz<\/title>\r\n    <!-- jquery for maximum compatibility -->\r\n\t<link type=\"text\/css\" rel=\"stylesheet\" href=\"https:\/\/stackpath.bootstrapcdn.com\/twitter-bootstrap\/2.2.1\/css\/bootstrap-combined.min.css\">\r\n    <!--<script src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.9.1\/jquery.min.js\"><\/script>-->\r\n\t<script src=\"https:\/\/code.jquery.com\/jquery-1.11.1.min.js\" integrity=\"sha256-VAvG3sHdS5LqTT+5A\/aeq\/bZGa\/Uj04xKxY8KM\/w9EE=\" crossorigin=\"anonymous\"><\/script>\r\n\t<script src=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/3.3.5\/js\/bootstrap.min.js\"><\/script>\r\n    <script>\r\n\r\n    var quiztitle = \"Pianificazione e programmazione\";\r\n\r\n    \/**\r\n    * Set the information about your questions here. The correct answer string needs to match\r\n    * the correct choice exactly, as it does string matching. (case sensitive)\r\n    *\r\n    *\/\r\n\r\n\/**\r\n*Let's create the randomization of the questions!\r\n*\/\r\nfunction speak(x) {\r\n  synth = speechSynthesis\r\n  utt = new SpeechSynthesisUtterance(x);\r\n  synth.speak(utt);\r\n  is_on = 1;\r\n}\r\nfunction shuffle(array) {\r\n  var currentIndex = array.length, temporaryValue, randomIndex;\r\n\r\n  \/\/ While there remain elements to shuffle...\r\n  while (0 !== currentIndex) {\r\n\r\n    \/\/ Pick a remaining element...\r\n    randomIndex = Math.floor(Math.random() * currentIndex);\r\n    currentIndex -= 1;\r\n\r\n    \/\/ And swap it with the current element.\r\n    temporaryValue = array[currentIndex];\r\n    array[currentIndex] = array[randomIndex];\r\n    array[randomIndex] = temporaryValue;\r\n  }\r\n\r\n  return array;\r\n}\r\n\t    \r\nif (!(\"scramble\" in Array.prototype)) {\r\n  Object.defineProperty(Array.prototype, \"scramble\", {\r\n    enumerable: false,\r\n    value: function() {\r\n      var o, i, ln = this.length;\r\n      while (ln--) {\r\n        i = Math.random() * (ln + 1) | 0;\r\n        o = this[ln];\r\n        this[ln] = this[i];\r\n        this[i] = o;\r\n      }\r\n      return this;\r\n    }\r\n  });\r\n}\t\t\r\n\t    \r\nlet quiz = [\r\n{\r\n\t\t\t\"question\"      :   \"How many elements are in m? m = [[x, y] for x in range(0, 4) for y in range(0, 4)]\",\r\n\t\t\t\"image\"         :   \"https:\/\/picsum.photos\/200\",\r\n\t\t\t\"choices\"       :   ['16', '8', '12', '32'],\r\n\t\t\t\"correct\"       :   \"16\",\r\n\t\t\t\"explanation\"   :   \"\", },{\r\n\t\t\t\"question\"      :   \"data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]; print(data[1][0][0])\",\r\n\t\t\t\"image\"         :   \"https:\/\/picsum.photos\/200\",\r\n\t\t\t\"choices\"       :   ['5', '1', '2', '4'],\r\n\t\t\t\"correct\"       :   \"5\",\r\n\t\t\t\"explanation\"   :   \"\", },\r\n];\r\n\r\nquiz.forEach(q => q.choices.scramble()); \/\/ Mescola l'ordine delle risposte\r\nquiz = shuffle(quiz);\r\nvar currentquestion = 0, score = 0, submt=true, picked;\r\nlet count_speak = 0;\r\njQuery(document).ready(function($){\r\n\r\n  \r\n  \r\n  \r\n  \r\n\tfunction addChoices(choices){\r\n\t\t\tif(typeof choices !== \"undefined\" && $.type(choices) == \"array\"){\r\n\t\t\t\t$('#choice-block').empty();\r\n\t\t\t\tfor(var i=0;i<choices.length; i++){\r\n          \/\/ added .css({'font-size':'36px'}) il 2 marzo 2019\r\n\t\t\t\t$(document\r\n          .createElement('li'))\r\n          .addClass('choice choice-box btn')\r\n          .attr('data-index', i)\r\n          .text(choices[i])\r\n          .appendTo('#choice-block')\r\n          .css({'font-size':'28px'});\t\t\/\/  Aggiunge risposte\r\n        }\r\n\t\t\t}\r\n        \r\n\t\t}\r\n        \r\n\r\n  \r\n  \r\n  function nextQuestion(){\r\n     \r\n\t\t\tsubmt = true;\r\n\t\t\t$('#explanation').empty(); \/\/ svuota spiegazione\r\n\t\t\t$('#question').text(quiz[currentquestion]['question']); \/\/ domanda attuale\r\n      \/\/ domanda n. di ... totale domande\r\n\t\t\t$('#pager').text('Domanda' + Number(currentquestion + 1) + ' di ' + quiz.length);\r\n      \/\/ Immagine... ?\r\n\t\t\tif(quiz[currentquestion].hasOwnProperty('image') && quiz[currentquestion]['image'] != \"\"){\r\n\t\t\t\tif($('#question-image').length == 0){\r\n\t\t\t\t\t$(document.createElement('img'))\r\n            .addClass('question-image')\r\n            .attr('id', 'question-image')\r\n            .attr('src', quiz[currentquestion]['image'])\r\n            .attr('alt', (quiz[currentquestion]['question']))\r\n            .insertAfter('#question');\r\n\t\t\t\t} else {\r\n\t\t\t\t\t$('#question-image')\r\n            .attr('src', quiz[currentquestion]['image'])\r\n            .attr('alt', (quiz[currentquestion]['question']));\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t$('#question-image')\r\n          .remove();\r\n\t\t\t}\r\n\r\n    \r\n\t\t\taddChoices(quiz[currentquestion]['choices']);\r\n      \r\n\t\t\tsetupButtons();\r\n\r\n\t\t\t\/\/ parla solo una volta ======|||||||||=====>>>\r\n            if (count_speak==0 && is_on==1){\r\n        speak(quiz[currentquestion]['question']);\r\n        count_speak = 1;\r\n      }\r\n           \/\/ parla solo una volta ======|||||||||=====>>>\r\n    \r\n\t\t\tjQuery(document).ready(function($){\r\n\t\t\t\t$(\"#question\").html(function(){\r\n\t\t\t\t\tvar text= $(this).text().trim().split(\" \");\r\n\t\t\t\t\tvar first = text.shift();\r\n\t\t\t\t\treturn (text.length > 0 ? \"<span class='number'>\"+ first +\"<\/span> \" : first) + text.join(\" \");\r\n\t\t\t\t});\r\n\t\t\t\t\r\n\t\t\t\t$('p.pager').each(function(){\r\n\t\t\t\t\tvar text = $(this).text().split(' ');\r\n\t\t\t\t\tif(text.length < 2)\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\r\n\t\t\t\t\ttext[1] = '<span class=\"qnumber\">'+text[1]+'<\/span>';\r\n\t\t\t\t\t$(this).html(\r\n\t\t\t\t\t\ttext.join(' ')\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t\t\t\r\n\t\t\t\r\n        } \/\/ function nextQuestion\r\n\r\n\r\n  function processQuestion(choice){\r\n    \r\n    \r\n    \/\/ ===========   Risposta ESATTA!  ==============================\r\n    if(quiz[currentquestion]['choices'][choice] == quiz[currentquestion]['correct'])\r\n      {\r\n\t\t\t\t$('.choice')\r\n          .eq(choice)\r\n          .addClass('btn-success')\r\n          .css({'font-size':'36px', 'font-weight':'bold', 'border-color':'#51a351', 'color':'#fff'});\r\n\t\t\t\t$('#explanation')\r\n          .html('<span class=\"correct\">ESATTO!<\/span> ' + (quiz[currentquestion]['explanation']));\r\n              let ff = [\"s\u00ec\",\"ok\",\"bene\",\"bravo\",\"corretto\",\"esatto\",\"perfetto\",\"eh s\u00ec\",\"ma s\u00ec\",\"certo\",\"giusto\",\"s\u00ec\",\r\n              \"molto bene\",\"ottimo\",\"stai andando bene\", \"continua cos\u00ec\", \"ottimo lavoro\", \"va benissimo\", \"certamente\"]\r\n              .sort(function(){return 0.5 - Math.random()})[0];\r\n        speak(ff);\r\n\t\t\t\t      score++;\r\n              count_speak = 0;\r\n\t\t\t} \r\n      \r\n    \r\n    else {\r\n      $('.choice')\r\n            .eq(choice)\r\n            .addClass('btn-danger')\r\n            .css({'font-weight':'bold', 'border-color':'#f93939', 'color':'#fff'});\r\n      $('#explanation')\r\n        .html('<span class=\"incorrect\">INESATTO!<\/span> ' + (quiz[currentquestion]['explanation']));\r\n        speak(\"No! \u00e8 \" + quiz[currentquestion]['correct']);\r\n            }\r\n        count_speak = 0;\r\n        currentquestion++;\r\n    \/\/ ========================= qui \u00e8 stata aggiunta da 322\r\n    if (currentquestion < quiz.length)  nextQuestion();\r\n    \/\/ =========================\r\n  \r\n\r\n      \/\/ SONO FINITE LE DOMANDE... MOSTRA I RISULTATI\r\n\t\t\tif(currentquestion == quiz.length){\r\n\t\t\t\t$('#submitbutton')\r\n          .html('GET QUIZ RESULTS')\r\n          .removeClass('btn-success')\r\n          .addClass('btn-info')\r\n          .css({'border-color':'#3a87ad', 'color':'#fff'})\r\n          .on('click', function(){\r\n\t\t\t\t\t    $(this).text('GET QUIZ RESULTS')\r\n                .on('click');\r\n\t\t\t\t\tendQuiz();\r\n\t\t\t\t})\r\n\t\t\t\t\r\n\t\t\t}\r\n      \r\n      else if (currentquestion < quiz.length){ \r\n      \/\/ SE CI SONO ANCORA DOMANDE, RIMETTE IL PULSANTE CONTROLLA LA RISPOSTA\r\n        \r\n\t\t\t\t$('#submitbutton').html('VAI ALLA PROSSIMA DOMANDA &raquo;')\r\n          .removeClass('btn-success')\r\n          .addClass('btn-warning')\r\n          .css({'font-weight':'bold', 'border-color':'#faa732', 'color':'#fff'})\r\n          .on('click', function(){\r\n          \r\n          \r\n        $(this).text(' CONTROLLA LA RISPOSTA ')\r\n          .removeClass('btn-warning')\r\n          .addClass('btn-success')\r\n          .css({'font-weight':'bold', 'border-color':'#51a351', 'color':'#fff'})\r\n          .on('click');\r\n\t\t\t\t  \r\n         \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n         \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ nextQuestion(); \/\/ VA ALLA PROSSIMA DOMANDA\r\n         \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n          \r\n          \r\n\r\n\t\t\t\t})\r\n  \t\t\t\r\n\t\t\t} \r\n    \r\n    else {\r\n\t\t\t\t$('#submitbutton').html('VAI ALLA PROSSIMA DOMANDA &raquo;').on('click', function(){\r\n\t\t\t\t$(this).text('- CONTROLLA LA RISPOSTA -').css({'color':'inherit'}).on('click');\r\n\t\t\t\t})\r\n\t\t\t}\r\n\r\n          \r\n\t\t\t\r\n\t\t}\r\n\r\n       \r\n  \r\n\t\r\n  \r\n  function setupButtons(){\r\n      \/\/speak(quiz[currentquestion]['question'])\r\n\t\t\t$('.choice').on('click', function(){\r\n\r\n\t\tsynth.cancel();\r\n        is_on = 0;\r\n\r\n\t\t\t\tpicked = $(this).attr('data-index');\r\n\t\t\t\t$('.choice').removeAttr('style').off('mouseout mouseover');\r\n\t\t\t\t$(this).css({'font-weight':'900', 'border-color':'#51a351', 'color':'#51a351', 'background' : 'gold'});\r\n\t\t\t\tif(submt){\r\n\t\t\t\t\tsubmt=false;\r\n\t\t\t\t\t$('#submitbutton').css({'color':'#fff','cursor':'pointer'}).on('click', function(){\r\n\t\t\t\t\t\t$('.choice').off('click');\r\n\t\t\t\t\t\t$(this).off('click');\r\n\t\t\t\t\t\tprocessQuestion(picked);\r\n            \/\/\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n        \r\n        \r\n  \r\n  \r\n\tfunction endQuiz(){\r\n\t\t\t$('#explanation').empty();\r\n\t\t\t$('#question').empty();\r\n\t\t\t$('#choice-block').empty();\r\n\t\t\t$('#submitbutton').remove();\r\n\t\t\t$('.rsform-block-submit').addClass('show');\r\n\t\t\t$('#question').text(\"You got \" + score + \" out of \" + quiz.length + \" correct.\");\r\n\t\t\t$(document.createElement('h4')).addClass('score').text(Math.round(score\/quiz.length * 100) + '%').insertAfter('#question');\t\t\t\r\n\t\t}\r\n\r\n        \/**\r\n         * Runs the first time and creates all of the elements for the quiz\r\n         *\/\r\n\t\tfunction init(){\r\n      speak(quiz[currentquestion]['question'])\r\n\t\t\t\/\/add title\r\n      \/*\r\n\t\t\tif(typeof quiztitle !== \"undefined\" && $.type(quiztitle) === \"string\"){\r\n\t\t\t\t$(document.createElement('h2')).text(quiztitle).appendTo('#frame');\r\n\t\t\t} else {\r\n\t\t\t\t$(document.createElement('h2')).text(\"Quiz\").appendTo('#frame');\r\n\t\t\t}\r\n      I removed the title to leave more space *\/\r\n\t\t\t\r\n\t\t\t\/\/add pager and questions\r\n\t\t\tif(typeof quiz !== \"undefined\" && $.type(quiz) === \"array\"){\r\n\t\t\t\t\/\/add pager\r\n        \r\n\t\t\t\t$(document.createElement('p')).addClass('pager').attr('id','pager').text('Domanda 1 di ' + quiz.length).appendTo('#frame');\r\n\t\t\t\t\/\/add first question\r\n\t\t\t\t$(document.createElement('h3')).addClass('question').attr('id', 'question').text(quiz[0]['question']).appendTo('#frame');\r\n\t\t\t\t\/\/add image if present\r\n\t\t\t\tif(quiz[0].hasOwnProperty('image') && quiz[0]['image'] != \"\"){\r\n\t\t\t\t\t$(document.createElement('img')).addClass('question-image').attr('width','100px').attr('id', 'question-image').attr('src', quiz[0]['image']).attr('alt', (quiz[0]['question'])).appendTo('#frame');\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t$(document.createElement('p')).addClass('explanation').attr('id','explanation').html('').appendTo('#question');\r\n\t\t\t\t\r\n\t\t\t\t\/\/questions holder\r\n\t\t\t\t$(document.createElement('ul')).attr('id', 'choice-block').appendTo('#frame');\r\n\t\t\t\t\r\n\t\t\t\t\/\/add choices\r\n\t\t\t\taddChoices(quiz[0]['choices']);\r\n\t\t\t\t\r\n\t\t\t\t\/\/add submit button\r\n\t\t\t\t$(document.createElement('div')).addClass('btn-success choice-box').attr('id', 'submitbutton').text('- CONTROLLA LA RISPOSTA -').css({'font-weight':'bold', 'color':'#fff','padding':'30px 0', 'border-radius':'10px'}).appendTo('#frame');\r\n\t\t\t\t\r\n\t\t\t\tsetupButtons();\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\t\tinit();\r\n\t\r\n\t});\r\n\t\t\r\n\tjQuery(document).ready(function($){\t\t\t\r\n\t\t$(\"#question\").html(function(){\r\n\t\tvar text= $(this).text().trim().split(\" \");\r\n\t\tvar first = text.shift();\r\n\t\t\treturn (text.length > 0 ? \"<span class='number'>\"+ first +\"<\/span> \" : first) + text.join(\" \");\r\n\t\t});\r\n\t\t\r\n\t\t$('p.pager').each(function(){\r\n\t\t\tvar text = $(this).text().split(' ');\r\n\t\t\tif(text.length < 2)\r\n\t\t\t\treturn;\r\n\t\t\t\r\n\t\t\ttext[1] = '<span class=\"qnumber\">'+text[1]+'<\/span>';\r\n\t\t\t$(this).html(\r\n\t\t\t\ttext.join(' ')\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t});\t\r\n\r\n\t\tfunction copyText() {\r\n\t\t\tvar output = document.getElementById(\"frame\").innerHTML;\r\n\t\t\tdocument.getElementById(\"placecontent\").value = output;\r\n\t\t}\r\n\t    \r\n    <\/script>\r\n    <style type=\"text\/css\" media=\"all\">\r\n      \r\n      .btn:hover, .btn:active {\r\n        color: blue;\r\n        font-weight: 800;\r\n      background-image: url(\"http:\/\/www.myiconfinder.com\/uploads\/iconsets\/65192ff2984e9928d32fd577bc743ea5.png\");\r\n        background-size: 100%;\r\n  \r\n      }\r\n\r\n      \/*        BODY                 *\/\r\nbody {\r\n    margin: 0;\r\n    font-family: \"Consolas\",Helvetica,Arial,sans-serif;\r\n    font-size: 24px;\r\n    line-height: 20px;\r\n    color: #ffffff;\r\n    background-color: #21517ee8;\r\n}\r\n    h3.question {\r\n    font-family: \"Consolas\",Helvetica,Arial,sans-serif;\r\n    font-weight: normal;\r\n    margin: 20px 0;\r\n    padding: 0;\r\n    font-style: italic;\r\n    display: block;\r\n    color: whitesmoke;\r\n    \r\n}  \r\n      \r\n\t\tinput \t\r\n      \r\n      { height:30px !important; }\r\n      \r\n\t\tinput[type=checkbox]\r\n      \r\n      { height:30px !important; margin-top:-3px !important; \r\n        margin-right:5px !important; box-shadow:none; background-color:#ffffff;\r\n        position:relative !important; }\r\n      \r\n\t\ttextarea\t\t\t\t\t\t\t\t\t\t\t\t\r\n      { width: 90%; margin: 0 auto; display: block; }\r\n      \r\n\t\tinput[type=radio]\t\t\t\t\t\t\t\t\r\n      { height:30px !important; margin-top:-3px !important; margin-right:5px !important; box-shadow:none; background-color:#ffffff; position:relative !important; }\r\n      \r\n\t\t.form-group input, .form-group select \t\t\t\t\t{ height:30px; padding: 0px 12px; }\r\n\t\t.form-horizontal .form-group\t\t\t\t\t\t\t{ margin:10px; }\r\n\t\t.formContainer .formControlLabel \t\t\t\t\t\t{ width:auto !important; min-width:150px; margin:0; padding:0; }\r\n\t\t.formControls\t\t\t\t\t\t\t\t\t\t\t{ width:100%; padding:0; margin: 10px 0 20px auto; }\r\n\t\t.radio \t\t\t\t\t\t\t\t\t\t\t\t\t{ padding-top:0 !important; padding-left:8px !important; }\r\n\t\t.radio-inline\t\t\t\t\t\t\t\t\t\t\t{ margin-right:10px; padding-top:0 !important; display:inline; }\r\n\t\t.bold\t\t\t\t\t\t\t\t\t\t\t\t\t{ font-weight:bold; }\r\n\t\t.italic \t\t\t\t\t\t\t\t\t\t\t\t{ font-style:italic; }\r\n\t\t.clear\t\t\t\t\t \t\t\t\t\t\t\t\t{ width:100%; margin:0 !important; }\r\n\t\t.rsform-block-submit \t\t\t\t\t\t\t\t\t{ display:none; }\r\n\t\t.show \t\t\t\t\t\t\t\t\t\t\t\t\t{ display: block !important; }\r\n\t\t#submit\t\t\t\t\t\t\t\t\t\t\t\t\t{ margin:0 auto; display:block; }\r\n\r\n\t\t\/* QUIZ STYLES *\/\r\n      li.choice-block {font-size: 28px};\r\n\t\tol,ul \t\t\t\t\t\t\t\t\t\t\t\t\t{ list-style:none; font-size: 48}\r\n\t\tstrong \t\t\t\t\t\t\t\t\t\t\t\t\t{ font-weight:700; }\r\n\t\t#frame \t\t\t\t\t\t\t\t\t\t\t\t\t{ width:auto; max-width: 800px; background:transparent; margin:3px auto; padding:10px;     color: #f94a4a !important; }\r\n\t\tdiv#frame h2 ul li\t\t\t\t\t\t\t\t\t\t\t{ color: white; width:auto; border-bottom:1px solid #bdbdbd; padding:0 0 5px 0; font-size:32px; }\r\n\t\th3.question \t\t\t\t\t\t\t\t\t\t\t{ font-weight:normal; margin:20px 0; padding:0; font-style:italic; display:block; }\r\n\t\tp.pager \t\t\t\t\t\t\t\t\t\t\t\t{ margin:5px 0 5px; color:#999; text-align:right; }\r\n\t\t.qnumber \t\t\t\t\t\t\t\t\t\t\t\t{ font-size:25px; font-weight:bold; font-style:italic; vertical-align:bottom; }\r\n\t\t.number \t\t\t\t\t\t\t\t\t\t\t\t{ font-family: \"Consolas\",Helvetica,Arial,sans-serif;font-size:24px; font-weight:bold; font-style:normal; vertical-align:inherit; padding-right:10px; }\r\n\t\t.score \t\t\t\t\t\t\t\t\t\t\t\t\t{ width:100%; display:inline-block; margin:30px 0; font-size:100px; text-align:center; }\r\n\t\timg.question-image \t\t\t\t\t\t\t\t\t\t{ width:25%; height:auto; display:block; max-width:150px; margin:10px auto; border:1px solid #ccc; }\r\n\t\t#choice-block \t\t\t\t\t\t\t\t\t\t\t{ display:block; list-style:none; margin:0; padding:0; cursor: pointer; }\r\n\t\/*\t#submitbutton \t\t\t\t\t\t\t\t\t\t\t{ cursor:pointer; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } *\/\r\n\t\/*\t#submitbutton:hover \t\t\t\t\t\t\t\t\t{ background:#7b8da6; } *\/\r\n\t\t#explanation \t\t\t\t\t\t\t\t\t\t\t{ width:auto; min-height:0px; margin:0 auto; padding:0px 0; text-align:center;}\r\n\t\t#explanation span \t\t\t\t\t\t\t\t\t\t{ font-weight:bold; padding-right:8px; }\r\n\t\t.choice-box \t\t\t\t\t\t\t\t\t\t\t{ width:100%;  display:block;  text-align:center;  margin:5px auto !important; padding:10px 0 !important; border:1px solid #bdbdbd; }\r\n      .choice-box.btn {font-size: 28px;}\r\n\t\t.correct \t\t\t\t\t\t\t\t\t\t\t\t{ color:#51a351; font-size: 32px; display: block; margin-bottom: 5px; border-bottom: 1px #51a351 solid; padding-bottom: 5px; }\r\n\t\t.incorrect \t\t\t\t\t\t\t\t\t\t\t\t{ color:#f93939; font-size: 32px; display: block; margin-bottom: 5px; border-bottom: 1px #f93939 solid; padding-bottom: 5px; }\r\n    \r\n#body{\r\nwidth:100vw;\r\nheight:100vh;\r\n}\r\n \r\n    <\/style>\r\n\r\n<\/head>\r\n\r\n<body>\r\n  \r\n\r\n  <!-- home button \r\n  <div id=\"menuDiv\">\r\n<script src=\"https:\/\/quarta.glitch.me\/dropdownclassi.js\"><\/script>\r\n<\/div>\r\n  -->\r\n\r\n\r\n  \r\n\r\n<div class=\"form-group rsform-block rsform-block-framecontent\"><div id=\"frame\" role=\"content\"><\/div>\r\n\r\n<\/div>\r\n<script>\r\n  \r\n  \r\n  <\/script>\r\n\t\t\t\r\n\r\n<\/body>\r\n<\/html>\r\n\r\n\n<p><iframe loading=\"lazy\" title=\"Pydarm: python to create quiz in html\" width=\"747\" height=\"560\" src=\"https:\/\/www.youtube.com\/embed\/0j4Om_feDNU?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<!-- se vuoi mettere un testo scorrevole\r\n[hoops name=\"typeWriterGen\"]\r\n\r\npoi metti un id diverso per ogni testo nella stessa pagina\r\n\r\n<div id=\"div01\">\r\n<script>\r\n\r\ntypeWriterGen(\"div01\",\"Esempio di testo scorrevole\");\r\n<\/script>\r\n\r\n-->\r\n<style>\r\n.avatar {\r\n  vertical-align: middle;\r\n  width: 100px;\r\n  height: 100px;\r\n  border-radius: 50%;\r\n}\r\n<\/style>\r\n\r\n<hr>\r\n\r\n<!-- NEWSLETTER LINK -->\r\n<a href=\"https:\/\/docs.google.com\/forms\/d\/e\/1FAIpQLSf7TniIPCWHDzCSGh2dYZaCwDvi9yLKS5ovFdKuK1sdfOvwEg\/viewform\">\r\n<img decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2023\/08\/image-13.png\" class=\"avatar\">\r\nSubscribe to the <b>newsletter<\/b> for updates<\/a><br>\r\n\r\n<!-- TKINTER TEMPLATE LINK -->\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/tkinter-templates\/\">\r\n<img decoding=\"async\" src=\"https:\/\/i0.wp.com\/pythonprogramming.altervista.org\/wp-content\/uploads\/2023\/07\/image-26.png\" class=\"avatar\">\r\nTkinter templates<\/a><br>\r\n\r\n<!-- MY AVATAR PUT A LINK TO YOUTUBE CHANNEL-->\r\n<iframe loading=\"lazy\" frameborder=\"0\" src=\"https:\/\/itch.io\/embed\/711828\" width=\"552\" height=\"167\"><a href=\"https:\/\/pythonprogrammi.itch.io\/pysnake\">PySnake by PythonProgrammi<\/a><\/iframe>\r\n<br>\r\n<style>\r\n.avatar {\r\n  vertical-align: middle;\r\n  width: 100px;\r\n  height: 100px;\r\n  border-radius: 50%;\r\n}\r\n<\/style>\r\n\r\n\r\n<a href=\"https:\/\/www.youtube.com\/channel\/UCzbxq5e9gLiY-je2-br1rvg\">\r\n\t<img decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/10\/avatar64x64.png\" alt=\"Avatar\" class=\"avatar\">\r\n\t My youtube channel<\/a><br>\r\n\r\n<br>\r\n\r\nTwitter: <a href=\"https:\/\/twitter.com\/pythonprogrammi\">@pythonprogrammi - python_pygame<\/a>\r\n<h3>Claude's Games<\/h3>\r\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/random-daily-game-1-arkanoid\/\">Arkanoid<\/a><br>\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/platform-2d-with-pygame-made-with-claude\/\">Platform 2d<\/a><\/p> <!-- videogames made with claude -->\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/artifacts-games-day-1-memory-game\/\">1. Memory game<\/a>\r\n<h4>Videos<\/h4>\r\n<a href=\"https:\/\/youtu.be\/ciLjWWw5pLY\">Speech recognition game<\/a>\r\n<h3>Pygame's Platform Game<\/h3>\r\n\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-5-sounds-and-mixer\/\"><img decoding=\"async\" src=\"https:\/\/i1.wp.com\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/01\/climbercover.png?w=557&ssl=1\"\/ width=\"50%\"><\/a>\r\n<script>\r\nvar title = \"Platform Pygame\";\r\n\t\tvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-animation-of-a-sprite-v-1-3\/\",\"Animation 1.3\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-sprite-animation-v-2-better-coding-test-it-checking-fps-on-the-screen\/\",\"Animation 1.2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-how-to-display-the-frame-rate-fps-on-the-screen\/\",\"Display Frame rate\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-sprite-animation-update\/\",\"Animation 1.1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platformer-1\/\",\"Pygame Platform Game 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-platform-game-2\/\",\"Pygame Platform 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-3-recap-cheatsheet\/\",\"Pygame PLatform 3 - recap and some Cheat Sheet\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-4-background-and-stuffs\/\",\"Pygame Platform 4 - Background & organizing code\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-5-sounds-and-mixer\/\",\"Pygame Platform 5 - Sounds\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/platform-game-in-detail-part-1\/\",\"Game in detail part 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/map-maker-1-2\/\", \"Map maker 1.2\"]\r\n\t\t];\r\n\t\t<\/script>\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\r\n\r\n<h3>Other Pygame's posts<\/h3>\r\n\r\n<script>\r\nvar title = \"Pygame's Posts\"\r\nvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platformer-1\/\",\"Platform game 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/make-a-platform-game-with-pygame-dafluffypotato\/\",\"DaFluffyPotato Platform Tutorials\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-and-classic-arcade-games-pong\/\",\"Pong Game Full\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-draws-in-colors-app-to-draw-with-pygame\/\",\"PyGameGIF 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-draw-app-with-animation\/\",\"PyGameGIF 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pydraw-2-0-app-to-draw-gif\/\",\"PyDraw 2.0\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-drawing-2\/\",\"Draw with Pygame\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/animation-with-pygame\",\"Sprite animation 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/animation-on-pygame-2-free-characters-and-more-actions\/\",\"Sprite animation 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/starting-with-pygame\/\",\"Starting movements with Pygame\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-3-move-sprite\/\", \"Move a Sprite\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-4-fonts\/\",\"Text and Fonts\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-animate-a-sprite\/\", \"Animate a sprite\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-and-mouse-events\/\",\"Mouse events\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pgp-aka-pygamepresentation-project\/\",\"Pygame presentation\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/moving-the-player-in-pygame-with-key-get_pressed\/\",\"How to use key.get_pressed()\"]\r\n]\r\n<\/script>\r\n\r\n\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\n","protected":false},"excerpt":{"rendered":"Make a quiz with python that manipulates html code\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/pydarm-python-to-generate-tests-in-html\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":7823,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1,932],"tags":[739,321,4,103,126],"class_list":["post-7821","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-examples","category-quiz","tag-generator","tag-html","tag-python","tag-quiz","tag-test"],"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\/7821","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=7821"}],"version-history":[{"count":4,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/7821\/revisions"}],"predecessor-version":[{"id":7826,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/7821\/revisions\/7826"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/7823"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=7821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=7821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=7821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}