Skip to content

Commit 2916df9

Browse files
remo5000ning-y
authored andcommitted
Use Markdown to render MCQ content (#294)
* Use JSX.Element for notifications * Use Markdown for MCQ content and hints * Update mocks
1 parent 60e632e commit 2916df9

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/components/workspace/MCQChooser.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Button, Card, Intent, Text } from '@blueprintjs/core'
1+
import { Button, Card, Intent } from '@blueprintjs/core'
22
import * as React from 'react'
33

44
import { showSuccessMessage, showWarningMessage } from '../../utils/notification'
55
import { IMCQQuestion } from '../assessment/assessmentShape'
6+
import Markdown from '../commons/Markdown'
67

78
export interface IMCQChooserProps {
89
mcq: IMCQQuestion
@@ -30,7 +31,7 @@ class MCQChooser extends React.PureComponent<IMCQChooserProps, State> {
3031
onClick={this.onButtonClickFactory(i)}
3132
minimal={true}
3233
>
33-
<Text className="Text"> {choice.content} </Text>
34+
<Markdown content={choice.content} />
3435
</Button>
3536
))
3637
return (
@@ -61,10 +62,11 @@ class MCQChooser extends React.PureComponent<IMCQChooserProps, State> {
6162
}
6263
const shouldDisplayMessage = this.props.mcq.solution && this.props.mcq.choices[i].hint
6364
if (shouldDisplayMessage) {
65+
const hintElement = <Markdown content={this.props.mcq.choices[i].hint!} />
6466
if (i === this.props.mcq.solution) {
65-
showSuccessMessage(this.props.mcq.choices[i].hint!, 4000)
67+
showSuccessMessage(hintElement, 4000)
6668
} else {
67-
showWarningMessage(this.props.mcq.choices[i].hint!, 4000)
69+
showWarningMessage(hintElement, 4000)
6870
}
6971
}
7072
}

src/mocks/assessmentAPI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ What's your favourite dinner food?
194194
'This is the 3rd question. Oddly enough, it is an ungraded MCQ question that uses the curves library! Option C has a null hint!',
195195
choices: [
196196
{
197-
content: 'A',
198-
hint: 'hint A'
197+
content: '**Option** `A`',
198+
hint: '_hint_ A is `here`'
199199
},
200200
{
201-
content: 'B',
201+
content: '### B',
202202
hint: 'hint B'
203203
},
204204
{

src/utils/notification.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const notification = Toaster.create({
44
position: Position.TOP
55
})
66

7-
export const showSuccessMessage = (message: string, timeout: number = 2000) => {
7+
export const showSuccessMessage = (message: string | JSX.Element, timeout: number = 2000) => {
88
notification.show({
99
intent: Intent.SUCCESS,
1010
message,
1111
timeout
1212
})
1313
}
1414

15-
export const showWarningMessage = (message: string, timeout: number = 2000) => {
15+
export const showWarningMessage = (message: string | JSX.Element, timeout: number = 2000) => {
1616
notification.show({
1717
intent: Intent.WARNING,
1818
message,

0 commit comments

Comments
 (0)