@@ -77,7 +77,7 @@ const exerciseWithStepDataProps: ExerciseWithStepDataProps = {
77
77
canUpdateCurrentStep : false ,
78
78
} ;
79
79
80
- const exerciseWithQuestionStatesProps = ( uid ?: string ) : ExerciseWithQuestionStatesProps => {
80
+ const exerciseWithQuestionStatesProps = ( uid ?: string , correctness ?: string ) : ExerciseWithQuestionStatesProps => {
81
81
return {
82
82
exercise : {
83
83
uid : uid || '1@1' ,
@@ -104,11 +104,11 @@ const exerciseWithQuestionStatesProps = (uid?: string): ExerciseWithQuestionStat
104
104
is_answer_order_important : false ,
105
105
answers : [ {
106
106
id : '1' ,
107
- correctness : undefined ,
107
+ correctness : correctness ,
108
108
content_html : 'True' ,
109
109
} , {
110
110
id : '2' ,
111
- correctness : undefined ,
111
+ correctness : correctness ,
112
112
content_html : 'False' ,
113
113
} ] ,
114
114
} ] ,
@@ -146,12 +146,6 @@ const exerciseWithQuestionStatesProps = (uid?: string): ExerciseWithQuestionStat
146
146
}
147
147
} ;
148
148
149
- const exerciseWithOverlayProps = ( overlayChildren : React . ReactNode ) => {
150
- return {
151
- overlayChildren,
152
- } ;
153
- }
154
-
155
149
type TextResizerValue = - 2 | - 1 | 0 | 1 | 2 | 3 ;
156
150
const textResizerScales = [ 0.75 , 0.9 , 1 , 1.25 , 1.5 , 2 ] ;
157
151
const textResizerValues : TextResizerValue [ ] = [ - 2 , - 1 , 0 , 1 , 2 , 3 ] ;
@@ -657,12 +651,12 @@ bitterness. The discriminant <span data-math='b^2 - 4ac'></span> could perhaps a
657
651
answers : [
658
652
{
659
653
id : '1' ,
660
- correctness : undefined ,
654
+ correctness : '1.0' ,
661
655
content_html : `<span data-math='\\sqrt[3]{\\text{Apple}}'></span>` ,
662
656
} ,
663
657
{
664
658
id : '2' ,
665
- correctness : undefined ,
659
+ correctness : '1.0' ,
666
660
content_html : `<span data-math='\\frac{\\text{Banana}^{2}}{4}'></span>` ,
667
661
} ,
668
662
] ,
@@ -677,12 +671,12 @@ bitterness. The discriminant <span data-math='b^2 - 4ac'></span> could perhaps a
677
671
answers : [
678
672
{
679
673
id : '1' ,
680
- correctness : undefined ,
674
+ correctness : '1.0' ,
681
675
content_html : `<span data-math='e^{\\text{Blue}}'></span>` ,
682
676
} ,
683
677
{
684
678
id : '2' ,
685
- correctness : undefined ,
679
+ correctness : '1.0' ,
686
680
content_html : `<span data-math='\\frac{\\pi}{2} + \\text{Red}'></span>` ,
687
681
} ,
688
682
] ,
@@ -731,12 +725,12 @@ export const PreviewCard = () => {
731
725
const props1 : ExerciseWithQuestionStatesProps = {
732
726
...exerciseWithQuestionStatesProps ( ) ,
733
727
questionStates : {
734
- '1 ' : {
728
+ '320733 ' : {
735
729
available_points : '1.0' ,
736
730
is_completed : true ,
737
731
answer_id_order : [ '1' , '2' , '3' , '4' ] ,
738
732
answer_id : randomlyCorrectAnswer ,
739
- free_response : '' ,
733
+ free_response : 'Feedback info ' ,
740
734
feedback_html : '' ,
741
735
correct_answer_id : randomlyCorrectAnswer . toString ( ) ,
742
736
correct_answer_feedback_html :
@@ -804,18 +798,24 @@ export const PreviewCard = () => {
804
798
{
805
799
id : 832300 ,
806
800
content_html : 'hypothalamus' ,
801
+ correctness : undefined ,
802
+ feedback_html : 'Feedback response' ,
807
803
} ,
808
804
{
809
805
id : 832303 ,
810
806
content_html : 'medulla oblongata' ,
807
+ correctness : '1.0' ,
808
+ feedback_html : 'Feedback response' ,
811
809
} ,
812
810
{
813
811
id : 832301 ,
814
812
content_html : 'corpus callosum' ,
813
+ correctness : undefined ,
815
814
} ,
816
815
{
817
816
id : 832302 ,
818
817
content_html : 'cerebellum' ,
818
+ correctness : undefined ,
819
819
} ,
820
820
] ,
821
821
hints : [ ] ,
@@ -828,9 +828,17 @@ export const PreviewCard = () => {
828
828
} ,
829
829
} ;
830
830
831
+ const [ showFeedback , setShowFeedback ] = React . useState < boolean > ( false ) ;
832
+
831
833
return (
832
834
< TextResizerProvider >
833
- < Exercise { ...props1 } className = 'preview-card' previewMode />
835
+ < button
836
+ onClick = { ( ) => setShowFeedback ( prev => ! prev ) } > { `Turn ${ showFeedback ? 'off' : 'on' } feedback` }
837
+ </ button >
838
+ < ExercisePreview
839
+ exercise = { props1 . exercise }
840
+ showAllFeedback = { showFeedback }
841
+ />
834
842
</ TextResizerProvider >
835
843
) ;
836
844
} ;
@@ -839,7 +847,6 @@ export const OverlayCard = () => {
839
847
const randomlyCorrectAnswer = Math . floor ( Math . random ( ) * 3 ) + 1 ;
840
848
const props1 : ExerciseWithQuestionStatesProps = {
841
849
...exerciseWithQuestionStatesProps ( '1@123' ) ,
842
- ...exerciseWithOverlayProps ( < button > Overlay</ button > ) ,
843
850
questionStates : {
844
851
'1' : {
845
852
available_points : '1.0' ,
@@ -938,17 +945,8 @@ export const OverlayCard = () => {
938
945
} ,
939
946
} ;
940
947
941
- const [ buttonVariant , setButtonVariant ] = React . useState < 'include' | 'remove' > ( 'include' ) ;
942
-
943
948
const props2 : ExerciseWithQuestionStatesProps = {
944
- ...exerciseWithQuestionStatesProps ( '1@321' ) ,
945
- ...exerciseWithOverlayProps (
946
- < IncludeRemoveQuestion
947
- buttonVariant = { buttonVariant }
948
- onIncludeHandler = { ( ) => setButtonVariant ( 'remove' ) }
949
- onRemoveHandler = { ( ) => setButtonVariant ( 'include' ) }
950
- />
951
- ) ,
949
+ ...exerciseWithQuestionStatesProps ( '1@321' , '1.0' ) ,
952
950
questionStates : {
953
951
'1' : {
954
952
available_points : '1.0' ,
@@ -976,29 +974,41 @@ export const OverlayCard = () => {
976
974
const includeHandler = ( exerciseUid : string ) => setSelectedQuestions ( previous => previous . concat ( exerciseUid ) ) ;
977
975
const removeHandler = ( exerciseUid : string ) => setSelectedQuestions ( previous => previous . filter ( ( id ) => id !== exerciseUid ) ) ;
978
976
977
+
978
+ const includeRemoveQuestionComponent1 =
979
+ < IncludeRemoveQuestion
980
+ buttonVariant = { selectedQuestions . includes ( props1 . exercise . uid ) ? 'remove' : 'include' }
981
+ onIncludeHandler = { ( ) => includeHandler ( props1 . exercise . uid ) }
982
+ onRemoveHandler = { ( ) => removeHandler ( props1 . exercise . uid ) }
983
+ onClickDetails = { ( ) => setShowDetails1 ( ( previous ) => ! previous ) }
984
+ /> ;
985
+
986
+ const includeRemoveQuestionComponent2 =
987
+ < IncludeRemoveQuestion
988
+ buttonVariant = { selectedQuestions . includes ( props2 . exercise . uid ) ? 'remove' : 'include' }
989
+ onIncludeHandler = { ( ) => includeHandler ( props2 . exercise . uid ) }
990
+ onRemoveHandler = { ( ) => removeHandler ( props2 . exercise . uid ) }
991
+ onClickDetails = { ( ) => setShowDetails2 ( ( previous ) => ! previous ) }
992
+ /> ;
993
+
979
994
return (
980
995
< TextResizerProvider >
981
996
< h2 > Exercise cards</ h2 >
982
- < Exercise { ...props1 } className = 'preview-card' previewMode />
983
- < Exercise { ...props2 } className = 'preview-card' previewMode />
997
+ < Exercise { ...props1 } overlayChildren = { < button > Overlay </ button > } className = 'preview-card' previewMode />
998
+ < Exercise { ...props2 } overlayChildren = { < button > Overlay </ button > } className = 'preview-card' previewMode />
984
999
< h2 > Exercise Preview cards</ h2 >
985
1000
{ showDetails1 && < h2 > Details 1!</ h2 > }
986
- < ExercisePreview
987
- selected = { selectedQuestions . includes ( props1 . exercise . uid ) }
988
- onIncludeHandler = { ( ) => includeHandler ( props1 . exercise . uid ) }
989
- onRemoveHandler = { ( ) => removeHandler ( props1 . exercise . uid ) }
990
- onClickDetails = { ( ) => setShowDetails1 ( ( previous ) => ! previous ) }
991
- enableOverlay
992
- exercise = { props1 . exercise }
1001
+ < ExercisePreview
1002
+ selected = { selectedQuestions . includes ( props1 . exercise . uid ) }
1003
+ overlayChildren = { includeRemoveQuestionComponent1 }
1004
+ exercise = { props1 . exercise }
993
1005
/>
994
1006
{ showDetails2 && < h2 > Details 2!</ h2 > }
995
- < ExercisePreview
996
- selected = { selectedQuestions . includes ( props2 . exercise . uid ) }
997
- onIncludeHandler = { ( ) => includeHandler ( props2 . exercise . uid ) }
998
- onRemoveHandler = { ( ) => removeHandler ( props2 . exercise . uid ) }
999
- onClickDetails = { ( ) => setShowDetails2 ( ( previous ) => ! previous ) }
1000
- enableOverlay
1001
- exercise = { props2 . exercise }
1007
+ < ExercisePreview
1008
+ selected = { selectedQuestions . includes ( props2 . exercise . uid ) }
1009
+ overlayChildren = { includeRemoveQuestionComponent2 }
1010
+ exercise = { props2 . exercise }
1011
+ showAllFeedback
1002
1012
/>
1003
1013
</ TextResizerProvider >
1004
1014
) ;
0 commit comments