Skip to content

Commit 7814244

Browse files
committed
abstract the shouldShowStudyClues logic
1 parent b860d1e commit 7814244

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

bases/rsptx/interactives/runestone/common/js/bookfuncs.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,26 @@ function createStudyCluesWidget() {
808808
});
809809
}
810810

811+
function shouldShowStudyCluesWidget() {
812+
if (!location.pathname.includes("/ns/books/")) {
813+
return false;
814+
}
815+
816+
const enabledBasecourses = ["csawesome2", "py4e-int", "thinkcspy", "PTXSB"];
817+
const enabledCourses = ["SI201-W26-MW and SI201-W26-TTh", "DukeCS101SP26", "mcd-csa-schoology", "mcd-csa-canvas"];
818+
const host = window.location.hostname;
819+
820+
if (host === "localhost") {
821+
return enabledBasecourses.includes(eBookConfig.basecourse);
822+
}
823+
824+
if (host === "runestone.academy") {
825+
return enabledCourses.includes(eBookConfig.course);
826+
}
827+
828+
return false;
829+
}
830+
811831
async function handlePageSetup() {
812832
var mess;
813833
if (eBookConfig.useRunestoneServices) {
@@ -880,8 +900,8 @@ async function handlePageSetup() {
880900
document.dispatchEvent(new Event("runestone:login"));
881901
addReadingList();
882902
// Only show the StudyClues widget for certain base courses and when the path includes "/ns/books/".
883-
if (["csawesome2", "py4e-int", "thinkcspy", "PTXSB"].includes(eBookConfig.basecourse)
884-
&& location.pathname.includes("/ns/books/")) {
903+
// This is a temporary measure to limit the widget to courses that are known to work well with it and to avoid showing it on non-book pages where it may not be as useful.
904+
if (shouldShowStudyCluesWidget()) {
885905
createStudyCluesWidget();
886906
}
887907
// Avoid the timedRefresh on the grading page.

0 commit comments

Comments
 (0)