@@ -4,8 +4,8 @@ const lti = require('ims-lti')
4
4
const jwt = require ( 'jsonwebtoken' ) ;
5
5
const jwtMiddleware = require ( 'express-jwt' ) ;
6
6
const level = require ( 'level' )
7
- const { SITE_NAME } = require ( "../common/global-config" ) ;
8
7
const { lessonMapping, numericalHashMapping } = require ( "./legacy-lesson-mapping" ) ;
8
+ const { SITE_NAME } = require ( "@common/global-config" )
9
9
const { calculateSemester } = require ( "../src/util/calculateSemester.js" ) ;
10
10
const to = require ( "await-to-js" ) . default ;
11
11
const path = require ( "path" ) ;
@@ -15,7 +15,7 @@ const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestor
15
15
const serviceAccount = require ( './oatutor-firebase-adminsdk.json' ) ;
16
16
17
17
initializeApp ( {
18
- credential : cert ( serviceAccount )
18
+ credential : cert ( serviceAccount )
19
19
} ) ;
20
20
21
21
const firestoredb = getFirestore ( ) ;
@@ -304,10 +304,10 @@ app.post('/postScore', jwtMiddleware({
304
304
// const submissionsRef = firestoredb.collection('development_problemSubmissions');
305
305
306
306
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' ) ;
311
311
const result = await queryRef . get ( ) ;
312
312
313
313
var formattedText = `
@@ -334,11 +334,11 @@ app.post('/postScore', jwtMiddleware({
334
334
335
335
// get time of first action
336
336
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 ) ;
342
342
const firstResult = await firstQueryRef . get ( ) ;
343
343
344
344
firstResult . forEach ( action => {
@@ -349,9 +349,9 @@ app.post('/postScore', jwtMiddleware({
349
349
350
350
// get time of last action before this lesson
351
351
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 ) ;
355
355
const prevResult = await prevQueryRef . get ( ) ;
356
356
357
357
if ( prevResult . size == 0 ) {
@@ -389,7 +389,7 @@ app.post('/postScore', jwtMiddleware({
389
389
var correct = null ;
390
390
if ( data [ "isCorrect" ] || data [ "hintIsCorrect" ] ) {
391
391
correct = true ;
392
- } else if ( data [ "isCorrect" ] == false || data [ "hintIsCorrect" ] == false ) {
392
+ } else if ( data [ "isCorrect" ] == false || data [ "hintIsCorrect" ] == false ) {
393
393
correct = false ;
394
394
}
395
395
@@ -425,14 +425,14 @@ app.post('/postScore', jwtMiddleware({
425
425
<h1> Component Breakdown </h1>
426
426
<h4> Overall score: ${ Math . round ( score * 10000 ) / 100 } %</h4>
427
427
${ 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, ' ' ) } :
431
431
${ "▮" . repeat ( ( + components [ key ] ) * 10 ) }
432
432
${ "▯" . repeat ( 10 - ( + components [ key ] ) * 10 ) }
433
433
</p>`
434
- )
435
- . join ( "" ) }
434
+ )
435
+ . join ( "" ) }
436
436
<h4 style="padding-top: 10px"> Problem Stats </h4>
437
437
${ formattedText }
438
438
` ;
0 commit comments