blob: a10808eb907e7fa1cf5db4d57810850b24e886fa [file] [log] [blame]
j7940eec2020-12-28 14:00:41 -06001/**
2 * @file DTPS Demo LMS
3 * @author jottocraft
4 *
j6e1a7bf2026-10-13 03:37:04 +00005 * @copyright Copyright (c) jottocraft 2020
j40db0272022-01-14 15:18:29 -08006 * @license MIT
j7940eec2020-12-28 14:00:41 -06007 *
8 * This LMS script is for demonstrating Power+ and doesn't fetch actual data
9 * JSDoc documentation for these LMS functions can be found near the end of core.js
10 */
11
12//DTPS LMS configuration
13var dtpsLMS = {
14 name: "Demo LMS",
15 shortName: "Demo",
16 description: "All content in this LMS is not real and is for demonstration purposes only",
17 url: "https://powerplus.app",
18 logo: "https://powerplus.app/logo.png",
j0e5b1c72026-10-13 03:49:38 +000019 source: "https://src.jottocraft.com/browser/dtps/+/refs/heads/main/scripts/lms/demo.js",
j7940eec2020-12-28 14:00:41 -060020 isDemoLMS: true
21};
22
23//Return sample user data
24dtpsLMS.fetchUser = function () {
25 return new Promise(function (resolve, reject) {
26 resolve({
27 name: "Demo User",
28 id: "1",
29 photoURL: "https://powerplus.app/logo.png"
30 });
31 })
32}
33
34//Fetch class data from Canvas
35dtpsLMS.fetchClasses = function (userID) {
36 return new Promise(function (resolve, reject) {
j2fcf4e52021-03-11 14:37:26 -080037 var baseClass = {
j7940eec2020-12-28 14:00:41 -060038 description: `<p>This class is for demonstration purposes only and is not a real class</p>`,
39 homepage: true,
40 numStudents: 1337,
41 modules: true,
42 discussions: true,
43 pages: true,
j7940eec2020-12-28 14:00:41 -060044 teacher: {
45 name: "Demo Teacher",
46 id: "2",
47 photoURL: "https://powerplus.app/logo.png"
48 }
j2fcf4e52021-03-11 14:37:26 -080049 };
50
51 resolve([
52 {
53 ...baseClass,
54 name: "Advisory",
55 icon: "school",
56 id: "1",
57 lmsID: "1",
58 subject: "Advisory",
59 color: "red"
60 },
61 {
62 ...baseClass,
63 name: "Physics",
64 id: "2",
65 lmsID: "2",
66 subject: "Physics",
67 color: "green",
68 letter: "A",
69 group: "Semester 1"
70 },
71 {
72 ...baseClass,
73 name: "English",
74 id: "3",
75 lmsID: "3",
76 subject: "English",
77 color: "blue",
78 letter: "A",
79 group: "Semester 1"
80 },
81 {
82 ...baseClass,
83 name: "History",
84 id: "4",
85 lmsID: "4",
86 subject: "History",
87 color: "orange",
88 letter: "P",
89 group: "Semester 1"
90 },
91 {
92 ...baseClass,
93 name: "Physics",
94 icon: "science",
95 id: "5",
96 lmsID: "5",
97 subject: "Physics",
98 color: "green",
99 group: "Semester 2"
100 },
101 {
102 ...baseClass,
103 name: "English",
104 icon: "description",
105 id: "6",
106 lmsID: "6",
107 subject: "English",
108 color: "blue",
109 grade: 98,
110 group: "Semester 2"
111 },
112 {
113 ...baseClass,
114 name: "History",
115 icon: "history_edu",
116 id: "7",
117 lmsID: "7",
118 subject: "History",
119 color: "orange",
120 letter: "A",
j2fcf4e52021-03-11 14:37:26 -0800121 group: "Semester 2"
122 }
123 ]);
j7940eec2020-12-28 14:00:41 -0600124 })
125}
126
j2fcf4e52021-03-11 14:37:26 -0800127function generateAssignmentName() {
128 var assignmentName = [];
129
130 assignmentName.push(["Unit 1", "Unit 2", "Unit 3", "Final", "Mid-Semester", "Pre", "Honors", "Extra Credit"].random());
131 assignmentName.push(["Exam", "Discussion Post", "Homework", "Assignment", "Project", "Research Project", "Check-In", "Quiz", "Test", "Survey", "Reading", "Essay", "Lab"].random());
132
133 return assignmentName.join(" ");
134}
135
j7940eec2020-12-28 14:00:41 -0600136//Fetches assignment data from Canvas
137dtpsLMS.fetchAssignments = function (userID, classID) {
138 return new Promise(function (resolve, reject) {
j2fcf4e52021-03-11 14:37:26 -0800139 var assignments = [];
140 if (Number(classID) < 5) return resolve([]);
141
142 Array.prototype.random = function () {
143 return this[Math.floor((Math.random() * this.length))];
144 };
145
146 for (var i = 0; i < 20; i++) {
147 //Get random assignment due date
148 var assignmentDate = new Date(new Date().getTime() + (Math.floor(Math.random() * 5.256e+9) - 2.628e+9));
149
150 assignmentDate.setHours(23);
151 assignmentDate.setMinutes(59);
152
153 assignments.push({
154 title: generateAssignmentName(),
155 id: Math.floor(Math.random() * 10000),
156 body: "<p>This assignment is for demonstration purposes only</p>",
157 dueAt: assignmentDate,
158 turnedIn: assignmentDate > new Date().getTime() ? Math.random() < 0.5 : false,
159 locked: assignmentDate < new Date().getTime() ? Math.random() < 0.5 : false,
160 value: Math.floor(Math.random() * 100),
161 publishedAt: new Date().getTime() - 100000000,
162 rubric: [
163 {
164 title: "Skills Assessment",
165 id: "1",
166 value: 4,
167 description: "This outcome is for demonstration purposes only"
168 },
169 {
170 title: "Writing Skills",
171 id: "2",
172 value: 4,
173 description: "This outcome is for demonstration purposes only"
174 },
175 {
176 title: "Research Skills",
177 id: "3",
178 value: 4,
179 description: "This outcome is for demonstration purposes only"
180 },
181 {
182 title: "Thinking Skills",
183 id: "3",
184 value: 4,
185 description: "This outcome is for demonstration purposes only"
186 }
187 ]
188 })
j7940eec2020-12-28 14:00:41 -0600189 }
j2fcf4e52021-03-11 14:37:26 -0800190
191 resolve(assignments);
j7940eec2020-12-28 14:00:41 -0600192 })
193}
194
195//Fetches modules data from Canvas
196dtpsLMS.fetchModules = function (userID, classID) {
197 return new Promise(function (resolve, reject) {
198 resolve([
199 {
200 title: "Demo module",
201 id: "1",
202 items: [
203 {
204 type: "url",
205 title: "google.com",
206 url: "https://www.google.com"
207 },
208 {
209 type: "page",
210 title: "Demo Page",
211 id: "1"
212 },
213 {
214 type: "discussion",
215 title: "Demo Discussion",
216 id: "1"
217 },
218 {
219 type: "assignment",
220 title: "Demo Assignment 1",
221 id: "191"
222 },
223 {
224 type: "assignment",
225 title: "Demo Assignment 2",
226 id: "192"
227 }
228 ]
229 }
230 ]);
231 });
232}
233
234//Fetches announcement data from Canvas
235dtpsLMS.fetchAnnouncements = function (classID) {
236 return new Promise(function (resolve, reject) {
237 resolve([{
j2fcf4e52021-03-11 14:37:26 -0800238 title: "Assignments Graded",
j7940eec2020-12-28 14:00:41 -0600239 postedAt: new Date().getDate(),
j36579d22022-01-15 20:12:01 -0800240 body: "<p>This is a demo announcement</p>"
j7940eec2020-12-28 14:00:41 -0600241 }]);
242 });
243}
244
245//Fetches homepage data from Canvas
246dtpsLMS.fetchHomepage = function (classID) {
247 return new Promise(function (resolve, reject) {
248 resolve(`<p>This homepage is for demonstration purposes only</p>`);
249 });
250}
251
252//Fetches discussion thread data from Canvas
253dtpsLMS.fetchDiscussionThreads = function (classID) {
254 return new Promise(function (resolve, reject) {
255 resolve([
256 {
257 title: "Demo Discussion",
258 id: "1",
259 locked: true
260 }
261 ])
262 })
263}
264
265//Fetches discussion thread posts from Canvas
266dtpsLMS.fetchDiscussionPosts = function (classID, threadID) {
267 return new Promise(function (resolve, reject) {
268 resolve({
269 title: "Demo Discussion",
270 id: "1",
271 locked: true,
272 requireInitialPost: false,
273 posts: [
274 {
275 id: "1",
276 body: `<p>This discussion is for demonstration purposes only</p>`,
277 postedAt: new Date(),
278 author: {
279 name: "Demo Teacher",
280 id: "2",
281 photoURL: "https://powerplus.app/logo.png"
282 }
283 }
284 ]
285 })
286 })
287}
288
289//Fetches pages list data from Canvas
290dtpsLMS.fetchPages = function (classID) {
291 return new Promise(function (resolve, reject) {
292 resolve([
293 {
294 title: "Demo Page",
295 id: "1"
296 }
297 ])
298 })
299}
300
301//Fetches pages list data from Canvas
302dtpsLMS.fetchPageContent = function (classID, pageID) {
303 return new Promise(function (resolve, reject) {
304 resolve({
305 title: "Demo Page",
306 id: "1",
307 updatedAt: new Date(),
308 content: `<p>This page is for demonstration purposes only</p>`,
309 author: {
310 name: "Demo Teacher",
311 id: "2",
312 photoURL: "https://powerplus.app/logo.png"
313 }
314 });
315 })
316}
317
j7940eec2020-12-28 14:00:41 -0600318//Load Power+
j36579d22022-01-15 20:12:01 -0800319jQuery.getScript(window.dtpsBaseURL + "/scripts/core.js");