From 32f7b4095c7e756aba838fec5d5d74d6d6e07c3b Mon Sep 17 00:00:00 2001 From: Bennett Gillig Date: Sat, 24 Oct 2020 08:37:58 -0400 Subject: [PATCH 1/2] synthetic assignments don't show statistics anymore fixed how synthetic assignments show statistics. --- public/js/home.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/public/js/home.js b/public/js/home.js index a970f215..68c1cb9a 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -19,6 +19,9 @@ let currentTableData = tableData[currentTableDataIndex]; let selected_class_i; let termsReset = {}; +//variable for the number of synthetic assignments at the top +let total_synthetic_assignments = 0 + let tempCell; // When the user clicks anywhere outside of a modal or dropdown, close it window.addEventListener("click", function(event) { @@ -316,13 +319,13 @@ let assignmentsTable = new Tabulator("#assignmentsTable", { { title: "Stats", titleFormatter: () => '', - formatter: cell => - (!isNaN(cell.getRow().getData().score)) ? + formatter: cell => + (!isNaN(cell.getRow().getData().score) && cell.getRow().getPosition() >= total_synthetic_assignments) ? '' : "", width: 40, align: "center", cellClick: async function(e, cell) { - if (isNaN(cell.getRow().getData().score)) { + if (isNaN(cell.getRow().getData().score) || cell.getRow().getPosition() < total_synthetic_assignments) { return; } noStats(); @@ -516,11 +519,18 @@ let assignmentsTable = new Tabulator("#assignmentsTable", { { title: "Add", titleFormatter: () => '', - headerClick: newAssignment, + headerClick: function () { + total_synthetic_assignments++; + newAssignment(); + }, formatter: "buttonCross", width: 40, align: "center", cellClick: function(e, cell) { + //if the index is less than the total number of synthetic assignments it must be a synthetic assignment + if (cell.getRow().getPosition() < total_synthetic_assignments) + total_synthetic_assignments--; + cell.getRow().delete(); }, headerSort: false, From 7fc940f37dfc738d7af11f85002ae4cebceea65a Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Fri, 30 Oct 2020 20:55:24 -0400 Subject: [PATCH 2/2] Mark synthetic assignments with an attribute Instead of keeping a global variable to count the number of synthetic assignments (which does not scale across classes), add a "synthetic" attribute to synthetic assignments and check against that. --- public/js/buttonFunctions.js | 1 + public/js/home.js | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/public/js/buttonFunctions.js b/public/js/buttonFunctions.js index 5315d8bd..bb528055 100755 --- a/public/js/buttonFunctions.js +++ b/public/js/buttonFunctions.js @@ -11,6 +11,7 @@ let newAssignment = function() { "max_score": 10, "percentage": 100, "color": "green", + "synthetic": "true", }); updateGradePage(); diff --git a/public/js/home.js b/public/js/home.js index 68c1cb9a..e3990efd 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -19,9 +19,6 @@ let currentTableData = tableData[currentTableDataIndex]; let selected_class_i; let termsReset = {}; -//variable for the number of synthetic assignments at the top -let total_synthetic_assignments = 0 - let tempCell; // When the user clicks anywhere outside of a modal or dropdown, close it window.addEventListener("click", function(event) { @@ -319,15 +316,21 @@ let assignmentsTable = new Tabulator("#assignmentsTable", { { title: "Stats", titleFormatter: () => '', - formatter: cell => - (!isNaN(cell.getRow().getData().score) && cell.getRow().getPosition() >= total_synthetic_assignments) ? - '' : "", + formatter: cell => ( + isNaN(cell.getRow().getData().score) + || currentTableData.currentTermData + .classes[selected_class_i] + .assignments[cell.getRow().getPosition()].synthetic + ) ? "" : '', width: 40, align: "center", cellClick: async function(e, cell) { - if (isNaN(cell.getRow().getData().score) || cell.getRow().getPosition() < total_synthetic_assignments) { - return; - } + if ( + isNaN(cell.getRow().getData().score) + || currentTableData.currentTermData + .classes[selected_class_i] + .assignments[cell.getRow().getPosition()].synthetic + ) return; noStats(); document.getElementById("no_stats_caption").innerHTML = "Loading Statistics..."; showModal("stats"); @@ -519,18 +522,11 @@ let assignmentsTable = new Tabulator("#assignmentsTable", { { title: "Add", titleFormatter: () => '', - headerClick: function () { - total_synthetic_assignments++; - newAssignment(); - }, + headerClick: newAssignment, formatter: "buttonCross", width: 40, align: "center", cellClick: function(e, cell) { - //if the index is less than the total number of synthetic assignments it must be a synthetic assignment - if (cell.getRow().getPosition() < total_synthetic_assignments) - total_synthetic_assignments--; - cell.getRow().delete(); }, headerSort: false,