{"version":3,"file":"report-viewer-components.min.js","sources":["../src/report-viewer-components.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint no-unused-vars: warn */\n/*eslint max-len: [\"error\", { \"code\": 160 }] */\n/*eslint-disable no-trailing-spaces */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {SimpleLine} from './simpleline';\nimport {get_strings} from 'core/str';\nimport {load_strings, format_date} from './string-helper';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\nimport {svgarcpath} from './svgarc';\nimport Debugger from './debugger';\n\n// Make π available as a constant\nconst π = Math.PI;\nconst LINE_GRAVITY = 1.3;\n\nexport default {\n install(Vue/*,options*/){\n let debug = new Debugger(\"treestudyplan-viewer\");\n debug.enable();\n\n let lastCaller = null;\n /**\n * Scroll current period into view\n * @param {*} handle A key to pass so subsequent calls with the same key won't trigger (always triggers when null or undefined)\n */\n function scrollCurrentIntoView(handle){\n const elScrollContainer = document.querySelector(\".r-studyplan-scrollable\");\n const elCurrentHeader = elScrollContainer.querySelector(\".s-studyline-header-period.current\");\n debug.info(`scrollCurrentIntoView called with handle ${handle}`);\n\n if(elCurrentHeader && ((!handle) || (handle != lastCaller))){\n lastCaller = handle;\n elCurrentHeader.scrollIntoView({\n behavior: \"smooth\",\n block: \"start\",\n inline: \"center\",\n });\n }\n }\n\n let strings = load_strings({\n invalid: {\n error: 'error',\n },\n grading: {\n ungraded: \"ungraded\",\n graded: \"graded\",\n allgraded: \"allgraded\",\n unsubmitted: \"unsubmitted\",\n nogrades: \"nogrades\",\n unknown: \"unknown\",\n },\n completion: {\n completed: \"completion_completed\",\n incomplete: \"completion_incomplete\",\n completed_pass: \"completion_passed\",\n completed_fail: \"completion_failed\",\n ungraded: \"ungraded\",\n aggregation_all: \"aggregation_all\",\n aggregation_any: \"aggregation_any\",\n aggregation_overall_all: \"aggregation_overall_all\",\n aggregation_overall_any: \"aggregation_overall_any\",\n completion_not_configured: \"completion_not_configured\",\n configure_completion: \"configure_completion\",\n },\n badge: {\n share_badge: \"share_badge\",\n dateissued: \"dateissued\",\n dateexpire: \"dateexpire\",\n badgeinfo: \"badgeinfo\",\n badgeissuedstats: \"badgeissuedstats\",\n },\n course: {\n completion_incomplete: \"completion_incomplete\",\n completion_failed: \"completion_failed\",\n completion_pending: \"completion_pending\",\n completion_progress: \"completion_progress\",\n completion_completed: \"completion_completed\",\n completion_good: \"completion_good\",\n completion_excellent: \"completion_excellent\",\n view_feedback: \"view_feedback\",\n coursetiming_past: \"coursetiming_past\",\n coursetiming_present: \"coursetiming_present\",\n coursetiming_future: \"coursetiming_future\",\n required_goal: \"required_goal\",\n },\n teachercourse: {\n select_conditions: \"select_conditions\",\n select_grades: \"select_grades\",\n coursetiming_past: \"coursetiming_past\",\n coursetiming_present: \"coursetiming_present\",\n coursetiming_future: \"coursetiming_future\", \n grade_include: \"grade_include\", \n grade_require: \"grade_require\", \n required_goal: \"required_goal\",\n }\n\n });\n\n /************************************\n * *\n * Treestudyplan Viewer components *\n * *\n ************************************/\n\n /**\n * Check if element is visible\n * @param {Object} elem The element to check\n * @returns {boolean} True if visible\n */\n function isVisible(elem){\n return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );\n }\n\n // Create new eventbus for interaction between item components\n const ItemEventBus = new Vue();\n\n Vue.component('r-progress-circle',{\n props: {\n value: {\n type: Number,\n },\n max: {\n type: Number,\n default: 100,\n },\n min: {\n type: Number,\n default: 0,\n },\n stroke: {\n type: Number,\n default: 0.2,\n },\n bgopacity: {\n type: Number,\n default: 0.2,\n },\n title: {\n type: String,\n default: \"\",\n },\n\n },\n data() {\n return {\n selectedstudyplan: null,\n };\n },\n computed: {\n range() {\n return this.max - this.min;\n },\n fraction(){\n if(this.max - this.min == 0){\n return 0;\n // 0 size is always empty :)\n } else {\n return (this.value - this.min)/(this.max - this.min);\n }\n },\n radius() {\n return 50 - (50*this.stroke);\n },\n arcpath() {\n let fraction = 0; \n const r = 50 - (50*this.stroke);\n if(this.max - this.min != 0){\n fraction = (this.value - this.min)/(this.max - this.min);\n }\n\n const Δ = fraction * 2*π;\n return svgarcpath([50,50],[r,r],[0,Δ], 1.5*π);\n },\n },\n methods: {\n },\n template: `\n \n `,\n });\n\n\n Vue.component('r-report', {\n props: {\n value: {\n type: Array,\n },\n guestmode: {\n type: Boolean,\n default: false,\n },\n teachermode: {\n type: Boolean,\n default: false,\n }\n },\n data() {\n return {\n selectedstudyplan: null,\n };\n },\n computed: {\n displayedstudyplan(){\n if(this.selectedstudyplan){\n return this.selectedstudyplan;\n } else if(this.value && this.value.length > 0){\n return this.value[0];\n } else {\n return null;\n }\n }\n },\n methods: {\n },\n template: `\n
{{g.name}}\n \n | \n{{g.grade}} | \n\n | \n\n {{ text[\"view_feedback\"]}}\n {{ value.course.fullname }}\n {{g.name}}\n \n \n | \n
{{cgroup.title}} | \n|||
---|---|---|---|
{{ci.title}}\n \n \n | {{ci.grade}} | \n\n \n | \n\n {{ text[\"view_feedback\"]}}\n {{ course.fullname }}\n {{ci.name}}\n \n \n | \n
{{g.name}}\n | \n \n | \n\n | \n
{{ text.aggregation_overall_all}}{{ text.aggregation_overall_any}} | \n|
{{text.completion_not_configured}}!\n \n {{text.configure_completion}}\n \n | \n |
1\"\n >{{ text.aggregation_all}}{{ text.aggregation_any}}\n {{cgroup.title}} | \n|
---|---|
\n \n | \n\n | \n
{{value.badge.description}}
\n{{txt.badge.badgeissuedstats}}:
\n