Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Moodle++
- // @namespace http://e-cfisd.hcde-texas.org/
- // @version 0.1
- // @description dark
- // @author Archer Calder
- // @match http://e-cfisd.hcde-texas.org/mod/quiz/view.php?id=726954
- // @require http://code.jquery.com/jquery-3.4.1.min.js
- // @require https://cdn.jsdelivr.net/npm/chart.js@2.8.0
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- var numOfZeros = 0;
- var numOfTwenties = 0;
- var numOfFourties = 0;
- var numOfSixties = 0;
- var numOfEighties = 0;
- var numOfHundreds = 0;
- var allQuizzes = $("td");
- $("td").each(function(index) {
- if ($(this).hasClass("cell c3")) {
- if ($(this).text() == "0") {
- numOfZeros++;
- }
- if ($(this).text() == "20") {
- numOfTwenties++;
- }
- if ($(this).text() == "40") {
- numOfFourties++;
- }
- if ($(this).text() == "60") {
- numOfSixties++;
- }
- if ($(this).text() == "80") {
- numOfEighties++;
- }
- if ($(this).text() == "100") {
- numOfHundreds++;
- }
- }
- });
- $(".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>'));
- var ctx = document.getElementById('myChart');
- var myChart = new Chart(ctx, {
- type: 'bar',
- data: {
- labels: ['Zeros', 'Ones', 'Twos', 'Threes', 'Fours', 'Fives'],
- datasets: [{
- label: 'Amount of quizzes',
- data: [numOfZeros, numOfTwenties, numOfFourties, numOfSixties, numOfEighties, numOfHundreds],
- backgroundColor: [
- 'rgba(255, 99, 132, 0.2)',
- 'rgba(54, 162, 235, 0.2)',
- 'rgba(255, 206, 86, 0.2)',
- 'rgba(75, 192, 192, 0.2)',
- 'rgba(153, 102, 255, 0.2)',
- 'rgba(255, 159, 64, 0.2)'
- ],
- borderColor: [
- 'rgba(255, 99, 132, 1)',
- 'rgba(54, 162, 235, 1)',
- 'rgba(255, 206, 86, 1)',
- 'rgba(75, 192, 192, 1)',
- 'rgba(153, 102, 255, 1)',
- 'rgba(255, 159, 64, 1)'
- ],
- borderWidth: 1
- }]
- },
- options: {
- scales: {
- yAxes: [{
- ticks: {
- beginAtZero: true
- }
- }]
- }
- }
- });
- $(".box").append("Moodle++ made by Archer Calder");
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement