File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import Markdown from '../commons/Markdown'
10
10
import Workspace , { WorkspaceProps } from '../workspace'
11
11
import { ControlBarProps } from '../workspace/ControlBar'
12
12
import { SideContentProps } from '../workspace/side-content'
13
+ import ToneMatrix from '../workspace/side-content/ToneMatrix'
13
14
import {
14
15
IAssessment ,
15
16
IMCQQuestion ,
@@ -228,6 +229,15 @@ class AssessmentWorkspace extends React.Component<
228
229
body : < Markdown content = { comment } />
229
230
} )
230
231
}
232
+
233
+ const functionsAttached = props . assessment ! . questions [ questionId ] . library . external . symbols
234
+ if ( functionsAttached . includes ( 'get_matrix' ) ) {
235
+ tabs . push ( {
236
+ label : `Tone Matrix` ,
237
+ icon : IconNames . GRID_VIEW ,
238
+ body : < ToneMatrix />
239
+ } )
240
+ }
231
241
return {
232
242
activeTab : props . activeTab ,
233
243
handleChangeActiveTab : props . handleChangeActiveTab ,
Original file line number Diff line number Diff line change
1
+ import { Button } from '@blueprintjs/core'
2
+ import * as React from 'react'
3
+
4
+ class ToneMatrix extends React . Component < { } , { } > {
5
+ private $container : HTMLElement | null
6
+
7
+ public shouldComponentUpdate ( ) {
8
+ return false
9
+ }
10
+
11
+ public componentDidMount ( ) {
12
+ if ( ( window as any ) . ToneMatrix ) {
13
+ ; ( window as any ) . ToneMatrix . initialise_matrix ( this . $container ! )
14
+ }
15
+ }
16
+
17
+ public handleClear ( ) {
18
+ ; ( window as any ) . ToneMatrix . clear_matrix ( )
19
+ }
20
+
21
+ public handleRandomise ( ) {
22
+ ; ( window as any ) . ToneMatrix . randomise_matrix ( )
23
+ }
24
+
25
+ public render ( ) {
26
+ return (
27
+ < div className = "sa-tone-matrix" >
28
+ < div className = "row" >
29
+ < div className = "controls col-xs-12 pt-dark pt-button-group" >
30
+ < Button id = "clear-matrix" onClick = { this . handleClear } >
31
+ Clear
32
+ </ Button >
33
+ < Button id = "randomise-matrix" onClick = { this . handleRandomise } >
34
+ Randomise
35
+ </ Button >
36
+ </ div >
37
+ </ div >
38
+ < div className = "row" >
39
+ < div className = "col-xs-12" ref = { r => ( this . $container = r ) } />
40
+ </ div >
41
+ </ div >
42
+ )
43
+ }
44
+ }
45
+
46
+ export default ToneMatrix
Original file line number Diff line number Diff line change @@ -180,6 +180,15 @@ const mockCurveLibrary: Library = {
180
180
globals : mockGlobals
181
181
}
182
182
183
+ const mockToneMatrixLibrary : Library = {
184
+ chapter : 1 ,
185
+ external : {
186
+ name : ExternalLibraryNames . SOUND ,
187
+ symbols : [ 'get_matrix' ]
188
+ } ,
189
+ globals : mockGlobals
190
+ }
191
+
183
192
export const mockAssessmentQuestions : Array < IProgrammingQuestion | IMCQQuestion > = [
184
193
{
185
194
answer : 'display("answer1");' ,
@@ -260,6 +269,15 @@ What's your favourite dinner food?
260
269
library : mockCurveLibrary ,
261
270
type : 'mcq' ,
262
271
solution : null
272
+ } ,
273
+ {
274
+ answer : null ,
275
+ comment : 'Wow you have come far! `Steady`' ,
276
+ content : 'You have reached the last question! Have some fun with the tone matrix...' ,
277
+ id : 1 ,
278
+ library : mockToneMatrixLibrary ,
279
+ solutionTemplate : '5th question mock solution template' ,
280
+ type : 'programming'
263
281
}
264
282
]
265
283
You can’t perform that action at this time.
0 commit comments