Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/mod/quiz/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/mod/quiz/amd/build/random_question_form_preview.min.js.map

{"version":3,"sources":["../src/random_question_form_preview.js"],"names":["define","$","Ajax","Str","Notification","Templates","PagedContentFactory","TEMPLATE_NAME","SELECTORS","LOADING_ICON_CONTAINER","QUESTION_COUNT_CONTAINER","QUESTION_LIST_CONTAINER","showLoadingIcon","root","find","removeClass","hideLoadingIcon","addClass","renderQuestionCount","questionCount","get_string","then","string","html","fail","exception","requestQuestions","categoryId","includeSubcategories","tagIds","contextId","limit","offset","call","methodname","args","categoryid","includesubcategories","tagids","contextid","renderQuestionsAsPagedContent","totalQuestionCount","firstPageQuestions","createFromAjax","pagesData","map","pageData","render","questions","response","reload","totalCount","totalcount","length","Deferred","resolve","js","container","replaceNodeContents","always"],"mappings":"AAwBAA,OAAM,yCACF,CACI,QADJ,CAEI,WAFJ,CAGI,UAHJ,CAII,mBAJJ,CAKI,gBALJ,CAMI,4BANJ,CADE,CASF,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOE,IAGEC,CAAAA,CAAa,CAAG,qDAHlB,CAIEC,CAAS,CAAG,CACZC,sBAAsB,CAAE,0CADZ,CAEZC,wBAAwB,CAAE,4CAFd,CAGZC,uBAAuB,CAAE,2CAHb,CAJd,CAeEC,CAAe,CAAG,SAASC,CAAT,CAAe,CACjCA,CAAI,CAACC,IAAL,CAAUN,CAAS,CAACC,sBAApB,EAA4CM,WAA5C,CAAwD,QAAxD,CACH,CAjBC,CAwBEC,CAAe,CAAG,SAASH,CAAT,CAAe,CACjCA,CAAI,CAACC,IAAL,CAAUN,CAAS,CAACC,sBAApB,EAA4CQ,QAA5C,CAAqD,QAArD,CACH,CA1BC,CAkCEC,CAAmB,CAAG,SAASL,CAAT,CAAeM,CAAf,CAA8B,CACpDhB,CAAG,CAACiB,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,CAAf,CAAmB,CAErB,GAAIC,CAAAA,CAAS,CAAG5C,CAAI,CAACC,IAAL,CAAUN,CAAS,CAACG,uBAApB,CAAhB,CACAN,CAAS,CAACqD,mBAAV,CAA8BD,CAA9B,CAAyClC,CAAzC,CAA+CiC,CAA/C,CAEH,CAlCE,EAmCFG,MAnCE,CAmCK,UAAW,CACf3C,CAAe,CAACH,CAAD,CAClB,CArCE,EAsCFW,IAtCE,CAsCGpB,CAAY,CAACqB,SAtChB,CAuCV,CAEM,CAEHb,eAAe,CAAEA,CAFd,CAGHI,eAAe,CAAEA,CAHd,CAKV,CAlNK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * JavaScript for the random_question_form_preview of the\n * add_random_form class.\n *\n * @module    mod_quiz/random_question_form_preview\n * @package   mod_quiz\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n    [\n        'jquery',\n        'core/ajax',\n        'core/str',\n        'core/notification',\n        'core/templates',\n        'core/paged_content_factory'\n    ],\n    function(\n        $,\n        Ajax,\n        Str,\n        Notification,\n        Templates,\n        PagedContentFactory\n    ) {\n\n    var ITEMS_PER_PAGE = 5;\n    var TEMPLATE_NAME = 'mod_quiz/random_question_form_preview_question_list';\n    var SELECTORS = {\n        LOADING_ICON_CONTAINER: '[data-region=\"overlay-icon-container\"]',\n        QUESTION_COUNT_CONTAINER: '[data-region=\"question-count-container\"]',\n        QUESTION_LIST_CONTAINER: '[data-region=\"question-list-container\"]'\n    };\n\n    /**\n     * Show the loading spinner over the preview section.\n     *\n     * @param  {jquery} root The root element.\n     */\n    var showLoadingIcon = function(root) {\n        root.find(SELECTORS.LOADING_ICON_CONTAINER).removeClass('hidden');\n    };\n\n    /**\n     * Hide the loading spinner.\n     *\n     * @param  {jquery} root The root element.\n     */\n    var hideLoadingIcon = function(root) {\n        root.find(SELECTORS.LOADING_ICON_CONTAINER).addClass('hidden');\n    };\n\n    /**\n     * Render the section of text to show the question count.\n     *\n     * @param  {jquery} root The root element.\n     * @param  {int} questionCount The number of questions.\n     */\n    var renderQuestionCount = function(root, questionCount) {\n        Str.get_string('questionsmatchingfilter', 'mod_quiz', questionCount)\n            .then(function(string) {\n                root.find(SELECTORS.QUESTION_COUNT_CONTAINER).html(string);\n                return;\n            })\n            .fail(Notification.exception);\n    };\n\n    /**\n     * Send a request to the server for more questions.\n     *\n     * @param  {int} categoryId A question category id.\n     * @param  {bool} includeSubcategories If the results should include subcategory questions\n     * @param  {int[]} tagIds The list of tag ids that each question must have.\n     * @param  {int} contextId The context where the questions will be added.\n     * @param  {int} limit How many questions to retrieve.\n     * @param  {int} offset How many questions to skip from the start of the result set.\n     * @return {promise} Resolved when the preview section has rendered.\n     */\n    var requestQuestions = function(\n        categoryId,\n        includeSubcategories,\n        tagIds,\n        contextId,\n        limit,\n        offset\n    ) {\n        var request = {\n            methodname: 'core_question_get_random_question_summaries',\n            args: {\n                categoryid: categoryId,\n                includesubcategories: includeSubcategories,\n                tagids: tagIds,\n                contextid: contextId,\n                limit: limit,\n                offset: offset\n            }\n        };\n\n        return Ajax.call([request])[0];\n    };\n\n    /**\n     * Build a paged content widget for questions with the given criteria. The\n     * criteria is used to fetch more questions from the server as the user\n     * requests new pages.\n     *\n     * @param  {int} categoryId A question category id.\n     * @param  {bool} includeSubcategories If the results should include subcategory questions\n     * @param  {int[]} tagIds The list of tag ids that each question must have.\n     * @param  {int} contextId The context where the questions will be added.\n     * @param  {int} totalQuestionCount How many questions match the criteria above.\n     * @param  {object[]} firstPageQuestions List of questions for the first page.\n     * @return {promise} A promise resolved with the HTML and JS for the paged content.\n     */\n    var renderQuestionsAsPagedContent = function(\n        categoryId,\n        includeSubcategories,\n        tagIds,\n        contextId,\n        totalQuestionCount,\n        firstPageQuestions\n    ) {\n        // Provide a callback, renderQuestionsPages,\n        // to control how the questions on each page are rendered.\n        return PagedContentFactory.createFromAjax(\n            totalQuestionCount,\n            ITEMS_PER_PAGE,\n            // Callback function to render the requested pages.\n            function(pagesData) {\n                return pagesData.map(function(pageData) {\n                    var limit = pageData.limit;\n                    var offset = pageData.offset;\n\n                    if (offset == 0) {\n                        // The first page is being requested and we've already got\n                        // that data so we can just render it immediately.\n                        return Templates.render(TEMPLATE_NAME, {questions: firstPageQuestions});\n                    } else {\n                        // Otherwise we need to ask the server for the data.\n                        return requestQuestions(\n                            categoryId,\n                            includeSubcategories,\n                            tagIds,\n                            contextId,\n                            limit,\n                            offset\n                        )\n                        .then(function(response) {\n                            var questions = response.questions;\n                            return Templates.render(TEMPLATE_NAME, {questions: questions});\n                        })\n                        .fail(Notification.exception);\n                    }\n                });\n            }\n        );\n    };\n\n    /**\n     * Re-render the preview section based on the provided filter criteria.\n     *\n     * @param  {jquery} root The root element.\n     * @param  {int} categoryId A question category id.\n     * @param  {bool} includeSubcategories If the results should include subcategory questions\n     * @param  {int[]} tagIds The list of tag ids that each question must have.\n     * @param  {int} contextId The context where the questions will be added.\n     * @return {promise} Resolved when the preview section has rendered.\n     */\n    var reload = function(root, categoryId, includeSubcategories, tagIds, contextId) {\n        // Show the loading spinner to tell the user that something is happening.\n        showLoadingIcon(root);\n        // Load the first set of questions.\n        return requestQuestions(categoryId, includeSubcategories, tagIds, contextId, ITEMS_PER_PAGE, 0)\n            .then(function(response) {\n                var totalCount = response.totalcount;\n                // Show the help message for the user to indicate how many questions\n                // match their filter criteria.\n                renderQuestionCount(root, totalCount);\n                return response;\n            })\n            .then(function(response) {\n                var totalQuestionCount = response.totalcount;\n                var questions = response.questions;\n\n                if (questions.length) {\n                    // We received some questions so render them as paged content\n                    // with a paging bar.\n                    return renderQuestionsAsPagedContent(\n                        categoryId,\n                        includeSubcategories,\n                        tagIds,\n                        contextId,\n                        totalQuestionCount,\n                        questions\n                    );\n                } else {\n                    // If we didn't receive any questions then we can return empty\n                    // HTML and JS to clear the preview section.\n                    return $.Deferred().resolve('', '');\n                }\n            })\n            .then(function(html, js) {\n                // Show the user the question set.\n                var container = root.find(SELECTORS.QUESTION_LIST_CONTAINER);\n                Templates.replaceNodeContents(container, html, js);\n                return;\n            })\n            .always(function() {\n                hideLoadingIcon(root);\n            })\n            .fail(Notification.exception);\n    };\n\n    return {\n        reload: reload,\n        showLoadingIcon: showLoadingIcon,\n        hideLoadingIcon: hideLoadingIcon\n    };\n});\n"],"file":"random_question_form_preview.min.js"}