Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Moodle++
  3. // @namespace http://e-cfisd.hcde-texas.org/
  4. // @version 0.1
  5. // @description dark
  6. // @author Archer Calder
  7. // @match http://e-cfisd.hcde-texas.org/mod/quiz/view.php?id=726954
  8. // @require http://code.jquery.com/jquery-3.4.1.min.js
  9. // @require https://cdn.jsdelivr.net/npm/chart.js@2.8.0
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16.  
  17. var numOfZeros = 0;
  18. var numOfTwenties = 0;
  19. var numOfFourties = 0;
  20. var numOfSixties = 0;
  21. var numOfEighties = 0;
  22. var numOfHundreds = 0;
  23. var allQuizzes = $("td");
  24.  
  25. $("td").each(function(index) {
  26. if ($(this).hasClass("cell c3")) {
  27. if ($(this).text() == "0") {
  28. numOfZeros++;
  29. }
  30. if ($(this).text() == "20") {
  31. numOfTwenties++;
  32. }
  33. if ($(this).text() == "40") {
  34. numOfFourties++;
  35. }
  36. if ($(this).text() == "60") {
  37. numOfSixties++;
  38. }
  39. if ($(this).text() == "80") {
  40. numOfEighties++;
  41. }
  42. if ($(this).text() == "100") {
  43. numOfHundreds++;
  44. }
  45. }
  46. });
  47.  
  48.  
  49. $(".box.generalbox").append('<center><h3><b>'.concat(allQuizzes.length,'</b> Total Quizzes</h3></center><center><p style="padding-bottom: 10px;">Average grade: ',Math.ceil((numOfTwenties+numOfFourties*2+numOfSixties*3+numOfEighties*4+numOfHundreds*5)/(numOfTwenties+numOfFourties+numOfSixties+numOfEighties+numOfHundreds)),'</p></center><canvas id="myChart"></canvas>'));
  50.  
  51. var ctx = document.getElementById('myChart');
  52. var myChart = new Chart(ctx, {
  53. type: 'bar',
  54. data: {
  55. labels: ['Zeros', 'Ones', 'Twos', 'Threes', 'Fours', 'Fives'],
  56. datasets: [{
  57. label: 'Amount of quizzes',
  58. data: [numOfZeros, numOfTwenties, numOfFourties, numOfSixties, numOfEighties, numOfHundreds],
  59. backgroundColor: [
  60. 'rgba(255, 99, 132, 0.2)',
  61. 'rgba(54, 162, 235, 0.2)',
  62. 'rgba(255, 206, 86, 0.2)',
  63. 'rgba(75, 192, 192, 0.2)',
  64. 'rgba(153, 102, 255, 0.2)',
  65. 'rgba(255, 159, 64, 0.2)'
  66. ],
  67. borderColor: [
  68. 'rgba(255, 99, 132, 1)',
  69. 'rgba(54, 162, 235, 1)',
  70. 'rgba(255, 206, 86, 1)',
  71. 'rgba(75, 192, 192, 1)',
  72. 'rgba(153, 102, 255, 1)',
  73. 'rgba(255, 159, 64, 1)'
  74. ],
  75. borderWidth: 1
  76. }]
  77. },
  78. options: {
  79. scales: {
  80. yAxes: [{
  81. ticks: {
  82. beginAtZero: true
  83. }
  84. }]
  85. }
  86. }
  87. });
  88. $(".box").append("Moodle++ made by Archer Calder");
  89. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement