/*eslint no-var: "error"*/ /*eslint no-console: "off"*/ /*eslint no-unused-vars: warn */ /*eslint max-len: ["error", { "code": 160 }] */ /*eslint-disable no-trailing-spaces */ /*eslint-env es6*/ // Put this file in path/to/plugin/amd/src import {SimpleLine} from './simpleline'; import {get_strings} from 'core/str'; import {load_strings, format_date} from './string-helper'; import {call} from 'core/ajax'; import notification from 'core/notification'; import {svgarcpath} from './svgarc'; import Debugger from './debugger'; // Make π available as a constant const π = Math.PI; export default { install(Vue/*,options*/){ let debug = new Debugger("treestudyplan-viewer"); debug.enable(); let strings = load_strings({ invalid: { error: 'error', }, grading: { ungraded: "ungraded", graded: "graded", allgraded: "allgraded", unsubmitted: "unsubmitted", nogrades: "nogrades", unknown: "unknown", }, completion: { completed: "completion_completed", incomplete: "completion_incomplete", completed_pass: "completion_passed", completed_fail: "completion_failed", ungraded: "ungraded", aggregation_all: "aggregation_all", aggregation_any: "aggregation_any", aggregation_overall_all: "aggregation_overall_all", aggregation_overall_any: "aggregation_overall_any", completion_not_configured: "completion_not_configured", configure_completion: "configure_completion", }, badge: { share_badge: "share_badge", dateissued: "dateissued", dateexpire: "dateexpire", badgeinfo: "badgeinfo", badgeissuedstats: "badgeissuedstats", }, course: { completion_incomplete: "completion_incomplete", completion_failed: "completion_failed", completion_pending: "completion_pending", completion_progress: "completion_progress", completion_completed: "completion_completed", completion_good: "completion_good", completion_excellent: "completion_excellent", view_feedback: "view_feedback", coursetiming_past: "coursetiming_past", coursetiming_present: "coursetiming_present", coursetiming_future: "coursetiming_future", required_goal: "required_goal", }, teachercourse: { select_conditions: "select_conditions", select_grades: "select_grades", coursetiming_past: "coursetiming_past", coursetiming_present: "coursetiming_present", coursetiming_future: "coursetiming_future", grade_include: "grade_include", grade_require: "grade_require", required_goal: "required_goal", } }); /************************************ * * * Treestudyplan Viewer components * * * ************************************/ /** * Check if element is visible * @param {Object} elem The element to check * @returns {boolean} True if visible */ function isVisible(elem){ return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); } // Create new eventbus for interaction between item components const ItemEventBus = new Vue(); Vue.component('r-progress-circle',{ props: { value: { type: Number, }, max: { type: Number, default: 100, }, min: { type: Number, default: 0, }, stroke: { type: Number, default: 0.2, }, bgopacity: { type: Number, default: 0.2, }, title: { type: String, default: "", }, }, data() { return { selectedstudyplan: null, }; }, computed: { range() { return this.max - this.min; }, fraction(){ if(this.max - this.min == 0){ return 0; // 0 size is always empty :) } else { return (this.value - this.min)/(this.max - this.min); } }, radius() { return 50 - (50*this.stroke); }, arcpath() { let fraction = 0; const r = 50 - (50*this.stroke); if(this.max - this.min != 0){ fraction = (this.value - this.min)/(this.max - this.min); } const Δ = fraction * 2*π; return svgarcpath([50,50],[r,r],[0,Δ], 1.5*π); }, }, methods: { }, template: ` `, }); Vue.component('r-report', { props: { value: { type: Array, }, guestmode: { type: Boolean, default: false, }, teachermode: { type: Boolean, default: false, } }, data() { return { selectedstudyplan: null, }; }, computed: { displayedstudyplan(){ if(this.selectedstudyplan){ return this.selectedstudyplan; } else if(this.value && this.value.length > 0){ return this.value[0]; } else { return null; } } }, methods: { }, template: `
{{g.name}} | {{g.grade}} |
{{ text["view_feedback"]}}
{{ value.course.fullname }}{{g.name}} |
{{cgroup.title}} | |||
---|---|---|---|
{{ci.title}} | {{ci.grade}} |
{{ text["view_feedback"]}}
{{ course.fullname }}{{ci.name}} |
{{g.name}}
|
|
{{ text.aggregation_overall_all}}{{ text.aggregation_overall_any}} | |
{{text.completion_not_configured}}!
{{text.configure_completion}} |
|
{{ text.aggregation_all}}{{ text.aggregation_any}} {{cgroup.title}} | |
---|---|
|
{{value.badge.description}}
{{txt.badge.badgeissuedstats}}: