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gBX,GAGtBf,EAAOI,GAAkBC,EAAKC,IAtDnD3H,EAAEC,UAAUE,GAAG,QAAS,iBAAiB,WAGrC,OADAoH,EADYvH,EAAEmB,QAEP,KAGXmG,EAAQ0B,MAAK,WAETzB,EADYvH,EAAEmB,e","sources":["webpack://app/./app/javascript/src/label/high-contrast-toggle.js","webpack://app/./app/javascript/src/knockout/init.js","webpack://app/./app/javascript/src/knockout/test_passage.js","webpack://app/./app/javascript/src/knockout/custom_test_passage.js","webpack://app/./app/javascript/application.js","webpack://app/./app/javascript/src/label/template.js","webpack://app/./app/javascript/src/paper-template/components/_toastr.js"],"sourcesContent":["import $ from \"jquery\";\n\nfunction setHighContrast() {\n\n $(document).off('click.high-contrast-toggle')\n $(document).on('click.high-contrast-toggle', '.high-contrast-toggle', function () {\n const $body = $('body');\n\n $body.toggleClass('high-contrast');\n\n let onOff = \"off\";\n if ($body.hasClass('high-contrast')) {\n onOff = \"on\"\n }\n document.cookie = `high-contrast=${onOff}; path=/; max-age=3600`\n })\n\n if (document.cookie.match(/high-contrast=on/)) {\n const $body = $('body');\n $body.addClass('high-contrast');\n } else {\n const $body = $('body');\n $body.removeClass('high-contrast');\n }\n}\n\n\ndocument.addEventListener('turbolinks:load', setHighContrast);\n$(setHighContrast);\n","import ko from 'knockout';\n\nwindow.ko = ko;","import ko from 'knockout';\nimport $ from 'jquery';\n\nconst questionCache = {};\n\nclass Question {\n constructor(data) {\n this.id = data.id;\n this.num = data.num;\n this.content = data.content;\n questionCache[this.id] = this;\n }\n}\n\nclass Answer {\n constructor(data) {\n if (Array.isArray(data)) { // загружаем из начальных данных\n this.question_id = data[0];\n this.answer = data[1];\n this.duration = data[2];\n this.postponed_at = data[3];\n this.answered_at = data[4];\n } else { // используем внутри\n this.question_id = data.question_id;\n this.answer = data.answer;\n this.duration = data.duration;\n this.postponed_at = data.postponed_at;\n this.answered_at = data.answered_at || Date.now();\n }\n }\n\n serialize() { // обмениваемся массивами, так как это намного быстрее\n return [\n this.question_id,\n this.answer,\n this.duration,\n this.postponed_at,\n this.answered_at\n ];\n }\n}\n\nclass TestPassage {\n constructor(data) {\n this.id = data.id;\n this.url = `/test_passages/${this.id}`;\n\n this.questions = ko.observableArray(data.questions.map((item) => new Question(item)));\n\n const localData = localStorage.getItem(this.localStorageKey());\n const localAnswers = localData && JSON.parse(localData);\n\n this.completeFromLocalStorage = false;\n let chosen = data.answers;\n if (localAnswers && localAnswers.answers && localAnswers.answers.length > data.answers.length) {\n chosen = localAnswers.answers;\n\n // если обрыв связи был на последнем вопросе, то надо сохраниться\n this.completeFromLocalStorage = chosen.length === data.questions.length;\n }\n\n this.answers = ko.observableArray(chosen.map((item) => new Answer(item)));\n\n this.postponed = ko.observableArray([]);\n this.answered = ko.observableArray([]);\n\n for (const a of chosen) {\n const q = questionCache[a[0]]; // question id\n this.questions.remove(q);\n\n if (a[3]) { // postponed_at\n this.postponed().push(q);\n } else {\n this.answered().push(q);\n }\n }\n\n this.currentQuestion = ko.observable(null);\n\n this.postponedCount = ko.computed(() => this.postponed().length);\n this.currentQuestionNumber = ko.computed(() => this.answers().length + 1);\n this.currentQuestionContent = ko.computed(() => this.currentQuestion() ? this.currentQuestion().content : '');\n this.currentQuestionId = ko.computed(() => this.currentQuestion() ? this.currentQuestion().id : null);\n this.selectedAnswer = ko.observable(null);\n\n this.activeIfSelected_0 = ko.computed(() => this.activeIfSelected(0));\n this.activeIfSelected_1 = ko.computed(() => this.activeIfSelected(1));\n this.activeIfSelected_2 = ko.computed(() => this.activeIfSelected(2));\n this.activeIfSelected_3 = ko.computed(() => this.activeIfSelected(3));\n\n this.view = ko.observable('instruction');\n if (this.currentQuestionNumber() > 1) {\n this.passage();\n }\n }\n\n activeIfSelected(answer) {\n this.selectedAnswer() == answer ? 'active' : 'inactive';\n }\n\n selectAnswer(answer) {\n this.selectedAnswer(answer);\n }\n\n confirmAnswer() {\n if (this.selectedAnswer() == null) {\n return;\n }\n this.selectAndConfirmAnswer(this.selectedAnswer());\n this.selectedAnswer(null);\n }\n\n answerPostponed() {\n this.questions.push(...this.postponed());\n this.answers.remove((a) => a.postponed_at);\n this.postponed.removeAll();\n this.passage();\n }\n\n selectAndConfirmAnswer(answerValue) {\n const question = this.currentQuestion();\n const answer = new Answer({\n question_id: question.id,\n answer: answerValue,\n duration: Math.floor((performance.now() - this.startQuestionTime)/1000)\n });\n this.answers.push(answer);\n this.answered.push(question);\n this.questions.remove(question);\n this.saveAnswers();\n\n this.passage();\n }\n\n getRandom(max) {\n return Math.floor(Math.random() * max);\n }\n\n randomQuestion() {\n const count = this.questions().length;\n\n if (count > 0) {\n return this.questions()[this.getRandom(count)];\n } else {\n return undefined;\n }\n }\n\n postponeQuestion() {\n const question = this.currentQuestion();\n\n this.questions.remove(question);\n this.postponed.push(question);\n\n const answer = new Answer({\n question_id: question.id,\n postponed_at: Date.now(),\n });\n this.answers.push(answer);\n\n this.saveAnswers();\n\n this.passage();\n }\n\n passage() {\n const nextQuestion = this.randomQuestion();\n\n if (nextQuestion) {\n this.currentQuestion(nextQuestion);\n this.startQuestionTime = performance.now();\n this.view('question');\n } else if (this.postponedCount() > 0) {\n this.view('postponed');\n } else {\n this.view('completed');\n if (this.completeFromLocalStorage) {\n this.saveAnswers();\n }\n }\n }\n\n localStorageKey() {\n return `testPassage#${this.id}`;\n }\n\n saveAnswers() {\n const url = this.url;\n const answers_array = this.answers().map(a => a.serialize());\n const data = JSON.stringify({answers: answers_array});\n\n $.ajax({\n url: url,\n method: 'PATCH',\n data: data,\n dataType: 'json',\n contentType: 'application/json; charset=utf-8',\n }).done((data) => {\n localStorage.removeItem(this.localStorageKey());\n\n if (data.completed) {\n window.location = url;\n }\n\n if (data.restart === true) {\n localStorage.removeItem(this.localStorageKey());\n this.view('monotonicDetected');\n }\n }).fail(() => {\n localStorage.setItem(this.localStorageKey(), data);\n this.view('saveFailed');\n });\n }\n}\n\nko.startPassage = function (data, questions) {\n data.questions = questions;\n ko.passageData = data; // debug\n const passage = new TestPassage(data);\n ko.passage = passage; // debug\n\n ko.applyBindings(passage);\n\n $('#no-ko-view').hide();\n $('#ko-view').show();\n}\n","import ko from 'knockout';\nimport $ from 'jquery';\n\nconst customQuestionCache = {}\n\nclass CustomQuestion {\n constructor(data) {\n this.id = data.id\n this.number = data.number\n this.content = data.content\n this.answers = data.answers\n customQuestionCache[this.id] = this\n }\n}\n\nclass CustomAnswer {\n constructor(data) {\n if (Array.isArray(data)) { // загружаем из начальных данных\n this.question_id = data[0]\n this.answer = data[1]\n this.duration = data[2]\n this.postponed_at = data[3]\n this.answered_at = data[4]\n } else { // используем внутри\n this.question_id = data.question_id\n this.answer = data.answer\n this.duration = data.duration\n this.postponed_at = data.postponed_at\n this.answered_at = data.answered_at || Date.now()\n }\n }\n\n serialize() { // обмениваемся массивами, так как это намного быстрее\n return [\n this.question_id,\n this.answer,\n this.duration,\n this.postponed_at,\n this.answered_at\n ]\n }\n}\n\nclass CustomTestPassage {\n constructor(data) {\n this.id = data.id\n this.url = `/custom_test_passages/${this.id}`\n\n this.questions = ko.observableArray(data.questions.map((item) => new CustomQuestion(item)))\n this.randomQuestionOrder = data.random_question_order\n\n const localData = localStorage.getItem(this.localStorageKey());\n const localAnswers = localData && JSON.parse(localData);\n\n this.completeFromLocalStorage = false;\n let chosen = data.answers;\n if (localAnswers && localAnswers.answers && localAnswers.answers.length > data.answers.length) {\n chosen = localAnswers.answers;\n\n // если обрыв связи был на последнем вопросе, то надо сохраниться\n this.completeFromLocalStorage = chosen.length === data.questions.length;\n }\n\n this.answers = ko.observableArray(chosen.map((item) => new CustomAnswer(item)))\n\n this.postponed = ko.observableArray([])\n this.answered = ko.observableArray([])\n\n for (const a of chosen) {\n const q = customQuestionCache[a[0]]\n this.questions.remove(q)\n\n if (a[3]) { // postponed_at\n this.postponed().push(q)\n } else {\n this.answered().push(q)\n }\n }\n\n this.currentQuestion = ko.observable(null)\n\n this.postponedCount = ko.computed(() => this.postponed().length)\n this.currentQuestionNumber = ko.computed(() => this.answers().length + 1)\n this.currentQuestionContent = ko.computed(() => this.currentQuestion() ? this.currentQuestion().content : '')\n this.currentQuestionId = ko.computed(() => this.currentQuestion() ? this.currentQuestion().id : null)\n this.selectedAnswer = ko.observable(null)\n\n this.currentQuestionAnswers = ko.computed(() => this.currentQuestion() ? this.currentQuestion().answers : [])\n\n this.view = ko.observable('instruction')\n if (this.currentQuestionNumber() > 1) {\n this.passage()\n }\n }\n\n selectAnswer(answer) {\n this.selectedAnswer(answer)\n }\n\n confirmAnswer() {\n if (this.selectedAnswer() == null) {\n return;\n }\n this.selectAndConfirmAnswer(this.selectedAnswer());\n this.selectedAnswer(null);\n }\n\n answerPostponed() {\n this.questions.push(...this.postponed())\n this.answers.remove((a) => a.postponed_at)\n this.postponed.removeAll()\n this.passage()\n }\n\n selectAndConfirmAnswer(answerValue) {\n const question = this.currentQuestion();\n const answer = new CustomAnswer({\n question_id: question.id,\n answer: answerValue,\n duration: Math.floor((performance.now() - this.startQuestionTime)/1000)\n });\n this.answers.push(answer);\n this.answered.push(question);\n this.questions.remove(question);\n this.saveAnswers();\n\n this.passage()\n }\n\n getRandom(max) {\n return Math.floor(Math.random() * max);\n }\n\n nextQuestion() {\n const count = this.questions().length;\n\n if (count > 0) {\n return this.randomQuestionOrder ? this.questions()[this.getRandom(count)] : this.questions()[0]\n } else {\n return undefined;\n }\n }\n\n postponeQuestion() {\n const question = this.currentQuestion();\n\n this.questions.remove(question)\n this.postponed.push(question)\n\n const answer = new CustomAnswer({\n question_id: question.id,\n postponed_at: Date.now(),\n });\n this.answers.push(answer)\n\n this.saveAnswers()\n\n this.passage()\n }\n\n passage() {\n const nextQuestion = this.nextQuestion()\n\n if (nextQuestion) {\n this.currentQuestion(nextQuestion)\n this.startQuestionTime = performance.now()\n this.view('question')\n } else if (this.postponedCount() > 0) {\n this.view('postponed')\n } else {\n this.view('completed')\n if (this.completeFromLocalStorage) {\n this.saveAnswers();\n }\n }\n }\n\n localStorageKey() {\n return `customTestPassage#${this.id}`;\n }\n\n saveAnswers() {\n const url = this.url;\n const answers_array = this.answers().map(a => a.serialize());\n const data = JSON.stringify({answers: answers_array});\n\n $.ajax({\n url: url,\n method: 'PATCH',\n data: data,\n dataType: 'json',\n contentType: 'application/json; charset=utf-8',\n }).done((data) => {\n localStorage.removeItem(this.localStorageKey());\n\n if (data.completed) {\n window.location = url\n }\n }).fail(() => {\n localStorage.setItem(this.localStorageKey(), data);\n this.view('saveFailed');\n });\n }\n}\n\nko.startCustomPassage = function (data, questions) {\n data.questions = questions\n\n ko.applyBindings(new CustomTestPassage(data))\n\n $('#no-ko-view').hide()\n $('#ko-view').show()\n}\n","// This file is automatically compiled by Webpack, along with any other files\n// present in this directory. You're encouraged to place your actual application logic in\n// a relevant structure within app/javascript and only use these pack files to reference\n// that code so it'll be compiled.\n\nrequire(\"@rails/ujs\").start()\nrequire(\"select2\")\n\n// Uncomment to copy all static images under ../images to the output folder and reference\n// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)\n// or the `imagePath` JavaScript helper below.\n//\n// const images = require.context('../images', true)\n// const imagePath = (name) => images(name, true)\n\n// import \"controllers\"\n\nimport \"app\"\n\nimport jQuery from 'jquery'\nwindow.$ = window.jQuery = jQuery;\n\nimport Rails from \"@rails/ujs\";\nwindow.Rails = Rails;\n","'use strict';\n\n$(function() {\n // THEME COLORS\n var style = getComputedStyle(document.body);\n var chartColors = [\"#696ffb\", \"#7db8f9\", \"#05478f\", \"#00cccc\", \"#6CA5E0\", \"#1A76CA\"];\n var primaryColor = style.getPropertyValue('--primary');\n var secondaryColor = style.getPropertyValue('--secondary');\n var successColor = style.getPropertyValue('--success');\n var warningColor = style.getPropertyValue('--warning');\n var dangerColor = style.getPropertyValue('--danger');\n var infoColor = style.getPropertyValue('--info');\n var darkColor = style.getPropertyValue('--dark');\n\n\n // BODY ELEMENTS\n var Body = $(\"body\");\n var TemplateSidebar = $('.sidebar');\n var TemplateHeader = $('.t-header');\n var PageContentWrapper = $(\".page-content-wrapper\");\n var DesktopToggler = $(\".t-header-desk-toggler\");\n var MobileToggler = $(\".t-header-mobile-toggler\");\n\n // SIDEBAR TOGGLE FUNCTION FOR MOBILE (SCREEN \"MD\" AND DOWN)\n MobileToggler.on(\"click\", function () {\n $(\".page-body\").toggleClass(\"sidebar-collpased\");\n });\n\n});\n","(function() {\n $(function () {\n \"use strict\";\n var toastr = require('toastr');\n\n var element = $(\".toast\");\n $(document).on('click', '.toast-action', function () {\n var $this = $(this);\n toastrInit($this);\n return false;\n });\n\n element.each(function () {\n var $this = $(this);\n toastrInit($this);\n });\n\n function toastrInit(el) {\n if (el) {\n var shortCutFunction = el.data('type');\n var msg = el.data('message');\n var title = el.data('title') || '';\n var $showDuration = el.data('show-duration');\n var $hideDuration = el.data('hide-duration');\n var $timeOut = el.data('time-out');\n var $extendedTimeOut = el.data('extended-time-out');\n var $showEasing = el.data('show-easing');\n var $hideEasing = el.data('hide-easing');\n var $showMethod = el.data('show-duration');\n var $hideMethod = el.data('hide-method');\n var $positionClass = el.data('position-class');\n\n if ($showDuration) {\n toastr.options.showDuration = $showDuration;\n }\n if ($hideDuration) {\n toastr.options.hideDuration = $hideDuration;\n }\n if ($timeOut) {\n toastr.options.timeOut = addClear ? 0 : $timeOut;\n }\n if ($extendedTimeOut) {\n toastr.options.extendedTimeOut = addClear ? 0 : $extendedTimeOut;\n }\n if ($showEasing) {\n toastr.options.showEasing = $showEasing;\n }\n if ($hideEasing) {\n toastr.options.hideEasing = $hideEasing;\n }\n if ($showMethod) {\n toastr.options.showMethod = $showMethod;\n }\n if ($hideMethod) {\n toastr.options.hideMethod = $hideMethod;\n }\n if ($positionClass) {\n toastr.options.positionClass = $positionClass;\n }\n\n var $toast = toastr[shortCutFunction](msg, title);\n\n }\n }\n })\n}());"],"names":["setHighContrast","$","document","off","on","$body","toggleClass","onOff","hasClass","cookie","match","addClass","removeClass","addEventListener","window","ko","questionCache","Question","constructor","data","this","id","num","content","Answer","Array","isArray","question_id","answer","duration","postponed_at","answered_at","Date","now","serialize","TestPassage","url","questions","map","item","localData","localStorage","getItem","localStorageKey","localAnswers","JSON","parse","completeFromLocalStorage","chosen","answers","length","postponed","answered","a","q","remove","push","currentQuestion","postponedCount","currentQuestionNumber","currentQuestionContent","currentQuestionId","selectedAnswer","activeIfSelected_0","activeIfSelected","activeIfSelected_1","activeIfSelected_2","activeIfSelected_3","view","passage","selectAnswer","confirmAnswer","selectAndConfirmAnswer","answerPostponed","removeAll","answerValue","question","Math","floor","performance","startQuestionTime","saveAnswers","getRandom","max","random","randomQuestion","count","postponeQuestion","nextQuestion","answers_array","stringify","method","dataType","contentType","done","removeItem","completed","location","restart","fail","setItem","hide","show","customQuestionCache","CustomQuestion","number","CustomAnswer","CustomTestPassage","randomQuestionOrder","random_question_order","currentQuestionAnswers","require","jQuery","Rails","style","getComputedStyle","body","getPropertyValue","toastr","element","toastrInit","el","shortCutFunction","msg","title","$showDuration","$hideDuration","$timeOut","$extendedTimeOut","$showEasing","$hideEasing","$showMethod","$hideMethod","$positionClass","options","showDuration","hideDuration","timeOut","addClear","extendedTimeOut","showEasing","hideEasing","showMethod","hideMethod","positionClass","each"],"sourceRoot":""}