From fb63894b857f7ab8a5765fc99e6af94471ea3460 Mon Sep 17 00:00:00 2001
From: TheJoeCoder <joe@radialbog9.uk>
Date: Mon, 3 Mar 2025 09:21:24 +0000
Subject: [PATCH] Update to add big_query condition

---
 bvletools.user.js | 24 ++++++++++++------------
 main.py           |  5 ++++-
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/bvletools.user.js b/bvletools.user.js
index a5680e5..0534af3 100644
--- a/bvletools.user.js
+++ b/bvletools.user.js
@@ -1,13 +1,13 @@
 // ==UserScript==
 // @name         Bromcom VLE Tools
-// @namespace    http://radialbog9.uk/
-// @version      2024-09-08
-// @description  Bromcom VLE dashboard widget
+// @namespace    https://radialbog9.uk/
+// @version      2025-02-28
+// @description  Bromcom VLE dashboard widget and student portal enhancements.
 // @author       Radialbog9
 // @match        https://vle.bromcomcloud.com/*
 // @match        https://app-uks-studentportal.azurewebsites.net/*
-// @downloadURL https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
-// @updateURL https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
+// @downloadURL  https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
+// @updateURL    https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
 // @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
 // @grant        none
 // ==/UserScript==
@@ -64,13 +64,13 @@
 
     function timetableToClipboardProcess(data) {
         var data_str = JSON.stringify(data);
-        console.log("[RB9] " + data_str);
+        console.log("[bvletools] " + data_str);
         navigator.clipboard.writeText(data_str);
         alert("Copied to Clipboard.\n Number of lessons " + data["table"].length);
     }
 
     if (window.location.href.endsWith("/Home/Dashboard")) {
-        console.log("[RB9] Page is Dashboard, injecting widget!");
+        console.log("[bvletools] Page is Dashboard, injecting widget!");
 
         $("#widgetsDahsboard .grid-stack")
             .append("\n<div class=\"grid-stack-item ui-draggable ui-resizable ui-resizable-autohide ui-resizable-disabled\" id=\"gs_RB9Buttons\" data-color=\"danger\" data-gs-id=\"gs_RB9Buttons\" data-gs-x=\"8\" data-gs-y=\"2\" data-gs-width=\"4\" data-gs-height=\"2\" data-gs-no-resize=\"yes\">\n        <div class=\"panel panel-danger shadow grid-stack-item-content ui-draggable-handle\">\n            <div class=\"panel-heading\">\n                <table>\n                    <tbody>\n                        <tr class=\"tableheader\">\n                            <td><i style=\"font-size:35px; padding-right:5px; padding-left:5px\" class=\"fa fa fa-wrench \"><\/i><\/td>\n                            <td>\n                                <h3 class=\"panel-title\">Toolkit<\/h3><h5 class=\"panelSubTitle\">Utilities Toolkit<\/h5>\n                            <\/td>\n                        <\/tr>\n                        <tr><\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n            <div id=\"content_RB9Buttons\" style=\"display:block; width: 100%;padding:0px;\" class=\"ifNoDataInWidget\">\n<\/div>\n        <\/div><div class=\"ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se\" style=\"z-index: 90; display: none;\"><\/div>\n    <\/div>");
@@ -115,7 +115,7 @@
     }
     // Behaviour page script modifications
     if (window.location.href.endsWith("/Behaviour")) {
-        console.log("[RB9] Behaviour function handlers");
+        console.log("[bvletools] Behaviour function handlers");
         // copied from https://vle.bromcomcloud.com/lib/pages/js/behaviour.js
         var toCamelCase = (str) => {
             return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
@@ -152,7 +152,7 @@
                         headerContentArrKeys.push(cc);
                     }
 
-                    console.log("[RB9] Existing field names: ");
+                    console.log("[bvletools] Existing field names: ");
                     console.log(headerContentArrKeys);
 
 
@@ -170,7 +170,7 @@
                                 };
 
                                 headerContentArr.push(dta);
-                                console.log("[RB9] " + JSON.stringify(dta));
+                                console.log("[bvletools] " + JSON.stringify(dta));
 
                                 lastPositionFromTop++;
                             }
@@ -237,12 +237,12 @@
             "</div>");
         
         $("#rb9ButtonBehavRefresh").on("click", () => {
-            console.log("[RB9] Destroying existing table.");
+            console.log("[bvletools] Destroying existing table.");
             if($.fn.DataTable.isDataTable("#Behaviour")) {
                 $("#Behaviour").DataTable().destroy();
             }
             $("#Behaviour").empty();
-            console.log("[RB9] Creating new table.");
+            console.log("[bvletools] Creating new table.");
             // <table id="Behaviour" class="DataTable table table-theme dataTable"><thead></thead><tbody></tbody></table>
             /*$("#BehaviourDiv").append(
                 "<table id=\"Behaviour\" class=\"DataTable table table-theme\">" +
diff --git a/main.py b/main.py
index 921402b..4921239 100644
--- a/main.py
+++ b/main.py
@@ -106,10 +106,13 @@ def eval_lesson_condition(input_lesson: dict, condition: dict) -> bool:
         elif condition["operator"] == ">=":
             return_value = matches >= match_target
         elif condition["operator"] == "<=":
-            return_value = matches <= match_target#
+            return_value = matches <= match_target
         else:
             logger.warning("Invalid big query condition operator %s, returning False.", condition["operator"])
             return_value = False
+
+        if return_value:
+            logger.debug("Big query success for input lesson %s, %d matches found.", input_lesson.get("subject"), matches)
     else:
         # Invalid condition type
         logger.warning("Invalid condition type %s, returning False.", condition["type"])
-- 
GitLab