forked from rage/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuiznator.js
More file actions
41 lines (37 loc) · 972 Bytes
/
Copy pathQuiznator.js
File metadata and controls
41 lines (37 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from "react"
import styled from "styled-components"
import withSimpleErrorBoundary from "../util/withSimpleErrorBoundary"
import { normalizeExerciseId } from "../util/strings"
const quizWrapper = styled.div`
code {
color: black !important;
}
`
class Quiznator extends React.Component {
componentDidMount() {
const { id } = this.props
if (!id || typeof window === "undefined") {
return
}
if (!window.loadQuiz) {
return
}
window.loadQuiz(document.getElementById(`unloaded-quiz-${id}`))
}
render() {
const { id } = this.props
if (!id) {
return <div>There should be quiz here but no quiz id is specified.</div>
}
return (
<quizWrapper id={normalizeExerciseId(`quiz-${id}`)}>
<div
id={`unloaded-quiz-${id}`}
className="quiz-plugin"
data-quiz-id={id}
/>
</quizWrapper>
)
}
}
export default withSimpleErrorBoundary(Quiznator)