{"name":"databarchart","key":"databarchart","version":"1.0.1","instructions":"This is a demonstration of how to use SQL queries and variables to them in your templates. It will give you a chart of the frequency of activity types in the current Moodle course.\nThe custom JS is a bit tough","showatto":"1","showplayers":"0","requirecss":"","requirejs":"//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js","shim":"","defaults":"width=600,height=400,datalabel=mydata,labels=\"jan,feb,march\",data=\"1,2,3\"","amd":"0","body":"","bodyend":"","script":"var units = \"\";\nvar values = \"\";\nfor(i in @@DATASET@@)\n{\n units += @@DATASET@@[i].name + ',';\n values += @@DATASET@@[i].value+ ',';\n}\nunits = units.slice(0, -1);\nvalues = values.slice(0,-1);\nvar data = values.split(\",\");\n//alert(JSON.stringify(data));\nvar ctx = document.getElementById(\"@@AUTOID@@\").getContext(\"2d\");\nvar cdoptions = {\n \n}\nvar cjdata = {\n labels:units.split(\",\"),\n datasets: [\n {\n label: \"@@datalabel@@\",\n fillColor: \"rgba(220,0,0,0.2)\",\n strokeColor: \"rgba(220,220,220,1)\",\n pointColor: \"rgba(220,220,220,1)\",\n pointStrokeColor: \"#fff\",\n pointHighlightFill: \"#fff\",\n pointHighlightStroke: \"rgba(220,220,220,1)\",\n data: values.split(\",\")\n }\n ]\n};\n\nvar myBarChart = new Chart(ctx).Bar(cjdata, cdoptions);","style":"","dataset":"SELECT modules.name AS \"name\", COUNT(c_modules.id) AS \"value\"\nFROM\nmdl_course_modules c_modules\nINNER JOIN mdl_modules modules ON c_modules.module = modules.id\nWHERE\n c_modules.visible = 1\nAND c_modules.course = ?\n\nGROUP BY\n\nmodules.name","datasetvars":"@@COURSE:id@@","alternate":"","alternateend":""}