| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 1 | /**
|
| 2 | * @file DTPS Demo LMS
|
| 3 | * @author jottocraft
|
| 4 | *
|
| j | 6e1a7bf | 2026-10-13 03:37:04 +0000 | [diff] [blame] | 5 | * @copyright Copyright (c) jottocraft 2020
|
| j | 40db027 | 2022-01-14 15:18:29 -0800 | [diff] [blame] | 6 | * @license MIT
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 7 | *
|
| 8 | * This LMS script is for demonstrating Power+ and doesn't fetch actual data
|
| 9 | * JSDoc documentation for these LMS functions can be found near the end of core.js
|
| 10 | */
|
| 11 |
|
| 12 | //DTPS LMS configuration
|
| 13 | var dtpsLMS = {
|
| 14 | name: "Demo LMS",
|
| 15 | shortName: "Demo",
|
| 16 | description: "All content in this LMS is not real and is for demonstration purposes only",
|
| 17 | url: "https://powerplus.app",
|
| 18 | logo: "https://powerplus.app/logo.png",
|
| j | 0e5b1c7 | 2026-10-13 03:49:38 +0000 | [diff] [blame^] | 19 | source: "https://src.jottocraft.com/browser/dtps/+/refs/heads/main/scripts/lms/demo.js",
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 20 | genericGradebook: false,
|
| 21 | useRubricGrades: true,
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 22 | isDemoLMS: true
|
| 23 | };
|
| 24 |
|
| 25 | //Return sample user data
|
| 26 | dtpsLMS.fetchUser = function () {
|
| 27 | return new Promise(function (resolve, reject) {
|
| 28 | resolve({
|
| 29 | name: "Demo User",
|
| 30 | id: "1",
|
| 31 | photoURL: "https://powerplus.app/logo.png"
|
| 32 | });
|
| 33 | })
|
| 34 | }
|
| 35 |
|
| 36 | //Fetch class data from Canvas
|
| 37 | dtpsLMS.fetchClasses = function (userID) {
|
| 38 | return new Promise(function (resolve, reject) {
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 39 | var baseClass = {
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 40 | description: `<p>This class is for demonstration purposes only and is not a real class</p>`,
|
| 41 | homepage: true,
|
| 42 | numStudents: 1337,
|
| 43 | modules: true,
|
| 44 | discussions: true,
|
| 45 | pages: true,
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 46 | teacher: {
|
| 47 | name: "Demo Teacher",
|
| 48 | id: "2",
|
| 49 | photoURL: "https://powerplus.app/logo.png"
|
| 50 | }
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 51 | };
|
| 52 |
|
| 53 | resolve([
|
| 54 | {
|
| 55 | ...baseClass,
|
| 56 | name: "Advisory",
|
| 57 | icon: "school",
|
| 58 | id: "1",
|
| 59 | lmsID: "1",
|
| 60 | subject: "Advisory",
|
| 61 | color: "red"
|
| 62 | },
|
| 63 | {
|
| 64 | ...baseClass,
|
| 65 | name: "Physics",
|
| 66 | id: "2",
|
| 67 | lmsID: "2",
|
| 68 | subject: "Physics",
|
| 69 | color: "green",
|
| 70 | letter: "A",
|
| 71 | group: "Semester 1"
|
| 72 | },
|
| 73 | {
|
| 74 | ...baseClass,
|
| 75 | name: "English",
|
| 76 | id: "3",
|
| 77 | lmsID: "3",
|
| 78 | subject: "English",
|
| 79 | color: "blue",
|
| 80 | letter: "A",
|
| 81 | group: "Semester 1"
|
| 82 | },
|
| 83 | {
|
| 84 | ...baseClass,
|
| 85 | name: "History",
|
| 86 | id: "4",
|
| 87 | lmsID: "4",
|
| 88 | subject: "History",
|
| 89 | color: "orange",
|
| 90 | letter: "P",
|
| 91 | group: "Semester 1"
|
| 92 | },
|
| 93 | {
|
| 94 | ...baseClass,
|
| 95 | name: "Physics",
|
| 96 | icon: "science",
|
| 97 | id: "5",
|
| 98 | lmsID: "5",
|
| 99 | subject: "Physics",
|
| 100 | color: "green",
|
| 101 | group: "Semester 2"
|
| 102 | },
|
| 103 | {
|
| 104 | ...baseClass,
|
| 105 | name: "English",
|
| 106 | icon: "description",
|
| 107 | id: "6",
|
| 108 | lmsID: "6",
|
| 109 | subject: "English",
|
| 110 | color: "blue",
|
| 111 | grade: 98,
|
| 112 | group: "Semester 2"
|
| 113 | },
|
| 114 | {
|
| 115 | ...baseClass,
|
| 116 | name: "History",
|
| 117 | icon: "history_edu",
|
| 118 | id: "7",
|
| 119 | lmsID: "7",
|
| 120 | subject: "History",
|
| 121 | color: "orange",
|
| 122 | letter: "A",
|
| 123 | previousLetter: "B+",
|
| 124 | group: "Semester 2"
|
| 125 | }
|
| 126 | ]);
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 127 | })
|
| 128 | }
|
| 129 |
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 130 | function generateAssignmentName() {
|
| 131 | var assignmentName = [];
|
| 132 |
|
| 133 | assignmentName.push(["Unit 1", "Unit 2", "Unit 3", "Final", "Mid-Semester", "Pre", "Honors", "Extra Credit"].random());
|
| 134 | assignmentName.push(["Exam", "Discussion Post", "Homework", "Assignment", "Project", "Research Project", "Check-In", "Quiz", "Test", "Survey", "Reading", "Essay", "Lab"].random());
|
| 135 |
|
| 136 | return assignmentName.join(" ");
|
| 137 | }
|
| 138 |
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 139 | //Fetches assignment data from Canvas
|
| 140 | dtpsLMS.fetchAssignments = function (userID, classID) {
|
| 141 | return new Promise(function (resolve, reject) {
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 142 | var assignments = [];
|
| 143 | if (Number(classID) < 5) return resolve([]);
|
| 144 |
|
| 145 | Array.prototype.random = function () {
|
| 146 | return this[Math.floor((Math.random() * this.length))];
|
| 147 | };
|
| 148 |
|
| 149 | for (var i = 0; i < 20; i++) {
|
| 150 | //Get random assignment due date
|
| 151 | var assignmentDate = new Date(new Date().getTime() + (Math.floor(Math.random() * 5.256e+9) - 2.628e+9));
|
| 152 |
|
| 153 | assignmentDate.setHours(23);
|
| 154 | assignmentDate.setMinutes(59);
|
| 155 |
|
| 156 | assignments.push({
|
| 157 | title: generateAssignmentName(),
|
| 158 | id: Math.floor(Math.random() * 10000),
|
| 159 | body: "<p>This assignment is for demonstration purposes only</p>",
|
| 160 | dueAt: assignmentDate,
|
| 161 | turnedIn: assignmentDate > new Date().getTime() ? Math.random() < 0.5 : false,
|
| 162 | locked: assignmentDate < new Date().getTime() ? Math.random() < 0.5 : false,
|
| 163 | value: Math.floor(Math.random() * 100),
|
| 164 | publishedAt: new Date().getTime() - 100000000,
|
| 165 | rubric: [
|
| 166 | {
|
| 167 | title: "Skills Assessment",
|
| 168 | id: "1",
|
| 169 | value: 4,
|
| 170 | description: "This outcome is for demonstration purposes only"
|
| 171 | },
|
| 172 | {
|
| 173 | title: "Writing Skills",
|
| 174 | id: "2",
|
| 175 | value: 4,
|
| 176 | description: "This outcome is for demonstration purposes only"
|
| 177 | },
|
| 178 | {
|
| 179 | title: "Research Skills",
|
| 180 | id: "3",
|
| 181 | value: 4,
|
| 182 | description: "This outcome is for demonstration purposes only"
|
| 183 | },
|
| 184 | {
|
| 185 | title: "Thinking Skills",
|
| 186 | id: "3",
|
| 187 | value: 4,
|
| 188 | description: "This outcome is for demonstration purposes only"
|
| 189 | }
|
| 190 | ]
|
| 191 | })
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 192 | }
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 193 |
|
| 194 | resolve(assignments);
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 195 | })
|
| 196 | }
|
| 197 |
|
| 198 | //Fetches modules data from Canvas
|
| 199 | dtpsLMS.fetchModules = function (userID, classID) {
|
| 200 | return new Promise(function (resolve, reject) {
|
| 201 | resolve([
|
| 202 | {
|
| 203 | title: "Demo module",
|
| 204 | id: "1",
|
| 205 | items: [
|
| 206 | {
|
| 207 | type: "url",
|
| 208 | title: "google.com",
|
| 209 | url: "https://www.google.com"
|
| 210 | },
|
| 211 | {
|
| 212 | type: "page",
|
| 213 | title: "Demo Page",
|
| 214 | id: "1"
|
| 215 | },
|
| 216 | {
|
| 217 | type: "discussion",
|
| 218 | title: "Demo Discussion",
|
| 219 | id: "1"
|
| 220 | },
|
| 221 | {
|
| 222 | type: "assignment",
|
| 223 | title: "Demo Assignment 1",
|
| 224 | id: "191"
|
| 225 | },
|
| 226 | {
|
| 227 | type: "assignment",
|
| 228 | title: "Demo Assignment 2",
|
| 229 | id: "192"
|
| 230 | }
|
| 231 | ]
|
| 232 | }
|
| 233 | ]);
|
| 234 | });
|
| 235 | }
|
| 236 |
|
| 237 | //Fetches announcement data from Canvas
|
| 238 | dtpsLMS.fetchAnnouncements = function (classID) {
|
| 239 | return new Promise(function (resolve, reject) {
|
| 240 | resolve([{
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 241 | title: "Assignments Graded",
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 242 | postedAt: new Date().getDate(),
|
| j | 36579d2 | 2022-01-15 20:12:01 -0800 | [diff] [blame] | 243 | body: "<p>This is a demo announcement</p>"
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 244 | }]);
|
| 245 | });
|
| 246 | }
|
| 247 |
|
| 248 | //Fetches homepage data from Canvas
|
| 249 | dtpsLMS.fetchHomepage = function (classID) {
|
| 250 | return new Promise(function (resolve, reject) {
|
| 251 | resolve(`<p>This homepage is for demonstration purposes only</p>`);
|
| 252 | });
|
| 253 | }
|
| 254 |
|
| 255 | //Fetches discussion thread data from Canvas
|
| 256 | dtpsLMS.fetchDiscussionThreads = function (classID) {
|
| 257 | return new Promise(function (resolve, reject) {
|
| 258 | resolve([
|
| 259 | {
|
| 260 | title: "Demo Discussion",
|
| 261 | id: "1",
|
| 262 | locked: true
|
| 263 | }
|
| 264 | ])
|
| 265 | })
|
| 266 | }
|
| 267 |
|
| 268 | //Fetches discussion thread posts from Canvas
|
| 269 | dtpsLMS.fetchDiscussionPosts = function (classID, threadID) {
|
| 270 | return new Promise(function (resolve, reject) {
|
| 271 | resolve({
|
| 272 | title: "Demo Discussion",
|
| 273 | id: "1",
|
| 274 | locked: true,
|
| 275 | requireInitialPost: false,
|
| 276 | posts: [
|
| 277 | {
|
| 278 | id: "1",
|
| 279 | body: `<p>This discussion is for demonstration purposes only</p>`,
|
| 280 | postedAt: new Date(),
|
| 281 | author: {
|
| 282 | name: "Demo Teacher",
|
| 283 | id: "2",
|
| 284 | photoURL: "https://powerplus.app/logo.png"
|
| 285 | }
|
| 286 | }
|
| 287 | ]
|
| 288 | })
|
| 289 | })
|
| 290 | }
|
| 291 |
|
| 292 | //Fetches pages list data from Canvas
|
| 293 | dtpsLMS.fetchPages = function (classID) {
|
| 294 | return new Promise(function (resolve, reject) {
|
| 295 | resolve([
|
| 296 | {
|
| 297 | title: "Demo Page",
|
| 298 | id: "1"
|
| 299 | }
|
| 300 | ])
|
| 301 | })
|
| 302 | }
|
| 303 |
|
| 304 | //Fetches pages list data from Canvas
|
| 305 | dtpsLMS.fetchPageContent = function (classID, pageID) {
|
| 306 | return new Promise(function (resolve, reject) {
|
| 307 | resolve({
|
| 308 | title: "Demo Page",
|
| 309 | id: "1",
|
| 310 | updatedAt: new Date(),
|
| 311 | content: `<p>This page is for demonstration purposes only</p>`,
|
| 312 | author: {
|
| 313 | name: "Demo Teacher",
|
| 314 | id: "2",
|
| 315 | photoURL: "https://powerplus.app/logo.png"
|
| 316 | }
|
| 317 | });
|
| 318 | })
|
| 319 | }
|
| 320 |
|
| j | 2fcf4e5 | 2021-03-11 14:37:26 -0800 | [diff] [blame] | 321 | dtpsLMS.gradebook = function (course) {
|
| 322 | return new Promise((resolve, reject) => {
|
| 323 | //RENDERER: RENDER GRADE CALCULATION SUMMARY ------------------------------------
|
| 324 | var gradeCalcSummary = /*html*/`
|
| 325 | <div id="gradeSummary" style="--size: 250px; margin: 0px 20px; --classColor: ${course.color};" class="grid flex">
|
| 326 | <div style="background-color: var(--classColor); color: white;" class="block status letterGrade card">
|
| 327 | <h2 class="main">${course.letter}</h2>
|
| 328 | ${course.previousLetter ? `<h5 class="previousGrade">Previous grade: ${course.previousLetter}</h5>` : ""}
|
| 329 | <h5 class="bottom"><i class="fluid-icon">grade</i> Grade</h5>
|
| 330 | </div>
|
| 331 | <div class="block status number75">
|
| 332 | <h2 class="main numFont">3.7</h2>
|
| 333 | <h5 class="bottom"><i class="fluid-icon">functions</i> 75% of outcomes (5) ≥</h5>
|
| 334 | </div>
|
| 335 | <div class="block status lowestScore">
|
| 336 | <h2 class="main numFont">3.5</h2>
|
| 337 | <h5 class="bottom"><i class="fluid-icon">leaderboard</i> Lowest outcome</h5>
|
| 338 | </div>
|
| 339 | </div>
|
| 340 |
|
| 341 | <div class="gradeSummaryShowHide">
|
| 342 | ${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>`}
|
| 343 | </div>
|
| 344 | `;
|
| 345 |
|
| 346 | var rubricColor = function (score) {
|
| 347 | if (score > 4.0) return "#20D684";
|
| 348 | if (score == 4.0) return "#41BA35";
|
| 349 | if (score >= 3.9) return "#50BC39";
|
| 350 | if (score >= 3.8) return "#5FBD3D";
|
| 351 | if (score >= 3.7) return "#6EBF40";
|
| 352 | if (score >= 3.6) return "#7DC044";
|
| 353 | if (score >= 3.5) return "#8CC248";
|
| 354 | if (score >= 3.4) return "#9AC44C";
|
| 355 | if (score >= 3.3) return "#A9C550";
|
| 356 | if (score >= 3.2) return "#B8C753";
|
| 357 | if (score >= 3.1) return "#C7C857";
|
| 358 | if (score >= 3.0) return "#D6CA5B";
|
| 359 | if (score >= 2.9) return "#D8C35A";
|
| 360 | if (score >= 2.8) return "#DABB59";
|
| 361 | if (score >= 2.7) return "#DCB458";
|
| 362 | if (score >= 2.6) return "#DEAC57";
|
| 363 | if (score >= 2.5) return "#E1A556";
|
| 364 | if (score >= 2.4) return "#E39E55";
|
| 365 | if (score >= 2.3) return "#E59654";
|
| 366 | if (score >= 2.2) return "#E78F53";
|
| 367 | if (score >= 2.1) return "#E98752";
|
| 368 | if (score >= 2.0) return "#EB8051";
|
| 369 | if (score >= 1.9) return "#E97A50";
|
| 370 | if (score >= 1.8) return "#E7744F";
|
| 371 | if (score >= 1.7) return "#E56F4E";
|
| 372 | if (score >= 1.6) return "#E3694D";
|
| 373 | if (score >= 1.5) return "#E1634C";
|
| 374 | if (score >= 1.4) return "#DE5D4A";
|
| 375 | if (score >= 1.3) return "#DC5749";
|
| 376 | if (score >= 1.2) return "#DA5248";
|
| 377 | if (score >= 1.1) return "#D84C47";
|
| 378 | if (score >= 1.0) return "#D64646";
|
| 379 | if (score >= 0.0) return "#D72727";
|
| 380 | if (score < 0.0) return "#BF0000";
|
| 381 | }
|
| 382 |
|
| 383 | //RENDERER: RENDER EACH OUTCOME ------------------------------------
|
| 384 | var outcomeHTML = []; //array of outcome html to be rendered
|
| 385 | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].forEach(() => {
|
| 386 | var avg = 3 + Math.random();
|
| 387 | outcomeHTML.push(/*html*/`
|
| 388 | <div style="border-radius: 20px;padding: 22px; padding-bottom: 20px;" class="card outcomeResults">
|
| 389 | <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>
|
| 390 |
|
| 391 | <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>
|
| 392 |
|
| 393 | <div class="assessments">
|
| 394 | ${[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(() => {
|
| 395 | var score = [3, 3.5, 4, 4, 4, 4].random();
|
| 396 | return /*html*/`
|
| 397 | <div class="assessmentWrapper" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 6px 0px;">
|
| 398 | <div style="color: ${rubricColor(score)};" class="editableScore">${score}</div>
|
| 399 | <span class="assessmentTitle" style="cursor: pointer;">${generateAssignmentName()}</span>
|
| 400 | </div>
|
| 401 | `;
|
| 402 | }).join("")}
|
| 403 | </div>
|
| 404 | </div>
|
| 405 | `);
|
| 406 | })
|
| 407 |
|
| 408 | //RESOLVE WITH HTML
|
| 409 | resolve(gradeCalcSummary + `<br />` + outcomeHTML.join(""));
|
| 410 | });
|
| 411 | }
|
| 412 |
|
| 413 | //scroll listener
|
| 414 | var scrollListenerAdded = false;
|
| 415 | dtpsLMS.gradebookDidRender = function (course) {
|
| 416 | //Keep the grade summary on top
|
| 417 | if (!scrollListenerAdded) {
|
| 418 | scrollListenerAdded = true;
|
| 419 | var gradeSummary = document.getElementById("gradeSummary");
|
| 420 | var sticky = gradeSummary.offsetTop - parseFloat($("body").css("padding-top")) - 10;
|
| 421 | window.onscroll = function () {
|
| 422 | if ((window.pageYOffset >= sticky) && ((dtps.classes[dtps.selectedClass]) && (dtps.selectedContent == "grades"))) {
|
| 423 | $(".classContent").addClass("fixedGradeSummary");
|
| 424 | } else {
|
| 425 | $(".classContent").removeClass("fixedGradeSummary");
|
| 426 | }
|
| 427 | };
|
| 428 | }
|
| 429 | }
|
| 430 |
|
| j | 7940eec | 2020-12-28 14:00:41 -0600 | [diff] [blame] | 431 |
|
| 432 | //Load Power+
|
| j | 36579d2 | 2022-01-15 20:12:01 -0800 | [diff] [blame] | 433 | jQuery.getScript(window.dtpsBaseURL + "/scripts/core.js");
|