Skip to content
Snippets Groups Projects
Commit 14b87197 authored by chris's avatar chris
Browse files

fix

parent f12c9684
No related branches found
No related tags found
1 merge request!411add readonly state to multiple choice ones
...@@ -170,7 +170,7 @@ const Hhmi = () => { ...@@ -170,7 +170,7 @@ const Hhmi = () => {
ref={editorRef} ref={editorRef}
customValues={{ showFeedBack: submitted, testMode }} customValues={{ showFeedBack: submitted, testMode }}
fileUpload={file => renderImage(file)} fileUpload={file => renderImage(file)}
value={content} // value={content}
readonly={readOnly} readonly={readOnly}
layout={HhmiLayout} layout={HhmiLayout}
onChange={source => console.log(source)} onChange={source => console.log(source)}
......
...@@ -44,7 +44,7 @@ const DropdownStyled = styled(Dropdown)` ...@@ -44,7 +44,7 @@ const DropdownStyled = styled(Dropdown)`
`; `;
const DropComponent = ({ getPos, node, view }) => { const DropComponent = ({ getPos, node, view }) => {
const [selectedOption, setSelectedOption] = useState(undefined); const [selectedOption, setSelectedOption] = useState(node.attrs.correct);
const context = useContext(WaxContext); const context = useContext(WaxContext);
const { const {
...@@ -52,7 +52,6 @@ const DropComponent = ({ getPos, node, view }) => { ...@@ -52,7 +52,6 @@ const DropComponent = ({ getPos, node, view }) => {
} = context; } = context;
const onChange = option => { const onChange = option => {
setSelectedOption(option);
const allNodes = getNodes(main); const allNodes = getNodes(main);
allNodes.forEach(singleNode => { allNodes.forEach(singleNode => {
if (singleNode.node.attrs.id === node.attrs.id) { if (singleNode.node.attrs.id === node.attrs.id) {
...@@ -68,14 +67,13 @@ const DropComponent = ({ getPos, node, view }) => { ...@@ -68,14 +67,13 @@ const DropComponent = ({ getPos, node, view }) => {
}); });
}; };
useEffect(() => { // useEffect(() => {
const value = selectedOption ? selectedOption.value : ''; // const found = find(node.attrs.options, { value: node.attrs.correct });
const found = find(node.attrs.options, { value });
if (!found) { // if (found) {
setSelectedOption(undefined); // setSelectedOption(found);
} // }
}, [node.attrs.options]); // }, [node.attrs.options]);
const MultipleDropDown = useMemo( const MultipleDropDown = useMemo(
() => ( () => (
......
...@@ -200,6 +200,8 @@ export default ({ node, view, getPos }) => { ...@@ -200,6 +200,8 @@ export default ({ node, view, getPos }) => {
}); });
}; };
const { testMode } = customProps;
return ( return (
<MatchingWrapper> <MatchingWrapper>
<span>Matching</span> <span>Matching</span>
...@@ -252,8 +254,7 @@ export default ({ node, view, getPos }) => { ...@@ -252,8 +254,7 @@ export default ({ node, view, getPos }) => {
)} )}
</CreateOptions> </CreateOptions>
)} )}
{(!(readOnly && !customProps.showFeedBack) || {!testMode && (
(readOnly && !customProps.testMode && !customProps.showFeedBack)) && (
<FeedbackComponent <FeedbackComponent
getPos={getPos} getPos={getPos}
node={node} node={node}
......
...@@ -8,7 +8,7 @@ import { Icon } from 'wax-prosemirror-components'; ...@@ -8,7 +8,7 @@ import { Icon } from 'wax-prosemirror-components';
import { WaxContext } from 'wax-prosemirror-core'; import { WaxContext } from 'wax-prosemirror-core';
import EditorComponent from './EditorComponent'; import EditorComponent from './EditorComponent';
import DropDownComponent from './DropDownComponent'; import DropDownComponent from './DropDownComponent';
import ReadOnlyDropDownComponent from './ReadOnlyDropDownComponent'; import TestModeDropDownComponent from './TestModeDropDownComponent';
const Option = styled.div` const Option = styled.div`
display: flex; display: flex;
...@@ -139,7 +139,7 @@ export default ({ node, view, getPos }) => { ...@@ -139,7 +139,7 @@ export default ({ node, view, getPos }) => {
)} )}
{readOnly && testMode && !showFeedBack && ( {readOnly && testMode && !showFeedBack && (
<ReadOnlyDropDownComponent getPos={getPos} node={node} view={view} /> <TestModeDropDownComponent getPos={getPos} node={node} view={view} />
)} )}
{readOnly && showFeedBack && ( {readOnly && showFeedBack && (
......
...@@ -41,7 +41,7 @@ const DropdownStyled = styled(Dropdown)` ...@@ -41,7 +41,7 @@ const DropdownStyled = styled(Dropdown)`
} }
`; `;
const ReadOnlyDropDownComponent = ({ getPos, node, view }) => { const TestModeDropDownComponent = ({ getPos, node, view }) => {
const [selectedOption, setSelectedOption] = useState(undefined); const [selectedOption, setSelectedOption] = useState(undefined);
const context = useContext(WaxContext); const context = useContext(WaxContext);
...@@ -97,7 +97,7 @@ const ReadOnlyDropDownComponent = ({ getPos, node, view }) => { ...@@ -97,7 +97,7 @@ const ReadOnlyDropDownComponent = ({ getPos, node, view }) => {
return ReadOnlyMultipleDropDown; return ReadOnlyMultipleDropDown;
}; };
export default ReadOnlyDropDownComponent; export default TestModeDropDownComponent;
const getNodes = view => { const getNodes = view => {
return DocumentHelpers.findInlineNodes(view.state.doc); return DocumentHelpers.findInlineNodes(view.state.doc);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment