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'
1010import Workspace , { WorkspaceProps } from '../workspace'
1111import { ControlBarProps } from '../workspace/ControlBar'
1212import { SideContentProps } from '../workspace/side-content'
13+ import ToneMatrix from '../workspace/side-content/ToneMatrix'
1314import {
1415 IAssessment ,
1516 IMCQQuestion ,
@@ -228,6 +229,15 @@ class AssessmentWorkspace extends React.Component<
228229 body : < Markdown content = { comment } />
229230 } )
230231 }
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+ }
231241 return {
232242 activeTab : props . activeTab ,
233243 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 = {
180180 globals : mockGlobals
181181}
182182
183+ const mockToneMatrixLibrary : Library = {
184+ chapter : 1 ,
185+ external : {
186+ name : ExternalLibraryNames . SOUND ,
187+ symbols : [ 'get_matrix' ]
188+ } ,
189+ globals : mockGlobals
190+ }
191+
183192export const mockAssessmentQuestions : Array < IProgrammingQuestion | IMCQQuestion > = [
184193 {
185194 answer : 'display("answer1");' ,
@@ -260,6 +269,15 @@ What's your favourite dinner food?
260269 library : mockCurveLibrary ,
261270 type : 'mcq' ,
262271 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'
263281 }
264282]
265283
You can’t perform that action at this time.
0 commit comments