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QrB,QACa,IAA7BsB,OAAOC,oBACdD,OAAOC,kBAAoB,IAE/B,IAAIC,EAAU,UAAYxB,EAC1BsB,OAAOC,kBAAkBC,GAAW,SAAUhB,GAC1Ca,EAAOd,aAAaC,IAlBhBiB,CAAcJ,EAAQA,EAAOrB,UAC/B,MAAO0B,GACLC,QAAQC,IAAI,mCAAmC7C,KAAKG,0CAC3BwC,KACzBC,QAAQC,IAAIF,EAAIG","sources":["webpack://WebComponents/./runestone/quizly/js/quizly.js"],"sourcesContent":["/*\n__author__ = Ralph Morelli\n__date__ = 4/9/2021 */\n\n/* **********\n This script renders the quizly HTML code and sets up functions\n to process the quiz when the user clicks on the quizly 'Check me'\n button. \n\n It gets the data it needs from the Quizly node created by quizly.py\n during the runestone build step.\n\n NOTE: An entry for quizly.js script must be added to the webpack.config.js.\n ************** */\n\n\"use strict\";\n\nimport RunestoneBase from \"../../common/js/runestonebase.js\";\n//import \"../css/poll.css\";\n\nvar DEBUG = false;\n\nexport var quizlyList = {};\n\nexport default class Quizly extends RunestoneBase {\n constructor(opts) {\n super(opts);\n var orig = opts.orig; // Looks something like: {\"orig\":{\"jQuery351095558298548049562\":{\"question_label\":\"1.1.2\"}}}\n if (DEBUG)\n console.log(\n \"DEBUG: Quizly constructor, opts=\" + JSON.stringify(opts)\n );\n this.origElem = orig;\n this.divid = orig.id;\n if (DEBUG)\n console.log(\"DEBUG: Quizly constructor, divid= \" + this.divid);\n this.resultsViewer = $(orig).data(\"results\");\n this.getIFrameAndQuizname();\n this.renderQuizly(); //generates HTML\n // Checks localStorage to see if this quizly has already been completed by this user.\n // this.checkQuizlyStorage();\n this.caption = \"Quizly\";\n this.addCaption(\"runestone\");\n }\n\n // The main content of the quizly node is the iframe.\n getIFrameAndQuizname() {\n var html = $(this.origElem).html();\n var p1 = html.search(\"\");\n this.iframe = html.slice(p1, p2 + 8);\n if (DEBUG) console.log(\"DEBUG: getIFrame() html = \" + html);\n if (DEBUG) console.log(\"DEBUG: getIFrame() iframe = \" + this.iframe);\n p1 = html.search(\"quizname=\");\n p2 = html.search(\"hints\");\n this.quizname = html.slice(p1 + 9, p2 - 5); // Grab the quizname from iframe\n if (DEBUG) console.log(\"DEBUG quizname= \", this.quizname);\n }\n\n // Generates the HTML that the user interacts with\n renderQuizly() {\n var _this = this;\n if (DEBUG) console.log(\"DEBUG: renderQuizly()\");\n this.containerDiv = document.createElement(\"div\");\n // this.quizlyFrame = document.createElement(\"iframe\");\n this.containerDiv.id = this.divid;\n $(this.containerDiv).addClass(this.origElem.getAttribute(\"class\"));\n $(this.containerDiv).html(this.iframe);\n $(this.origElem).replaceWith(this.containerDiv);\n if (DEBUG)\n console.log(\n \"DEBUG: renderQuizly(), this = \" + JSON.stringify(this)\n );\n }\n\n // Called from the exercise when user clicks submit button\n // Checks for the result, sets localstorage and submits to the server\n submitQuizly(result) {\n if (DEBUG)\n console.log(\n \"DEBUG: submitQuizly result = \" + JSON.stringify(result)\n );\n var answer = result[\"xml\"];\n var correct = result[\"result\"] == true ? \"T\" : \"F\";\n var loganswer = \"answer:\" + (correct == \"T\" ? \"correct\" : \"no\"); // backward compatible\n var eventInfo = {\n event: \"quizly\",\n act: loganswer,\n answer: answer,\n correct: correct,\n div_id: this.divid,\n };\n // Log the response to the database\n this.logBookEvent(eventInfo); // in bookfuncs.js\n if (DEBUG)\n console.log(\n \"DEBUG: submitquizly logbookevent = \" +\n JSON.stringify(eventInfo)\n );\n // Log the fact that the user has attempted this quizly exercise to local storage\n localStorage.setItem(this.divid, \"true\");\n }\n}\n\n/*=================================\n== Find the custom HTML tags and ==\n== execute our code on them ==\n=================================*/\n$(document).on(\"runestone:login-complete\", function () {\n $(\"[data-component=quizly\").each(function (index) {\n try {\n var quizly = new Quizly({ orig: this });\n quizlyList[this.id] = quizly;\n if (DEBUG)\n console.log(\"DEBUG: Quizly rendering, this.id = \" + this.id);\n setupCallback(quizly, quizly.quizname);\n } catch (err) {\n console.log(`Error rendering Quizly Exercise ${this.id}\n Details: ${err}`);\n console.log(err.stack);\n }\n });\n});\n\n// Sets up a unique callback function on the window containing the quizly component\n// The quizly param is a reference to this quizly object so that it can be use during callback.\n// The quizname param is used to construct a unique callback function name\nfunction setupCallback(quizly, quizname) {\n if (typeof window.component_factory === \"undefined\") {\n window.component_factory = {};\n }\n var fn_name = \"quizly_\" + quizname; // Unique function name\n window.component_factory[fn_name] = function (result) {\n quizly.submitQuizly(result);\n };\n}\n"],"names":["quizlyList","Quizly","constructor","opts","super","orig","this","origElem","divid","id","resultsViewer","$","data","getIFrameAndQuizname","renderQuizly","caption","addCaption","html","p1","search","p2","iframe","slice","quizname","containerDiv","document","createElement","addClass","getAttribute","replaceWith","submitQuizly","result","answer","correct","eventInfo","event","act","div_id","logBookEvent","localStorage","setItem","on","each","index","quizly","window","component_factory","fn_name","setupCallback","err","console","log","stack"],"sourceRoot":""}