blob: e4169cd64d7db7b074dbbe080df07dd79b06bb7e [file] [log] [blame]
j7940eec2020-12-28 14:00:41 -06001/**
2 * @file DTPS assignment functions
3 * @author jottocraft
4 *
j6e1a7bf2026-10-13 03:37:04 +00005 * @copyright Copyright (c) jottocraft 2020
j40db0272022-01-14 15:18:29 -08006 * @license MIT
j7940eec2020-12-28 14:00:41 -06007 */
8
9/**
10 * Renders HTML for an assignment item in a list
11 *
12 * @param {Assignment} assignment The assignment object to render
13 * @param {string} [childDisplay] Text to display for specifying the child or children this assignment is for
14 * @return {string} Assignment HTML for use in a list
15 */
16dtps.renderAssignment = function (assignment, childDisplay) {
17 //Render points/letter score
18 var scoreHTML = dtps.renderAssignmentScore(assignment);
19
j29812c42022-04-27 15:41:40 -070020 let highlightUnusualDate = false;
21 if (assignment.dueAt && (fluid.get("pref-unusualDueDates") != "false")) {
22 const dayTimeMinutes = dtps.dayTimeMinutes(assignment.dueAt);
23 const range = dtps.classes[assignment.class].usualDueRange;
24 if (range && !isNaN(range[0]) && !isNaN(range[1]) && (dayTimeMinutes !== null)) {
25 if ((dayTimeMinutes < range[0]) || (dayTimeMinutes > range[1])) highlightUnusualDate = true;
26 }
27 }
28
j7940eec2020-12-28 14:00:41 -060029 var HTML = /*html*/`
30 <div
31 onclick="${`dtps.assignment('` + assignment.id + `', ` + assignment.class + `, ` + (!isNaN(childDisplay) ? true : false) + `)`}"
32 class="card ${scoreHTML ? "graded assignment" : "assignment"}"
33 style="${'--classColor: ' + dtps.classes[assignment.class].color}"
34 >
35
36 <!-- Color bar for the dashboard -->
37 <div class="colorBar"></div>
38
39 <!-- Assignment title and points -->
40 <h4>
41 <span>${assignment.title}</span>
42
43 <!-- Points display -->
44 ${scoreHTML ? `<div class="points">${scoreHTML}</div>` : ``}
45 </h4>
46
47 <h5>
48 <!-- Assignment info -->
49 <div class="info">
j2566c4e2021-10-01 15:25:49 -070050 ${assignment.error ? `<div style="color: #f2392c;" class="infoChip weighted"><i class="fluid-icon">error</i> Error</div>` : ""}
j29812c42022-04-27 15:41:40 -070051 ${assignment.dueAt ? `<div ${highlightUnusualDate ? `style="font-weight: bold;color: var(--themeText);background-color: var(--theme);padding: 0px 8px;border-radius: 10px;"` : ""} class="infoChip"><i style="margin-top: -2px;" class="fluid-icon">alarm</i> Due ` + dtps.formatDate(assignment.dueAt) + `</div>` : ""}
j7940eec2020-12-28 14:00:41 -060052 ${assignment.outcomes ? `<div class="infoChip weighted"><i class="fluid-icon">adjust</i>` + assignment.outcomes.length + `</div>` : ""}
53 ${assignment.category ? `<div class="infoChip weighted"><i class="fluid-icon">category</i> ` + assignment.category + `</div>` : ""}
54 ${childDisplay ? `<div class="infoChip weighted"><i class="fluid-icon">person</i> ` + childDisplay + `</div>` : ""}
55 </div>
56
57 <!-- Status icons -->
58 <div class="status">
59 ${assignment.turnedIn ? `<i title="Assignment submitted" class="fluid-icon statusIcon" style="color: #0bb75b;">assignment_turned_in</i>` : ``}
60 ${assignment.missing ? `<i title="Assignment is missing" class="fluid-icon statusIcon" style="color: #c44848;">remove_circle_outline</i>` : ``}
61 ${assignment.late ? `<i title="Assignment is late" class="fluid-icon statusIcon" style="color: #c44848;">assignment_late</i>` : ``}
62 ${assignment.locked ? `<i title="Assignment submissions are locked" class="fluid-icon statusIcon" style="color: var(--secText, gray);">lock_outline</i>` : ``}
63 ${assignment.pending ? `<i title="Grade is pending review" class="fluid-icon statusIcon" style="color: #b3b70b;">rate_review</i>` : ``}
64 </div>
65 </h5>
66 </div>
67 `;
68
69 return HTML;
70}
71
72/**
73* Renders HTML for an assignment score if the assignment is graded
74*
75* @param {Assignment} assignment The assignment object to render a score for
76* @return {string} Assignment score HTML
77*/
78dtps.renderAssignmentScore = function (assignment) {
79 var scoreHTML = "";
80
j0f3d7db2026-10-13 04:56:55 +000081 if (assignment.grade || (assignment.grade == 0)) {
j7940eec2020-12-28 14:00:41 -060082 scoreHTML = /*html*/`
83 <div class="assignmentGrade">
84 <div class="grade">${Number(assignment.grade.toFixed(2))}</div>
85 <div class="value">/${Number(assignment.value.toFixed(2))}</div>
86 ${assignment.letter ? `<div class="letter">${assignment.letter.replace("incomplete", `<i class="fluid-icon">cancel</i>`).replace("complete", `<i class="fluid-icon">done</i>`)}</div>` : ""}
87 <div class="percentage">${Math.round((assignment.grade / assignment.value) * 100)}%</div>
88 </div>
89 `;
90 }
91
92 return scoreHTML;
93}
94
95/**
96* Merges and renders assignments for children in the same class
97*
98* @param {Assignment[]} assignments An array of assignment objects to merge
99* @return {string} HTML with the assignments merged and labelled
100*/
101dtps.mergeAndRenderChildAssignments = function (assignments) {
102 var assignmentGroups = [];
103
104 assignments.forEach(assignment => {
105 var matchedGroup = false;
106 assignmentGroups.forEach(group => {
107 var groupAssignment = group[0];
108
109 //Check if assignment matches group assignment
110 var matchKeys = ["id", "dueAt", "locked", "category", "turnedIn", "late", "missing", "grade", "value", "letter"];
111 var matches = 0;
112 matchKeys.forEach(k => {
113 if (assignment[k] == groupAssignment[k]) matches++;
114 });
115
116 if (matches == matchKeys.length) {
117 matchedGroup = true;
118 group.push(assignment);
119 }
120 });
121
122 if (!matchedGroup) {
123 assignmentGroups.push([assignment]);
124 }
125 });
126
127 return assignmentGroups.map(g => {
128 return dtps.renderAssignment(g[0], g.length == 1 ? dtps.user.children.find(c => c.id == dtps.classes[g[0].class].userID).name : g.length);
129 }).join("");
130}
131
132/**
133 * Renders the DTPS dashboard and calls dtps.renderCalendar, dtps.renderUpdates, and dtps.renderUpcoming
134 */
135dtps.mainStream = function () {
136 //Ensure classes are rendered in the sidebar
137 dtps.presentClass("dash");
138 dtps.showClasses();
139
140 //Clear active state from all tabs
141 $("#dtpsTabBar .btn").removeClass("active");
142
143 //Count amount of classes that are loaded
144 var ready = 0;
145 dtps.classes.forEach(course => {
146 if (course.assignments) ready++;
147 });
148
149 //Check if all classes are loaded
150 var doneLoading = ready == dtps.classes.length;
151
152 //Returns dashboard item container HTML for an item
153 function dashboardContainerHTML(dashboardItem) {
154 if (dashboardItem.id == "dtps.calendar") {
155 return window.FullCalendar ? `<div id="calendar" class="card" style="padding: 20px;"></div>` : "";
156 } else if (dashboardItem.id == "dtps.updates") {
157 return `<div class="updatesStream recentlyGraded announcements"></div>`;
158 } else if (dashboardItem.id == "dtps.dueToday") {
159 return `<div style="padding: 20px 0px;" class="dueToday"></div>`;
160 } else if (dashboardItem.id == "dtps.upcoming") {
161 return `<div style="padding: 20px 0px;" class="assignmentStream"></div>`;
162 }
163 }
164
165 //Render HTML with loading placeholder
166 if (dtps.selectedClass == "dash") {
167 jQuery(".classContent").html(/*html*/`
168 <div style="letter-spacing: 0px;">
169 <div style="float: left; width: 45%; display: inline-block;" class="dash">
170 ${dtps.leftDashboard.map(dashboardItem => {
171 return dashboardContainerHTML(dashboardItem);
172 }).join("")}
173 </div>
174
175 <div style="float: left; width: 55%; display: inline-block;" class="dash">
176 ${!doneLoading ? `<div style="margin: 75px 25px 10px 75px;"><div class="spinner"></div></div>` : ""}
177 ${dtps.rightDashboard.map(dashboardItem => {
178 return dashboardContainerHTML(dashboardItem);
179 }).join("")}
180 </div>
181 </div>
182 `);
183 }
184
185 //Render updates stream
186 dtps.renderUpdates();
187
188 //Render upcoming assignments stream
189 dtps.renderUpcoming();
190
191 //Render calendar
192 dtps.calendar(doneLoading);
193
194 //Render due today
195 dtps.renderDueToday(doneLoading);
196}
197
198/**
199 * Checks if a due date is on a date
200 *
201 * @param {Date} date Date to check
202 * @param {Date} [onDate] Date checked against (defaults to today)
203 */
jc7c211e2022-08-19 18:42:15 -0700204dtps.isDueOnDate = function (date, onDate = new Date()) {
205 const d1 = new Date(date);
j7940eec2020-12-28 14:00:41 -0600206
jc7c211e2022-08-19 18:42:15 -0700207 const isOnDate = d1.getFullYear() === onDate.getFullYear() &&
208 d1.getMonth() === onDate.getMonth() &&
209 d1.getDate() === onDate.getDate();
j7940eec2020-12-28 14:00:41 -0600210
jc7c211e2022-08-19 18:42:15 -0700211 return isOnDate;
j7940eec2020-12-28 14:00:41 -0600212}
213
214/**
215 * Compiles and displays due today / to-do stream
216 *
217 * @param {boolean} doneLoading True if all classes have finished loading their assignment lists
218 * @param {Date} [fromDate] The date to display assignments from. Defaults to the current date.
219 */
220dtps.renderDueToday = function (doneLoading, fromDate) {
221 //Combine class stream arrays
222 var combinedStream = [];
223 if (dtps.classes) {
224 dtps.classes.forEach(course => {
225 if (course.assignments) {
226 //If course has assignments, add them to the combined stream array
227 course.assignments.forEach(assignment => {
228 //Only assignments that are due today
229 if (dtps.isDueOnDate(assignment.dueAt, fromDate)) {
230 combinedStream.push(assignment);
231 }
232 })
233 }
234 })
235 }
236
237 //Sort combined stream by date
238 combinedStream.sort(function (a, b) {
239 var keyA = new Date(a.dueAt).getTime(),
240 keyB = new Date(b.dueAt).getTime();
241
242 // Compare the 2 dates
243 if (keyA > keyB) return 1;
244 if (keyA < keyB) return -1;
245 return 0;
246 });
247
248 //Get due today stream HTML
249 if (dtps.user.parent) {
250 var combinedHTML = dtps.mergeAndRenderChildAssignments(combinedStream);
251 } else {
252 var combinedHTML = combinedStream.map(assignment => {
253 return dtps.renderAssignment(assignment);
254 }).join("");
255 }
256
257 if (combinedStream.length == 0) {
258 //Nothing due today
259 if (doneLoading) {
260 combinedHTML = `<p style="text-align: center;margin: 10px 0px; font-size: 18px;"><i class="fluid-icon">done</i> ${fromDate ? "Nothing is due on " + fromDate.toLocaleString("en", { weekday: 'short', month: 'short', day: 'numeric' }) : "Nothing is due today"}</p>`;
261 } else {
262 combinedHTML = ``;
263 }
264 } else {
265 //Add header
266 combinedHTML = /*html*/`
267 <h5 style="text-align: center; margin: 10px 0px; font-weight: bold;">${fromDate ? "Due on " + fromDate.toLocaleString("en", { weekday: 'short', month: 'short', day: 'numeric' }) : "Due Today"}</h5>
268 ` + combinedHTML;
269 }
270
271 if (dtps.selectedClass == "dash") {
272 jQuery(".classContent .dash .dueToday").html(combinedHTML);
273 }
274}
275
276/**
277 * Compiles and displays upcoming assignments stream
278 *
279 * @param {Date} [fromDate] The date to display assignments from. Defaults to the current date.
280 */
281dtps.renderUpcoming = function (fromDate) {
282 //Combine class stream arrays
283 var today = fromDate ? new Date(fromDate) : new Date();
284 var combinedStream = [];
285 if (dtps.classes) {
286 dtps.classes.forEach(course => {
287 if (course.assignments) {
288 //If course has assignments, add them to the combined stream array
289 course.assignments.forEach(assignment => {
290 //Only include upcoming assignments that aren't due today
291 if ((new Date(assignment.dueAt).getTime() > today.getTime()) && !dtps.isDueOnDate(assignment.dueAt, today)) {
292 combinedStream.push(assignment);
293 }
294 })
295 }
296 })
297 }
298
299 //Sort combined stream by date
300 combinedStream.sort(function (a, b) {
301 var keyA = new Date(a.dueAt).getTime(),
302 keyB = new Date(b.dueAt).getTime();
303
304 // Compare the 2 dates
305 if (keyA > keyB) return 1;
306 if (keyA < keyB) return -1;
307 return 0;
308 });
309
310 //Limit stream length to 30 assignments
311 if (combinedStream.length > 30) {
312 combinedStream.length = 30;
313 }
314
315 //Render upcoming assignments stream
316 if (dtps.user.parent) {
317 var combinedHTML = dtps.mergeAndRenderChildAssignments(combinedStream);
318 } else {
319 var combinedHTML = combinedStream.map(assignment => {
320 return dtps.renderAssignment(assignment);
321 }).join("");
322 }
323
324 //No upcoming assignments
325 if (combinedStream.length == 0) {
326 combinedHTML = "";
327 }
328
329 if (dtps.selectedClass == "dash") {
330 jQuery(".classContent .dash .assignmentStream").html(combinedHTML);
331 }
332}
333
334/**
335 * Renders updates stream (recently graded & announcements)
336 *
337 * @param {boolean} [dateSelected] True if a date is selected in the dashboard
338 */
339dtps.renderUpdates = function (dateSelected) {
340 //Get updates HTML
341 var updatesHTML = "";
342
j7940eec2020-12-28 14:00:41 -0600343 if (dateSelected && (dtps.selectedClass == "dash")) {
344 return jQuery(".classContent .dash .updatesStream").html(/*html*/`
345 <div style="cursor: auto; padding: 20px; --classColor: var(--secText);" class="announcement card open">
346 <div class="className">Date Selected</div>
347 <p>Updates are not shown while a date is selected</p>
348 </div>
349 `);
350 }
351
352 dtps.updates.forEach(update => {
353 if (update.type == "announcement") {
354 updatesHTML += /*html*/`
355 <div onclick="$(this).toggleClass('open');" style="cursor: pointer; padding: 20px; --classColor: ${dtps.classes[update.class].color};" class="announcement card">
356 <div class="className">${update.title}</div>
357 ${update.body}
358 </div>
359 `;
360 } else if (update.type == "assignment") {
361 var scoreHTML = dtps.renderAssignmentScore(update);
362 updatesHTML += /*html*/`
363 <div onclick="dtps.assignment('${update.id}', ${update.class})" style="--classColor: ${dtps.classes[update.class].color};" class="card recentGrade">
364 <h5>
365 <span>${update.title}</span>
366
367 <!-- Points display -->
368 ${scoreHTML ? `<div class="points">${scoreHTML}</div>` : ``}
369 </h5>
370
371 <p>${dtps.user.parent ? "Graded for " + dtps.user.children.find(c => c.id == dtps.classes[update.class].userID).name : "Graded"} at ${dtps.formatDate(update.gradedAt)}</p>
372 </div>
373 `;
374 }
375 })
376
377 if (dtps.selectedClass == "dash") {
378 jQuery(".classContent .dash .updatesStream").html(updatesHTML);
379 }
380}
381
382
383/**
384 * Compiles and displays the assignment calendar
385 *
386 * @param {boolean} doneLoading True if all classes have finished loading their assignment lists
387 */
388dtps.calendar = function (doneLoading) {
389 if (dtps.selectedClass == "dash") {
390 //Calendar events array
391 var calEvents = [];
392
393 //Add assignments from every class to calEvents array
394 dtps.classes.forEach((course, courseIndex) => {
395 if (course.assignments) {
396 //Class has assignments
397 course.assignments.forEach(assignment => {
j7940eec2020-12-28 14:00:41 -0600398 var date = new Date(assignment.dueAt);
j7940eec2020-12-28 14:00:41 -0600399
400 var existingEvent = calEvents.find(e => e.id == assignment.id);
401 if (existingEvent && assignment.missing) {
402 //Mark existing event as missing and link to missing assignment
403 existingEvent.missing = true;
404 existingEvent.borderColor = "#c44848";
405 existingEvent.assignmentID = assignment.id;
406 existingEvent.classNum = courseIndex;
407 } else if (!existingEvent) {
408 calEvents.push({
409 title: assignment.title,
410 start: date,
411 id: assignment.id,
412 allDay: true,
413 backgroundColor: course.color,
414 borderColor: (assignment.missing === true) ? '#c44848' : 'transparent',
415 textColor: "white",
416 classNum: courseIndex,
417 assignmentID: assignment.id,
418 missing: assignment.missing
419 });
420 }
421 });
422 }
423 });
424
425 //Render calendar
426 if (window.FullCalendar) {
427 var calendarEl = document.getElementById('calendar');
428 calendar = new FullCalendar.Calendar(calendarEl, {
429 locale: "en",
430 initialView: 'dayGridMonth',
431 events: calEvents,
432 eventContent: info => {
433 const { missing } = info.event.extendedProps;
434 const html = /*html*/`
435 <div class='fc-event-main-frame'>
436 <div class='fc-event-title-container'>
437 <div class='fc-event-title fc-sticky'>
438 ${missing ? `<i title="Assignment is missing" class="fluid-icon statusIcon">remove_circle_outline</i>` : ``}
439 <span style="vertical-align: middle;">${info.event.title}</span>
440 </div>
441 </div>
442 </div>
443 `;
444 return { html };
445 },
446 contentHeight: 0,
447 handleWindowResize: false,
448 headerToolbar: {
449 start: 'title',
450 center: '',
451 end: 'prev,next'
452 },
453 dateClick: function (info) {
454 if ($(info.dayEl).hasClass("fc-day-today")) return fluid.screen();
455
456 //Update calendar
457 $("#calendar .fc-daygrid-day").removeClass("active");
458 $(info.dayEl).addClass("active");
459 $("#calendar").addClass("dateSelected");
460
461 //Display selected date
462 $(".headerArea .contentLabel i").text("event");
463 $(".headerArea .contentLabel span").text("Showing assignments from " + info.date.toLocaleString("en", { weekday: 'short', month: 'short', day: 'numeric' }));
464 $(".headerArea .contentLabel").show();
465
466 //Re-render dashboard from the selected date
467 dtps.renderDueToday(doneLoading, info.date);
468 dtps.renderUpcoming(info.date);
469 dtps.renderUpdates(true);
470 },
471 eventClick: function (info) {
472 dtps.assignment(info.event.extendedProps.assignmentID, info.event.extendedProps.classNum);
473 }
474 });
475 calendar.render();
476 }
477 }
478}
479
480/**
481 * Shows the assignments stream for a class
482 *
483 * @param {string} classID The class ID to show assignments for
484 * @param {Assignment[]} [searchResults] An array of assignemnts to render instead of course.assignments. Used for assignment search.
485 */
486dtps.classStream = function (classID, searchResults) {
487 //Get class index and set as selected class
488 var classNum = dtps.classes.map(course => course.id).indexOf(classID);
489 dtps.selectedClass = classNum;
490
491 //Set stream as the selected content
492 dtps.selectedContent = "stream";
493 $("#dtpsTabBar .btn").removeClass("active");
494 $("#dtpsTabBar .btn.stream").addClass("active");
495
496 //Save coursework stream preference
497 window.localStorage.setItem("courseworkPref-" + classID, "stream");
498
499 //Load class color, name, etc.
500 dtps.presentClass(classNum);
501
502 //Ensure classes are shown in the sidebar
503 dtps.showClasses();
504
505 if (classNum == -1) {
506 //Class does not exist
507 dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.classStream");
508 }
509
510 //Use search results to render or render all class assignments
511 var assignments = searchResults || dtps.classes[classNum].assignments;
512
513 //Render assignments
514 if (!assignments) {
515 //Assignments are still loading
516 if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "stream")) {
517 jQuery(".classContent").html(dtps.renderStreamTools(classNum, "stream") + [1, 2, 3, 4].map(() => (
518 /*html*/`
519 <div class="card assignment graded">
520 <h4>
521 <span style="width: 450px;" class="shimmer">Assignment Title</span>
522 <div class="points shimmer">00/00</div>
523 </h4>
524
525 <h5 style="white-space: nowrap; overflow: hidden;">
526 <div style="width: 200px;" class="infoChip shimmer"></div>
527 <i class="fluid-icon statusIcon shimmer">more_horiz</i>
528 </h5>
529 </div>
530 `
531 )).join(""));
532 }
533 } else if (assignments.length == 0) {
534 //This class doesn't have any assignments
535 if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "stream")) {
536 $(".classContent").html(dtps.renderStreamTools(classNum, "stream") + /*html*/`
537 <div style="text-align: center;">
538 <div style="margin: 60px; padding: 20px 40px; display: inline-block; border: 2px solid var(--elements); border-radius: var(--elementRadius);">
539 <h5>No Assignments</h5>
540 <p>There aren't any assignments in this class yet.</p>
541 </div>
542 </div>
543 `);
544 }
545 } else {
546 //Sort assignments
547 assignments.sort(function (a, b) {
548 var keyA = new Date(a.dueAt).getTime(),
549 keyB = new Date(b.dueAt).getTime();
550
551 var now = new Date().getTime();
552
553 //Put assignments without a due date at the end
554 if (!a.dueAt) { keyA = 0; }
555 if (!b.dueAt) { keyB = 0; }
556
557 //Put upcoming assignments at the top
558 if ((keyA < now) || (keyB < now)) {
559 // Sort upcoming assignments from earliest -> latest
560 if (keyA < keyB) return 1;
561 if (keyA > keyB) return -1;
562 return 0;
563 } else {
564 // Sort old assignments from latest -> earliest
565 if (keyA > keyB) return 1;
566 if (keyA < keyB) return -1;
567 return 0;
568 }
569 });
570
571 //Render assignments
572 var prevAssignment = null;
573 var streamHTML = assignments.map(assignment => {
574 var divider = "";
575
576 if (!assignment.dueAt) {
577 if (prevAssignment && (prevAssignment !== "undated")) {
578 divider = `<h5 style="margin: 75px 20px 10px 20px;font-weight: bold;">Undated Assignments</h5>`;
579 }
580
581 prevAssignment = "undated";
582 } else if (new Date(assignment.dueAt) < new Date()) {
583 if (prevAssignment && (prevAssignment !== "old")) {
584 divider = `<h5 style="margin: 75px 20px 10px 20px;font-weight: bold;">Old Assignments</h5>`;
585 }
586
587 prevAssignment = "old";
588 } else {
589 prevAssignment = "upcoming";
590 }
591
592 return divider + dtps.renderAssignment(assignment);
593 }).join("");
594
595 //Add stream header with class info buttons and search box
596 streamHTML = dtps.renderStreamTools(classNum, "stream") + streamHTML;
597
598 if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "stream")) {
599 $(".classContent").html(streamHTML);
600 }
601 }
602}
603
604/**
605 * Shows details for an assignment given the assignment ID and class number
606 *
607 * @param {string} id Assignment ID
608 * @param {number} classNum Assignment class number
609 * @param {boolean} [generic] True if user-specific details, such as grades, should not be displayed
610 */
611dtps.assignment = function (id, classNum, generic) {
612 //Get assignment from the id prop
613 var assignmentIDs = dtps.classes[classNum].assignments.map(assignment => assignment.id);
614 var assignment = dtps.classes[classNum].assignments[assignmentIDs.indexOf(id)];
615
616 //The assignment body is rendered in an iFrame to keep its content and styling isolated from the rest of the page
617 var assignmentBodyHTML = null;
618 if (assignment.body) {
619 //Get computed background and text color to style the iFrame with
620 var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
621 var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
622
623 var body = assignment.body;
624 if ($("body").hasClass("dark")) {
625 body = dtps.brightenTextForDarkMode(assignment.body, computedBackgroundColor);
626 }
627
jd80b6e02021-04-19 20:16:38 -0700628 //Generate a blob with the assignment body and get its data URL
629 var blob = new Blob([`
j7940eec2020-12-28 14:00:41 -0600630 <base target="_blank" />
631 <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
jd80b6e02021-04-19 20:16:38 -0700632 <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};}</style>
633 ${body}
634 `], { type: 'text/html' });
635 assignmentBodyHTML = `<iframe id="assignmentIframe" onload="dtps.iframeLoad('assignmentIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${window.URL.createObjectURL(blob)}" />`;
636
j7940eec2020-12-28 14:00:41 -0600637 }
638
639 //Get assignment rubric HTML
640 var assignmentRubricHTML = "";
641 if (assignment.rubric) {
642 var assignmentRubricHTML = assignment.rubric.map(function (rubricItem) {
643 return /*html*/`
644 <div class="dtpsAssignmentRubricItem">
645 <h5>${rubricItem.title}</h5>
646 <div class="score">
647 <p style="color: ${(!generic && rubricItem.color) ? rubricItem.color : "var(--secText)"};" class="scoreName">
648 ${generic ? "" : (rubricItem.score !== undefined ? rubricItem.scoreName || "" : "Not assessed")}
649
650 <div class="points">
j2fcf4e52021-03-11 14:37:26 -0800651 <p class="earned">${generic || (rubricItem.score == undefined) ? "" : rubricItem.score}</p>
j7940eec2020-12-28 14:00:41 -0600652 <p class="possible">${"/" + rubricItem.value}</p>
653 </div>
654 </p>
655 </div>
656 </div>
657 `
658 }).join("");
659 }
660
661 //Get assignment feedback HTML
662 var assignmentFeedbackHTML = "";
663 if (assignment.feedback) {
664 var assignmentFeedbackHTML = assignment.feedback.map(feedback => {
665 return /*html*/`
666 <div class="dtpsSubmissionComment">
667 ${feedback.author ? /*html*/`
668 <img src="${feedback.author.photoURL}" />
669 <h5>${feedback.author.name}</h5>
670 ` : ``}
671
672 <p>${feedback.comment}</p>
673 </div>
674 `
675 }).join("");
676 }
677
678 //Get assignment score HTML
679 var scoreHTML = dtps.renderAssignmentScore(assignment);
680
681 //Render assignment details
682 $(".card.details").html(/*html*/`
683 <i onclick="fluid.cards.close('.card.details'); $('.card.details').html('');" class="fluid-icon close">close</i>
684
685 <h4 style="font-weight: bold;">${assignment.title}</h4>
686
687 <div>
688 ${assignment.dueAt ? `<div class="assignmentChip"><i class="fluid-icon">alarm</i><span>Due ${dtps.formatDate(assignment.dueAt)}</span></div>` : ""}
689 ${assignment.turnedIn && !generic ? `<div title="Assignment submitted" class="assignmentChip" style="color: #0bb75b"><i class="fluid-icon">assignment_turned_in</i></div>` : ""}
690 ${assignment.missing && !generic ? `<div title="Assignment is missing" class="assignmentChip" style="color: #c44848"><i class="fluid-icon">remove_circle_outline</i></div>` : ""}
691 ${assignment.late && !generic ? `<div title="Assignment is late" class="assignmentChip" style="color: #c44848"><i class="fluid-icon">assignment_late</i></div>` : ""}
692 ${assignment.locked && !generic ? `<div title="Assignment submissions are locked" class="assignmentChip" style="color: var(--secText, gray);"><i class="fluid-icon">lock_outline</i></div>` : ""}
693 ${(dtps.user.parent && !generic) ? `<div class="assignmentChip"><i class="fluid-icon">person</i><span>${dtps.user.children.find(c => c.id == dtps.classes[assignment.class].userID).name}</span></div>` : ""}
694 ${generic ? "" : scoreHTML}
695 </div>
696
j2566c4e2021-10-01 15:25:49 -0700697 ${assignment.error ? /*html*/`
698 <div>
699 <div class="alert error">
700 <div class="header">
701 <h5><i class="fluid-icon">error</i> Assignment Error</h5>
702 </div>
703
704 <p>${assignment.error}</p>
705 </div>
706 </div>
707 ` : ``}
708
j7940eec2020-12-28 14:00:41 -0600709 <div style="margin-top: 20px;" class="assignmentBody">
710 ${assignment.body ? assignmentBodyHTML : ""}
711 </div>
712
713 ${assignment.body ? `<div style="margin: 5px 0px; background-color: var(--darker); height: 1px; width: 100%;" class="divider"></div>` : ""}
714
715 <div style="width: calc(40% - 2px); margin-top: 20px; display: inline-block; overflow: hidden; vertical-align: top;">
716 ${assignment.publishedAt ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">add_box</i> Published: ${dtps.formatDate(assignment.publishedAt)}</p>` : ""}
717 ${assignment.dueAt ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">alarm</i> Due: ${dtps.formatDate(assignment.dueAt)}</p>` : ""}
718 ${assignment.value ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">bar_chart</i> Point value: ${assignment.value}</p>` : ""}
719 ${(assignment.grade || (assignment.grade == 0)) && !generic ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">assessment</i> Points earned: ${assignment.grade}</p>` : ""}
720 ${assignment.letter && !generic ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">font_download</i> Letter grade: ${assignment.letter}</p>` : ""}
721 ${assignment.category ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">category</i> Category: ${assignment.category}</p>` : ""}
722 ${assignment.rubric ? assignment.rubric.map(function (rubricItem) { return `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">adjust</i> ${rubricItem.title}</p>`; }).join("") : ""}
723 <p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">class</i> Class: ${dtps.classes[assignment.class].subject}</p>
724 ${dtps.env == "dev" ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="fluid-icon">code</i> Assignment ID: ${assignment.id}</p>` : ""}
725
726 <br />
727 <div class="row">
728 ${assignment.url ? `<button class="btn small outline" onclick="window.open('${assignment.url}')"><i class="fluid-icon">open_in_new</i> Open in ${dtpsLMS.shortName || dtpsLMS.name}</button>` : ``}
729 </div>
730 </div>
731
j5bcb1122021-05-25 12:53:21 -0700732 <div style="width: calc(60% - 10px); margin-top: 20px; margin-left: 5px; display: inline-block; overflow: hidden; vertical-align: middle;">
j7940eec2020-12-28 14:00:41 -0600733 ${!generic ? assignmentFeedbackHTML : ""}
734
735 ${assignmentRubricHTML}
736 </div>
737 `);
738
739 //Close other active cards and open the assignment details card
740 fluid.cards.close(".card.focus");
741 fluid.cards(".card.details");
742}
743
744/**
745 * Shows the module stream for a class
746 *
747 * @param {string} classID Class number to fetch modules for
748 */
749dtps.moduleStream = function (classID) {
750 //Get class index and set as selected class
751 var classNum = dtps.classes.map(course => course.id).indexOf(classID);
752 dtps.selectedClass = classNum;
753
754 //Set stream as the selected content
755 dtps.selectedContent = "moduleStream";
756 $("#dtpsTabBar .btn").removeClass("active");
757 $("#dtpsTabBar .btn.stream").addClass("active");
758
759 //Save coursework stream preference
760 window.localStorage.setItem("courseworkPref-" + classID, "moduleStream");
761
762 //Load class color, name, etc.
763 dtps.presentClass(classNum);
764
765 //Ensure classes are shown in the sidebar
766 dtps.showClasses();
767
768 if (classNum == -1) {
769 //Class does not exist
770 dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.moduleStream");
771 }
772
773 //Show loading indicator
774 if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "moduleStream")) {
775 jQuery(".classContent").html(dtps.renderStreamTools(classNum, "modules") + /*html*/`
776 <div class="module card collapsed">
777 <h4>
778 <i class="fluid-icon collapseIcon shimmer">star</i>
779 <span class="shimmer">[SHIMMER] Module title (collapsed)</span>
780 </h4>
781 <div class="moduleContents" style="padding-top: 10px;"></div>
782 </div>
783 <div class="module card">
784 <h4>
785 <i class="fluid-icon collapseIcon shimmer">star</i>
786 <span class="shimmer">[SHIMMER] Module title</span>
787 </h4>
788
789 <div class="moduleContents" style="padding-top: 10px;">
790 <div class="moduleItem shimmer">[SHMMER] module item</div>
791 <div class="moduleItem shimmer">[SHMMER] module item</div>
792 <div class="moduleItem shimmer">[SHMMER] module item</div>
793 <div class="moduleItem shimmer">[SHMMER] module item</div>
794 <div class="moduleItem shimmer">[SHMMER] module item</div>
795 </div>
796 </div>
797 `);
798 }
799
800 new Promise(resolve => {
801 if (dtps.classes[classNum].modules && (dtps.classes[classNum].modules !== true)) {
802 resolve(dtps.classes[classNum].modules);
803 } else {
804 dtpsLMS.fetchModules(dtps.user.id, dtps.classes[classNum].lmsID).then(data => resolve(data));
805 }
806 }).then(data => {
807 //Save modules data in the class object for future use
808 dtps.classes[classNum].modules = data;
809
810 var modulesHTML = dtps.renderStreamTools(classNum, "modules");
811 var allCollapsed = true;
812
813 data.forEach(module => {
814 var moduleItemHTML = "";
815 if (!module.collapsed) allCollapsed = false;
816
817 //Get HTML for each module item
818 module.items.forEach(item => {
819 //Get module item icon
820 var icon = "list";
821 if (item.type == "assignment") icon = "assignment";
822 if (item.type == "page") icon = "insert_drive_file";
823 if (item.type == "discussion") icon = "forum";
824 if (item.type == "url") icon = "open_in_new";
825 if (item.type == "header") icon = "format_size";
826 if (item.type == "embed") icon = "web";
827
828 //Get module action
829 var action = "";
830 if (item.type == "assignment") action = "dtps.assignment('" + item.id + "', " + classNum + ")";
831 if (item.type == "page") {
832 action = "fluid.screen('pages', '" + classID + "|" + item.id + "|true')";
833 }
834 if (item.type == "discussion") {
835 action = "fluid.screen('discussions', '" + classID + "|" + item.id + "|true')";
836 }
837 if (item.type == "url") action = "window.open('" + item.url + "')";
838 if (item.type == "header") action = "";
839 if (item.type == "embed") action = "dtps.showIFrameCard('" + item.url + "')";
840
841 //Get module HTML
842 if (item.type == "header") {
843 moduleItemHTML += `<h5 style="font-size: 16px;padding: 0px 10px; text-decoration: underline;">${item.title}</h5>`;
844 } else {
845 moduleItemHTML += `
846 <div class="moduleItem" onclick="${action}" style="margin-left: ${item.indent * 15}px;">
847 <i ${item.completed ? `style="color: #27ba3c"` : ""} class="fluid-icon">${item.completed ? "check" : icon}</i>
848 ${item.title}
849 </div>
850 `;
851 }
852 });
853
854 //Add HTML for this module to the string
855 modulesHTML += /*html*/`
856 <div class="module card ${module.collapsed ? "collapsed" : ""}">
857 <h4>
858 <i onclick="dtps.moduleCollapse(this, '${dtps.classes[classNum].id}', '${module.id}');"
859 class="fluid-icon collapseIcon">${module.collapsed ? "keyboard_arrow_right" : "keyboard_arrow_down"}</i>
860 ${module.title}
861 </h4>
862
863 <div class="moduleContents" style="padding-top: 10px;">
864 ${moduleItemHTML}
865 </div>
866 </div>
867 `;
868 });
869
870 if (data.length == 0) {
871 modulesHTML += /*html*/`
872 <div style="text-align: center;">
873 <div style="margin: 60px; padding: 20px 40px; display: inline-block; border: 2px solid var(--elements); border-radius: var(--elementRadius);">
874 <h5>No Modules</h5>
875 <p>There aren't any modules in this class yet.</p>
876 </div>
877 </div>
878 `;
879 }
880
881 //Render module HTML
882 if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "moduleStream")) {
883 $(".classContent").html(modulesHTML);
884 if (dtpsLMS.collapseAllModules) {
885 $("#moduleExpandCollapse").html(allCollapsed ? `<i class="fluid-icon">unfold_more</i> Expand all` : `<i class="fluid-icon">unfold_less</i> Collapse all`);
886 $("#moduleExpandCollapse").attr("onclick", allCollapsed ? `dtps.moduleCollapseAll(false)` : `dtps.moduleCollapseAll(true)`);
887 $("#moduleExpandCollapse").show();
888 }
889 }
890 }).catch(err => {
891 dtps.error("Could not load modules", "Caught promise rejection @ dtps.moduleStream", err);
892 });
893}
894
895/**
896 * Collapses a module
897 *
898 * @param {Element} ele Element of the module collapse arrow
899 * @param {string} classID Class ID
900 * @param {string} modID Module ID of the module to collapse
901 */
902dtps.moduleCollapse = function (ele, classID, modID) {
903 //Add collapsed class to module card
904 $(ele).parents('.card').toggleClass('collapsed');
905
906 //Update arrow icon and, if the LMS supports it, collapse the module in the LMS as well
907 if ($(ele).parents('.card').hasClass('collapsed')) {
908 if (dtpsLMS.collapseModule) dtpsLMS.collapseModule(classID, modID, true);
909 $(ele).html('keyboard_arrow_right');
910 dtps.classes[dtps.selectedClass].modules.find(m => m.id == modID).collapsed = true;
911 } else {
912 if (dtpsLMS.collapseModule) dtpsLMS.collapseModule(classID, modID, false);
913 $(ele).html('keyboard_arrow_down');
914 dtps.classes[dtps.selectedClass].modules.find(m => m.id == modID).collapsed = false;
915 }
j7940eec2020-12-28 14:00:41 -0600916}
917
918
919/**
920 * Collapses all module
921 *
922 * @param {boolean} collapse If true, modules will be collapsed, otherwise, they will all be expanded
923 */
924dtps.moduleCollapseAll = function (collapse) {
925 if (collapse && dtpsLMS.collapseAllModules) {
926 dtpsLMS.collapseAllModules(dtps.classes[dtps.selectedClass].lmsID, true);
927 $(".classContent .card.module h4 i").text("keyboard_arrow_right");
928 $(".classContent .module.card").addClass("collapsed");
929 dtps.classes[dtps.selectedClass].modules.forEach(m => m.collapsed = true);
930 $("#moduleExpandCollapse").html(`<i class="fluid-icon">unfold_more</i> Expand all`);
931 $("#moduleExpandCollapse").attr("onclick", `dtps.moduleCollapseAll(false)`);
932 } else if (dtpsLMS.collapseAllModules) {
933 dtpsLMS.collapseAllModules(dtps.classes[dtps.selectedClass].lmsID, false);
934 $(".classContent .card.module h4 i").text("keyboard_arrow_down");
935 $(".classContent .module.card").removeClass("collapsed");
936 dtps.classes[dtps.selectedClass].modules.forEach(m => m.collapsed = false);
937 $("#moduleExpandCollapse").html(`<i class="fluid-icon">unfold_less</i> Collapse all`);
938 $("#moduleExpandCollapse").attr("onclick", `dtps.moduleCollapseAll(true)`);
939 }
940}
941
942/**
943 * Gets stream tools HTML (search box, class info, and modules/assignment switcher)
944 *
945 * @param {number} num Class number
946 * @param {string} type Class content these tools are for (e.g. "stream")
947 * @return {string} Stream tools HTML
948 */
949dtps.renderStreamTools = function (num, type) {
950 var modulesSelector = dtps.classes[num].modules;
951 return /*html*/`
952 ${(type == "modules") || (type == "stream") ? /*html*/`
953 <div style="text-align: right;${modulesSelector ? "" : "margin-top: 20px;"}">
954 ${modulesSelector ? /*html*/`
955 ${(type == "modules") && dtpsLMS.collapseAllModules ? `<button id="moduleExpandCollapse" onclick="dtps.moduleCollapseAll()" style="margin-right:20px;display:none;" class="btn"></button>` : ""}
j0954c042020-12-28 15:20:33 -0600956 <div class="btns row small assignmentPicker" style="margin: 5px 20px 5px 0px !important;">
j7940eec2020-12-28 14:00:41 -0600957 <button class="btn ${type == "stream" ? "active" : ""}" onclick="fluid.screen('stream', dtps.classes[dtps.selectedClass].id);"><i class="fluid-icon">assignment</i>Assignments</button>
958 <button class="btn ${type == "modules" ? "active" : ""}" onclick="fluid.screen('moduleStream', dtps.classes[dtps.selectedClass].id);"><i class="fluid-icon">view_module</i>Modules</button>
959 </div>
960 ` : ``}
961
962 </div>` : ``
963 }
964 `;
965}
966
967/**
968 * Shows the generic gradebook
969 *
970 * @param {string} classID Class ID
971 */
972dtps.gradebook = function (classID) {
973 //Get class index and set as selected class
974 var classNum = dtps.classes.map(course => course.id).indexOf(classID);
975 dtps.selectedClass = classNum;
976
977 //Set stream as the selected content
978 dtps.selectedContent = "grades";
979 $("#dtpsTabBar .btn").removeClass("active");
980 $("#dtpsTabBar .btn.grades").addClass("active");
981
982 //Load class color, name, etc.
983 dtps.presentClass(classNum);
984
985 //Ensure classes are shown in the sidebar
986 dtps.showClasses();
987
988 if (classNum == -1) {
989 //Class does not exist
990 dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.gradebook");
991 }
992
993 //Show loading indicator
994 if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "grades")) {
995 jQuery(".classContent").html(`<div class="spinner"></div>`);
996 }
997
998 //Terminate function if the class doesn't have a letter grade or assignments
jb39e6d92021-01-30 20:34:04 -0800999 if (!(dtps.classes[classNum].letter || dtps.classes[classNum].grade) || !dtps.classes[classNum].assignments) {
j7940eec2020-12-28 14:00:41 -06001000 return;
1001 }
1002
1003 //Define variables for total points and zeros
1004 var zeros = 0;
1005 var totalPoints = 0;
1006 var earnedPoints = 0;
1007 var gradedAssignments = 0;
1008
1009 //Define variable for assignment HTML string
1010 var assignmentHTML = "";
1011
1012 //Calculate total points and zeros
1013 dtps.classes[classNum].assignments.forEach(assignment => {
1014 if (assignment.grade || (assignment.grade == 0)) {
1015 earnedPoints += assignment.grade;
1016 gradedAssignments++;
1017
1018 assignmentHTML += /*html*/`
jdc6ea0e2022-04-26 16:03:27 -07001019 <div onclick="dtps.assignment('${assignment.id}', ${classNum})" class="gradebookAssignment">
j7940eec2020-12-28 14:00:41 -06001020 <h5>
1021 ${assignment.title}
1022
1023 <div class="stats">
1024 ${assignment.letter ? `<div class="gradebookLetter">${assignment.letter}</div>` : ""}
jb39e6d92021-01-30 20:34:04 -08001025 <div class="gradebookScore">${Math.round(assignment.grade * 100) / 100}</div>
1026 <div class="gradebookValue">/${Math.round(assignment.value * 100) / 100}</div>
j7940eec2020-12-28 14:00:41 -06001027 <div class="gradebookPercentage">${Math.round((assignment.grade / assignment.value) * 100)}%</div>
1028 </div>
1029 </h5>
1030 </div>
1031 `;
1032 }
1033
1034 if (assignment.value) {
1035 totalPoints += assignment.value;
1036 }
1037
1038 if ((assignment.grade == 0) && assignment.value) {
1039 zeros++;
1040 }
1041 })
1042
1043 //Grade calculation summary
j0f3d7db2026-10-13 04:56:55 +00001044 var gradesSummary = /*html*/`
j7940eec2020-12-28 14:00:41 -06001045 <div style="--classColor: ${dtps.classes[classNum].color}" class="card">
1046 <h3 class="gradeTitle">
1047 Grade Summary
1048 <div class="classGradeCircle">
jb39e6d92021-01-30 20:34:04 -08001049 ${dtps.classes[classNum].grade ? `<div class="percentage">${dtps.classes[classNum].grade}%</div>` : ``}
1050 ${dtps.classes[classNum].letter ? `<div class="letter">${dtps.classes[classNum].letter}</div>` : ""}
j7940eec2020-12-28 14:00:41 -06001051 </div>
1052 </h3>
1053
1054 ${zeros ? /*html*/`
1055 <h5 style="color: #d63d3d;" class="gradeStat">
1056 Zeros
1057 <div style="color: #d63d3d;" class="numFont">${zeros}</div>
1058 </h5>
1059 ` : ``}
1060
1061 <div style="${dtps.gradebookExpanded ? "" : "display: none;"}" id="genericClassGradeMore">
1062 <br />
1063
j7940eec2020-12-28 14:00:41 -06001064 <h5 class="smallStat">
1065 Points
1066 <div class="numFont fraction">
jb39e6d92021-01-30 20:34:04 -08001067 <span class="earned">${Math.round(earnedPoints)}</span>
1068 <span class="total">/${Math.round(totalPoints)}</span>
j7940eec2020-12-28 14:00:41 -06001069 </div>
1070 </h5>
1071
1072 <h5 class="smallStat">
1073 Graded Assignments
1074 <div class="numFont">${gradedAssignments}</div>
1075 </h5>
1076 </div>
1077
1078 <br />
1079 <a onclick="$('#genericClassGradeMore').toggle(); if ($('#genericClassGradeMore').is(':visible')) {$(this).html('Show less'); dtps.gradebookExpanded = true;} else {$(this).html('Show more'); dtps.gradebookExpanded = false;}"
1080 style="color: var(--secText, gray); cursor: pointer; margin-right: 10px;">${dtps.gradebookExpanded ? "Show less" : "Show more"}</a>
1081 </div>
1082
1083 <br />
1084 `;
1085
1086
1087 //Render HTML
1088 if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "grades")) {
j0f3d7db2026-10-13 04:56:55 +00001089 $(".classContent").html(gradesSummary + assignmentHTML);
j7940eec2020-12-28 14:00:41 -06001090 }
1091}
1092
1093//Fluid UI screen definitions
1094fluid.externalScreens.dashboard = () => {
1095 dtps.mainStream();
1096}
1097
1098fluid.externalScreens.stream = (courseID) => {
1099 dtps.classStream(courseID);
1100}
1101
1102fluid.externalScreens.moduleStream = (courseID) => {
1103 dtps.moduleStream(courseID);
1104}
1105
1106fluid.externalScreens.gradebook = (courseID) => {
j0f3d7db2026-10-13 04:56:55 +00001107 dtps.gradebook(courseID);
j7940eec2020-12-28 14:00:41 -06001108}
1109
1110//Type definitions
1111
1112/**
1113* @typedef {Object} Assignment
1114* @description Defines assignments objects in DTPS
1115* @property {string} title Title of the assignment
1116* @property {string} [body] HTML of the assignment's body
1117* @property {string} id Assignment ID
1118* @property {number} class Automatically managed by DTPS. The class number that this assignment belongs to.
1119* @property {Date} [dueAt] Assignment due date
1120* @property {string} [url] Assignment URL
1121* @property {AssignmentFeedback[]} [feedback] Feedback / private comments for this assignment
1122* @property {User} [grader] Assignment grader
1123* @property {boolean} [turnedIn] True if the assignment is turned in
1124* @property {boolean} [late] True if the assignment is late
1125* @property {boolean} [missing] True if the assignment is missing
1126* @property {boolean} [locked] True if assignment submissions are locked
1127* @property {string} [category] Assignment category
1128* @property {Date} [publishedAt] Date for when the assignment was published
1129* @property {Date} [gradedAt] Date for when the assignment was graded
1130* @property {number} [grade] Points earned on this assignment
1131* @property {string} [letter] Letter grade on this assignment
1132* @property {number} [value] Total amount of points possible for this assignment
1133* @property {RubricItem[]} [rubric] Assignment rubric
j2566c4e2021-10-01 15:25:49 -07001134* @property {string} [error] If an error occures when processing this assignment, store an error message here to notify the user that some features/data may be unavailable
j7940eec2020-12-28 14:00:41 -06001135*/
1136
1137/**
1138* @typedef {Object} Module
1139* @description Defines module objects in DTPS
1140* @property {string} title Title of the module
1141* @property {string} id Module ID
1142* @property {boolean} [collapsed] True if the module is collapsed, false otherwise. undefined or null if this module does not support collapsing.
1143* @property {ModuleItem[]} items An array of items for this module.
1144*/
1145
1146/**
1147 * @typedef {Object} ModuleItem
1148 * @description Defines module items in DTPS
1149 * @property {string} type Either "assignment", "page", "discussion", "url", "embed", or "header".
1150 * @property {string} [title] Required for URL and header items, and can be used to override the title of assignment, page, and discussion items.
1151 * @property {string} [id] Required for assignment, page, and discussion items.
1152 * @property {string} [url] Required for URL and embed items. Required for discussion and page items if the class does not support the pages or discussions feature.
1153 * @property {number} [indent] Indent level
1154 * @property {boolean} [completed] True if the module item has been completed
1155 */
1156
1157/**
1158* @typedef {Object} Announcement
1159* @description Defines announcement objects in DTPS
1160* @property {string} title Title of the announcement
1161* @property {Date} postedAt Date when the announcement was posted
1162* @property {string} body Announcement content
1163* @property {string} url Announcement URL
1164*/
1165
1166/**
1167* @typedef {Object} AssignmentFeedback
1168* @description Defines assignment feedback objects in DTPS
1169* @property {string} comment Feedback comment
1170* @property {User} [author] Feedback author
1171*/
1172
1173/**
1174* @typedef {Object} RubricItem
1175* @description Defines rubric item objects in DTPS
1176* @property {string} title Title of the rubric item
1177* @property {string} id Rubric item ID (only needs to be unique to this assignment)
1178* @property {number} value Total amount of points possible
j7940eec2020-12-28 14:00:41 -06001179* @property {string} [description] Rubric item description
1180* @property {number} [score] Rubric assessment score in points
1181* @property {string} [scoreName] Rubric assessment score name
1182* @property {string} [color] Score color in a CSS color format
1183*/
1184
1185/**
1186 * @typedef {Object} DashboardItem
1187 * @description Defines dashboard items in DTPS
1188 * @property {string} name Dashbord item name
1189 * @property {string} id Unique dashboard item ID
1190 * @property {string} icon Dashboard item icon
1191 * @property {boolean} supportsCompactMode True if this dashboard item supports compact mode
1192 * @property {number} size The approximate size of this dashboard item relative to other dashboard items. Should be no less than 20.
1193 * @property {string} defaultSide The default side of this dashboard item. Either "right" or "left".
1194 * @property {boolean} compact True if the user has turned on compact mode for this item.
j1c53f822020-06-07 15:32:06 -07001195 */