blob: 45554219af5bc8522b9ebbab75b92288610ef826 [file] [log] [blame]
j1c53f822020-06-07 15:32:06 -07001<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>JSDoc: Source: assignments.js</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14</head>
15
16<body>
17
18<div id="main">
19
20 <h1 class="page-title">Source: assignments.js</h1>
21
22
23
24
25
26
27 <section>
28 <article>
29 <pre class="prettyprint source linenums"><code>/**
30 * @file DTPS assignment functions
31 * @author jottocraft
32 *
33 * @copyright Copyright (c) 2018-2020 jottocraft. All rights reserved.
34 * @license GPL-2.0-only
35 */
36
j1c53f822020-06-07 15:32:06 -070037/**
38 * Renders HTML for an assignment item in a list
39 *
40 * @param {Assignment} assignment The assignment object to render
j1c53f822020-06-07 15:32:06 -070041 * @return {string} Assignment HTML for use in a list
42 */
43dtps.renderAssignment = function (assignment) {
j1c53f822020-06-07 15:32:06 -070044 //Render points/letter score
j35a697e2020-07-24 20:28:00 -070045 var scoreHTML = dtps.renderAssignmentScore(assignment);
j1c53f822020-06-07 15:32:06 -070046
47 var HTML = /*html*/`
48 &lt;div
49 onclick="${`dtps.assignment('` + assignment.id + `', ` + assignment.class + `)`}"
50 class="card graded assignment"
51 style="${'--classColor: ' + dtps.classes[assignment.class].color}"
52 >
53
54 &lt;!-- Color bar for the dashboard -->
55 &lt;div class="colorBar">&lt;/div>
56
57 &lt;!-- Assignment title and points -->
58 &lt;h4>
59 ${assignment.title}
60
61 &lt;!-- Points display -->
j35a697e2020-07-24 20:28:00 -070062 ${scoreHTML ? `&lt;div class="points">${scoreHTML}&lt;/div>` : ``}
j1c53f822020-06-07 15:32:06 -070063 &lt;/h4>
64
65 &lt;h5 style="white-space: nowrap; overflow: hidden;">
66 &lt;!-- Assignment info -->
67 ${assignment.dueAt ? `&lt;div class="infoChip">&lt;i style="margin-top: -2px;" class="material-icons">alarm&lt;/i> Due ` + dtps.formatDate(assignment.dueAt) + `&lt;/div>` : ""}
68 ${assignment.outcomes ? `&lt;div class="infoChip weighted">&lt;i class="material-icons">adjust&lt;/i>` + assignment.outcomes.length + `&lt;/div>` : ""}
69 ${assignment.category ? `&lt;div class="infoChip weighted">&lt;i class="material-icons">category&lt;/i> ` + assignment.category + `&lt;/div>` : ""}
70
71 &lt;!-- Status icons -->
72 ${assignment.turnedIn ? `&lt;i title="Assignment submitted" class="material-icons statusIcon" style="color: #0bb75b;">assignment_turned_in&lt;/i>` : ``}
73 ${assignment.missing ? `&lt;i title="Assignment is missing" class="material-icons statusIcon" style="color: #c44848;">remove_circle_outline&lt;/i>` : ``}
74 ${assignment.late ? `&lt;i title="Assignment is late" class="material-icons statusIcon" style="color: #c44848;">assignment_late&lt;/i>` : ``}
75 ${assignment.locked ? `&lt;i title="Assignment submissions are locked" class="material-icons statusIcon" style="font-family: 'Material Icons Extended'; color: var(--secText, gray);">lock_outline&lt;/i>` : ``}
76 ${assignment.pending ? `&lt;i title="Grade is pending review" class="material-icons statusIcon" style="color: #b3b70b;">rate_review&lt;/i>` : ``}
77 &lt;/h5>
78 &lt;/div>
79 `;
80
81 return HTML;
82}
83
84/**
j35a697e2020-07-24 20:28:00 -070085* Renders HTML for an assignment score if the assignment is graded
86*
87* @param {Assignment} assignment The assignment object to render a score for
88* @return {string} Assignment score HTML
89*/
90dtps.renderAssignmentScore = function (assignment) {
91 var scoreHTML = "";
92
93 //Use rubric score over points score if possible
94 if (dtpsLMS.useRubricGrades &amp;&amp; assignment.rubric) {
95 var rubricHTML = [];
96
97 assignment.rubric.forEach(rubricItem => {
98 if (rubricItem.score) {
99 rubricHTML.push(/*html*/`
100 &lt;div title="${rubricItem.title}" style="color: ${rubricItem.color || "var(--text)"};">
101 ${rubricItem.score}
102 &lt;/div>
103 `);
104 }
105 });
106
107 if (rubricHTML.length) scoreHTML = `&lt;div class="dtpsRubricScore">${rubricHTML.join("")}&lt;/div>`;
108
109 } else if (!dtpsLMS.useRubricGrades &amp;&amp; (assignment.grade || (assignment.grade == 0))) {
110 scoreHTML = /*html*/`
111 &lt;div class="assignmentGrade">
112 &lt;div class="grade">${assignment.grade}&lt;/div>
113 &lt;div class="value">/${assignment.value}&lt;/div>
114 ${assignment.letter ? `&lt;div class="letter">${assignment.letter.replace("incomplete", `&lt;i class="material-icons">cancel&lt;/i>`).replace("complete", `&lt;i class="material-icons">done&lt;/i>`)}&lt;/div>` : ""}
115 &lt;div class="percentage">${Math.round((assignment.grade / assignment.value) * 100)}%&lt;/div>
116 &lt;/div>
117 `;
118 }
119
120 return scoreHTML;
121}
122
123/**
j1c53f822020-06-07 15:32:06 -0700124 * Renders the DTPS dashboard and calls dtps.renderCalendar, dtps.renderUpdates, and dtps.renderUpcoming
125 */
126dtps.masterStream = function () {
127 //Ensure classes are rendered in the sidebar
128 dtps.presentClass("dash");
129 dtps.showClasses();
130
j35a697e2020-07-24 20:28:00 -0700131 //Clear active state from all tabs
132 $("#dtpsTabBar .btn").removeClass("active");
133
j1c53f822020-06-07 15:32:06 -0700134 //Count amount of classes that are loaded
135 var ready = 0;
136 dtps.classes.forEach(course => {
137 if (course.assignments) ready++;
138 });
139
140 //Check if all classes are loaded
141 var doneLoading = ready == dtps.classes.length;
142
143 //Returns dashboard item container HTML for an item
144 function dashboardContainerHTML(dashboardItem) {
145 if (dashboardItem.id == "dtps.calendar") {
146 return $.fullCalendar !== undefined ? `&lt;div id="calendar" class="card" style="padding: 20px;">&lt;/div>` : "";
147 } else if (dashboardItem.id == "dtps.updates") {
148 return `&lt;div class="updatesStream recentlyGraded announcements">&lt;/div>`;
149 } else if (dashboardItem.id == "dtps.dueToday") {
150 return `&lt;div style="padding: 20px 0px;" class="dueToday">&lt;/div>`;
151 } else if (dashboardItem.id == "dtps.upcoming") {
152 return `&lt;div style="padding: 20px 0px;" class="assignmentStream">&lt;/div>`;
153 }
154 }
155
156 //Render HTML with loading placeholder
157 if (dtps.selectedClass == "dash") {
158 jQuery(".classContent").html(/*html*/`
159 &lt;div class="dash cal" style="width: 40%;display: inline-block; vertical-align: top;">
160 ${dtps.leftDashboard.map(dashboardItem => {
j35a697e2020-07-24 20:28:00 -0700161 return dashboardContainerHTML(dashboardItem);
162 }).join("")}
j1c53f822020-06-07 15:32:06 -0700163 &lt;/div>
164
165 &lt;div style="width: 59%; display: inline-block;" class="dash stream">
166 ${!doneLoading ? `&lt;div style="margin: 75px 25px 10px 75px;">&lt;div class="spinner">&lt;/div>&lt;/div>` : ""}
167 ${dtps.rightDashboard.map(dashboardItem => {
j35a697e2020-07-24 20:28:00 -0700168 return dashboardContainerHTML(dashboardItem);
169 }).join("")}
j1c53f822020-06-07 15:32:06 -0700170 &lt;/div>
171 `);
172 }
173
174 //Render updates stream
175 dtps.renderUpdates();
176
177 //Render upcoming assignments stream
178 dtps.renderUpcoming();
179
180 //Render calendar
181 dtps.calendar();
182
183 //Render due today
184 dtps.renderDueToday();
185}
186
187/**
188 * Compiles and displays due today / to-do stream
189 */
190dtps.renderDueToday = function () {
191 //Combine class stream arrays
192 var combinedStream = [];
193 if (dtps.classes) {
194 dtps.classes.forEach(course => {
195 if (course.assignments) {
196 //If course has assignments, add them to the combined stream array
197 course.assignments.forEach(assignment => {
198 //Only assignments that are due today
199 if (dtps.isToday(assignment.dueAt)) {
200 combinedStream.push(assignment);
201 }
202 })
203 }
204 })
205 }
206
207 //Sort combined stream by date
208 combinedStream.sort(function (a, b) {
209 var keyA = new Date(a.dueAt).getTime(),
210 keyB = new Date(b.dueAt).getTime();
211
212 // Compare the 2 dates
213 if (keyA > keyB) return 1;
214 if (keyA &lt; keyB) return -1;
215 return 0;
216 });
217
218 //Get due today stream HTML
219 var combinedHTML = combinedStream.map(assignment => {
220 return dtps.renderAssignment(assignment);
221 }).join("");
222
223 if (combinedStream.length == 0) {
224 //Nothing due today
225 combinedHTML = `&lt;p style="text-align: center;margin: 10px 25px 10px 75px; font-size: 18px;">&lt;i class="material-icons">done&lt;/i> Nothing due today&lt;/p>`;
226 } else {
227 //Add header
228 combinedHTML = /*html*/`
229 &lt;h5 style="text-align: center; margin: 10px 25px 10px 75px; font-weight: bold;">Due today&lt;/h5>
230 ` + combinedHTML;
231 }
232
233 if (dtps.selectedClass == "dash") {
234 jQuery(".classContent .dash .dueToday").html(combinedHTML);
235 }
236}
237
238/**
239 * Compiles and displays upcoming assignments stream
240 */
241dtps.renderUpcoming = function () {
242 //Combine class stream arrays
243 var combinedStream = [];
244 if (dtps.classes) {
245 dtps.classes.forEach(course => {
246 if (course.assignments) {
247 //If course has assignments, add them to the combined stream array
248 course.assignments.forEach(assignment => {
249 //Only include upcoming assignments that aren't due today
250 if ((new Date(assignment.dueAt) > new Date()) &amp;&amp; !dtps.isToday(assignment.dueAt)) {
251 combinedStream.push(assignment);
252 }
253 })
254 }
255 })
256 }
257
258 //Sort combined stream by date
259 combinedStream.sort(function (a, b) {
260 var keyA = new Date(a.dueAt).getTime(),
261 keyB = new Date(b.dueAt).getTime();
262
263 // Compare the 2 dates
264 if (keyA > keyB) return 1;
265 if (keyA &lt; keyB) return -1;
266 return 0;
267 });
268
269 //Render upcoming assignments stream
270 var combinedHTML = combinedStream.map(assignment => {
271 return dtps.renderAssignment(assignment);
272 }).join("");
273
274 //No upcoming assignments
275 if (combinedStream.length == 0) {
276 combinedHTML = "";
277 }
278
279 if (dtps.selectedClass == "dash") {
280 jQuery(".classContent .dash .assignmentStream").html(combinedHTML);
281 }
282}
283
284/**
285 * Renders updates stream (recently graded &amp; announcements)
j1c53f822020-06-07 15:32:06 -0700286 */
287dtps.renderUpdates = function () {
j35a697e2020-07-24 20:28:00 -0700288 //Get updates HTML
289 var updatesHTML = "";
290
291 dtps.updates.forEach(update => {
292 if (update.type == "announcement") {
293 updatesHTML += /*html*/`
294 &lt;div onclick="$(this).toggleClass('open');" style="cursor: pointer; padding: 20px; --classColor: ${dtps.classes[update.class].color};" class="announcement card">
295 &lt;div class="className">${dtps.classes[update.class].subject}&lt;/div>
296 ${update.body}
j1c53f822020-06-07 15:32:06 -0700297 &lt;/div>
j35a697e2020-07-24 20:28:00 -0700298 `;
299 } else if (update.type == "assignment") {
300 var scoreHTML = dtps.renderAssignmentScore(update);
301 updatesHTML += `
302 &lt;div onclick="dtps.assignment('${update.id}', ${update.class})" style="--classColor: ${dtps.classes[update.class].color};" class="card recentGrade">
303 &lt;h5>
304 ${update.title}
305
306 &lt;!-- Points display -->
307 ${scoreHTML ? `&lt;div class="points">${scoreHTML}&lt;/div>` : ``}
308 &lt;/h5>
309
310 &lt;p>Graded at ${dtps.formatDate(update.gradedAt)}&lt;/p>
311 &lt;/div>
312 `;
j1c53f822020-06-07 15:32:06 -0700313 }
j35a697e2020-07-24 20:28:00 -0700314 })
315
316 if (dtps.selectedClass == "dash") {
317 jQuery(".classContent .dash .updatesStream").html(updatesHTML);
318 }
j1c53f822020-06-07 15:32:06 -0700319}
320
321
322/**
323 * Compiles and displays the assignment calendar
324 */
325dtps.calendar = function () {
326 if (dtps.selectedClass == "dash") {
327 //Calendar events array
328 var calEvents = [];
329
330 //Add assignments from every class to calEvents array
331 dtps.classes.forEach((course, courseIndex) => {
332 if (course.assignments) {
333 //Class has assignments
334 course.assignments.forEach(assignment => {
335 calEvents.push({
336 title: assignment.title,
337 start: moment(new Date(assignment.dueAt)).toISOString(true),
338 allDay: false,
339 color: course.color,
340 classNum: courseIndex,
341 assignmentID: assignment.id
342 });
343 });
344 }
345 });
346
347 //Render calendar
348 if ($.fullCalendar !== undefined) {
349 $('#calendar').fullCalendar({
350 events: calEvents,
351 header: {
352 left: 'title',
353 right: 'prev,next'
354 },
355 eventClick: function (calEvent, jsEvent, view) {
356 dtps.assignment(calEvent.assignmentID, calEvent.classNum);
357 },
358 eventAfterAllRender: function () {
359 $(".fc-prev-button").html(`&lt;i class="material-icons">keyboard_arrow_left&lt;/i>`);
360 $(".fc-next-button").html(`&lt;i class="material-icons">keyboard_arrow_right&lt;/i>`);
361 }
362 });
363 }
364 $(".fc-prev-button").html(`&lt;i class="material-icons">keyboard_arrow_left&lt;/i>`);
365 $(".fc-next-button").html(`&lt;i class="material-icons">keyboard_arrow_right&lt;/i>`);
366
367 }
368}
369
370/**
371 * Shows the assignments stream for a class
372 *
373 * @param {string} classID The class ID to show assignments for
j35a697e2020-07-24 20:28:00 -0700374 * @param {Assignment[]} [searchResults] An array of assignemnts to render instead of course.assignments. Used for assignment search.
375 * @param {string} [searchText] Text to render in the search box. Used for assignment search.
j1c53f822020-06-07 15:32:06 -0700376 */
j35a697e2020-07-24 20:28:00 -0700377dtps.classStream = function (classID, searchResults, searchText) {
j1c53f822020-06-07 15:32:06 -0700378 //Get class index and set as selected class
379 var classNum = dtps.classes.map(course => course.id).indexOf(classID);
380 dtps.selectedClass = classNum;
381
382 //Set stream as the selected content
383 dtps.selectedContent = "stream";
384 $("#dtpsTabBar .btn").removeClass("active");
385 $("#dtpsTabBar .btn.stream").addClass("active");
386
387 //Load class color, name, etc.
388 dtps.presentClass(classNum);
389
390 //Ensure classes are shown in the sidebar
391 dtps.showClasses();
392
393 if (classNum == -1) {
394 //Class does not exist
395 dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.classStream");
396 }
397
j35a697e2020-07-24 20:28:00 -0700398 //Use search results to render or render all class assignments
399 var assignments = searchResults || dtps.classes[classNum].assignments;
400
j1c53f822020-06-07 15:32:06 -0700401 //Render assignments
j35a697e2020-07-24 20:28:00 -0700402 if (!assignments) {
j1c53f822020-06-07 15:32:06 -0700403 //Assignments are still loading
404 jQuery(".classContent").html(`&lt;div class="spinner">&lt;/div>`);
j35a697e2020-07-24 20:28:00 -0700405 } else if (assignments.length == 0) {
406 if (searchText) {
407 //No search results
408 $(".classContent").html(/*html*/`
409 &lt;div style="cursor: auto;" class="card assignment">
410 &lt;h4>No results&lt;/h4>
411 &lt;p>There weren't any search results&lt;/p>
412 &lt;button onclick="fluid.screen()" class="btn">&lt;i class="material-icons">arrow_back&lt;/i> Back&lt;/button>
413 &lt;/div>
414 `);
415 } else {
416 //This class doesn't have any assignments
417 $(".classContent").html(`&lt;div style="cursor: auto;" class="card assignment">&lt;h4>No assignments&lt;/h4>&lt;p>There aren't any assignments in this class yet&lt;/p>&lt;/div>`);
418 }
j1c53f822020-06-07 15:32:06 -0700419 } else {
420 //Sort assignments
j35a697e2020-07-24 20:28:00 -0700421 assignments.sort(function (a, b) {
j1c53f822020-06-07 15:32:06 -0700422 var keyA = new Date(a.dueAt).getTime(),
423 keyB = new Date(b.dueAt).getTime();
424
425 var now = new Date().getTime();
426
427 //Put assignments without a due date at the end
428 if (!a.dueAt) { keyA = 0; }
429 if (!b.dueAt) { keyB = 0; }
430
431 //Put upcoming assignments at the top
432 if ((keyA &lt; now) || (keyB &lt; now)) {
433 // Sort upcoming assignments from earliest -> latest
434 if (keyA &lt; keyB) return 1;
435 if (keyA > keyB) return -1;
436 return 0;
437 } else {
438 // Sort old assignments from latest -> earliest
439 if (keyA > keyB) return 1;
440 if (keyA &lt; keyB) return -1;
441 return 0;
442 }
443 });
444
445 //Render assignments
j35a697e2020-07-24 20:28:00 -0700446 var streamHTML = assignments.map(assignment => {
j1c53f822020-06-07 15:32:06 -0700447 return dtps.renderAssignment(assignment);
448 }).join("");
449
450 //Add stream header with class info buttons and search box
j35a697e2020-07-24 20:28:00 -0700451 streamHTML = dtps.renderClassTools(classNum, "stream", searchText) + streamHTML;
j1c53f822020-06-07 15:32:06 -0700452
453 $(".classContent").html(streamHTML);
454 }
455}
456
457/**
458 * Shows details for an assignment given the assignment ID and class number
459 *
460 * @param {string} id Assignment ID
461 * @param {number} classNum Assignment class number
j1c53f822020-06-07 15:32:06 -0700462 */
j35a697e2020-07-24 20:28:00 -0700463dtps.assignment = function (id, classNum) {
j1c53f822020-06-07 15:32:06 -0700464 //Get assignment from the id prop
465 var assignmentIDs = dtps.classes[classNum].assignments.map(assignment => assignment.id);
466 var assignment = dtps.classes[classNum].assignments[assignmentIDs.indexOf(id)];
467
j35a697e2020-07-24 20:28:00 -0700468 //The assignment body is rendered in an iFrame to keep its content and styling isolated from the rest of the page
469 var assignmentBodyURL = null;
470 if (assignment.body) {
471 //Get computed background and text color to style the iFrame with
472 var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
473 var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
j1c53f822020-06-07 15:32:06 -0700474
j35a697e2020-07-24 20:28:00 -0700475 //Generate a blob with the assignment body and get its data URL
476 var blob = new Blob([`
j1c53f822020-06-07 15:32:06 -0700477 &lt;base target="_blank" />
478 &lt;link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
479 &lt;style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};&lt;/style>
480 ${assignment.body}
481 `], { type: 'text/html' });
j35a697e2020-07-24 20:28:00 -0700482 assignmentBodyURL = window.URL.createObjectURL(blob);
483 }
j1c53f822020-06-07 15:32:06 -0700484
j35a697e2020-07-24 20:28:00 -0700485 //Get assignment rubric HTML
486 var assignmentRubricHTML = "";
487 if (assignment.rubric) {
488 var assignmentRubricHTML = assignment.rubric.map(function (rubricItem) {
489 return /*html*/`
j1c53f822020-06-07 15:32:06 -0700490 &lt;div class="dtpsAssignmentRubricItem">
491 &lt;h5>${rubricItem.title}&lt;/h5>
492 &lt;div class="score">
493 &lt;p style="color: ${rubricItem.color ? rubricItem.color : "var(--secText)"};" class="scoreName">
494 ${rubricItem.score ? rubricItem.scoreName || "" : "Not assessed"}
495
496 &lt;div class="points">
497 &lt;p class="earned">${rubricItem.score || ""}&lt;/p>
498 &lt;p class="possible">${"/" + rubricItem.value}&lt;/p>
499 &lt;/div>
500 &lt;/p>
501 &lt;/div>
502 &lt;/div>
503 `
j35a697e2020-07-24 20:28:00 -0700504 }).join("");
505 }
j1c53f822020-06-07 15:32:06 -0700506
j35a697e2020-07-24 20:28:00 -0700507 //Get assignment feedback HTML
508 var assignmentFeedbackHTML = "";
509 if (assignment.feedback) {
510 var assignmentFeedbackHTML = assignment.feedback.map(feedback => {
511 return /*html*/`
j1c53f822020-06-07 15:32:06 -0700512 &lt;div class="dtpsSubmissionComment">
513 ${feedback.author ? /*html*/`
514 &lt;img src="${feedback.author.photoURL}" />
515 &lt;h5>${feedback.author.name}&lt;/h5>
516 ` : ``}
517
518 &lt;p>${feedback.comment}&lt;/p>
519 &lt;/div>
520 `
j35a697e2020-07-24 20:28:00 -0700521 }).join("");
522 }
j1c53f822020-06-07 15:32:06 -0700523
j35a697e2020-07-24 20:28:00 -0700524 //Get assignment score HTML
525 var scoreHTML = dtps.renderAssignmentScore(assignment);
j1c53f822020-06-07 15:32:06 -0700526
j35a697e2020-07-24 20:28:00 -0700527 //Render assignment details
528 $(".card.details").html(/*html*/`
j1c53f822020-06-07 15:32:06 -0700529 &lt;i onclick="fluid.cards.close('.card.details'); $('.card.details').html('');" class="material-icons close">close&lt;/i>
530
531 &lt;h4 style="font-weight: bold;">${assignment.title}&lt;/h4>
532
533 &lt;div>
534 ${assignment.dueAt ? `&lt;div class="assignmentChip">&lt;i class="material-icons">alarm&lt;/i>&lt;span>Due ${dtps.formatDate(assignment.dueAt)}&lt;/span>&lt;/div>` : ""}
535 ${assignment.turnedIn ? `&lt;div title="Assignment submitted" class="assignmentChip" style="color: #0bb75b">&lt;i class="material-icons">assignment_turned_in&lt;/i>&lt;/div>` : ""}
536 ${assignment.missing ? `&lt;div title="Assignment is missing" class="assignmentChip" style="color: #c44848">&lt;i class="material-icons">remove_circle_outline&lt;/i>&lt;/div>` : ""}
537 ${assignment.late ? `&lt;div title="Assignment is late" class="assignmentChip" style="color: #c44848">&lt;i class="material-icons">assignment_late&lt;/i>&lt;/div>` : ""}
538 ${assignment.locked ? `&lt;div title="Assignment submissions are locked" class="assignmentChip" style="color: var(--secText, gray);">&lt;i style="font-family: 'Material Icons Extended';" class="material-icons">lock_outline&lt;/i>&lt;/div>` : ""}
539 ${scoreHTML}
540 &lt;/div>
541
542 &lt;div style="margin-top: 20px;" class="assignmentBody">
543 ${assignment.body ? `&lt;iframe id="assignmentIframe" onload="dtps.iframeLoad('assignmentIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${assignmentBodyURL}" />` : ""}
544 &lt;/div>
545
546 ${assignment.body ? `&lt;div style="margin: 5px 0px; background-color: var(--darker); height: 1px; width: 100%;" class="divider">&lt;/div>` : ""}
547
548 &lt;div style="width: calc(40% - 2px); margin-top: 20px; display: inline-block; overflow: hidden; vertical-align: top;">
549 ${assignment.publishedAt ? `&lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">add_box&lt;/i> Published: ${dtps.formatDate(assignment.publishedAt)}&lt;/p>` : ""}
550 ${assignment.dueAt ? `&lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">alarm&lt;/i> Due: ${dtps.formatDate(assignment.dueAt)}&lt;/p>` : ""}
551 ${assignment.value ? `&lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">bar_chart&lt;/i> Point value: ${assignment.value}&lt;/p>` : ""}
j35a697e2020-07-24 20:28:00 -0700552 ${(assignment.grade || (assignment.grade == 0)) ? `&lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">assessment&lt;/i> Points earned: ${assignment.grade}&lt;/p>` : ""}
j1c53f822020-06-07 15:32:06 -0700553 ${assignment.letter ? `&lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">font_download&lt;/i> Letter grade: ${assignment.letter}&lt;/p>` : ""}
554 ${assignment.category ? `&lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">category&lt;/i> Category: ${assignment.category}&lt;/p>` : ""}
555 ${assignment.rubric ? assignment.rubric.map(function (rubricItem) { return `&lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">adjust&lt;/i> ${rubricItem.title}&lt;/p>`; }).join("") : ""}
556 &lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">class&lt;/i> Class: ${dtps.classes[assignment.class].subject}&lt;/p>
557 &lt;p style="color: var(--secText); margin: 5px 0px;">&lt;i style="vertical-align: middle;" class="material-icons">bug_report&lt;/i> Assignment ID: ${assignment.id}&lt;/p>
558
559 &lt;br />
560 &lt;div class="row">
j1c53f822020-06-07 15:32:06 -0700561 &lt;div class="btn small outline" onclick="window.open('${assignment.url}')">&lt;i class="material-icons">open_in_new&lt;/i> Open in ${dtpsLMS.shortName || dtpsLMS.name}&lt;/div>
562 &lt;/div>
563 &lt;/div>
564
565 &lt;div style="width: calc(60% - 7px); margin-top: 20px; margin-left: 5px; display: inline-block; overflow: hidden; vertical-align: middle;">
566 ${assignmentFeedbackHTML}
567
568 ${assignmentRubricHTML}
569 &lt;/div>
570 `);
j1c53f822020-06-07 15:32:06 -0700571
572 //Close other active cards and open the assignment details card
573 fluid.cards.close(".card.focus");
574 fluid.modal(".card.details");
575}
576
577/**
578 * Searches the assignment stream for a keyword using Fuse.js
j1c53f822020-06-07 15:32:06 -0700579 */
580dtps.search = function () {
j35a697e2020-07-24 20:28:00 -0700581 if ($("input.search").val() == "") {
582 fluid.screen();
j1c53f822020-06-07 15:32:06 -0700583 } else {
j35a697e2020-07-24 20:28:00 -0700584 var input = $("input.search").val();
585 var search = new Fuse(dtps.classes[dtps.selectedClass].assignments, {
586 keys: ["title", "body"]
587 });
588 dtps.classStream(dtps.classes[dtps.selectedClass].id, search.search(input), input);
j1c53f822020-06-07 15:32:06 -0700589 }
590}
591
592/**
j35a697e2020-07-24 20:28:00 -0700593 * Shows the module stream for a class
j1c53f822020-06-07 15:32:06 -0700594 *
j35a697e2020-07-24 20:28:00 -0700595 * @param {string} classID Class number to fetch modules for
j1c53f822020-06-07 15:32:06 -0700596 */
j35a697e2020-07-24 20:28:00 -0700597dtps.moduleStream = function (classID) {
598 //Get class index and set as selected class
599 var classNum = dtps.classes.map(course => course.id).indexOf(classID);
600 dtps.selectedClass = classNum;
601
602 //Set stream as the selected content
j1c53f822020-06-07 15:32:06 -0700603 dtps.selectedContent = "moduleStream";
j35a697e2020-07-24 20:28:00 -0700604 $("#dtpsTabBar .btn").removeClass("active");
605 $("#dtpsTabBar .btn.stream").addClass("active");
606
607 //Load class color, name, etc.
608 dtps.presentClass(classNum);
609
610 //Ensure classes are shown in the sidebar
611 dtps.showClasses();
612
613 if (classNum == -1) {
614 //Class does not exist
615 dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.moduleStream");
616 }
617
618 //Show loading indicator
619 jQuery(".classContent").html(`&lt;div class="spinner">&lt;/div>`);
620
621 new Promise(resolve => {
622 if (dtps.classes[classNum].modules &amp;&amp; (dtps.classes[classNum].modules !== true)) {
623 resolve(dtps.classes[classNum].modules);
624 } else {
625 dtpsLMS.fetchModules(dtps.classes[classNum].id).then(data => resolve(data));
626 }
627 }).then(data => {
628 //Save modules data in the class object for future use
629 dtps.classes[classNum].modules = data;
630
631 var modulesHTML = dtps.renderClassTools(classNum, "modules");
632
633 data.forEach(module => {
634 var moduleItemHTML = "";
635
636 //Get HTML for each module item
637 module.items.forEach(item => {
638 //Get module item icon
639 var icon = "list";
640 if (item.type == "assignment") icon = "assignment";
641 if (item.type == "page") icon = "insert_drive_file";
642 if (item.type == "discussion") icon = "forum";
643 if (item.type == "url") icon = "open_in_new";
644 if (item.type == "header") icon = "format_size";
645 if (item.type == "embed") icon = "web";
646
647 //Get module action
648 var action = "";
649 if (item.type == "assignment") action = "dtps.assignment('" + item.id + "', " + classNum + ")";
650 if (item.type == "page") action = "fluid.screen('pages', '" + classID + "|" + item.id + "')";
651 if (item.type == "discussion") action = "fluid.screen('discussions', '" + classID + "|" + item.id + "')";
652 if (item.type == "url") action = "window.open('" + item.url + "')";
653 if (item.type == "header") action = "";
654 if (item.type == "embed") action = "dtps.showIFrameCard('" + item.url + "')";
655
656 //Get module HTML
657 if (item.type == "header") {
658 moduleItemHTML += `&lt;h5 style="font-size: 22px;padding: 2px 10px;">${item.title}&lt;/h5>`;
659 } else {
660 moduleItemHTML += `
661 &lt;div class="moduleItem" onclick="${action}" style="margin-left: ${item.indent * 15}px;">
662 &lt;i class="material-icons">${icon}&lt;/i>
663 ${item.title}
664 &lt;/div>
665 `;
j1c53f822020-06-07 15:32:06 -0700666 }
j35a697e2020-07-24 20:28:00 -0700667 });
668
669 //Add HTML for this module to the string
670 modulesHTML += /*html*/`
671 &lt;div class="module card ${module.collapsed ? "collapsed" : ""}">
672 &lt;h4>
673 &lt;i onclick="dtps.moduleCollapse(this, '${dtps.classes[classNum].id}', '${module.id}');"
674 class="material-icons collapseIcon">${module.collapsed ? "keyboard_arrow_right" : "keyboard_arrow_down"}&lt;/i>
675 ${module.title}
676 &lt;/h4>
677
678 &lt;div class="moduleContents" style="padding-top: 10px;">
679 ${moduleItemHTML}
680 &lt;/div>
681 &lt;/div>
682 `;
j1c53f822020-06-07 15:32:06 -0700683 });
j35a697e2020-07-24 20:28:00 -0700684
685 //Render module HTML
686 if ((dtps.selectedClass == classNum) &amp;&amp; (dtps.selectedContent == "moduleStream")) {
687 jQuery(".classContent").html(modulesHTML);
688 }
689 }).catch(err => {
690 dtps.error("Could not load modules", "Caught promise rejection @ dtps.moduleStream", err);
j1c53f822020-06-07 15:32:06 -0700691 });
692}
693
694/**
695 * Collapses a module
696 *
697 * @param {Element} ele Element of the module collapse arrow
698 * @param {string} classID Class ID
699 * @param {string} modID Module ID of the module to collapse
j1c53f822020-06-07 15:32:06 -0700700 */
701dtps.moduleCollapse = function (ele, classID, modID) {
j35a697e2020-07-24 20:28:00 -0700702 //Add collapsed class to module card
j1c53f822020-06-07 15:32:06 -0700703 $(ele).parents('.card').toggleClass('collapsed');
j35a697e2020-07-24 20:28:00 -0700704
705 //Update arrow icon and, if the LMS supports it, collapse the module in the LMS as well
j1c53f822020-06-07 15:32:06 -0700706 if ($(ele).parents('.card').hasClass('collapsed')) {
j35a697e2020-07-24 20:28:00 -0700707 if (dtpsLMS.collapseModule) dtpsLMS.collapseModule(classID, modID, true);
j1c53f822020-06-07 15:32:06 -0700708 $(ele).html('keyboard_arrow_right');
709 } else {
j35a697e2020-07-24 20:28:00 -0700710 if (dtpsLMS.collapseModule) dtpsLMS.collapseModule(classID, modID, false);
j1c53f822020-06-07 15:32:06 -0700711 $(ele).html('keyboard_arrow_down');
712 }
713
714}
715
716/**
717 * Gets stream tools HTML (search box, class info, and modules/assignment switcher)
718 *
719 * @param {number} num Class number
720 * @param {string} type Class content these tools are for (e.g. "stream")
j35a697e2020-07-24 20:28:00 -0700721 * @param {string} [searchText] Text to render in the search box for assignment search
j1c53f822020-06-07 15:32:06 -0700722 * @return {string} Stream tools HTML
723 */
j35a697e2020-07-24 20:28:00 -0700724dtps.renderClassTools = function (num, type, searchText) {
725 var modulesSelector = dtps.classes[num].modules;
j1c53f822020-06-07 15:32:06 -0700726 return /*html*/`
727 &lt;div style="position: absolute;display:inline-block;margin: ${modulesSelector ? "82px" : "38px 82px"};">
728
729 ${dtps.classes[num].teacher ? /*html*/`
730 &lt;div class="acrylicMaterial" style="border-radius: 20px; display: inline-block; margin-right: 5px;">
731 &lt;img src="${dtps.classes[num].teacher.photoURL}" style="width: 40px; height: 40px; border-radius: 50%;vertical-align: middle;">
732 &lt;div style="font-size: 16px;display: inline-block;vertical-align: middle;margin: 0px 10px;">${dtps.classes[num].teacher.name}&lt;/div>
733 &lt;/div>` : ``
734 }
735
736 &lt;div onclick="dtps.classInfo(${num})" class="acrylicMaterial" style="border-radius: 50%; height: 40px; width: 40px; text-align: center; display: inline-block; vertical-align: middle; cursor: pointer; margin-right: 3px;">
737 &lt;i style="line-height: 40px;" class="material-icons">info&lt;/i>
738 &lt;/div>
739
j35a697e2020-07-24 20:28:00 -0700740 ${dtps.classes[num].homepage ? /*html*/`
j1c53f822020-06-07 15:32:06 -0700741 &lt;div onclick="dtps.classHome(${num})" class="acrylicMaterial" style="border-radius: 50%; height: 40px; width: 40px; text-align: center; display: inline-block; vertical-align: middle; cursor: pointer;">
742 &lt;i style="line-height: 40px;" class="material-icons">home&lt;/i>
743 &lt;/div>` : ""
744 }
745
746 &lt;/div>
747
748 ${(type == "modules") || (type == "stream") ? /*html*/`
749 &lt;div style="text-align: right;${modulesSelector ? "" : "margin-top: 20px;"}">
750
j35a697e2020-07-24 20:28:00 -0700751 ${type == "stream" ? `&lt;i class="inputIcon material-icons">search&lt;/i>&lt;input ${searchText ? `value="${searchText}"` : ``} onchange="dtps.search()" class="search inputIcon filled shadow" placeholder="Search assignments" type="search" />` : ""}
j1c53f822020-06-07 15:32:06 -0700752
753 &lt;br />
754 ${modulesSelector ? /*html*/`
755 &lt;div class="btns row small acrylicMaterial assignmentPicker" style="margin: ${type == "stream" ? `20px 80px 20px 0px !important` : `63px 80px 20px 0px !important`};">
j35a697e2020-07-24 20:28:00 -0700756 &lt;button class="btn ${type == "stream" ? "active" : ""}" onclick="fluid.screen('stream', dtps.classes[dtps.selectedClass].id);">&lt;i class="material-icons">assignment&lt;/i>Assignments&lt;/button>
757 &lt;button class="btn ${type == "modules" ? "active" : ""}" onclick="fluid.screen('moduleStream', dtps.classes[dtps.selectedClass].id);">&lt;i class="material-icons">view_module&lt;/i>Modules&lt;/button>
j1c53f822020-06-07 15:32:06 -0700758 &lt;/div>
759 ` : ``}
760
761 &lt;/div>` : ``
762 }
763 `;
764}
765
766/**
767 * Displays class info &amp; syllabus card
768 *
769 * @param {number} num Class number to show info for
770 */
771dtps.classInfo = function (num) {
j35a697e2020-07-24 20:28:00 -0700772 //Get syllabus blob if the class has a syllabus
j1c53f822020-06-07 15:32:06 -0700773 if ((dtps.classes[num].syllabus !== "") &amp;&amp; dtps.classes[num].syllabus !== null) {
j35a697e2020-07-24 20:28:00 -0700774 //Get computed background and text color to style the iFrame with
775 var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
776 var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
777
778 //Generate a blob with the assignment body and get its data URL
779 var blob = new Blob([`
780 &lt;base target="_blank" />
781 &lt;link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
782 &lt;style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};&lt;/style>
783 ${dtps.classes[num].syllabus}
784 `], { type: 'text/html' });
785 var syllabusURL = window.URL.createObjectURL(blob);
j1c53f822020-06-07 15:32:06 -0700786 }
j35a697e2020-07-24 20:28:00 -0700787
788 //Show class info HTML
789 $(".card.details").html(/*html*/`
790 &lt;i onclick="fluid.cards.close('.card.details')" class="material-icons close">close&lt;/i>
791
792 &lt;h4 style="font-weight: bold;">${dtps.classes[num].name}&lt;/h4>
793 &lt;p style="color: var(--secText)">${dtps.classes[num].description || ""}&lt;/p>
794
795 &lt;div class="assignmentChip">&lt;i class="material-icons">group&lt;/i>&lt;span>${dtps.classes[num].numStudents} students&lt;/span>&lt;/div>
796 &lt;div class="assignmentChip">&lt;i class="material-icons">bug_report&lt;/i>&lt;span>Class ID: ${dtps.classes[num].id}&lt;/span>&lt;/div>
797
798 &lt;br />
799
800 &lt;div style="margin-top: 20px;" class="syllabusBody">
801 ${dtps.classes[num].syllabus ? `
802 &lt;iframe id="syllabusIframe" onload="dtps.iframeLoad('syllabusIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${syllabusURL}" />` : ""}
803 &lt;/div>
j1c53f822020-06-07 15:32:06 -0700804 `)
j35a697e2020-07-24 20:28:00 -0700805
806 //Show the class info card
j1c53f822020-06-07 15:32:06 -0700807 fluid.modal(".card.details")
808}
809
810/**
811 * Displays the class homepage
812 *
813 * @param {number} num Class number to show the homepage for
814 */
815dtps.classHome = function (num) {
816 //Render loading screen
817 $(".card.details").html(/*html*/`
818 &lt;i onclick="fluid.cards.close('.card.details')" class="material-icons close">close&lt;/i>
819 &lt;h4 style="font-weight: bold;">${dtps.classes[num].subject} Homepage&lt;/h4>
820
821 &lt;br />
822 &lt;p>Loading...&lt;/p>
823 `);
824
j35a697e2020-07-24 20:28:00 -0700825 //Fetch homepage from the LMS
826 dtpsLMS.fetchHomepage(dtps.classes[num].id).then(homepage => {
827 if (homepage) {
828 //Get computed background and text color to style the iFrame with
829 var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
830 var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
831
832 //Generate a blob with the assignment body and get its data URL
833 var blob = new Blob([`
834 &lt;base target="_blank" />
835 &lt;link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
836 &lt;style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};&lt;/style>
837 ${homepage}
838 `], { type: 'text/html' });
839 var homepageURL = window.URL.createObjectURL(blob);
840
841 $(".card.details").html(/*html*/`
842 &lt;i onclick="fluid.cards.close('.card.details')" class="material-icons close">close&lt;/i>
843
844 &lt;h4 style="font-weight: bold;">${dtps.classes[num].subject} Homepage&lt;/h4>
845
846 &lt;br />
847 &lt;div style="margin-top: 20px;" class="homepageBody">
848 &lt;iframe id="homepageIframe" onload="dtps.iframeLoad('homepageIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${homepageURL}" />
849 &lt;/div>
850 `);
851
852 fluid.modal(".card.details");
j1c53f822020-06-07 15:32:06 -0700853 } else {
j35a697e2020-07-24 20:28:00 -0700854 fluid.cards.close('.card.details');
855 dtps.error("Homepage unavailable", "homepage is either empty or undefined @ dtps.classHome");
856 }
857 }).catch(e => {
858 dtps.error("Couldn't load homepage", "Caught a promise rejection @ dtps.classHome", e);
859 })
860}
861
862/**
863 * Shows the generic gradebook
864 *
865 * @param {string} classID Class ID
866 */
867dtps.gradebook = function (classID) {
868 //Get class index and set as selected class
869 var classNum = dtps.classes.map(course => course.id).indexOf(classID);
870 dtps.selectedClass = classNum;
871
872 //Set stream as the selected content
873 dtps.selectedContent = "grades";
874 $("#dtpsTabBar .btn").removeClass("active");
875 $("#dtpsTabBar .btn.grades").addClass("active");
876
877 //Load class color, name, etc.
878 dtps.presentClass(classNum);
879
880 //Ensure classes are shown in the sidebar
881 dtps.showClasses();
882
883 if (classNum == -1) {
884 //Class does not exist
885 dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.gradebook");
886 }
887
888 //Show loading indicator
889 jQuery(".classContent").html(`&lt;div class="spinner">&lt;/div>`);
890
891 //Terminate function if the class doesn't have a letter grade or assignments
892 if (!dtps.classes[classNum].letter || !dtps.classes[classNum].assignments) {
893 return;
894 }
895
896 //Define variables for total points and zeros
897 var zeros = 0;
898 var totalPoints = 0;
899 var earnedPoints = 0;
900 var gradedAssignments = 0;
901
902 //Define variable for assignment HTML string
903 var assignmentHTML = "";
904
905 //Calculate total points and zeros
906 dtps.classes[classNum].assignments.forEach(assignment => {
907 if (assignment.grade || (assignment.grade == 0)) {
908 earnedPoints += assignment.grade;
909 gradedAssignments++;
910
911 assignmentHTML += /*html*/`
912 &lt;div onclick="dtps.assignment('${assignment.id}', ${classNum})" class="gradebookAssignment card">
913 &lt;h5>
914 ${assignment.title}
915
916 &lt;div class="stats">
917 ${assignment.letter ? `&lt;div class="gradebookLetter">${assignment.letter}&lt;/div>` : ""}
918 &lt;div class="gradebookScore">${assignment.grade}&lt;/div>
919 &lt;div class="gradebookValue">/${assignment.value}&lt;/div>
920 &lt;div class="gradebookPercentage">${Math.round((assignment.grade / assignment.value) * 100)}%&lt;/div>
921 &lt;/div>
922 &lt;/h5>
923 &lt;/div>
924 `;
925 }
926
927 if (assignment.value) {
928 totalPoints += assignment.value;
929 }
930
931 if ((assignment.grade == 0) &amp;&amp; assignment.value) {
932 zeros++;
j1c53f822020-06-07 15:32:06 -0700933 }
934 })
j35a697e2020-07-24 20:28:00 -0700935
936 //Grade calculation summary
937 var gradeCalcSummary = /*html*/`
938 &lt;div style="--classColor: ${dtps.classes[classNum].color}" class="card">
939 &lt;h3 class="gradeTitle">
940 Grade Summary
941 &lt;div class="classGradeCircle">
942 ${dtps.classes[classNum].grade ? `&lt;span class="percentage">${dtps.classes[classNum].grade}%&lt;/span>` : ``}
943 &lt;div class="letter">${dtps.classes[classNum].letter || ``}&lt;/div>
944 &lt;/div>
945 &lt;/h3>
946
947 ${zeros ? /*html*/`
948 &lt;h5 style="color: #d63d3d;" class="gradeStat">
949 Zeros
950 &lt;div style="color: #d63d3d;" class="numFont">${zeros}&lt;/div>
951 &lt;/h5>
952 ` : ``}
953
954 &lt;div style="${dtps.gradebookExpanded ? "" : "display: none;"}" id="classGradeMore">
955 &lt;br />
956
957 ${dtps.classes[classNum].previousLetter ? /*html*/`
958 &lt;h5 class="smallStat">
959 Previous Grade
960 &lt;div class="numFont">${dtps.classes[classNum].previousLetter}&lt;/div>
961 &lt;/h5>
962 ` : ``}
963
964 &lt;h5 class="smallStat">
965 Points
966 &lt;div class="numFont fraction">
967 &lt;span class="earned">${earnedPoints}&lt;/span>
968 &lt;span class="total">/${totalPoints}&lt;/span>
969 &lt;/div>
970 &lt;/h5>
971
972 &lt;h5 class="smallStat">
973 Graded Assignments
974 &lt;div class="numFont">${gradedAssignments}&lt;/div>
975 &lt;/h5>
976 &lt;/div>
977
978 &lt;br />
979 &lt;a onclick="$('#classGradeMore').toggle(); if ($('#classGradeMore').is(':visible')) {$(this).html('Show less'); dtps.gradebookExpanded = true;} else {$(this).html('Show more'); dtps.gradebookExpanded = false;}"
980 style="color: var(--secText, gray); cursor: pointer; margin-right: 10px;">${dtps.gradebookExpanded ? "Show less" : "Show more"}&lt;/a>
981 &lt;/div>
982
983 &lt;br />
984 `;
985
986
987 //Render HTML
988 $(".classContent").html(gradeCalcSummary + assignmentHTML);
j1c53f822020-06-07 15:32:06 -0700989}
990
991//Fluid UI screen definitions
992fluid.externalScreens.dashboard = () => {
993 dtps.masterStream();
994}
995
996fluid.externalScreens.stream = (courseID) => {
997 dtps.classStream(courseID);
998}
999
j35a697e2020-07-24 20:28:00 -07001000fluid.externalScreens.moduleStream = (courseID) => {
1001 dtps.moduleStream(courseID);
1002}
1003
1004fluid.externalScreens.gradebook = (courseID) => {
1005 dtps.gradebook(courseID);
1006}
1007
j1c53f822020-06-07 15:32:06 -07001008//Type definitions
1009
1010/**
1011* @typedef {Object} Assignment
1012* @description Defines assignments objects in DTPS
1013* @property {string} title Title of the assignment
1014* @property {string} [body] HTML of the assignment's body
1015* @property {string} id Assignment ID
1016* @property {Date} [dueAt] Assignment due date
1017* @property {string} url Assignment URL
1018* @property {AssignmentFeedback[]} [feedback] Feedback / private comments for this assignment
1019* @property {User} [grader] Assignment grader
1020* @property {boolean} [turnedIn] True if the assignment is turned in
1021* @property {boolean} [late] True if the assignment is late
1022* @property {boolean} [missing] True if the assignment is missing
1023* @property {boolean} [locked] True if assignment submissions are locked
1024* @property {string} [category] Assignment category
1025* @property {Date} [publishedAt] Date for when the assignment was published
1026* @property {Date} [gradedAt] Date for when the assignment was graded
1027* @property {number} [grade] Points earned on this assignment
1028* @property {string} [letter] Letter grade on this assignment
1029* @property {number} [value] Total amount of points possible for this assignment
1030* @property {RubricItem[]} [rubric] Assignment rubric
1031*/
1032
1033/**
j35a697e2020-07-24 20:28:00 -07001034* @typedef {Object} Module
1035* @description Defines module objects in DTPS
1036* @property {string} title Title of the module
1037* @property {string} id Module ID
1038* @property {boolean} [collapsed] True if the module is collapsed, false otherwise. undefined or null if this module does not support collapsing.
1039* @property {ModuleItem[]} items An array of items for this module.
1040*/
1041
1042/**
1043 * @typedef {Object} ModuleItem
1044 * @description Defines module items in DTPS
1045 * @property {string} type Either "assignment", "page", "discussion", "url", "embed", or "header".
1046 * @property {string} [title] Required for URL and header items, and can be used to override the title of assignment, page, and discussion items.
1047 * @property {string} [id] Required for assignment, page, and discussion items.
1048 * @property {string} [url] Required for URL and embed items.
1049 * @property {number} [indent] Indent level
1050 */
1051
1052/**
1053* @typedef {Object} Announcement
1054* @description Defines announcement objects in DTPS
1055* @property {string} title Title of the announcement
1056* @property {Date} postedAt Date when the announcement was posted
1057* @property {string} body Announcement content
1058*/
1059
1060/**
j1c53f822020-06-07 15:32:06 -07001061* @typedef {Object} AssignmentFeedback
1062* @description Defines assignment feedback objects in DTPS
1063* @property {string} comment Feedback comment
1064* @property {User} [author] Feedback author
1065*/
1066
1067/**
1068* @typedef {Object} RubricItem
1069* @description Defines rubric item objects in DTPS
1070* @property {string} title Title of the rubric item
1071* @property {string} id Rubric item ID (does NOT have to be unique)
1072* @property {number} value Total amount of points possible
1073* @property {string} [outcome] The ID of the outcome this rubric item is assessing. This is only used for grade calculation.
1074* @property {string} [description] Rubric item description
1075* @property {number} [score] Rubric assessment score in points
1076* @property {string} [scoreName] Rubric assessment score name
1077* @property {string} [scoreColor] Score color in CSS color format
1078*/
1079
1080/**
1081 * @typedef {Object} DashboardItem
1082 * @description Defines dashboard items in DTPS
1083 * @property {string} name Dashbord item name
1084 * @property {string} id Unique dashboard item ID
1085 * @property {string} icon Dashboard item icon
1086 * @property {boolean} supportsCompactMode True if this dashboard item supports compact mode
1087 * @property {number} size The approximate size of this dashboard item relative to other dashboard items. Should be no less than 20.
1088 * @property {string} defaultSide The default side of this dashboard item. Either "right" or "left".
1089 * @property {boolean} compact True if the user has turned on compact mode for this item.
1090 */</code></pre>
1091 </article>
1092 </section>
1093
1094
1095
1096
1097</div>
1098
1099<nav>
1100 <h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="dtps.html">dtps</a></li><li><a href="dtpsLMS.html">dtpsLMS</a></li></ul><h3><a href="global.html">Global</a></h3>
1101</nav>
1102
1103<br class="clear">
1104
1105<footer>
j35a697e2020-07-24 20:28:00 -07001106 Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Fri Jul 24 2020 19:25:37 GMT-0700 (Pacific Daylight Time)
j1c53f822020-06-07 15:32:06 -07001107</footer>
1108
1109<script> prettyPrint(); </script>
1110<script src="scripts/linenumber.js"> </script>
1111</body>
1112</html>