From 3b65cc6802a8048ed35a0ff8e7e55d1921b281f8 Mon Sep 17 00:00:00 2001 From: Colin-Fredericks Date: Thu, 22 Feb 2024 14:24:40 -0500 Subject: [PATCH] Make sure Logger exists --- hx.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hx.js b/hx.js index 25e2cad..a567683 100644 --- a/hx.js +++ b/hx.js @@ -161,9 +161,13 @@ var HXGlobalJS = function () { logThatThing({ course_log_id: courseLogID }); // Listen for events that rewrite problem HTML. - Logger.listen('problem_check', null, (en, es) => onProblemRewrite(en, es)); - Logger.listen('problem_show', null, (en, es) => onProblemRewrite(en, es)); - Logger.listen('problem_reset', null, (en, es) => onProblemRewrite(en, es)); + if( typeof Logger !== 'undefined' ){ + Logger.listen('problem_check', null, (en, es) => onProblemRewrite(en, es)); + Logger.listen('problem_show', null, (en, es) => onProblemRewrite(en, es)); + Logger.listen('problem_reset', null, (en, es) => onProblemRewrite(en, es)); + }else{ + console.log('Logger is not available.'); + } /**************************************/ // Load outside scripts. @@ -1401,7 +1405,11 @@ var HXGlobalJS = function () { // Send logs both to the console and to the official edX logamajig. function logThatThing(ThatThing) { console.log(JSON.stringify(ThatThing)); - Logger.log(courseLogID + '.hxjs', ThatThing); + if(typeof Logger !== 'undefined') { + Logger.log(courseLogID + '.hxjs', ThatThing); + }else{ + console.log('Logger is not available.'); + } } // Let's publish a few of these.