Skip to content

Commit c9d584f

Browse files
committed
fix: lti-middleware usage of global config
1 parent e3065c7 commit c9d584f

File tree

6 files changed

+41
-22
lines changed

6 files changed

+41
-22
lines changed

common/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "common",
3+
"version": "1.0.0",
4+
"main": "global-config.js",
5+
"dependencies": {
6+
}
7+
}

jsconfig.paths.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"compilerOptions": {
33
"baseUrl": ".",
44
"paths": {
5-
"@common/*": ["common/*"],
65
"@generated/*": ["generated/*"],
76
"@components/*": ["src/components/*"]
87
}

lti-middleware/app.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const lti = require('ims-lti')
44
const jwt = require('jsonwebtoken');
55
const jwtMiddleware = require('express-jwt');
66
const level = require('level')
7-
const { SITE_NAME } = require("../common/global-config");
87
const { lessonMapping, numericalHashMapping } = require("./legacy-lesson-mapping");
8+
const { SITE_NAME } = require("@common/global-config")
99
const { calculateSemester } = require("../src/util/calculateSemester.js");
1010
const to = require("await-to-js").default;
1111
const path = require("path");
@@ -15,7 +15,7 @@ const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestor
1515
const serviceAccount = require('./oatutor-firebase-adminsdk.json');
1616

1717
initializeApp({
18-
credential: cert(serviceAccount)
18+
credential: cert(serviceAccount)
1919
});
2020

2121
const firestoredb = getFirestore();
@@ -304,10 +304,10 @@ app.post('/postScore', jwtMiddleware({
304304
// const submissionsRef = firestoredb.collection('development_problemSubmissions');
305305

306306
const queryRef = submissionsRef.where('semester', '==', semester)
307-
.where('lms_user_id', '==', lmsUserId)
308-
.where('lesson', '==', lesson)
309-
.orderBy('time_stamp', 'asc')
310-
.orderBy('problemID', 'asc');
307+
.where('lms_user_id', '==', lmsUserId)
308+
.where('lesson', '==', lesson)
309+
.orderBy('time_stamp', 'asc')
310+
.orderBy('problemID', 'asc');
311311
const result = await queryRef.get();
312312

313313
var formattedText = `
@@ -334,11 +334,11 @@ app.post('/postScore', jwtMiddleware({
334334

335335
// get time of first action
336336
const firstQueryRef = submissionsRef.where('semester', '==', semester)
337-
.where('lms_user_id', '==', lmsUserId)
338-
.where('lesson', '==', lesson)
339-
.orderBy('time_stamp', 'asc')
340-
.orderBy('problemID', 'asc')
341-
.limit(1);
337+
.where('lms_user_id', '==', lmsUserId)
338+
.where('lesson', '==', lesson)
339+
.orderBy('time_stamp', 'asc')
340+
.orderBy('problemID', 'asc')
341+
.limit(1);
342342
const firstResult = await firstQueryRef.get();
343343

344344
firstResult.forEach(action => {
@@ -349,9 +349,9 @@ app.post('/postScore', jwtMiddleware({
349349

350350
// get time of last action before this lesson
351351
const prevQueryRef = submissionsRef.where('lms_user_id', '==', lmsUserId)
352-
.where('time_stamp', '<', lastTime)
353-
.orderBy('time_stamp', 'desc')
354-
.limit(1);
352+
.where('time_stamp', '<', lastTime)
353+
.orderBy('time_stamp', 'desc')
354+
.limit(1);
355355
const prevResult = await prevQueryRef.get();
356356

357357
if (prevResult.size == 0) {
@@ -389,7 +389,7 @@ app.post('/postScore', jwtMiddleware({
389389
var correct = null;
390390
if (data["isCorrect"] || data["hintIsCorrect"]) {
391391
correct = true;
392-
} else if (data["isCorrect"] == false || data["hintIsCorrect"] == false ) {
392+
} else if (data["isCorrect"] == false || data["hintIsCorrect"] == false) {
393393
correct = false;
394394
}
395395

@@ -425,14 +425,14 @@ app.post('/postScore', jwtMiddleware({
425425
<h1> Component Breakdown </h1>
426426
<h4> Overall score: ${Math.round(score * 10000) / 100}%</h4>
427427
${Object
428-
.keys(components)
429-
.map((key, i) =>
430-
`<p>${i + 1}) ${key.replace(/_/g, ' ')}:
428+
.keys(components)
429+
.map((key, i) =>
430+
`<p>${i + 1}) ${key.replace(/_/g, ' ')}:
431431
${"&#9646;".repeat((+components[key]) * 10)}
432432
${"&#9647;".repeat(10 - (+components[key]) * 10)}
433433
</p>`
434-
)
435-
.join("")}
434+
)
435+
.join("")}
436436
<h4 style="padding-top: 10px"> Problem Stats </h4>
437437
${formattedText}
438438
`;

lti-middleware/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lti-middleware/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"ims-lti": "~3.0.2",
1212
"jsonwebtoken": "~8.5.1",
1313
"level": "~7.0.1",
14-
"lodash.memoize": "^4.1.2"
14+
"lodash.memoize": "^4.1.2",
15+
"@common/global-config": "file:../common"
1516
},
1617
"scripts": {
1718
"test": "echo \"Error: no test specified\" && exit 1"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@common/global-config": "file:./common",
67
"@material-ui/core": "~4.12.3",
78
"@material-ui/icons": "~4.11.2",
89
"algebrite": "~1.4.0",

0 commit comments

Comments
 (0)