Skip to content
Snippets Groups Projects
Commit 5452d908 authored by chris's avatar chris
Browse files

submit matching

parent b3a1210e
No related branches found
No related tags found
No related merge requests found
...@@ -59,12 +59,10 @@ const initialContent = `<p class="paragraph"></p> ...@@ -59,12 +59,10 @@ const initialContent = `<p class="paragraph"></p>
<p class="paragraph">first <span id="16ec8f33-db5b-4839-9567-8aa73b776bcf" class="fill-the-gap" answer="">answer1; answer2; answer3</span> second <span id="72f23a71-e774-4834-acba-f357afb6a243" class="fill-the-gap" answer="">answer 4; answer5;</span></p> <p class="paragraph">first <span id="16ec8f33-db5b-4839-9567-8aa73b776bcf" class="fill-the-gap" answer="">answer1; answer2; answer3</span> second <span id="72f23a71-e774-4834-acba-f357afb6a243" class="fill-the-gap" answer="">answer 4; answer5;</span></p>
</div>`; </div>`;
const val = `<p class="paragraph"></p><div id="9703faf4-523d-49b2-a719-3f4ecfff65b2" class="matching-container" options="[{&quot;label&quot;:&quot;dsdsd&quot;,&quot;value&quot;:&quot;633b428e-4fda-4b6d-a660-8e3f1f221391&quot;}]" feedback=""><p class="paragraph"><div id="60ccd550-7f65-4624-9e1e-eef7e4e68a73" class="matching-option" isfirst="true" answer="" correct="">dsdsdd</div></p><p class="paragraph"></p></div>`;
const Hhmi = () => { const Hhmi = () => {
const [submited, isSubmited] = useState(false); const [submited, isSubmited] = useState(false);
const [readOnly, isReadOnly] = useState(false); const [readOnly, isReadOnly] = useState(false);
const [content, setContent] = useState(val); const [content, setContent] = useState(initialContent);
const readOnlyQuestions = () => { const readOnlyQuestions = () => {
setContent(editorRef.current.getContent()); setContent(editorRef.current.getContent());
...@@ -92,7 +90,7 @@ const Hhmi = () => { ...@@ -92,7 +90,7 @@ const Hhmi = () => {
value={content} value={content}
readonly={readOnly} readonly={readOnly}
layout={HhmiLayout} layout={HhmiLayout}
onChange={source => console.log(source)} // onChange={source => console.log(source)}
/> />
</> </>
); );
......
...@@ -43,7 +43,7 @@ import { ...@@ -43,7 +43,7 @@ import {
CustomTagInlineToolGroupService, CustomTagInlineToolGroupService,
CustomTagBlockToolGroupService, CustomTagBlockToolGroupService,
CustomTagService, CustomTagService,
OenContainersService, OENContainersService,
} from 'wax-prosemirror-services'; } from 'wax-prosemirror-services';
import { EditoriaSchema } from 'wax-prosemirror-utilities'; import { EditoriaSchema } from 'wax-prosemirror-utilities';
...@@ -153,7 +153,7 @@ export default { ...@@ -153,7 +153,7 @@ export default {
}, },
services: [ services: [
new OenContainersService(), new OENContainersService(),
new CustomTagService(), new CustomTagService(),
new DisplayBlockLevelService(), new DisplayBlockLevelService(),
new DisplayToolGroupService(), new DisplayToolGroupService(),
......
...@@ -53,7 +53,7 @@ export { default as MatchingService } from './src/MatchingService/MatchingServic ...@@ -53,7 +53,7 @@ export { default as MatchingService } from './src/MatchingService/MatchingServic
export { default as EnterService } from './src/EnterService/EnterService'; export { default as EnterService } from './src/EnterService/EnterService';
export { default as MultipleDropDownService } from './src/MultipleDropDownService/MultipleDropDownService'; export { default as MultipleDropDownService } from './src/MultipleDropDownService/MultipleDropDownService';
export { default as OenContainersService } from './src/OenContainersService/OenContainersService'; export { default as OENContainersService } from './src/OENContainersService/OENContainersService';
/* /*
ToolGroups ToolGroups
*/ */
......
...@@ -58,7 +58,6 @@ const EditorWrapper = styled.div` ...@@ -58,7 +58,6 @@ const EditorWrapper = styled.div`
const EditorComponent = ({ node, view, getPos }) => { const EditorComponent = ({ node, view, getPos }) => {
const editorRef = useRef(); const editorRef = useRef();
console.log(node);
const context = useContext(WaxContext); const context = useContext(WaxContext);
const { const {
......
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */
import React, { useContext } from 'react'; import React, { useContext, useState } from 'react';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { TextSelection } from 'prosemirror-state'; import { TextSelection } from 'prosemirror-state';
import { Fragment } from 'prosemirror-model'; import { Fragment } from 'prosemirror-model';
...@@ -43,6 +43,23 @@ const StyledIconAction = styled(Icon)` ...@@ -43,6 +43,23 @@ const StyledIconAction = styled(Icon)`
width: 24px; width: 24px;
`; `;
const AnswerContainer = styled.div`
margin-left: 10px;
display: flex;
flex-direction: column;
`;
const CorrectAnswer = styled.span`
span {
color: #008000;
}
`;
const Answer = styled.span`
span {
color: ${props => (props.isCorrect ? '#008000' : '#FF3030')};
}
`;
export default ({ node, view, getPos }) => { export default ({ node, view, getPos }) => {
const context = useContext(WaxContext); const context = useContext(WaxContext);
const { const {
...@@ -90,6 +107,16 @@ export default ({ node, view, getPos }) => { ...@@ -90,6 +107,16 @@ export default ({ node, view, getPos }) => {
}); });
}; };
const answer = node.attrs.options.find(
option => option.value === node.attrs.answer,
);
const correct = node.attrs.options.find(
option => option.value === node.attrs.correct,
);
const isCorrect = node.attrs.correct === node.attrs.answer;
return ( return (
<Option> <Option>
{!readOnly && ( {!readOnly && (
...@@ -115,7 +142,15 @@ export default ({ node, view, getPos }) => { ...@@ -115,7 +142,15 @@ export default ({ node, view, getPos }) => {
)} )}
{readOnly && customProps && customProps.showFeedBack && ( {readOnly && customProps && customProps.showFeedBack && (
<span> Submit </span> <AnswerContainer>
<CorrectAnswer>
Correct : &nbsp;{correct && <span>{correct.label} </span>}
</CorrectAnswer>
<Answer isCorrect={isCorrect}>
Answer : &nbsp;
{answer && <span>{answer.label} </span>}
</Answer>
</AnswerContainer>
)} )}
</DropDownContainer> </DropDownContainer>
</Option> </Option>
......
...@@ -31,9 +31,9 @@ const StyledIconAction = styled(Icon)` ...@@ -31,9 +31,9 @@ const StyledIconAction = styled(Icon)`
const AnswerContainer = styled.div` const AnswerContainer = styled.div`
display: inline-block; display: inline-block;
border-bottom: ${props => border-bottom: ${props =>
props.isCorrect ? '1px solid green;' : '1px solid red'}; props.isCorrect ? '1px solid #008000;' : '1px solid #FF3030'};
border-top: ${props => border-top: ${props =>
props.isCorrect ? '1px solid green;' : '1px solid red'}; props.isCorrect ? '1px solid #008000;' : '1px solid #FF3030'};
border-radius: 192px; border-radius: 192px;
padding: 2px 4px 2px 4px; padding: 2px 4px 2px 4px;
`; `;
......
...@@ -2,8 +2,8 @@ import { OenContainerNode } from 'wax-prosemirror-schema'; ...@@ -2,8 +2,8 @@ import { OenContainerNode } from 'wax-prosemirror-schema';
import Service from '../Service'; import Service from '../Service';
import './oenContainers.css'; import './oenContainers.css';
class OenContainersService extends Service { class OENContainersService extends Service {
name = 'OenContainersService'; name = 'OENContainersService';
boot() {} boot() {}
...@@ -16,4 +16,4 @@ class OenContainersService extends Service { ...@@ -16,4 +16,4 @@ class OenContainersService extends Service {
} }
} }
export default OenContainersService; export default OENContainersService;
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