v3.0.0
diff --git a/docs/static/README.md b/docs/static/README.md
new file mode 100644
index 0000000..eb52c1a
--- /dev/null
+++ b/docs/static/README.md
@@ -0,0 +1 @@
+The source code for the Power+ docs website is hosted [here](https://github.com/jottocraft/dtps/tree/master/docs)
\ No newline at end of file
diff --git a/docs/static/jsdoc/assignments.js.html b/docs/static/jsdoc/assignments.js.html
index c56797f..4555421 100644
--- a/docs/static/jsdoc/assignments.js.html
+++ b/docs/static/jsdoc/assignments.js.html
@@ -34,34 +34,15 @@
* @license GPL-2.0-only
*/
-
/**
* Renders HTML for an assignment item in a list
*
* @param {Assignment} assignment The assignment object to render
- * @todo Add support for points/letter scores
* @return {string} Assignment HTML for use in a list
*/
dtps.renderAssignment = function (assignment) {
- var scoreHTML = "";
//Render points/letter score
-
- //Use rubric score over points score if possible
- if (assignment.rubric) {
- var rubricHTML = [];
-
- assignment.rubric.forEach(rubricItem => {
- if (rubricItem.score) {
- rubricHTML.push(/*html*/`
- <div title="${rubricItem.title}" style="color: ${rubricItem.color || "var(--text)"};">
- ${rubricItem.score}
- </div>
- `);
- }
- });
-
- scoreHTML = `<div class="dtpsRubricScore">${rubricHTML.join("")}</div>`;
- }
+ var scoreHTML = dtps.renderAssignmentScore(assignment);
var HTML = /*html*/`
<div
@@ -78,9 +59,7 @@
${assignment.title}
<!-- Points display -->
- <div class="points">
- ${scoreHTML}
- </div>
+ ${scoreHTML ? `<div class="points">${scoreHTML}</div>` : ``}
</h4>
<h5 style="white-space: nowrap; overflow: hidden;">
@@ -103,6 +82,45 @@
}
/**
+* Renders HTML for an assignment score if the assignment is graded
+*
+* @param {Assignment} assignment The assignment object to render a score for
+* @return {string} Assignment score HTML
+*/
+dtps.renderAssignmentScore = function (assignment) {
+ var scoreHTML = "";
+
+ //Use rubric score over points score if possible
+ if (dtpsLMS.useRubricGrades && assignment.rubric) {
+ var rubricHTML = [];
+
+ assignment.rubric.forEach(rubricItem => {
+ if (rubricItem.score) {
+ rubricHTML.push(/*html*/`
+ <div title="${rubricItem.title}" style="color: ${rubricItem.color || "var(--text)"};">
+ ${rubricItem.score}
+ </div>
+ `);
+ }
+ });
+
+ if (rubricHTML.length) scoreHTML = `<div class="dtpsRubricScore">${rubricHTML.join("")}</div>`;
+
+ } else if (!dtpsLMS.useRubricGrades && (assignment.grade || (assignment.grade == 0))) {
+ scoreHTML = /*html*/`
+ <div class="assignmentGrade">
+ <div class="grade">${assignment.grade}</div>
+ <div class="value">/${assignment.value}</div>
+ ${assignment.letter ? `<div class="letter">${assignment.letter.replace("incomplete", `<i class="material-icons">cancel</i>`).replace("complete", `<i class="material-icons">done</i>`)}</div>` : ""}
+ <div class="percentage">${Math.round((assignment.grade / assignment.value) * 100)}%</div>
+ </div>
+ `;
+ }
+
+ return scoreHTML;
+}
+
+/**
* Renders the DTPS dashboard and calls dtps.renderCalendar, dtps.renderUpdates, and dtps.renderUpcoming
*/
dtps.masterStream = function () {
@@ -110,6 +128,9 @@
dtps.presentClass("dash");
dtps.showClasses();
+ //Clear active state from all tabs
+ $("#dtpsTabBar .btn").removeClass("active");
+
//Count amount of classes that are loaded
var ready = 0;
dtps.classes.forEach(course => {
@@ -137,15 +158,15 @@
jQuery(".classContent").html(/*html*/`
<div class="dash cal" style="width: 40%;display: inline-block; vertical-align: top;">
${dtps.leftDashboard.map(dashboardItem => {
- return dashboardContainerHTML(dashboardItem);
- }).join("")}
+ return dashboardContainerHTML(dashboardItem);
+ }).join("")}
</div>
<div style="width: 59%; display: inline-block;" class="dash stream">
${!doneLoading ? `<div style="margin: 75px 25px 10px 75px;"><div class="spinner"></div></div>` : ""}
${dtps.rightDashboard.map(dashboardItem => {
- return dashboardContainerHTML(dashboardItem);
- }).join("")}
+ return dashboardContainerHTML(dashboardItem);
+ }).join("")}
</div>
`);
}
@@ -262,55 +283,39 @@
/**
* Renders updates stream (recently graded & announcements)
- *
- * @todo pending v3 support
*/
dtps.renderUpdates = function () {
- /*var context = [];
- for (var i = 0; i < dtps.classes.length; i++) {
- if (fluid.get("pref-hideClass" + dtps.classes[i].id) !== "true") {
- if (!context.length) { context.push("?context_codes[]=course_" + dtps.classes[i].id) } else { context.push("&context_codes[]=course_" + dtps.classes[i].id) }
- }
- }
- dtps.webReq("canvas", "/api/v1/announcements" + context.join(""), function (resp) {
- var ann = JSON.parse(resp);
- var updates = [];
- for (var i = 0; i < ann.length; i++) {
- var dtpsClass = null;
- for (var ii = 0; ii < dtps.classes.length; ii++) {
- if (dtps.classes[ii].id == ann[i].context_code.split("_")[1]) {
- dtpsClass = ii;
- }
- }
- updates.push({
- type: "announcement",
- date: ann[i].posted_at,
- dom: `<div onclick="$(this).toggleClass('open');" style="cursor: pointer; padding: 20px;" class="announcement card color ` + dtps.classes[dtpsClass].col + `">
- <div class="className">` + ann[i].title + `</div>` + ann[i].message + `
+ //Get updates HTML
+ var updatesHTML = "";
+
+ dtps.updates.forEach(update => {
+ if (update.type == "announcement") {
+ updatesHTML += /*html*/`
+ <div onclick="$(this).toggleClass('open');" style="cursor: pointer; padding: 20px; --classColor: ${dtps.classes[update.class].color};" class="announcement card">
+ <div class="className">${dtps.classes[update.class].subject}</div>
+ ${update.body}
</div>
- `
- });
+ `;
+ } else if (update.type == "assignment") {
+ var scoreHTML = dtps.renderAssignmentScore(update);
+ updatesHTML += `
+ <div onclick="dtps.assignment('${update.id}', ${update.class})" style="--classColor: ${dtps.classes[update.class].color};" class="card recentGrade">
+ <h5>
+ ${update.title}
+
+ <!-- Points display -->
+ ${scoreHTML ? `<div class="points">${scoreHTML}</div>` : ``}
+ </h5>
+
+ <p>Graded at ${dtps.formatDate(update.gradedAt)}</p>
+ </div>
+ `;
}
- if (dtps.recentlyGraded) {
- dtps.recentlyGraded.forEach(grade => {
- updates.push({
- type: "grade",
- date: grade.date,
- dom: `<div onclick="dtps.assignment('` + grade.id + `', '` + grade.class + `')" class="card ` + dtps.classes[grade.class].col + ` recentGrade">
- <div style="float: right; margin-left: 10px;" class="earned outcomes">` + dtps.renderOutcomeScore(grade.rubric).join("") + `</div>
- <h5>` + grade.name + `</h5>
- <p>Graded at ` + (new Date(grade.date).toDateString().slice(0, -5) + ", " + dtps.ampm(new Date(grade.date))) + `</p>
- </div>`
- })
- })
- }
- updates.sort((a, b) => {
- return new Date(b.date) - new Date(a.date);
- })
- if ((dtps.selectedClass == "dash") && (dtps.masterContent == "assignments")) {
- jQuery(".dash .updatesStream").html(updates.map(update => update.dom).join(""));
- }
- });*/
+ })
+
+ if (dtps.selectedClass == "dash") {
+ jQuery(".classContent .dash .updatesStream").html(updatesHTML);
+ }
}
@@ -366,8 +371,10 @@
* Shows the assignments stream for a class
*
* @param {string} classID The class ID to show assignments for
+ * @param {Assignment[]} [searchResults] An array of assignemnts to render instead of course.assignments. Used for assignment search.
+ * @param {string} [searchText] Text to render in the search box. Used for assignment search.
*/
-dtps.classStream = function (classID) {
+dtps.classStream = function (classID, searchResults, searchText) {
//Get class index and set as selected class
var classNum = dtps.classes.map(course => course.id).indexOf(classID);
dtps.selectedClass = classNum;
@@ -388,16 +395,30 @@
dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.classStream");
}
+ //Use search results to render or render all class assignments
+ var assignments = searchResults || dtps.classes[classNum].assignments;
+
//Render assignments
- if (!dtps.classes[dtps.selectedClass].assignments) {
+ if (!assignments) {
//Assignments are still loading
jQuery(".classContent").html(`<div class="spinner"></div>`);
- } else if (dtps.classes[dtps.selectedClass].assignments.length == 0) {
- //This class doesn't have any assignments
- $(".classContent").html(`<div style="cursor: auto;" class="card assignment"><h4>No assignments</h4><p>There aren't any assignments in this class yet</p></div>`);
+ } else if (assignments.length == 0) {
+ if (searchText) {
+ //No search results
+ $(".classContent").html(/*html*/`
+ <div style="cursor: auto;" class="card assignment">
+ <h4>No results</h4>
+ <p>There weren't any search results</p>
+ <button onclick="fluid.screen()" class="btn"><i class="material-icons">arrow_back</i> Back</button>
+ </div>
+ `);
+ } else {
+ //This class doesn't have any assignments
+ $(".classContent").html(`<div style="cursor: auto;" class="card assignment"><h4>No assignments</h4><p>There aren't any assignments in this class yet</p></div>`);
+ }
} else {
//Sort assignments
- dtps.classes[dtps.selectedClass].assignments.sort(function (a, b) {
+ assignments.sort(function (a, b) {
var keyA = new Date(a.dueAt).getTime(),
keyB = new Date(b.dueAt).getTime();
@@ -422,12 +443,12 @@
});
//Render assignments
- var streamHTML = dtps.classes[dtps.selectedClass].assignments.map(assignment => {
+ var streamHTML = assignments.map(assignment => {
return dtps.renderAssignment(assignment);
}).join("");
//Add stream header with class info buttons and search box
- streamHTML = dtps.renderClassTools(classNum, "stream") + streamHTML;
+ streamHTML = dtps.renderClassTools(classNum, "stream", searchText) + streamHTML;
$(".classContent").html(streamHTML);
}
@@ -438,48 +459,34 @@
*
* @param {string} id Assignment ID
* @param {number} classNum Assignment class number
- * @param {boolean} [submissions] If true, assignment submissions will be shown
- * @todo Support numerical grades
*/
-dtps.assignment = function (id, classNum, submissions) {
+dtps.assignment = function (id, classNum) {
//Get assignment from the id prop
var assignmentIDs = dtps.classes[classNum].assignments.map(assignment => assignment.id);
var assignment = dtps.classes[classNum].assignments[assignmentIDs.indexOf(id)];
- if (submissions) {
- //Render assignment submissions
- $(".card.details").css("background-color", "white");
- $(".card.details").css("color", "black")
- $(".card.details").html(`<i style="color: black !important;" onclick="fluid.cards.close('.card.details')" class="material-icons close">close</i>
- <i style="left: 0; right: auto; color: black !important;" onclick="dtps.assignment(` + id + `, ` + classNum + `)" class="material-icons close">arrow_back</i>
- <br /><br />
- <iframe style="width: 100%; height: calc(100vh - 175px); border: none;" src="` + assignment.submissions + `"></iframe>
- `);
- } else {
- //Render assignment
+ //The assignment body is rendered in an iFrame to keep its content and styling isolated from the rest of the page
+ var assignmentBodyURL = null;
+ if (assignment.body) {
+ //Get computed background and text color to style the iFrame with
+ var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
+ var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
- //The assignment body is rendered in an iFrame to keep its content and styling isolated from the rest of the page
- var assignmentBodyURL = null;
- if (assignment.body) {
- //Get computed background and text color to style the iFrame with
- var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
- var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
-
- //Generate a blob with the assignment body and get its data URL
- var blob = new Blob([`
+ //Generate a blob with the assignment body and get its data URL
+ var blob = new Blob([`
<base target="_blank" />
<link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
<style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};</style>
${assignment.body}
`], { type: 'text/html' });
- assignmentBodyURL = window.URL.createObjectURL(blob);
- }
+ assignmentBodyURL = window.URL.createObjectURL(blob);
+ }
- //Get assignment rubric HTML
- var assignmentRubricHTML = "";
- if (assignment.rubric) {
- var assignmentRubricHTML = assignment.rubric.map(function (rubricItem) {
- return /*html*/`
+ //Get assignment rubric HTML
+ var assignmentRubricHTML = "";
+ if (assignment.rubric) {
+ var assignmentRubricHTML = assignment.rubric.map(function (rubricItem) {
+ return /*html*/`
<div class="dtpsAssignmentRubricItem">
<h5>${rubricItem.title}</h5>
<div class="score">
@@ -494,14 +501,14 @@
</div>
</div>
`
- }).join("");
- }
+ }).join("");
+ }
- //Get assignment feedback HTML
- var assignmentFeedbackHTML = "";
- if (assignment.feedback) {
- var assignmentFeedbackHTML = assignment.feedback.map(feedback => {
- return /*html*/`
+ //Get assignment feedback HTML
+ var assignmentFeedbackHTML = "";
+ if (assignment.feedback) {
+ var assignmentFeedbackHTML = assignment.feedback.map(feedback => {
+ return /*html*/`
<div class="dtpsSubmissionComment">
${feedback.author ? /*html*/`
<img src="${feedback.author.photoURL}" />
@@ -511,32 +518,14 @@
<p>${feedback.comment}</p>
</div>
`
- }).join("");
- }
+ }).join("");
+ }
- //Get assignment score HTML
- var scoreHTML = "";
+ //Get assignment score HTML
+ var scoreHTML = dtps.renderAssignmentScore(assignment);
- //Use rubric score over points score if possible
- if (assignment.rubric) {
- var rubricHTML = [];
-
- //Loop over every rubric item to get HTML for each
- assignment.rubric.forEach(rubricItem => {
- if (rubricItem.score) {
- rubricHTML.push(/*html*/`
- <div class="assignmentChip" title="${rubricItem.title}" style="color: ${rubricItem.color || "var(--text)"}; font-weight: bold;">
- ${rubricItem.score}
- </div>
- `);
- }
- });
-
- scoreHTML = rubricHTML.join("");
- }
-
- //Render assignment details
- $(".card.details").html(/*html*/`
+ //Render assignment details
+ $(".card.details").html(/*html*/`
<i onclick="fluid.cards.close('.card.details'); $('.card.details').html('');" class="material-icons close">close</i>
<h4 style="font-weight: bold;">${assignment.title}</h4>
@@ -560,7 +549,7 @@
${assignment.publishedAt ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">add_box</i> Published: ${dtps.formatDate(assignment.publishedAt)}</p>` : ""}
${assignment.dueAt ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">alarm</i> Due: ${dtps.formatDate(assignment.dueAt)}</p>` : ""}
${assignment.value ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">bar_chart</i> Point value: ${assignment.value}</p>` : ""}
- ${assignment.grade ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">assessment</i> Points earned: ${assignment.grade}</p>` : ""}
+ ${(assignment.grade || (assignment.grade == 0)) ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">assessment</i> Points earned: ${assignment.grade}</p>` : ""}
${assignment.letter ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">font_download</i> Letter grade: ${assignment.letter}</p>` : ""}
${assignment.category ? `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">category</i> Category: ${assignment.category}</p>` : ""}
${assignment.rubric ? assignment.rubric.map(function (rubricItem) { return `<p style="color: var(--secText); margin: 5px 0px;"><i style="vertical-align: middle;" class="material-icons">adjust</i> ${rubricItem.title}</p>`; }).join("") : ""}
@@ -569,7 +558,6 @@
<br />
<div class="row">
- <div class="btn small outline" onclick="dtps.assignment('${assignment.id}', ${classNum}, true)"><i class="material-icons">assignment</i> Submissions</div>
<div class="btn small outline" onclick="window.open('${assignment.url}')"><i class="material-icons">open_in_new</i> Open in ${dtpsLMS.shortName || dtpsLMS.name}</div>
</div>
</div>
@@ -580,7 +568,6 @@
${assignmentRubricHTML}
</div>
`);
- }
//Close other active cards and open the assignment details card
fluid.cards.close(".card.focus");
@@ -589,82 +576,118 @@
/**
* Searches the assignment stream for a keyword using Fuse.js
- *
- * @todo pending v3 support
*/
dtps.search = function () {
- alert("This feature has not been implemented yet");
- throw "DTPS v3 IMPLEMENTATION ERR";
- if (dtps.selectedClass == "dash") {
- if ($("input.search").val() == "") {
- jQuery(".classContent .stream").html(dtps.renderStream(dtps.latestStream, ""))
- } else {
- jQuery(".classContent .stream").html(dtps.renderStream(dtps.fuse.search($("input.search").val()), $("input.search").val()))
- }
- $(".card.assignment").addClass("color");
+ if ($("input.search").val() == "") {
+ fluid.screen();
} else {
- if ($("input.search").val() == "") {
- jQuery(".classContent").html(dtps.renderStream(dtps.latestStream, ""))
- } else {
- jQuery(".classContent").html(dtps.renderStream(dtps.fuse.search($("input.search").val()), $("input.search").val()))
- }
+ var input = $("input.search").val();
+ var search = new Fuse(dtps.classes[dtps.selectedClass].assignments, {
+ keys: ["title", "body"]
+ });
+ dtps.classStream(dtps.classes[dtps.selectedClass].id, search.search(input), input);
}
}
/**
- * Fetches module stream for a class
+ * Shows the module stream for a class
*
- * @param {number} num Class number to fetch modules for
- * @todo pending v3 support
+ * @param {string} classID Class number to fetch modules for
*/
-dtps.moduleStream = function (num) {
- alert("This feature has not been implemented yet");
- throw "DTPS v3 IMPLEMENTATION ERR";
+dtps.moduleStream = function (classID) {
+ //Get class index and set as selected class
+ var classNum = dtps.classes.map(course => course.id).indexOf(classID);
+ dtps.selectedClass = classNum;
+
+ //Set stream as the selected content
dtps.selectedContent = "moduleStream";
- var moduleRootHTML = dtps.renderClassTools(num, false, true);
- if (dtps.selectedContent == "moduleStream") jQuery(".classContent").html(moduleRootHTML + `<div class="spinner"></div>`);
- streamData = [];
- dtps.webReq("canvas", "/api/v1/courses/" + dtps.classes[num].id + "/modules?include[]=items&include[]=content_details", function (resp) {
- dtps.webReq("canvas", "/courses/" + dtps.classes[num].id + "/modules/progressions", function (progResp) {
- var data = JSON.parse(resp);
- var progData = JSON.parse(progResp);
- var collapsed = {};
- for (var i = 0; i < progData.length; i++) {
- collapsed[progData[i].context_module_progression.context_module_id] = progData[i].context_module_progression.collapsed;
- }
- for (var i = 0; i < data.length; i++) {
- var subsetData = [];
- for (var ii = 0; ii < data[i].items.length; ii++) {
- var icon = "star_border";
- if (data[i].items[ii].type == "ExternalTool") icon = "insert_link";
- if (data[i].items[ii].type == "ExternalUrl") icon = "open_in_new";
- if (data[i].items[ii].type == "Assignment") icon = "assignment";
- if (data[i].items[ii].type == "Page") icon = "insert_drive_file";
- if (data[i].items[ii].type == "Discussion") icon = "forum";
- if (data[i].items[ii].type == "Quiz") icon = "assessment";
- if (data[i].items[ii].type == "SubHeader") icon = "format_size";
- var open = `window.open('` + data[i].items[ii].html_url + `')`;
- if (data[i].items[ii].type == "ExternalTool") open = `$('#moduleIFrame').attr('src', ''); fluid.cards('.card.moduleURL'); $.getJSON('` + data[i].items[ii].url + `', function (data) { $('#moduleIFrame').attr('src', data.url); });`
- if (data[i].items[ii].type == "Assignment") open = `dtps.assignment(` + data[i].items[ii].content_id + `, dtps.selectedClass);`
- if (data[i].items[ii].type == "Page") open = `dtps.getPage(dtps.classes[dtps.selectedClass].id, '` + data[i].items[ii].page_url + `', true)`
- if (data[i].items[ii].type == "SubHeader") {
- subsetData.push(`<h5 style="font-size: 22px;padding: 2px 10px;">` + data[i].items[ii].title + `</h5>`);
- } else {
- subsetData.push(`<div onclick="` + open + `" style="color: var(--lightText); padding:10px;font-size:17px;border-radius:15px;margin:5px 0;margin-left: ` + (data[i].items[ii].indent * 15) + `px; cursor: pointer;">
-<i class="material-icons" style="vertical-align: middle; margin-right: 10px;">` + icon + `</i>` + data[i].items[ii].title + `</div>`);
- }
+ $("#dtpsTabBar .btn").removeClass("active");
+ $("#dtpsTabBar .btn.stream").addClass("active");
+
+ //Load class color, name, etc.
+ dtps.presentClass(classNum);
+
+ //Ensure classes are shown in the sidebar
+ dtps.showClasses();
+
+ if (classNum == -1) {
+ //Class does not exist
+ dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.moduleStream");
+ }
+
+ //Show loading indicator
+ jQuery(".classContent").html(`<div class="spinner"></div>`);
+
+ new Promise(resolve => {
+ if (dtps.classes[classNum].modules && (dtps.classes[classNum].modules !== true)) {
+ resolve(dtps.classes[classNum].modules);
+ } else {
+ dtpsLMS.fetchModules(dtps.classes[classNum].id).then(data => resolve(data));
+ }
+ }).then(data => {
+ //Save modules data in the class object for future use
+ dtps.classes[classNum].modules = data;
+
+ var modulesHTML = dtps.renderClassTools(classNum, "modules");
+
+ data.forEach(module => {
+ var moduleItemHTML = "";
+
+ //Get HTML for each module item
+ module.items.forEach(item => {
+ //Get module item icon
+ var icon = "list";
+ if (item.type == "assignment") icon = "assignment";
+ if (item.type == "page") icon = "insert_drive_file";
+ if (item.type == "discussion") icon = "forum";
+ if (item.type == "url") icon = "open_in_new";
+ if (item.type == "header") icon = "format_size";
+ if (item.type == "embed") icon = "web";
+
+ //Get module action
+ var action = "";
+ if (item.type == "assignment") action = "dtps.assignment('" + item.id + "', " + classNum + ")";
+ if (item.type == "page") action = "fluid.screen('pages', '" + classID + "|" + item.id + "')";
+ if (item.type == "discussion") action = "fluid.screen('discussions', '" + classID + "|" + item.id + "')";
+ if (item.type == "url") action = "window.open('" + item.url + "')";
+ if (item.type == "header") action = "";
+ if (item.type == "embed") action = "dtps.showIFrameCard('" + item.url + "')";
+
+ //Get module HTML
+ if (item.type == "header") {
+ moduleItemHTML += `<h5 style="font-size: 22px;padding: 2px 10px;">${item.title}</h5>`;
+ } else {
+ moduleItemHTML += `
+ <div class="moduleItem" onclick="${action}" style="margin-left: ${item.indent * 15}px;">
+ <i class="material-icons">${icon}</i>
+ ${item.title}
+ </div>
+ `;
}
- streamData.push(`<div class="card ` + (collapsed[data[i].id] ? "collapsed" : "") + `">
-<h4 style="margin: 5px 2px; font-size: 32px; font-weight: bold;">
-<i onclick="dtps.moduleCollapse(this, '` + dtps.classes[num].id + `', '` + data[i].id + `');" style="cursor: pointer; vertical-align: middle; color:var(--lightText);" class="material-icons collapseIcon">` + (collapsed[data[i].id] ? "keyboard_arrow_right" : "keyboard_arrow_down") + `</i>
-` + data[i].name + `</h4>
-<div class="moduleContents" style="padding-top: 10px;">
-` + subsetData.join("") + `
-</div>
-</div>`)
- }
- if (dtps.selectedContent == "moduleStream") jQuery(".classContent").html(moduleRootHTML + streamData.join(""));
+ });
+
+ //Add HTML for this module to the string
+ modulesHTML += /*html*/`
+ <div class="module card ${module.collapsed ? "collapsed" : ""}">
+ <h4>
+ <i onclick="dtps.moduleCollapse(this, '${dtps.classes[classNum].id}', '${module.id}');"
+ class="material-icons collapseIcon">${module.collapsed ? "keyboard_arrow_right" : "keyboard_arrow_down"}</i>
+ ${module.title}
+ </h4>
+
+ <div class="moduleContents" style="padding-top: 10px;">
+ ${moduleItemHTML}
+ </div>
+ </div>
+ `;
});
+
+ //Render module HTML
+ if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "moduleStream")) {
+ jQuery(".classContent").html(modulesHTML);
+ }
+ }).catch(err => {
+ dtps.error("Could not load modules", "Caught promise rejection @ dtps.moduleStream", err);
});
}
@@ -674,17 +697,17 @@
* @param {Element} ele Element of the module collapse arrow
* @param {string} classID Class ID
* @param {string} modID Module ID of the module to collapse
- * @todo pending v3 support
*/
dtps.moduleCollapse = function (ele, classID, modID) {
- alert("This feature has not been implemented yet");
- throw "DTPS v3 IMPLEMENTATION ERR";
+ //Add collapsed class to module card
$(ele).parents('.card').toggleClass('collapsed');
+
+ //Update arrow icon and, if the LMS supports it, collapse the module in the LMS as well
if ($(ele).parents('.card').hasClass('collapsed')) {
- dtps.webReq("canCOLLAPSE", "/courses/" + classID + "/modules/" + modID + "/collapse", undefined, { collapse: 1, forceLoad: true })
+ if (dtpsLMS.collapseModule) dtpsLMS.collapseModule(classID, modID, true);
$(ele).html('keyboard_arrow_right');
} else {
- dtps.webReq("canCOLLAPSE", "/courses/" + classID + "/modules/" + modID + "/collapse", undefined, { collapse: 0, forceLoad: true })
+ if (dtpsLMS.collapseModule) dtpsLMS.collapseModule(classID, modID, false);
$(ele).html('keyboard_arrow_down');
}
@@ -695,10 +718,11 @@
*
* @param {number} num Class number
* @param {string} type Class content these tools are for (e.g. "stream")
- * @param {boolean} [modulesSelector] True if the class supports modules
+ * @param {string} [searchText] Text to render in the search box for assignment search
* @return {string} Stream tools HTML
*/
-dtps.renderClassTools = function (num, type, modulesSelector) {
+dtps.renderClassTools = function (num, type, searchText) {
+ var modulesSelector = dtps.classes[num].modules;
return /*html*/`
<div style="position: absolute;display:inline-block;margin: ${modulesSelector ? "82px" : "38px 82px"};">
@@ -713,7 +737,7 @@
<i style="line-height: 40px;" class="material-icons">info</i>
</div>
- ${dtps.classes[num].defaultView == "wiki" ? /*html*/`
+ ${dtps.classes[num].homepage ? /*html*/`
<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;">
<i style="line-height: 40px;" class="material-icons">home</i>
</div>` : ""
@@ -724,13 +748,13 @@
${(type == "modules") || (type == "stream") ? /*html*/`
<div style="text-align: right;${modulesSelector ? "" : "margin-top: 20px;"}">
- ${type == "stream" ? `<i class="inputIcon material-icons">search</i><input onchange="dtps.search()" class="search inputIcon shadow" placeholder="Search assignments" type="search" />` : ""}
+ ${type == "stream" ? `<i class="inputIcon material-icons">search</i><input ${searchText ? `value="${searchText}"` : ``} onchange="dtps.search()" class="search inputIcon filled shadow" placeholder="Search assignments" type="search" />` : ""}
<br />
${modulesSelector ? /*html*/`
<div class="btns row small acrylicMaterial assignmentPicker" style="margin: ${type == "stream" ? `20px 80px 20px 0px !important` : `63px 80px 20px 0px !important`};">
- <button class="btn ${type == "stream" ? "active" : ""}" onclick="dtps.classStream(dtps.selectedClass);"><i class="material-icons">assignment</i>Assignments</button>
- <button class="btn ${type == "modules" ? "active" : ""}" onclick="dtps.moduleStream(dtps.selectedClass);"><i class="material-icons">view_module</i>Modules</button>
+ <button class="btn ${type == "stream" ? "active" : ""}" onclick="fluid.screen('stream', dtps.classes[dtps.selectedClass].id);"><i class="material-icons">assignment</i>Assignments</button>
+ <button class="btn ${type == "modules" ? "active" : ""}" onclick="fluid.screen('moduleStream', dtps.classes[dtps.selectedClass].id);"><i class="material-icons">view_module</i>Modules</button>
</div>
` : ``}
@@ -745,20 +769,41 @@
* @param {number} num Class number to show info for
*/
dtps.classInfo = function (num) {
+ //Get syllabus blob if the class has a syllabus
if ((dtps.classes[num].syllabus !== "") && dtps.classes[num].syllabus !== null) {
- var blob = new Blob([`<base target="_blank" /> <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
- <style>body {background-color: ` + getComputedStyle($(".card.details")[0]).getPropertyValue("--cards") + `; color: ` + getComputedStyle($(".card.details")[0]).getPropertyValue("--text") + `}</style>` + dtps.classes[num].syllabus], { type: 'text/html' });
- var newurl = window.URL.createObjectURL(blob);
+ //Get computed background and text color to style the iFrame with
+ var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
+ var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
+
+ //Generate a blob with the assignment body and get its data URL
+ var blob = new Blob([`
+ <base target="_blank" />
+ <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
+ <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};</style>
+ ${dtps.classes[num].syllabus}
+ `], { type: 'text/html' });
+ var syllabusURL = window.URL.createObjectURL(blob);
}
- $(".card.details").html(`<i onclick="fluid.cards.close('.card.details')" class="material-icons close">close</i>
- <h4 style="font-weight: bold;">` + dtps.classes[num].name + `</h4>
- <p style="color: var(--secText)">` + (dtps.classes[num].description ? dtps.classes[num].description : "") + `</p>
- <div class="assignmentChip"><i class="material-icons">group</i><span>` + dtps.classes[num].numStudents + ` students</span></div>
- <div class="assignmentChip"><i class="material-icons">bug_report</i><span>Class ID: ` + dtps.classes[num].id + `</span></div>
- ` + (dtps.classes[num].favorite ? `<div title="Favorited class" class="assignmentChip" style="background-color: #daa520"><i style="color:white;font-family: 'Material Icons Outline'" class="material-icons">star_border</i></div>` : "") + `
- <br />
- <div style="margin-top: 20px;" class="syllabusBody">` + ((dtps.classes[num].syllabus !== "") && dtps.classes[num].syllabus !== null ? `<iframe id="syllabusIframe" onload="dtps.iframeLoad('syllabusIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="` + newurl + `" />` : "") + `</div>
+
+ //Show class info HTML
+ $(".card.details").html(/*html*/`
+ <i onclick="fluid.cards.close('.card.details')" class="material-icons close">close</i>
+
+ <h4 style="font-weight: bold;">${dtps.classes[num].name}</h4>
+ <p style="color: var(--secText)">${dtps.classes[num].description || ""}</p>
+
+ <div class="assignmentChip"><i class="material-icons">group</i><span>${dtps.classes[num].numStudents} students</span></div>
+ <div class="assignmentChip"><i class="material-icons">bug_report</i><span>Class ID: ${dtps.classes[num].id}</span></div>
+
+ <br />
+
+ <div style="margin-top: 20px;" class="syllabusBody">
+ ${dtps.classes[num].syllabus ? `
+ <iframe id="syllabusIframe" onload="dtps.iframeLoad('syllabusIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${syllabusURL}" />` : ""}
+ </div>
`)
+
+ //Show the class info card
fluid.modal(".card.details")
}
@@ -777,23 +822,170 @@
<p>Loading...</p>
`);
- dtps.webReq("canvas", "/api/v1/courses/" + dtps.classes[num].id + "/front_page", function (resp) {
- var data = JSON.parse(resp);
- if (!data.message) {
- var blob = new Blob([`<base target="_blank" /> <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
- <style>body {background-color: ` + getComputedStyle($(".card.details")[0]).getPropertyValue("--cards") + `; color: ` + getComputedStyle($(".card.details")[0]).getPropertyValue("--text") + `}</style>` + data.body], { type: 'text/html' });
- var newurl = window.URL.createObjectURL(blob);
- $(".card.details").html(`<i onclick="fluid.cards.close('.card.details')" class="material-icons close">close</i>
- <h4 style="font-weight: bold;">` + data.title + `</h4>
- <br />
- <div style="margin-top: 20px;" class="homepageBody"><iframe id="homepageIframe" onload="dtps.iframeLoad('homepageIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="` + newurl + `" /></div>
- `)
- fluid.modal(".card.details")
+ //Fetch homepage from the LMS
+ dtpsLMS.fetchHomepage(dtps.classes[num].id).then(homepage => {
+ if (homepage) {
+ //Get computed background and text color to style the iFrame with
+ var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards");
+ var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text");
+
+ //Generate a blob with the assignment body and get its data URL
+ var blob = new Blob([`
+ <base target="_blank" />
+ <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/>
+ <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};</style>
+ ${homepage}
+ `], { type: 'text/html' });
+ var homepageURL = window.URL.createObjectURL(blob);
+
+ $(".card.details").html(/*html*/`
+ <i onclick="fluid.cards.close('.card.details')" class="material-icons close">close</i>
+
+ <h4 style="font-weight: bold;">${dtps.classes[num].subject} Homepage</h4>
+
+ <br />
+ <div style="margin-top: 20px;" class="homepageBody">
+ <iframe id="homepageIframe" onload="dtps.iframeLoad('homepageIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${homepageURL}" />
+ </div>
+ `);
+
+ fluid.modal(".card.details");
} else {
- alert("Error: No homepage found for this class")
- fluid.cards.close('.card.details')
+ fluid.cards.close('.card.details');
+ dtps.error("Homepage unavailable", "homepage is either empty or undefined @ dtps.classHome");
+ }
+ }).catch(e => {
+ dtps.error("Couldn't load homepage", "Caught a promise rejection @ dtps.classHome", e);
+ })
+}
+
+/**
+ * Shows the generic gradebook
+ *
+ * @param {string} classID Class ID
+ */
+dtps.gradebook = function (classID) {
+ //Get class index and set as selected class
+ var classNum = dtps.classes.map(course => course.id).indexOf(classID);
+ dtps.selectedClass = classNum;
+
+ //Set stream as the selected content
+ dtps.selectedContent = "grades";
+ $("#dtpsTabBar .btn").removeClass("active");
+ $("#dtpsTabBar .btn.grades").addClass("active");
+
+ //Load class color, name, etc.
+ dtps.presentClass(classNum);
+
+ //Ensure classes are shown in the sidebar
+ dtps.showClasses();
+
+ if (classNum == -1) {
+ //Class does not exist
+ dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.gradebook");
+ }
+
+ //Show loading indicator
+ jQuery(".classContent").html(`<div class="spinner"></div>`);
+
+ //Terminate function if the class doesn't have a letter grade or assignments
+ if (!dtps.classes[classNum].letter || !dtps.classes[classNum].assignments) {
+ return;
+ }
+
+ //Define variables for total points and zeros
+ var zeros = 0;
+ var totalPoints = 0;
+ var earnedPoints = 0;
+ var gradedAssignments = 0;
+
+ //Define variable for assignment HTML string
+ var assignmentHTML = "";
+
+ //Calculate total points and zeros
+ dtps.classes[classNum].assignments.forEach(assignment => {
+ if (assignment.grade || (assignment.grade == 0)) {
+ earnedPoints += assignment.grade;
+ gradedAssignments++;
+
+ assignmentHTML += /*html*/`
+ <div onclick="dtps.assignment('${assignment.id}', ${classNum})" class="gradebookAssignment card">
+ <h5>
+ ${assignment.title}
+
+ <div class="stats">
+ ${assignment.letter ? `<div class="gradebookLetter">${assignment.letter}</div>` : ""}
+ <div class="gradebookScore">${assignment.grade}</div>
+ <div class="gradebookValue">/${assignment.value}</div>
+ <div class="gradebookPercentage">${Math.round((assignment.grade / assignment.value) * 100)}%</div>
+ </div>
+ </h5>
+ </div>
+ `;
+ }
+
+ if (assignment.value) {
+ totalPoints += assignment.value;
+ }
+
+ if ((assignment.grade == 0) && assignment.value) {
+ zeros++;
}
})
+
+ //Grade calculation summary
+ var gradeCalcSummary = /*html*/`
+ <div style="--classColor: ${dtps.classes[classNum].color}" class="card">
+ <h3 class="gradeTitle">
+ Grade Summary
+ <div class="classGradeCircle">
+ ${dtps.classes[classNum].grade ? `<span class="percentage">${dtps.classes[classNum].grade}%</span>` : ``}
+ <div class="letter">${dtps.classes[classNum].letter || ``}</div>
+ </div>
+ </h3>
+
+ ${zeros ? /*html*/`
+ <h5 style="color: #d63d3d;" class="gradeStat">
+ Zeros
+ <div style="color: #d63d3d;" class="numFont">${zeros}</div>
+ </h5>
+ ` : ``}
+
+ <div style="${dtps.gradebookExpanded ? "" : "display: none;"}" id="classGradeMore">
+ <br />
+
+ ${dtps.classes[classNum].previousLetter ? /*html*/`
+ <h5 class="smallStat">
+ Previous Grade
+ <div class="numFont">${dtps.classes[classNum].previousLetter}</div>
+ </h5>
+ ` : ``}
+
+ <h5 class="smallStat">
+ Points
+ <div class="numFont fraction">
+ <span class="earned">${earnedPoints}</span>
+ <span class="total">/${totalPoints}</span>
+ </div>
+ </h5>
+
+ <h5 class="smallStat">
+ Graded Assignments
+ <div class="numFont">${gradedAssignments}</div>
+ </h5>
+ </div>
+
+ <br />
+ <a onclick="$('#classGradeMore').toggle(); if ($('#classGradeMore').is(':visible')) {$(this).html('Show less'); dtps.gradebookExpanded = true;} else {$(this).html('Show more'); dtps.gradebookExpanded = false;}"
+ style="color: var(--secText, gray); cursor: pointer; margin-right: 10px;">${dtps.gradebookExpanded ? "Show less" : "Show more"}</a>
+ </div>
+
+ <br />
+ `;
+
+
+ //Render HTML
+ $(".classContent").html(gradeCalcSummary + assignmentHTML);
}
//Fluid UI screen definitions
@@ -805,6 +997,14 @@
dtps.classStream(courseID);
}
+fluid.externalScreens.moduleStream = (courseID) => {
+ dtps.moduleStream(courseID);
+}
+
+fluid.externalScreens.gradebook = (courseID) => {
+ dtps.gradebook(courseID);
+}
+
//Type definitions
/**
@@ -831,6 +1031,33 @@
*/
/**
+* @typedef {Object} Module
+* @description Defines module objects in DTPS
+* @property {string} title Title of the module
+* @property {string} id Module ID
+* @property {boolean} [collapsed] True if the module is collapsed, false otherwise. undefined or null if this module does not support collapsing.
+* @property {ModuleItem[]} items An array of items for this module.
+*/
+
+/**
+ * @typedef {Object} ModuleItem
+ * @description Defines module items in DTPS
+ * @property {string} type Either "assignment", "page", "discussion", "url", "embed", or "header".
+ * @property {string} [title] Required for URL and header items, and can be used to override the title of assignment, page, and discussion items.
+ * @property {string} [id] Required for assignment, page, and discussion items.
+ * @property {string} [url] Required for URL and embed items.
+ * @property {number} [indent] Indent level
+ */
+
+/**
+* @typedef {Object} Announcement
+* @description Defines announcement objects in DTPS
+* @property {string} title Title of the announcement
+* @property {Date} postedAt Date when the announcement was posted
+* @property {string} body Announcement content
+*/
+
+/**
* @typedef {Object} AssignmentFeedback
* @description Defines assignment feedback objects in DTPS
* @property {string} comment Feedback comment
@@ -876,7 +1103,7 @@
<br class="clear">
<footer>
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sun Jun 07 2020 14:02:58 GMT-0700 (Pacific Daylight Time)
+ 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)
</footer>
<script> prettyPrint(); </script>
diff --git a/docs/static/jsdoc/core.js.html b/docs/static/jsdoc/core.js.html
index b5fa136..110acc8 100644
--- a/docs/static/jsdoc/core.js.html
+++ b/docs/static/jsdoc/core.js.html
@@ -29,7 +29,7 @@
<pre class="prettyprint source linenums"><code>/**
* @file DTPS Core functions and module loader
* @author jottocraft
- * @version v2.9.1
+ * @version v3.0.0
*
* @copyright Copyright (c) 2018-2020 jottocraft. All rights reserved.
* @license GPL-2.0-only
@@ -49,34 +49,36 @@
* @property {Class[]} classes DTPS classes array
* @property {string} baseURL The base URL that DTPS is being loaded from
* @property {boolean} unstable This is true if loading an unstable version of DTPS
+ * @property {boolean} gradebookExpanded True if gradebook details (Show more...) is open. Used in the generic gradebook and may be used in custom gradebook implementations.
* @property {string|undefined} popup Popup to show when loaded. Either undefined (no popup), "firstrun", or "changelog".
* @property {User} user Current user, fetched with dtps.init
* @property {number|string} selectedClass The selected class number, or "dash" if the dashboard is selected. Set when the first screen is loaded in dtps.init.
* @property {string} selectedContent The selected class content/tab. Set when the first class content is loaded. Defaults to "stream".
* @property {number|undefined} bgTimeout Background transition timeout when switching between classes
+ * @property {Array<Assignment|Announcement>} updates Array of up to 10 recently graded assignments or announcements.
* @property {DashboardItem[]} dashboardItems Array of items that can be shown on the dashboard
* @property {DashboardItem[]} leftDashboard Items on the left side of the dashboard based on dtps.dashboardItems and user prefrences. Set in dtps.loadDashboardPrefs.
* @property {DashboardItem[]} rightDashboard Items on the right side of the dashboard based on dtps.dashboardItems and user prefrences. Set in dtps.loadDashboardPrefs.
*/
var dtps = {
- ver: 291,
- readableVer: "v2.9.1 (beta)",
+ ver: 300,
+ readableVer: "v3.0.0",
classes: [],
- baseURL: document.currentScript.src.split('/')[0] + '//' + document.currentScript.src.split('/')[2],
- unstable: true || window.localStorage.dtpsLoaderPref == "canary" || window.localStorage.dtpsLoaderPref == "debugging" || String(document.currentScript.src).includes("http://localhost"),
+ baseURL: String(document.currentScript.src).split('/')[0] + "//" + String(document.currentScript.src).split('/')[2],
+ unstable: window.localStorage.dtpsLoaderPref == "canary" || window.localStorage.dtpsLoaderPref == "debugging" || String(document.currentScript.src).includes("http://localhost"),
+ gradebookExpanded: false,
+ updates: [],
dashboardItems: [
{
name: "Calendar",
id: "dtps.calendar",
icon: "event",
- supportsCompactMode: false,
size: 100,
defaultSide: "left"
}, {
- name: "Updates [NYI]",
+ name: "Updates",
id: "dtps.updates",
- icon: "construction",
- supportsCompactMode: true,
+ icon: "calendar_view_day",
size: 80,
defaultSide: "left"
}, {
@@ -89,7 +91,6 @@
name: "Upcoming Assignments",
id: "dtps.upcoming",
icon: "view_stream",
- supportsCompactMode: true,
size: 250,
defaultSide: "right"
}
@@ -130,7 +131,7 @@
*
* @param {Date} date Date string to check
*/
-dtps.isToday = function(date) {
+dtps.isToday = function (date) {
var today = new Date();
var d1 = new Date(date);
@@ -186,15 +187,17 @@
*
* @param {string} msg The error to display
* @param {string} [devNotes] Technical error details displayed in a smaller font
- * @param {Error} [err] An error object to log to the console
+ * @param {Error} [err] An error object to log to the console. If this is null, DTPS will assume the error has been handled elsewhere.
*/
dtps.error = function (msg, devNotes, err) {
- var formattedDevNotes = "";
- if (devNotes) {
- formattedDevNotes = '<div style="font-size: 12px; color: var(--secText, gray); margin-top: 10px;">' + devNotes + '</div>';
+ if (err !== null) {
+ var formattedDevNotes = "";
+ if (devNotes) {
+ formattedDevNotes = '<div style="font-size: 12px; color: var(--secText, gray); margin-top: 10px;">' + devNotes + '</div>';
+ }
+ fluid.alert("Error", msg + formattedDevNotes, "error");
+ console.error("[DTPS !!ERROR!!]", devNotes + ": ", err);
}
- fluid.alert("Error", msg + formattedDevNotes, "error");
- console.error("[DTPS !!ERROR!!]", devNotes + ": ", err);
}
/**
@@ -204,7 +207,7 @@
//Set latest changelog version to current version
window.localStorage.setItem('dtps', dtps.ver);
- //Welcome to Power+ screen HTML
+ //Welcome to DTPS screen HTML
jQuery(".card.changelog").html(/*html*/`
<h3 style="margin-bottom: 0px;">Welcome to Power+</h3>
<h5 style="color: var(--secText); font-weight: bold; font-size: 22px;">${dtps.readableVer}</h5>
@@ -236,16 +239,16 @@
</div>
`);
- //Show Welcome to Power+ card
+ //Show Welcome to DTPS card
fluid.cards.close(".card.focus");
fluid.cards(".card.changelog", "stayOpen");
};
/**
- * Renders the Power+ loading screen
+ * Renders the DTPS loading screen
*/
dtps.renderLoadingScreen = function () {
- if (!window.dtpsPreLoader) {
+ if (!window.dtpsPreLoader || dtps.user) {
//Only show the loader if the extension hasn't already shown it
jQuery("body").append(/*html*/`
<div id="dtpsNativeOverlay" style="position: fixed; top: 0px; left: 0px; width: 100vw; height: 100vh; z-index: 999; background: #191919; text-align: center; z-index: 999; transition: opacity 0.2s;">
@@ -373,7 +376,19 @@
//Fetch user and class data
dtpsLMS.fetchUser().then(data => {
- dtps.user = data;
+ //Prevent resetting the user if the user is already set (for parent accounts)
+ if (!dtps.user) {
+ dtps.user = data;
+
+ //Set lmsID as current user ID by default
+ dtps.user.lmsID = dtps.user.id;
+
+ //If this is a parent account, show the parent UI
+ if (dtps.user.children && dtps.user.children.length) {
+ dtps.user.lmsID = dtps.user.children[0].id;
+ dtps.user.parent = true;
+ }
+ }
return dtpsLMS.fetchClasses();
}).then((rawClasses) => {
@@ -444,7 +459,7 @@
fluid.defaultScreen = "dashboard";
fluid.screens.dashboard = dtps.baseURL + "/scripts/assignments.js";
fluid.screens.stream = dtps.baseURL + "/scripts/assignments.js";
- fluid.screens.modules = dtps.baseURL + "/scripts/assignments.js";
+ fluid.screens.moduleStream = dtps.baseURL + "/scripts/assignments.js";
fluid.screens.pages = dtps.baseURL + "/scripts/pages-discussions.js";
fluid.screens.discussions = dtps.baseURL + "/scripts/pages-discussions.js";
@@ -453,7 +468,7 @@
fluid.screens.gradebook = dtps.showLMSGradebook;
} else if (dtpsLMS.genericGradebook) {
//Generic gradebook script
- fluid.screens.gradebook = dtps.baseURL + "/scripts/generic-gradebook.js";
+ fluid.screens.gradebook = dtps.baseURL + "/scripts/assignments.js";
}
//Begin fetching class assignments
@@ -474,11 +489,29 @@
//Store assignments in the class
course.assignments = assignments;
- //Add class props to assignments
+ //Add class props to assignments and add recent assignments to updates array
course.assignments.forEach(assignment => {
assignment.class = courseIndex;
+
+ if (assignment.gradedAt && assignment.grade) {
+ //Add class number and type to object
+ dtps.updates.push({
+ class: course.num,
+ type: "assignment",
+ ...assignment
+ })
+ }
});
+ //Sort updates array from newest -> oldest
+ dtps.updates.sort(function (a, b) {
+ //Sort by postedAt (announcements) or gradedAt (assignments)
+ return new Date(b.gradedAt || b.postedAt).getTime() - new Date(a.gradedAt || a.postedAt).getTime()
+ });
+
+ //Keep only the 10 most recent updates
+ if (dtps.updates.length > 10) dtps.updates.length = 10;
+
//Calculate class grade if supported
if (dtpsLMS.calculateGrade) {
let gradeCalcResults = dtpsLMS.calculateGrade(course, assignments);
@@ -533,6 +566,32 @@
fluid.screen();
}
});
+
+ dtpsLMS.fetchAnnouncements(course.id).then(announcements => {
+ //Add announcements to updates array
+ announcements.forEach(announcement => {
+ //Add class number and type to object
+ dtps.updates.push({
+ class: course.num,
+ type: "announcement",
+ ...announcement
+ })
+ });
+
+ //Sort updates array from newest -> oldest
+ dtps.updates.sort(function (a, b) {
+ //Sort by postedAt (announcements) or gradedAt (assignments)
+ return new Date(b.gradedAt || b.postedAt).getTime() - new Date(a.gradedAt || a.postedAt).getTime()
+ });
+
+ //Keep only the 10 most recent updates
+ if (dtps.updates.length > 10) dtps.updates.length = 10;
+
+ if (dtps.selectedClass == "dash") {
+ fluid.screen();
+ }
+
+ });
});
//Render remaining HTML
@@ -598,6 +657,26 @@
}
/**
+ * Switches the current child account being observed
+ *
+ * @param {Element} ele The dropdown element used to switch accounts
+ */
+dtps.obsSwitch = function (ele) {
+ //Reset URL state
+ history.replaceState(null, null, ' ');
+
+ //Change user LMS id based on dropdown value
+ dtps.user.lmsID = $(ele).val();
+
+ //Clear data
+ dtps.classes = [];
+ dtps.updates = [];
+
+ //Reload Power+
+ dtps.init();
+}
+
+/**
* Adjusts the height of an iFrame to match its content
*
* @param {string} iframeID The ID of the iFrame element to adjust
@@ -667,7 +746,7 @@
var letterGradeHTML = "";
if (dtps.classes[i].letter) letterGradeHTML = dtps.classes[i].letter;
if (dtps.classes[i].letter == null) letterGradeHTML = "--";
- if (dtps.classes[i].letter == "...") letterGradeHTML = `<div class="spinner" style="background-color: var(--norm); margin: -2px -13px"></div>`; //Show loading indicator for ...
+ if (dtps.classes[i].letter == "...") letterGradeHTML = `<div class="spinner" style="background-color: var(--norm); margin: -8px -10px;"></div>`; //Show loading indicator for ...
//Add class HTML to array
dtps.classlist.push(/*html*/`
@@ -687,12 +766,12 @@
//Only render HTML if the sidebar doesn't already have the classes rendered, or if override is true
if (!jQuery(".sidebar .class.dash")[0] || override) {
jQuery(".sidebar").html(/*html*/`
- <div class="bigLogo" style="text-align: center; margin: 10px 0 20px;">
- <img style="width: 28px; margin-right: 7px; vertical-align: middle;" src="${dtps.baseURL + "/gh-pages/icon.svg"}" />
+ <div class="bigLogo" style="text-align: center; margin: 10px 0 20px; white-space: nowrap; overflow: hidden;">
+ <img style="width: 28px; margin-right: 7px; vertical-align: middle;" src="https://powerplus.app/icon.svg" />
<h4 style="color: var(--text); display: inline-block; font-size: 28px; vertical-align: middle; margin: 0px;">Power+</h4>
</div>
- <img class="logo" src="${dtps.baseURL + "/gh-pages/favicon.png"}" />
+ <img class="logo" src="https://powerplus.app/favicon.png" />
<div class="items">
@@ -873,11 +952,39 @@
//Show loading indicator
jQuery(".classContent").html(`<div class="spinner"></div>`);
- dtpsLMS.gradebook(dtps.classes[classNum]).then(html => {
- $(".classContent").html(html);
- }).catch(function (err) {
- dtps.error("Could not load the gradebook", "Caught promise rejection @ dtps.showLMSGradebook", err);
- });
+ //Function to load gradebook HTML
+ function renderGradebook() {
+ dtpsLMS.gradebook(dtps.classes[classNum]).then(html => {
+ if (html) $(".classContent").html(html);
+ }).catch(function (err) {
+ dtps.error("Could not load the gradebook", "Caught promise rejection @ dtps.showLMSGradebook", err);
+ });
+ }
+
+ if (!fluid.externalScreens.stream) {
+ //Load assignment functions first
+ jQuery.getScript(dtps.baseURL + "/scripts/assignments.js", () => {
+ renderGradebook();
+ })
+ } else {
+ renderGradebook();
+ }
+}
+
+/**
+ * Shows a URL in the iFrame card
+ *
+ * @param {string} url The URL to load
+ */
+dtps.showIFrameCard = function (url) {
+ //Remove any previous URLs
+ $('#CardIFrame').attr('src', '');
+
+ //Show iFrame card
+ fluid.cards('.card.iFrameCard');
+
+ //Load new URL
+ $('#CardIFrame').attr('src', url);
}
/**
@@ -926,14 +1033,6 @@
<i class="material-icons">${dashboardItem.icon}</i>
<span>${dashboardItem.name}</span>
</h5>
-
- ${dashboardItem.supportsCompactMode ? /*html*/`
- <div class="compactModeSwitch">
- <div dashboardItem-id="${dashboardItem.id}" onclick="$(this).toggleClass('active'); dtps.saveDashboardPrefs();"
- class="switch ${dashboardItem.compact ? "active" : ""}"><span class="head"></span></div>
- <div class="label"><i class="material-icons">view_compact</i> Compact mode (NYI)</div>
- </div>
- ` : ``}
</div>
`;
}).join("");
@@ -972,14 +1071,13 @@
//Add item to dashboardPrefs array
dashboardPrefs.push({
id: child.attr("dashboardItem-id"),
- side: child.parent().attr("id").includes("left") ? "left" : "right",
- compact: child.find(".switch") && child.find(".switch").hasClass("active")
+ side: child.parent().attr("id").includes("left") ? "left" : "right"
});
}
//Save to local storage
window.localStorage.setItem("dtpsDashboardItems", JSON.stringify(dashboardPrefs));
-
+
//Reload dashboard items
dtps.loadDashboardPrefs();
}
@@ -987,7 +1085,7 @@
/**
* Loads dashboard prefrences
*/
-dtps.loadDashboardPrefs = function() {
+dtps.loadDashboardPrefs = function () {
//Define left and right dashboard columns
dtps.leftDashboard = [];
dtps.rightDashboard = [];
@@ -1011,11 +1109,6 @@
//Get item from dtps.dashboardItems array
var dashboardItem = dtps.dashboardItems[itemIndex];
- //Set compact mode
- if (dashboardItemPref.compact) {
- dashboardItem.compact = true;
- }
-
//Add item to dashboard
if (dashboardItemPref.side == "left") {
dtps.leftDashboard.push(dashboardItem);
@@ -1052,10 +1145,10 @@
jQuery("<link/>", {
rel: "shortcut icon",
type: "image/png",
- href: dtps.baseURL + "/gh-pages/favicon.png"
+ href: "https://powerplus.app/favicon.png"
}).appendTo("head");
- //Remove existing LMS HTML (excluding Power+ loading screen HTML)
+ //Remove existing LMS HTML (excluding DTPS loading screen HTML)
jQuery("body *:not(#dtpsNativeOverlay):not(#dtpsNativeOverlay *)").remove();
//Render HTML
@@ -1119,10 +1212,10 @@
</div>
<!-- General iFrame card (with white background) -->
- <div style="border-radius: 30px; top: 50px; background-color: white; color: black;" class="card focus close moduleURL container">
- <i style="color: black !important;" onclick="fluid.cards.close('.card.moduleURL'); $('#moduleIFrame').attr('src', '');" class="material-icons close">close</i>
+ <div style="border-radius: 30px; top: 50px; background-color: white; color: black;" class="card focus close iFrameCard container">
+ <i style="color: black !important;" onclick="fluid.cards.close('.card.iFrameCard'); $('#CardIFrame').attr('src', '');" class="material-icons close">close</i>
<br /><br />
- <iframe style="width: 100%; height: calc(100vh - 175px); border: none;" id="moduleIFrame"></iframe>
+ <iframe style="width: 100%; height: calc(100vh - 175px); border: none;" id="CardIFrame"></iframe>
</div>
`);
}
@@ -1134,7 +1227,7 @@
//Add hideGrades body class if enabled and preference listener
if (fluid.get("pref-hideGrades") == "true") { jQuery('body').addClass('hidegrades'); }
document.addEventListener("pref-hideGrades", function (e) {
- if (e.detail == "true") {
+ if ((e.detail == "true") || (e.detail == true)) {
//hideGrades has been enabled, add class to body to hide grades via CSS
jQuery('body').addClass('hidegrades');
} else {
@@ -1149,7 +1242,7 @@
<div class="sidenav" style="position: fixed; height: calc(100% - 50px); border-radius: 20px 0px 0px 20px;">
<div class="title">
- <img src="${dtps.baseURL + "/gh-pages/icon.svg"}" style="width: 50px;vertical-align: middle;padding: 7px; padding-top: 14px;" />
+ <img src="https://powerplus.app/icon.svg" style="width: 50px;vertical-align: middle;padding: 7px; padding-top: 14px;" />
<div style="vertical-align: middle; display: inline-block;">
<h5 style="font-weight: bold;display: inline-block;vertical-align: middle;">Power+</h5>
<p>${dtps.readableVer}</p>
@@ -1204,7 +1297,7 @@
${window.localStorage.githubCanary || window.localStorage.dtpsDebuggingPort ? /*html*/`
<br /><br />
- <p><b>Prerelease testing</b></p>
+ <p>Prerelease testing</p>
<div>
<div class="btns row small">
@@ -1235,6 +1328,7 @@
<div style="display: none;" class="abtpage dashboard">
<h5>Dashboard</h5>
+ <p>You can rearrange the items shown on the dashboard by dragging them below. You might have to reload Power+ for changes to take effect.</p>
<br />
@@ -1248,7 +1342,7 @@
<h5>About</h5>
<div class="card" style="padding: 10px 20px; box-shadow: none !important; border: 2px solid var(--elements); margin-top: 20px;">
- <img src="${dtps.baseURL + "/gh-pages/icon.svg"}" style="height: 50px; margin-right: 10px; vertical-align: middle; margin-top: 20px;" />
+ <img src="https://powerplus.app/icon.svg" style="height: 50px; margin-right: 10px; vertical-align: middle; margin-top: 20px;" />
<div style="display: inline-block; vertical-align: middle;">
<h4 style="font-weight: bold; font-size: 32px; margin-bottom: 0px;">Power+</h4>
@@ -1318,7 +1412,15 @@
//Render toolbar (the thing with the name and settings button at the top-right)
jQuery(".toolbar.items").html(/*html*/`
<div style="text-align: right;">
- <h4 style="font-size: 22px;">${dtps.user.name}</h4>
+ ${dtps.user.parent ? /*html*/`
+ <select onchange="dtps.obsSwitch(this)">
+ ${dtps.user.children.map(child => {
+ return `<option ${dtps.user.lmsID == child.id ? "selected" : ""} value = "${child.id}">${child.name}</option>`;
+ }).join("")}
+ </select>
+ ` : /*html*/`
+ <h4 style="font-size: 22px;">${dtps.user.name}</h4>
+ `}
<img src="${dtps.user.photoURL}" style="height: 34px; margin: 0px; margin-right: 10px; border-radius: 50%; vertical-align: middle;" />
</div>
@@ -1386,7 +1488,7 @@
* @property {string} logo LMS logo image URL
* @property {string} url URL to the LMS' website
* @property {string} source URL to the LMS integration's source code
- * @property {boolean} [institutionSpecific] True if the LMS is designed for a specific institution
+ * @property {boolean} [institutionSpecific] True if the LMS is designed for a specific institution instead of a broader LMS
* @property {boolean} [preferRubricGrades] True if DTPS should prefer rubric grades for assignments
* @property {boolean} [genericGradebook] True if DTPS should show the generic gradebook. Ignored if dtpsLMS.gradebook defined.
*/
@@ -1414,6 +1516,40 @@
*/
/**
+* @name dtpsLMS.fetchModules
+* @description [OPTIONAL] Fetches module data for a course from the LMS
+* @kind function
+* @param {string} classID The class ID to fetch modules for
+* @return {Promise<Module[]>} A promise which resolves to an array of Module objects
+*/
+
+/**
+* @name dtpsLMS.collapseModule
+* @description [OPTIONAL] Collapses a module in the LMS
+* @kind function
+* @param {string} classID The ID of the class
+* @param {string} moduleID The ID of the module to collapse
+* @param {boolean} collapsed True if the module is collapsed, false otherwise
+* @return {Promise} A promise which resolves when the operation is completed
+*/
+
+/**
+* @name dtpsLMS.fetchAnnouncements
+* @description [OPTIONAL] Fetches recent announcements for a course from the LMS
+* @kind function
+* @param {string} classID The class ID to fetch announcements for
+* @return {Promise<Announcement[]>} A promise which resolves to an array of Announcement objects
+*/
+
+/**
+* @name dtpsLMS.fetchHomepage
+* @description [OPTIONAL] Fetches homepage HTML for a course from the LMS
+* @kind function
+* @param {string} classID The class ID to get the homepage for
+* @return {Promise<string>} A promise which resolves to the HTML for the class homepage
+*/
+
+/**
* @name dtpsLMS.fetchDiscussionThreads
* @description [OPTIONAL] Fetches discussion threads for a course from the LMS
* @kind function
@@ -1493,6 +1629,9 @@
* @property {string} name User name
* @property {string} id User ID
* @property {string} photoURL User photo URL
+ * @property {User[]} [children] [ONLY FOR DTPS.USER] Array of child users. If this is defined, the user is treated as a parent account. Sub-children are not allowed.
+ * @property {boolean} parent [ONLY FOR DTPS.USER] Automatically managed by DTPS. True if the user is a parent account.
+ * @property {string} lmsID [ONLY FOR DTPS.USER] Automatically managed by DTPS. This is the user ID that all LMS web requests should use. Can change when a parent account changes the selected child.
*/
/**
@@ -1503,10 +1642,12 @@
* @property {number} num Index of the class in the dtps.classes array
* @property {string} subject Class subject
* @property {Assignment[]} assignments Class assignments. Assume assignments are still loading if this is undefined. The class has no assignments if this is an empty array. Loaded in dtps.init.
+* @property {Module[]|boolean} [modules] Class modules. Assume this class supports the modules feature, but is not yet loaded, if this is true and that the class has no modules if this is an empty array. For LMSs that do not support modules, either keep it undefined or set it to false.
* @property {DiscussionThread[]|boolean} [discussions] Class discussion threads. Assume this class supports discussions, but not yet loaded, if this is true and that the class has no threads if this is an empty array. For LMSs that do not support discussions, either keep it undefined or set it to false.
* @property {Page[]|boolean} [pages] Class pages. Assume this class supports the pages feature, but not yet loaded, if true and that the class has no pages if this is an empty array. For LMSs that do not support pages, either keep it undefined or set it to false.
* @property {string} [newDiscussionThreadURL] A URL the user can visit to create a new discussion thread in this class
* @property {string} [syllabus] Class syllabus HTML
+* @property {boolean} [homepage] True if the class has a homepage. If a class has a homepage, dtpsLMS.fetchHomepage must be implemented.
* @property {string} [description] Class description HTML
* @property {number} [numStudents] Number of students in the class
* @property {string} [term] Class term
@@ -1534,7 +1675,7 @@
<br class="clear">
<footer>
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sun Jun 07 2020 14:02:58 GMT-0700 (Pacific Daylight Time)
+ 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)
</footer>
<script> prettyPrint(); </script>
diff --git a/docs/static/jsdoc/dtps.html b/docs/static/jsdoc/dtps.html
index 57cf790..47e9226 100644
--- a/docs/static/jsdoc/dtps.html
+++ b/docs/static/jsdoc/dtps.html
Binary files differ
diff --git a/docs/static/jsdoc/dtpsLMS.html b/docs/static/jsdoc/dtpsLMS.html
index 6cd2cc4..68af1ee 100644
--- a/docs/static/jsdoc/dtpsLMS.html
+++ b/docs/static/jsdoc/dtpsLMS.html
@@ -302,7 +302,7 @@
- <td class="description last">True if the LMS is designed for a specific institution</td>
+ <td class="description last">True if the LMS is designed for a specific institution instead of a broader LMS</td>
</tr>
@@ -403,7 +403,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1350">line 1350</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1452">line 1452</a>
</li></ul></dd>
@@ -566,7 +566,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1430">line 1430</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1566">line 1566</a>
</li></ul></dd>
@@ -627,6 +627,370 @@
+ <h4 class="name" id=".collapseModule"><span class="type-signature">(static) </span>collapseModule<span class="signature">(classID, moduleID, collapsed)</span><span class="type-signature"> → {Promise}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ [OPTIONAL] Collapses a module in the LMS
+</div>
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>classID</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">The ID of the class</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>moduleID</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">The ID of the module to collapse</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>collapsed</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">boolean</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">True if the module is collapsed, false otherwise</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1498">line 1498</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+<div class="param-desc">
+ A promise which resolves when the operation is completed
+</div>
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id=".fetchAnnouncements"><span class="type-signature">(static) </span>fetchAnnouncements<span class="signature">(classID)</span><span class="type-signature"> → {Promise.<Array.<<a href="global.html#Announcement">Announcement</a>>>}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ [OPTIONAL] Fetches recent announcements for a course from the LMS
+</div>
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>classID</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">The class ID to fetch announcements for</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1508">line 1508</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+<div class="param-desc">
+ A promise which resolves to an array of Announcement objects
+</div>
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.<Array.<<a href="global.html#Announcement">Announcement</a>>></span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
<h4 class="name" id=".fetchAssignments"><span class="type-signature">(static) </span>fetchAssignments<span class="signature">(classID)</span><span class="type-signature"> → {Promise.<Array.<<a href="global.html#Assignment">Assignment</a>>>}</span></h4>
@@ -728,7 +1092,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1380">line 1380</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1482">line 1482</a>
</li></ul></dd>
@@ -838,7 +1202,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1373">line 1373</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1475">line 1475</a>
</li></ul></dd>
@@ -1020,7 +1384,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1396">line 1396</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1532">line 1532</a>
</li></ul></dd>
@@ -1179,7 +1543,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1388">line 1388</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1524">line 1524</a>
</li></ul></dd>
@@ -1237,6 +1601,324 @@
+ <h4 class="name" id=".fetchHomepage"><span class="type-signature">(static) </span>fetchHomepage<span class="signature">(classID)</span><span class="type-signature"> → {Promise.<string>}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ [OPTIONAL] Fetches homepage HTML for a course from the LMS
+</div>
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>classID</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">The class ID to get the homepage for</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1516">line 1516</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+<div class="param-desc">
+ A promise which resolves to the HTML for the class homepage
+</div>
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.<string></span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id=".fetchModules"><span class="type-signature">(static) </span>fetchModules<span class="signature">(classID)</span><span class="type-signature"> → {Promise.<Array.<<a href="global.html#Module">Module</a>>>}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ [OPTIONAL] Fetches module data for a course from the LMS
+</div>
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>classID</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">The class ID to fetch modules for</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1490">line 1490</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+<div class="param-desc">
+ A promise which resolves to an array of Module objects
+</div>
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.<Array.<<a href="global.html#Module">Module</a>>></span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
<h4 class="name" id=".fetchPageContent"><span class="type-signature">(static) </span>fetchPageContent<span class="signature">(classID, pageID)</span><span class="type-signature"> → {Promise.<string>}</span></h4>
@@ -1361,7 +2043,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1413">line 1413</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1549">line 1549</a>
</li></ul></dd>
@@ -1520,7 +2202,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1405">line 1405</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1541">line 1541</a>
</li></ul></dd>
@@ -1630,7 +2312,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1366">line 1366</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1468">line 1468</a>
</li></ul></dd>
@@ -1789,7 +2471,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1422">line 1422</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1558">line 1558</a>
</li></ul></dd>
@@ -1948,7 +2630,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1439">line 1439</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1575">line 1575</a>
</li></ul></dd>
@@ -2107,7 +2789,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1447">line 1447</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1583">line 1583</a>
</li></ul></dd>
@@ -2181,7 +2863,7 @@
<br class="clear">
<footer>
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sun Jun 07 2020 14:02:58 GMT-0700 (Pacific Daylight Time)
+ 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)
</footer>
<script> prettyPrint(); </script>
diff --git a/docs/static/jsdoc/global.html b/docs/static/jsdoc/global.html
index 3eed726..a53c201 100644
--- a/docs/static/jsdoc/global.html
+++ b/docs/static/jsdoc/global.html
@@ -102,6 +102,176 @@
+<h4 class="name" id="Announcement">Announcement</h4>
+
+
+
+
+<div class="description">
+ Defines announcement objects in DTPS
+</div>
+
+
+
+ <h5>Type:</h5>
+ <ul>
+ <li>
+
+<span class="param-type">Object</span>
+
+
+ </li>
+ </ul>
+
+
+
+
+
+ <h5 class="subsection-title">Properties:</h5>
+
+
+
+<table class="props">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>title</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">Title of the announcement</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>postedAt</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type"><a href="global.html#Date">Date</a></span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">Date when the announcement was posted</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>body</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">Announcement content</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line1024">line 1024</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
<h4 class="name" id="Assignment">Assignment</h4>
@@ -739,7 +909,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line782">line 782</a>
+ <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line982">line 982</a>
</li></ul></dd>
@@ -902,7 +1072,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line805">line 805</a>
+ <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line1032">line 1032</a>
</li></ul></dd>
@@ -1118,6 +1288,40 @@
<tr>
+ <td class="name"><code>modules</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">Array.<<a href="global.html#Module">Module</a>></span>
+|
+
+<span class="param-type">boolean</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Class modules. Assume this class supports the modules feature, but is not yet loaded, if this is true and that the class has no modules if this is an empty array. For LMSs that do not support modules, either keep it undefined or set it to false.</td>
+ </tr>
+
+
+
+ <tr>
+
<td class="name"><code>discussions</code></td>
@@ -1248,6 +1452,37 @@
<tr>
+ <td class="name"><code>homepage</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">boolean</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">True if the class has a homepage. If a class has a homepage, dtpsLMS.fetchHomepage must be implemented.</td>
+ </tr>
+
+
+
+ <tr>
+
<td class="name"><code>description</code></td>
@@ -1621,7 +1856,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1470">line 1470</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1609">line 1609</a>
</li></ul></dd>
@@ -1883,7 +2118,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line825">line 825</a>
+ <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line1052">line 1052</a>
</li></ul></dd>
@@ -1955,7 +2190,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1457">line 1457</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1593">line 1593</a>
</li></ul></dd>
@@ -2269,7 +2504,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="pages-discussions.js.html">pages-discussions.js</a>, <a href="pages-discussions.js.html#line450">line 450</a>
+ <a href="pages-discussions.js.html">pages-discussions.js</a>, <a href="pages-discussions.js.html#line480">line 480</a>
</li></ul></dd>
@@ -2521,7 +2756,484 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="pages-discussions.js.html">pages-discussions.js</a>, <a href="pages-discussions.js.html#line440">line 440</a>
+ <a href="pages-discussions.js.html">pages-discussions.js</a>, <a href="pages-discussions.js.html#line470">line 470</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+<h4 class="name" id="Module">Module</h4>
+
+
+
+
+<div class="description">
+ Defines module objects in DTPS
+</div>
+
+
+
+ <h5>Type:</h5>
+ <ul>
+ <li>
+
+<span class="param-type">Object</span>
+
+
+ </li>
+ </ul>
+
+
+
+
+
+ <h5 class="subsection-title">Properties:</h5>
+
+
+
+<table class="props">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+ <th>Attributes</th>
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>title</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Title of the module</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>id</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Module ID</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>collapsed</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">boolean</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">True if the module is collapsed, false otherwise. undefined or null if this module does not support collapsing.</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>items</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">Array.<<a href="global.html#ModuleItem">ModuleItem</a>></span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">An array of items for this module.</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line1005">line 1005</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+<h4 class="name" id="ModuleItem">ModuleItem</h4>
+
+
+
+
+<div class="description">
+ Defines module items in DTPS
+</div>
+
+
+
+ <h5>Type:</h5>
+ <ul>
+ <li>
+
+<span class="param-type">Object</span>
+
+
+ </li>
+ </ul>
+
+
+
+
+
+ <h5 class="subsection-title">Properties:</h5>
+
+
+
+<table class="props">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+ <th>Attributes</th>
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>type</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Either "assignment", "page", "discussion", "url", "embed", or "header".</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>title</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Required for URL and header items, and can be used to override the title of assignment, page, and discussion items.</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>id</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Required for assignment, page, and discussion items.</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>url</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Required for URL and embed items.</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>indent</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">number</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">Indent level</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line1014">line 1014</a>
</li></ul></dd>
@@ -2773,7 +3485,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="pages-discussions.js.html">pages-discussions.js</a>, <a href="pages-discussions.js.html#line462">line 462</a>
+ <a href="pages-discussions.js.html">pages-discussions.js</a>, <a href="pages-discussions.js.html#line492">line 492</a>
</li></ul></dd>
@@ -3118,7 +3830,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line812">line 812</a>
+ <a href="assignments.js.html">assignments.js</a>, <a href="assignments.js.html#line1039">line 1039</a>
</li></ul></dd>
@@ -3175,6 +3887,8 @@
<th>Type</th>
+ <th>Attributes</th>
+
@@ -3200,6 +3914,12 @@
</td>
+ <td class="attributes">
+
+
+
+ </td>
+
@@ -3223,6 +3943,12 @@
</td>
+ <td class="attributes">
+
+
+
+ </td>
+
@@ -3246,6 +3972,12 @@
</td>
+ <td class="attributes">
+
+
+
+ </td>
+
@@ -3253,6 +3985,95 @@
</tr>
+
+ <tr>
+
+ <td class="name"><code>children</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">Array.<<a href="global.html#User">User</a>></span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ <optional><br>
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">[ONLY FOR DTPS.USER] Array of child users. If this is defined, the user is treated as a parent account. Sub-children are not allowed.</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>parent</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">boolean</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">[ONLY FOR DTPS.USER] Automatically managed by DTPS. True if the user is a parent account.</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>lmsID</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">[ONLY FOR DTPS.USER] Automatically managed by DTPS. This is the user ID that all LMS web requests should use. Can change when a parent account changes the selected child.</td>
+ </tr>
+
+
</tbody>
</table>
@@ -3288,7 +4109,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="core.js.html">core.js</a>, <a href="core.js.html#line1462">line 1462</a>
+ <a href="core.js.html">core.js</a>, <a href="core.js.html#line1598">line 1598</a>
</li></ul></dd>
@@ -3324,7 +4145,7 @@
<br class="clear">
<footer>
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sun Jun 07 2020 14:02:58 GMT-0700 (Pacific Daylight Time)
+ 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)
</footer>
<script> prettyPrint(); </script>
diff --git a/docs/static/jsdoc/index.html b/docs/static/jsdoc/index.html
index 1a4aca0..62047a3 100644
--- a/docs/static/jsdoc/index.html
+++ b/docs/static/jsdoc/index.html
@@ -179,7 +179,7 @@
<dt class="tag-version">Version:</dt>
- <dd class="tag-version"><ul class="dummy"><li>v2.9.1</li></ul></dd>
+ <dd class="tag-version"><ul class="dummy"><li>v3.0.0</li></ul></dd>
@@ -269,112 +269,6 @@
<header>
- <h2>generic-gradebook.js</h2>
-
-
-</header>
-
-<article>
- <div class="container-overview">
-
-
- <div class="description">DTPS Generic Gradebook</div>
-
-
-
-
-
-<dl class="details">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <dt class="tag-author">Author:</dt>
- <dd class="tag-author">
- <ul>
- <li>jottocraft</li>
- </ul>
- </dd>
-
-
-
- <dt class="tag-copyright">Copyright:</dt>
- <dd class="tag-copyright"><ul class="dummy"><li>Copyright (c) 2018-2020 jottocraft. All rights reserved.</li></ul></dd>
-
-
-
- <dt class="tag-license">License:</dt>
- <dd class="tag-license"><ul class="dummy"><li>GPL-2.0-only</li></ul></dd>
-
-
-
-
-
- <dt class="tag-source">Source:</dt>
- <dd class="tag-source"><ul class="dummy"><li>
- <a href="generic-gradebook.js.html">generic-gradebook.js</a>, <a href="generic-gradebook.js.html#line1">line 1</a>
- </li></ul></dd>
-
-
-
-
-
-
-
-</dl>
-
-
-
-
- </div>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-</article>
-
-</section>
-
-
-
-
-
-
-
-<section>
-
-<header>
-
<h2>pages-discussions.js</h2>
@@ -483,7 +377,7 @@
<br class="clear">
<footer>
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sun Jun 07 2020 14:02:58 GMT-0700 (Pacific Daylight Time)
+ 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)
</footer>
<script> prettyPrint(); </script>
diff --git a/docs/static/jsdoc/pages-discussions.js.html b/docs/static/jsdoc/pages-discussions.js.html
index 7e5e257..d113ee9 100644
--- a/docs/static/jsdoc/pages-discussions.js.html
+++ b/docs/static/jsdoc/pages-discussions.js.html
@@ -39,8 +39,9 @@
* Renders the discussions list for a class
*
* @param {string} courseID The course ID to render discussion threads for
+ * @param {string} [defaultThread] The thread to load by default
*/
-dtps.loadThreadsList = function (courseID) {
+dtps.loadThreadsList = function (courseID, defaultThread) {
//Get class index and set as selected class
var classNum = dtps.classes.map(course => course.id).indexOf(courseID);
dtps.selectedClass = classNum;
@@ -134,6 +135,11 @@
`);
}
+ //Load default thread if provided
+ if (defaultThread) {
+ dtps.loadThreadPosts(classNum, defaultThread);
+ }
+
//Add click event listeners for discussion threads
$(".sidebar .item:not(.back)").click(function (event) {
//Show the selected thread as active
@@ -166,13 +172,18 @@
}
//Get discussion data
- var thread = {};
+ var thread = null;
dtps.classes[classNum].discussions.forEach(discussionThread => {
if (discussionThread.id == threadID) {
thread = discussionThread;
}
});
+ if (!thread) {
+ dtps.error("Thread does not exist", "thread is null @ dtps.loadThreadPosts");
+ throw null;
+ }
+
//Fetch discussion posts from the LMS
dtpsLMS.fetchDiscussionPosts(dtps.classes[classNum].id, threadID).then(function (postData) {
//Store posts in the discussion thread
@@ -284,8 +295,9 @@
* Renders the pages list for a class
*
* @param {string} courseID The course ID to render pages for
+ * @param {string} [defaultPage] If provided, load the pageID by default
*/
-dtps.loadPagesList = function (courseID) {
+dtps.loadPagesList = function (courseID, defaultPage) {
//Get class index and set as selected class
var classNum = dtps.classes.map(course => course.id).indexOf(courseID);
dtps.selectedClass = classNum;
@@ -342,7 +354,7 @@
//Loop over discusson threads array to create discussion thread HTML for the sidebar
var pageHTML = dtps.classes[classNum].pages.map(page => {
return /*html*/`
- <div data-pageID="${page.id}" class="item">
+ <div data-pageID="${page.id}" class="item ${(defaultPage && (page.id == defaultPage)) ? "active" : ""}">
<span class="label">${page.title}</span>
<div class="icon">
<i class="material-icons">insert_drive_file</i>
@@ -367,6 +379,11 @@
`);
}
+ //Load default page if provided
+ if (defaultPage) {
+ dtps.loadPage(classNum, defaultPage);
+ }
+
//Add click event listeners for pages
$(".sidebar .item:not(.back)").click(function (event) {
//Show the selected thread as active
@@ -398,13 +415,18 @@
}
//Get page data
- var page = {};
+ var page = null;
dtps.classes[classNum].pages.forEach(pageCheck => {
if (pageCheck.id == pageID) {
page = pageCheck;
}
});
+ if (!page) {
+ dtps.error("Page does not exist", "page is null @ dtps.loadPage");
+ throw null;
+ }
+
//Fetch page content
dtpsLMS.fetchPageContent(dtps.classes[classNum].id, page.id).then(function (pageContentData) {
//Store page content in the page object
@@ -455,12 +477,20 @@
}
//Fluid UI screen definitions
-fluid.externalScreens.discussions = (courseID) => {
- dtps.loadThreadsList(courseID);
+fluid.externalScreens.discussions = (param) => {
+ //Split parameter string into variables
+ var courseID = param.split("|")[0];
+ var threadID = param.split("|")[1];
+
+ dtps.loadThreadsList(courseID, threadID);
}
-fluid.externalScreens.pages = (courseID) => {
- dtps.loadPagesList(courseID);
+fluid.externalScreens.pages = (param) => {
+ //Split parameter string into variables
+ var courseID = param.split("|")[0];
+ var pageID = param.split("|")[1];
+
+ dtps.loadPagesList(courseID, pageID);
}
//Type definitions
@@ -511,7 +541,7 @@
<br class="clear">
<footer>
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sun Jun 07 2020 14:02:58 GMT-0700 (Pacific Daylight Time)
+ 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)
</footer>
<script> prettyPrint(); </script>