update
diff --git a/scripts/assignments.js b/scripts/assignments.js
index ce18708..ca0dd72 100644
--- a/scripts/assignments.js
+++ b/scripts/assignments.js
@@ -724,7 +724,7 @@
${generic ? "" : (rubricItem.score !== undefined ? rubricItem.scoreName || "" : "Not assessed")}
<div class="points">
- <p class="earned">${generic ? "" : rubricItem.score ?? "-"}</p>
+ <p class="earned">${generic || (rubricItem.score == undefined) ? "" : rubricItem.score}</p>
<p class="possible">${"/" + rubricItem.value}</p>
</div>
</p>
diff --git a/scripts/core.js b/scripts/core.js
index 5c1c13b..5e9e6fa 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -1458,8 +1458,10 @@
*/
dtps.render = function () {
//Remove all existing link tags and LMS head content
- $("link:not(.dtpsHeadItem)").remove();
- $("head *:not(.dtpsHeadItem)").remove();
+ if (!dtpsLMS.isDemoLMS) {
+ $("link:not(.dtpsHeadItem)").remove();
+ $("head *:not(.dtpsHeadItem)").remove();
+ }
//Set default body classes
$("body").attr("class", "dark showThemeWindows hasSidebar hasNavbar dashboard");
@@ -1485,7 +1487,7 @@
<h4>${dtps.baseURL == "https://dev.dtps.jottocraft.com" ? "Power+ (dev)" : "Power+"}</h4>
</div>
- ${dtps.unstable ? `
+ ${dtps.unstable && !dtpsLMS.isDemoLMS ? `
<div id="dtpsUnstable" class="navitem">
<i style="font-size: 16px;" class="fluid-icon">warning</i>
<span style="font-weight: bold; font-size: 10px;">THIS IS AN UNSTABLE VERSION OF POWER+. USE AT YOUR OWN RISK.</span>
diff --git a/scripts/lms/canvas.js b/scripts/lms/canvas.js
index 430aa81..6a64f55 100644
--- a/scripts/lms/canvas.js
+++ b/scripts/lms/canvas.js
@@ -687,8 +687,5 @@
})
}
-//Get baseURL from the URL of this script
-var baseURL = document.currentScript.src.split("/scripts/lms/canvas.js")[0];
-
//Load Power+
-jQuery.getScript(baseURL + "/scripts/core.js");
\ No newline at end of file
+jQuery.getScript(window.dtpsBaseURL + "/scripts/core.js");
\ No newline at end of file
diff --git a/scripts/lms/demo.js b/scripts/lms/demo.js
index 2f552f5..315f54e 100644
--- a/scripts/lms/demo.js
+++ b/scripts/lms/demo.js
@@ -17,7 +17,8 @@
url: "https://powerplus.app",
logo: "https://powerplus.app/logo.png",
source: "https://github.com/jottocraft/dtps/blob/main/scripts/lms/demo.js",
- genericGradebook: true,
+ genericGradebook: false,
+ useRubricGrades: true,
isDemoLMS: true
};
@@ -35,154 +36,162 @@
//Fetch class data from Canvas
dtpsLMS.fetchClasses = function (userID) {
return new Promise(function (resolve, reject) {
- resolve([{
- name: "Demo Class",
- id: "1",
- subject: "Demo Class",
+ var baseClass = {
description: `<p>This class is for demonstration purposes only and is not a real class</p>`,
homepage: true,
numStudents: 1337,
modules: true,
discussions: true,
pages: true,
- color: "#8800ff",
- grade: 81,
- letter: "B-",
- previousLetter: "A",
- image: "https://powerplus.app/wallpaper.png",
teacher: {
name: "Demo Teacher",
id: "2",
photoURL: "https://powerplus.app/logo.png"
}
- }]);
+ };
+
+ resolve([
+ {
+ ...baseClass,
+ name: "Advisory",
+ icon: "school",
+ id: "1",
+ lmsID: "1",
+ subject: "Advisory",
+ color: "red"
+ },
+ {
+ ...baseClass,
+ name: "Physics",
+ id: "2",
+ lmsID: "2",
+ subject: "Physics",
+ color: "green",
+ letter: "A",
+ group: "Semester 1"
+ },
+ {
+ ...baseClass,
+ name: "English",
+ id: "3",
+ lmsID: "3",
+ subject: "English",
+ color: "blue",
+ letter: "A",
+ group: "Semester 1"
+ },
+ {
+ ...baseClass,
+ name: "History",
+ id: "4",
+ lmsID: "4",
+ subject: "History",
+ color: "orange",
+ letter: "P",
+ group: "Semester 1"
+ },
+ {
+ ...baseClass,
+ name: "Physics",
+ icon: "science",
+ id: "5",
+ lmsID: "5",
+ subject: "Physics",
+ color: "green",
+ group: "Semester 2"
+ },
+ {
+ ...baseClass,
+ name: "English",
+ icon: "description",
+ id: "6",
+ lmsID: "6",
+ subject: "English",
+ color: "blue",
+ grade: 98,
+ group: "Semester 2"
+ },
+ {
+ ...baseClass,
+ name: "History",
+ icon: "history_edu",
+ id: "7",
+ lmsID: "7",
+ subject: "History",
+ color: "orange",
+ letter: "A",
+ previousLetter: "B+",
+ group: "Semester 2"
+ }
+ ]);
})
}
+function generateAssignmentName() {
+ var assignmentName = [];
+
+ assignmentName.push(["Unit 1", "Unit 2", "Unit 3", "Final", "Mid-Semester", "Pre", "Honors", "Extra Credit"].random());
+ assignmentName.push(["Exam", "Discussion Post", "Homework", "Assignment", "Project", "Research Project", "Check-In", "Quiz", "Test", "Survey", "Reading", "Essay", "Lab"].random());
+
+ return assignmentName.join(" ");
+}
+
//Fetches assignment data from Canvas
dtpsLMS.fetchAssignments = function (userID, classID) {
return new Promise(function (resolve, reject) {
- if (classID == "1") {
- resolve([
- {
- title: "Demo assignment 1",
- id: "191",
- body: "<p>This assignment is for demonstration purposes only</p>",
- dueAt: new Date().getTime() + 3000000,
- turnedIn: true,
- locked: false,
- category: "Demo assignments",
- value: 12,
- publishedAt: new Date().getTime() - 100000000,
- rubric: [
- {
- title: "Demo outcome 1",
- id: "1",
- value: 4,
- description: "This outcome is for demonstration purposes only"
- },
- {
- title: "Demo outcome 2",
- id: "2",
- value: 4,
- description: "This outcome is for demonstration purposes only"
- },
- {
- title: "Demo outcome 3",
- id: "3",
- value: 4,
- description: "This outcome is for demonstration purposes only"
- }
- ]
- },
- {
- title: "Demo assignment 2",
- id: "192",
- body: "<p>This assignment is for demonstration purposes only</p>",
- dueAt: new Date().getTime() - 100000000,
- turnedIn: true,
- locked: true,
- gradedAt: new Date(),
- grade: 8,
- value: 8,
- letter: "A",
- category: "Demo assignments",
- publishedAt: new Date().getTime() - 1000000000,
- rubric: [
- {
- title: "Demo outcome 1",
- id: "1",
- value: 4,
- description: "This outcome is for demonstration purposes only",
- score: 4,
- scoreName: "Beyond Innovation++",
- color: "#4f9e59"
- },
- {
- title: "Demo outcome 2",
- id: "2",
- value: 4,
- description: "This outcome is for demonstration purposes only",
- score: 4,
- scoreName: "Beyond Innovation++",
- color: "#4f9e59"
- }
- ]
- },
- {
- title: "Demo assignment 3",
- id: "193",
- body: "<p>This assignment is for demonstration purposes only</p>",
- dueAt: new Date().getTime() - 100000000,
- turnedIn: true,
- late: true,
- locked: true,
- grade: 5,
- gradedAt: new Date(),
- value: 8,
- letter: "B",
- category: "Demo assignments",
- publishedAt: new Date().getTime() - 1000000000,
- rubric: [
- {
- title: "Demo outcome 1",
- id: "1",
- value: 4,
- description: "This outcome is for demonstration purposes only",
- score: 2,
- scoreName: "Developing",
- color: "#c26d44"
- },
- {
- title: "Demo outcome 2",
- id: "2",
- value: 4,
- description: "This outcome is for demonstration purposes only",
- score: 3,
- scoreName: "Proficient",
- color: "#a1b553"
- }
- ]
- },
- {
- title: "Demo assignment 4",
- id: "194",
- body: "<p>This assignment is for demonstration purposes only</p>",
- dueAt: new Date().getTime() + 10000000,
- value: 4,
- category: "Demo assignments",
- publishedAt: new Date().getTime() - 1000000000,
- rubric: [
- {
- title: "Demo outcome 1",
- id: "1",
- value: 4,
- description: "This outcome is for demonstration purposes only"
- }
- ]
- }
- ])
+ var assignments = [];
+ if (Number(classID) < 5) return resolve([]);
+
+ Array.prototype.random = function () {
+ return this[Math.floor((Math.random() * this.length))];
+ };
+
+ for (var i = 0; i < 20; i++) {
+ //Get random assignment due date
+ var assignmentDate = new Date(new Date().getTime() + (Math.floor(Math.random() * 5.256e+9) - 2.628e+9));
+
+ assignmentDate.setHours(23);
+ assignmentDate.setMinutes(59);
+
+ assignments.push({
+ title: generateAssignmentName(),
+ id: Math.floor(Math.random() * 10000),
+ body: "<p>This assignment is for demonstration purposes only</p>",
+ dueAt: assignmentDate,
+ turnedIn: assignmentDate > new Date().getTime() ? Math.random() < 0.5 : false,
+ locked: assignmentDate < new Date().getTime() ? Math.random() < 0.5 : false,
+ value: Math.floor(Math.random() * 100),
+ publishedAt: new Date().getTime() - 100000000,
+ rubric: [
+ {
+ title: "Skills Assessment",
+ id: "1",
+ value: 4,
+ description: "This outcome is for demonstration purposes only"
+ },
+ {
+ title: "Writing Skills",
+ id: "2",
+ value: 4,
+ description: "This outcome is for demonstration purposes only"
+ },
+ {
+ title: "Research Skills",
+ id: "3",
+ value: 4,
+ description: "This outcome is for demonstration purposes only"
+ },
+ {
+ title: "Thinking Skills",
+ id: "3",
+ value: 4,
+ description: "This outcome is for demonstration purposes only"
+ }
+ ]
+ })
}
+
+ resolve(assignments);
})
}
@@ -229,9 +238,9 @@
dtpsLMS.fetchAnnouncements = function (classID) {
return new Promise(function (resolve, reject) {
resolve([{
- title: "Demo Announcement",
+ title: "Assignments Graded",
postedAt: new Date().getDate(),
- body: "<p>This announcement is for demonstration purposes only</p>"
+ body: "<p>Hello,</p><p>The assignments have finally been graded. Sorry about the delay. There is a test coming up on Tuesday, so make sure you study for it since it will be really hard and you will probably fail.</p><br /><br /><br /><br /><p>This is a demo announcement</p>"
}]);
});
}
@@ -309,8 +318,116 @@
})
}
-//Get baseURL from the URL of this script
-var baseURL = document.currentScript.src.split("/scripts/lms/demo.js")[0];
+dtpsLMS.gradebook = function (course) {
+ return new Promise((resolve, reject) => {
+ //RENDERER: RENDER GRADE CALCULATION SUMMARY ------------------------------------
+ var gradeCalcSummary = /*html*/`
+ <div id="gradeSummary" style="--size: 250px; margin: 0px 20px; --classColor: ${course.color};" class="grid flex">
+ <div style="background-color: var(--classColor); color: white;" class="block status letterGrade card">
+ <h2 class="main">${course.letter}</h2>
+ ${course.previousLetter ? `<h5 class="previousGrade">Previous grade: ${course.previousLetter}</h5>` : ""}
+ <h5 class="bottom"><i class="fluid-icon">grade</i> Grade</h5>
+ </div>
+ <div class="block status number75">
+ <h2 class="main numFont">3.7</h2>
+ <h5 class="bottom"><i class="fluid-icon">functions</i> 75% of outcomes (5) ≥</h5>
+ </div>
+ <div class="block status lowestScore">
+ <h2 class="main numFont">3.5</h2>
+ <h5 class="bottom"><i class="fluid-icon">leaderboard</i> Lowest outcome</h5>
+ </div>
+ </div>
+
+ <div class="gradeSummaryShowHide">
+ ${dtps.gradebookExpanded ? `<i class="fluid-icon">keyboard_arrow_up</i> <span>Show less</span>` : `<i class="fluid-icon">keyboard_arrow_down</i> <span>Show more</span>`}
+ </div>
+ `;
+
+ var rubricColor = function (score) {
+ if (score > 4.0) return "#20D684";
+ if (score == 4.0) return "#41BA35";
+ if (score >= 3.9) return "#50BC39";
+ if (score >= 3.8) return "#5FBD3D";
+ if (score >= 3.7) return "#6EBF40";
+ if (score >= 3.6) return "#7DC044";
+ if (score >= 3.5) return "#8CC248";
+ if (score >= 3.4) return "#9AC44C";
+ if (score >= 3.3) return "#A9C550";
+ if (score >= 3.2) return "#B8C753";
+ if (score >= 3.1) return "#C7C857";
+ if (score >= 3.0) return "#D6CA5B";
+ if (score >= 2.9) return "#D8C35A";
+ if (score >= 2.8) return "#DABB59";
+ if (score >= 2.7) return "#DCB458";
+ if (score >= 2.6) return "#DEAC57";
+ if (score >= 2.5) return "#E1A556";
+ if (score >= 2.4) return "#E39E55";
+ if (score >= 2.3) return "#E59654";
+ if (score >= 2.2) return "#E78F53";
+ if (score >= 2.1) return "#E98752";
+ if (score >= 2.0) return "#EB8051";
+ if (score >= 1.9) return "#E97A50";
+ if (score >= 1.8) return "#E7744F";
+ if (score >= 1.7) return "#E56F4E";
+ if (score >= 1.6) return "#E3694D";
+ if (score >= 1.5) return "#E1634C";
+ if (score >= 1.4) return "#DE5D4A";
+ if (score >= 1.3) return "#DC5749";
+ if (score >= 1.2) return "#DA5248";
+ if (score >= 1.1) return "#D84C47";
+ if (score >= 1.0) return "#D64646";
+ if (score >= 0.0) return "#D72727";
+ if (score < 0.0) return "#BF0000";
+ }
+
+ //RENDERER: RENDER EACH OUTCOME ------------------------------------
+ var outcomeHTML = []; //array of outcome html to be rendered
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].forEach(() => {
+ var avg = 3 + Math.random();
+ outcomeHTML.push(/*html*/`
+ <div style="border-radius: 20px;padding: 22px; padding-bottom: 20px;" class="card outcomeResults">
+ <h5 style="max-width: calc(100% - 50px); font-size: 24px; margin: 0px; margin-bottom: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;">${["Learning Skills", "Critical Thinking", "Reading Skills", "Research Skills", "Writing Skills", "Collaborative Skills"].random()}</h5>
+
+ <div class="numFont" style="position: absolute; top: 20px; right: 20px; font-size: 26px; font-weight: bold; display: inline-block; color: ${rubricColor(avg)}">${avg.toFixed(2)}</div>
+
+ <div class="assessments">
+ ${[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(() => {
+ var score = [3, 3.5, 4, 4, 4, 4].random();
+ return /*html*/`
+ <div class="assessmentWrapper" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 6px 0px;">
+ <div style="color: ${rubricColor(score)};" class="editableScore">${score}</div>
+ <span class="assessmentTitle" style="cursor: pointer;">${generateAssignmentName()}</span>
+ </div>
+ `;
+ }).join("")}
+ </div>
+ </div>
+ `);
+ })
+
+ //RESOLVE WITH HTML
+ resolve(gradeCalcSummary + `<br />` + outcomeHTML.join(""));
+ });
+}
+
+//scroll listener
+var scrollListenerAdded = false;
+dtpsLMS.gradebookDidRender = function (course) {
+ //Keep the grade summary on top
+ if (!scrollListenerAdded) {
+ scrollListenerAdded = true;
+ var gradeSummary = document.getElementById("gradeSummary");
+ var sticky = gradeSummary.offsetTop - parseFloat($("body").css("padding-top")) - 10;
+ window.onscroll = function () {
+ if ((window.pageYOffset >= sticky) && ((dtps.classes[dtps.selectedClass]) && (dtps.selectedContent == "grades"))) {
+ $(".classContent").addClass("fixedGradeSummary");
+ } else {
+ $(".classContent").removeClass("fixedGradeSummary");
+ }
+ };
+ }
+}
+
//Load Power+
-jQuery.getScript(baseURL + "/scripts/core.js");
\ No newline at end of file
+jQuery.getScript(window.dtpsBaseURL + "/scripts/core.js");
\ No newline at end of file
diff --git a/scripts/lms/dtech.js b/scripts/lms/dtech.js
index 2ab9ef5..cf1c273 100644
--- a/scripts/lms/dtech.js
+++ b/scripts/lms/dtech.js
@@ -8,11 +8,8 @@
* JSDoc documentation for these LMS functions can be found near the end of core.js
*/
-//Get baseURL from the URL of this script
-var baseURL = document.currentScript.src.split("/scripts/lms/dtech.js")[0];
-
//Load Canvas integration
-jQuery.getScript(baseURL + "/scripts/lms/canvas.js", function () {
+jQuery.getScript(window.dtpsBaseURL + "/scripts/lms/canvas.js", function () {
//Add d.tech-specific items to dtpsLMS
dtpsLMS.name = "d.tech";
dtpsLMS.legalName = "Canvas LMS, Design Tech High School, or Instructure Inc";
diff --git a/www/demo/index.html b/www/demo/index.html
index 982de87..1b151f6 100644
--- a/www/demo/index.html
+++ b/www/demo/index.html
@@ -2,27 +2,27 @@
<html lang="en">
<head>
- <link dtps="true" rel="shortcut icon" href="https://powerplus.app/favicon.png" type="image/png">
- <meta dtps="true" name="viewport" content="width=device-width, initial-scale=1">
- <meta dtps="true" charset="utf-8">
- <title dtps="true">Power+ Demo</title>
- <meta dtps="true" name="description" content="Power+ demonstration website">
- <meta dtps="true" name="author" content="jottocraft">
- <script dtps="true">window.dtpsPreLoader = true; window.dtpsBaseURL = "https://powerplus.app";</script>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" dtps="true"></script>
- <script src="https://powerplus.app/scripts/lms/demo.js" dtps="true"></script>
+ <link rel="shortcut icon" href="https://powerplus.app/favicon.png" type="image/png">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta charset="utf-8">
+ <title>Power+ Demo</title>
+ <meta name="description" content="Power+ demonstration website">
+ <meta name="author" content="jottocraft">
+ <script>window.dtpsPreLoader = true; window.dtpsBaseURL = window.location.origin;</script>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
+ <script src="/scripts/lms/demo.js"></script>
</head>
<body>
- <div dtps="true" id="dtpsNativeOverlay"
+ <div id="dtpsNativeOverlay"
style="background-color: #151515; position: fixed; top: 0px; left: 0px; width: 100%; height: 100vh; z-index: 99;text-align: center;z-index: 999;transition: opacity 0.2s;">
- <img dtps="true" style="height: 100px; margin-top: 132px;" src="https://i.imgur.com/7dDUVh2.png" />
- <br dtps="true" />
- <div dtps="true" class="progress">
- <div dtps="true" class="indeterminate"></div>
+ <img style="height: 100px; margin-top: 132px;" src="https://i.imgur.com/7dDUVh2.png" />
+ <br />
+ <div class="progress">
+ <div class="indeterminate"></div>
</div>
- <style dtps="true">
+ <style>
body {
background-color: #151515;
overflow: hidden;