@@ -32,15 +32,11 @@ interface ConceptLevelQuestions {
32
32
lowerLevelQuestions : GameboardItem [ ] ;
33
33
}
34
34
35
- function categoriseConceptQuestions ( conceptQuestions : GameboardItem [ ] ) : ConceptLevelQuestions | null {
36
- let result = null ;
37
- if ( conceptQuestions !== null ) {
38
- result = {
39
- upperLevelQuestions : conceptQuestions . filter ( question => getFastTrackLevel ( question . tags ) === 'ft_upper' ) ,
40
- lowerLevelQuestions : conceptQuestions . filter ( question => getFastTrackLevel ( question . tags ) === 'ft_lower' ) ,
41
- } ;
42
- }
43
- return result ;
35
+ function categoriseConceptQuestions ( conceptQuestions : GameboardItem [ ] ) : ConceptLevelQuestions {
36
+ return {
37
+ upperLevelQuestions : conceptQuestions . filter ( question => getFastTrackLevel ( question . tags ) === 'ft_upper' ) ,
38
+ lowerLevelQuestions : conceptQuestions . filter ( question => getFastTrackLevel ( question . tags ) === 'ft_lower' ) ,
39
+ } ;
44
40
}
45
41
46
42
interface AugmentedQuestion {
@@ -100,8 +96,8 @@ function generateHexagonPoints(halfWidth: number, quarterHeight: number) {
100
96
}
101
97
102
98
103
- export function FastTrackProgress ( { doc, search} : { doc : IsaacFastTrackQuestionPageDTO ; search : string } ) {
104
- const { questionHistory : qhs } : { questionHistory ?: string } = queryString . parse ( search ) ;
99
+ export function FastTrackProgress ( { doc, search} : { doc : IsaacFastTrackQuestionPageDTO ; search : string } ) {
100
+ const { questionHistory : qhs } : { questionHistory ?: string } = queryString . parse ( search ) ;
105
101
const questionHistory = qhs ? qhs . split ( "," ) : [ ] ;
106
102
107
103
const dispatch = useDispatch ( ) ;
@@ -118,9 +114,10 @@ export function FastTrackProgress({doc, search}: { doc: IsaacFastTrackQuestionPa
118
114
const hexagonQuarterHeight = hexagonUnitLength / Math . sqrt ( 3 ) ;
119
115
const progressBarPadding = deviceSize !== 'xs' ? 5 : 1 ;
120
116
121
- const conceptQuestions = gameboardMaybeNull && fasttrackConcepts && fasttrackConcepts . gameboardId === gameboardMaybeNull . id && fasttrackConcepts . concept === doc . title ?
122
- fasttrackConcepts . items
123
- : null ;
117
+ const conceptQuestions =
118
+ gameboardMaybeNull && fasttrackConcepts && fasttrackConcepts . gameboardId === gameboardMaybeNull . id && fasttrackConcepts . concept === doc . title ?
119
+ fasttrackConcepts . items
120
+ : null ;
124
121
125
122
useEffect ( ( ) => {
126
123
if ( conceptQuestions === null && gameboardMaybeNull ) {
@@ -245,9 +242,6 @@ export function FastTrackProgress({doc, search}: { doc: IsaacFastTrackQuestionPa
245
242
}
246
243
247
244
function orderConceptQuestionsById ( unorderedConceptQuestions : ConceptLevelQuestions ) {
248
- if ( unorderedConceptQuestions === null ) {
249
- throw new Error ( "No unoderedConceptQuestions" ) ;
250
- }
251
245
let result : ConceptLevelQuestions = { upperLevelQuestions : [ ] , lowerLevelQuestions : [ ] } ;
252
246
for ( let conceptLevelName of conceptLevels ) {
253
247
result [ conceptLevelName ] = unorderedConceptQuestions [ conceptLevelName ] . slice ( ) . sort ( ( a : { id ?: string } , b : { id ?: string } ) => a . id === b . id ? 0 : ( a . id === undefined || ( b . id !== undefined && a . id > b . id ) ) ? 1 : - 1 ) ;
@@ -393,7 +387,7 @@ export function FastTrackProgress({doc, search}: { doc: IsaacFastTrackQuestionPa
393
387
}
394
388
result += line ( sourceHexagonX + hexagon . x . center , hexagon . y . center ) ;
395
389
396
- // Horrizontal connection
390
+ // Horizontal connection
397
391
if ( Math . abs ( sourceIndex - targetIndex ) > 1 ) {
398
392
result += line ( targetHexagonX + hexagon . x . center , hexagon . y . center ) ;
399
393
}
@@ -409,16 +403,18 @@ export function FastTrackProgress({doc, search}: { doc: IsaacFastTrackQuestionPa
409
403
}
410
404
411
405
function createQuestionHexagon ( question : AugmentedQuestion ) {
412
- let fillColour = 'none' ;
413
- if ( question . isCompleted ) {
414
- fillColour = question . isCurrentQuestion ? hexagon . base . fill . completedColour : hexagon . base . fill . deselectedCompletedColour ;
415
- } else {
416
- fillColour = question . isCurrentQuestion ? hexagon . base . fill . selectedColour : hexagon . base . fill . deselectedColour ;
417
- }
406
+ const fillColour = ( question . isCompleted ) ?
407
+ question . isCurrentQuestion ? hexagon . base . fill . completedColour : hexagon . base . fill . deselectedCompletedColour :
408
+ question . isCurrentQuestion ? hexagon . base . fill . selectedColour : hexagon . base . fill . deselectedColour ;
418
409
419
410
return < Link to = { question . href } >
420
411
< title > { question . title + ( question . isCurrentQuestion ? ' (Current)' : '' ) } </ title >
421
- { generateHexagon ( [ true ] , allVisible => allVisible === true , hexagon . base , fillColour , true ) }
412
+ { generateHexagon (
413
+ [ true ] ,
414
+ allVisible => allVisible ,
415
+ hexagon . base ,
416
+ fillColour ,
417
+ true ) }
422
418
423
419
{ generateHexagon (
424
420
question . questionPartStates ,
@@ -427,8 +423,9 @@ export function FastTrackProgress({doc, search}: { doc: IsaacFastTrackQuestionPa
427
423
'none' ,
428
424
false ) }
429
425
430
- { question . isCompleted ? generateCompletionTick ( question . isCurrentQuestion )
431
- : generateHexagonTitle ( question . hexagonTitle , question . isCurrentQuestion ) }
426
+ { question . isCompleted ?
427
+ generateCompletionTick ( question . isCurrentQuestion ) :
428
+ generateHexagonTitle ( question . hexagonTitle , question . isCurrentQuestion ) }
432
429
</ Link > ;
433
430
}
434
431
@@ -480,22 +477,17 @@ export function FastTrackProgress({doc, search}: { doc: IsaacFastTrackQuestionPa
480
477
< svg id = "ft-progress" width = "100%" height = { progressBarHeight } >
481
478
< g id = "progress-bar-padding" transform = { `translate(${ progressBarPadding } , ${ progressBarPadding } )` } >
482
479
< g id = "concept-connections" >
483
- { progress . connections . topTenToUpper . length > 0 &&
484
- createConceptConnectionRow ( progress . connections . topTenToUpper , 'top-ten-to-upper' , 0 )
485
- }
486
- { progress . connections . upperToLower . length > 0 &&
487
- createConceptConnectionRow ( progress . connections . upperToLower , 'upper-to-lower' , 1 )
488
- }
489
-
480
+ { progress . connections . topTenToUpper . length &&
481
+ createConceptConnectionRow ( progress . connections . topTenToUpper , 'top-ten-to-upper' , 0 ) }
482
+ { progress . connections . upperToLower . length &&
483
+ createConceptConnectionRow ( progress . connections . upperToLower , 'upper-to-lower' , 1 ) }
490
484
</ g >
491
485
< g id = "question-hexagons" >
492
486
{ createQuestionRow ( progress . questions . topTen , 'top_ten' , 0 ) }
493
- { progress . questions . upper . length > 0 &&
494
- createQuestionRow ( progress . questions . upper , 'upper' , 1 )
495
- }
496
- { progress . questions . lower . length > 0 &&
497
- createQuestionRow ( progress . questions . lower , 'lower' , 2 )
498
- }
487
+ { progress . questions . upper . length &&
488
+ createQuestionRow ( progress . questions . upper , 'upper' , 1 ) }
489
+ { progress . questions . lower . length &&
490
+ createQuestionRow ( progress . questions . lower , 'lower' , 2 ) }
499
491
</ g >
500
492
</ g >
501
493
</ svg >
@@ -512,4 +504,4 @@ export function FastTrackProgress({doc, search}: { doc: IsaacFastTrackQuestionPa
512
504
if ( ! categorisedConceptQuestions ) return null ;
513
505
const progress = evaluateProgress ( categorisedConceptQuestions , questionHistory ) ;
514
506
return renderProgress ( progress ) ;
515
- }
507
+ }
0 commit comments