people tab update
diff --git a/scripts/lms/canvas.js b/scripts/lms/canvas.js
index 47e140e..8859a1a 100644
--- a/scripts/lms/canvas.js
+++ b/scripts/lms/canvas.js
@@ -44,7 +44,7 @@
type: "GET",
headers: dtpsLMS.commonHeaders,
success: function (childrenData) {
-
+
if (childrenData && childrenData.length) {
//Parent account
user.children = childrenData.map(child => {
@@ -55,7 +55,7 @@
}
});
}
-
+
resolve(user);
},
error: function (err) {
@@ -430,34 +430,57 @@
dtpsLMS.fetchUsers = function (classID) {
return new Promise(function (resolve, reject) {
jQuery.ajax({
- url: "/api/v1/courses/" + classID + "/sections?include[]=avatar_url&include[]=students",
+ url: "/api/v1/courses/" + classID + "/sections?include[]=avatar_url&include[]=students&per_page=99",
type: "GET",
headers: dtpsLMS.commonHeaders,
success: function (data) {
- var sections = [];
- data.forEach(section => {
- if (!section.students) return;
+ jQuery.ajax({
+ url: "/api/v1/courses/" + classID + "/users?per_page=99&enrollment_type[]=teacher&include[]=avatar_url",
+ type: "GET",
+ headers: dtpsLMS.commonHeaders,
+ success: function (teachers) {
+ var sections = [{
+ title: "Teachers",
+ id: "lms.dtps.canvas-teachers",
+ users: []
+ }];
- var users = [];
- section.students.forEach(student => {
- users.push({
- name: student.short_name,
- id: student.id,
- photoURL: student.avatar_url,
- url: "/courses/" + classID + "/users/" + student.id
+ teachers.forEach(teacher => {
+ sections[0].users.push({
+ name: teacher.name,
+ id: teacher.id,
+ photoURL: teacher.avatar_url,
+ url: "/courses/" + classID + "/users/" + teacher.id
+ });
});
- });
- var dtechMatch = section.name.match(/[0-9](?=\(A)/);
- if (dtpsLMS.dtech && dtechMatch) {
- section.name = "Period " + dtechMatch[0];
+
+ data.forEach(section => {
+ if (!section.students) return;
+ var users = [];
+ section.students.forEach(student => {
+ users.push({
+ name: student.short_name,
+ id: student.id,
+ photoURL: student.avatar_url,
+ url: "/courses/" + classID + "/users/" + student.id
+ });
+ });
+ var dtechMatch = section.name.match(/[0-9](?=\(A)/);
+ if (dtpsLMS.dtech && dtechMatch) {
+ section.name = dtechMatch[0] == 7 ? "@d.tech" : "Period " + dtechMatch[0];
+ }
+ sections.push({
+ title: section.name,
+ id: section.id,
+ users
+ });
+ });
+ resolve(sections);
+ },
+ error: function (err) {
+ reject(err);
}
- sections.push({
- title: section.name,
- id: section.id,
- users
- });
});
- resolve(sections);
},
error: function (err) {
reject(err);
diff --git a/scripts/lms/dtech.js b/scripts/lms/dtech.js
index d0a17dc..a2d60ff 100644
--- a/scripts/lms/dtech.js
+++ b/scripts/lms/dtech.js
@@ -590,7 +590,7 @@
var gradeSummary = document.getElementById("gradeSummary");
var sticky = gradeSummary.offsetTop - parseFloat($("body").css("padding-top")) - 10;
window.onscroll = function () {
- if (window.pageYOffset >= sticky) {
+ if ((window.pageYOffset >= sticky) && ((dtps.classes[dtps.selectedClass]) && (dtps.selectedContent == "grades"))) {
$(".classContent").addClass("fixedGradeSummary");
} else {
$(".classContent").removeClass("fixedGradeSummary");
diff --git a/scripts/people.js b/scripts/people.js
index 9d4747d..f3002f5 100644
--- a/scripts/people.js
+++ b/scripts/people.js
@@ -35,9 +35,23 @@
if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "people")) {
jQuery(".classContent").html(/*html*/`
+ <div style="--size: 250px; margin: 0px 20px;" class="grid flex">
+ <div class="block status card">
+ <h2 class="main"><span class="shimmer">--</span></h2>
+ <h5 class="bottom"><i class="material-icons">contact_page</i> Your section</h5>
+ </div>
+ <div class="block status">
+ <h2 class="main numFont"><span class="shimmer">--</span></h2>
+ <h5 class="bottom"><i class="material-icons">groups</i> Total Students</h5>
+ </div>
+ <div class="block status">
+ <h2 class="main numFont"><span class="shimmer">--</span></h2>
+ <h5 class="bottom"><i class="material-icons">school</i> Teachers</h5>
+ </div>
+ </div>
<div class="card">
<h5><b style="width: 300px; display: inline-block;" class="shimmer">Title</b></h5>
- ${[1,2,3,4,5,6].map(() => (
+ ${[1, 2, 3, 4, 5, 6].map(() => (
/*html*/`
<div>
<p class="shimmerParent">
@@ -46,13 +60,31 @@
</p>
</div>
`
- )).join("")}
+ )).join("")}
</div>
`);
}
//Fetch users list
dtpsLMS.fetchUsers(dtps.classes[classNum].id).then(function (sections) {
+ //Count students and teachers by user ID
+ var allStudents = [];
+ var allTeachers = [];
+ var currentSection = null;
+ sections.forEach(section => {
+ section.users.forEach(user => {
+ if ((section.title == "Teachers") && !allTeachers.includes(user.id)) {
+ allTeachers.push(user.id);
+ } else if (!allStudents.includes(user.id)) {
+ allStudents.push(user.id);
+ }
+
+ if (!currentSection && (user.id == dtps.user.id)) {
+ currentSection = section.title;
+ }
+ });
+ });
+
if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "people")) {
if (!sections || (sections.length == 0)) {
//No people in this class? (this shouldn't be possible)
@@ -66,16 +98,16 @@
jQuery(".classContent").html(/*html*/`
<div style="--size: 250px; margin: 0px 20px;" class="grid flex">
<div class="block status card">
- <h2 class="main">--</h2>
+ <h2 class="main">${currentSection || "--"}</h2>
<h5 class="bottom"><i class="material-icons">contact_page</i> Your section</h5>
</div>
<div class="block status">
- <h2 class="main numFont">--</h2>
+ <h2 class="main numFont">${allStudents.length}</h2>
<h5 class="bottom"><i class="material-icons">groups</i> Total Students</h5>
</div>
<div class="block status">
- <h2 class="main numFont">--</h2>
- <h5 class="bottom"><i class="material-icons">school</i> Teachers</h5>
+ <h2 class="main numFont">${allTeachers.length}</h2>
+ <h5 class="bottom"><i class="material-icons">school</i> ${allTeachers.length == 1 ? "Teacher" : "Teachers"}</h5>
</div>
</div>
` + sections.map(section => (
@@ -91,7 +123,7 @@
</p>
</div>
`
- )).join("")}
+ )).join("")}
</div>
`
)).join(""));