File tree Expand file tree Collapse file tree 1 file changed +21
-13
lines changed
shared/src/components/question Expand file tree Collapse file tree 1 file changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -135,19 +135,27 @@ class Question extends React.Component {
135135 }
136136
137137 if ( this . hasSolution ( ) ) {
138- solution =
139- < div className = "detailed-solution" >
140- < div className = "header" >
141- Detailed solution:
142- </ div >
143- < ArbitraryHtmlAndMath
144- { ...htmlAndMathProps }
145- className = "solution"
146- block = { true }
147- html = { map ( collaborator_solutions . filter (
148- ( sol ) => sol . solution_type === 'detailed'
149- ) , 'content_html' ) . join ( '' ) } />
150- </ div > ;
138+ const solutionTypes = [ 'detailed' , 'summary' ] ;
139+ solution = solutionTypes . map ( ( type ) => {
140+ const solutionHTML = collaborator_solutions
141+ . filter ( ( sol ) => sol . solution_type === type )
142+ . map ( ( sol ) => sol . content_html )
143+ . join ( '' ) ;
144+ return solutionHTML === ''
145+ ? null
146+ : (
147+ < div className = "detailed-solution" >
148+ < div className = "header" >
149+ { `${ type [ 0 ] . toUpperCase ( ) } ${ type . slice ( 1 ) } solution:` }
150+ </ div >
151+ < ArbitraryHtmlAndMath
152+ { ...htmlAndMathProps }
153+ className = "solution"
154+ block = { true }
155+ html = { solutionHTML } />
156+ </ div >
157+ ) ;
158+ } )
151159 }
152160
153161 return (
You can’t perform that action at this time.
0 commit comments