diff --git a/editors/demo/src/HHMI/HHMI.js b/editors/demo/src/HHMI/HHMI.js index 1b9ce865f386cfeb6241f51e97f78f3652137516..19ab37c7bd3d70f8d215612b458ac567b67731be 100644 --- a/editors/demo/src/HHMI/HHMI.js +++ b/editors/demo/src/HHMI/HHMI.js @@ -167,10 +167,11 @@ const Hhmi = () => { ref={editorRef} customValues={{ showFeedBack: submitted, testMode }} fileUpload={file => renderImage(file)} - value={content} + // value={content} + targetFormat="JSON" readonly={readOnly} layout={HhmiLayout} - // onChange={source => console.log(source)} + onChange={source => console.log(source)} /> </> ); diff --git a/wax-questions-service/src/NumericalAnswerService/NumericalAnswerContainerNodeView.js b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerContainerNodeView.js new file mode 100644 index 0000000000000000000000000000000000000000..460e1f78ea108721ddf44dba85870f43595ef2d7 --- /dev/null +++ b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerContainerNodeView.js @@ -0,0 +1,40 @@ +import { QuestionsNodeView } from 'wax-prosemirror-core'; + +export default class NumericalAnswerContainerNodeView extends QuestionsNodeView { + constructor( + node, + view, + getPos, + decorations, + createPortal, + Component, + context, + ) { + super(node, view, getPos, decorations, createPortal, Component, context); + + this.node = node; + this.outerView = view; + this.getPos = getPos; + this.context = context; + } + + static name() { + return 'numerical_answer_container'; + } + + selectNode() { + this.context.pmViews[this.node.attrs.id].focus(); + } + + stopEvent(event) { + if (event.target.type === 'textarea' || !event.target.type) { + return true; + } + + return ( + this.context.pmViews[this.node.attrs.id] !== undefined && + event.target !== undefined && + this.context.pmViews[this.node.attrs.id].dom.contains(event.target) + ); + } +} diff --git a/wax-questions-service/src/NumericalAnswerService/NumericalAnswerQuestion.js b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerQuestion.js new file mode 100644 index 0000000000000000000000000000000000000000..ba6a9891e0439b77eea0ffdf6f2e43657be1461e --- /dev/null +++ b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerQuestion.js @@ -0,0 +1,34 @@ +import { injectable } from 'inversify'; +import { findWrapping } from 'prosemirror-transform'; +import { v4 as uuidv4 } from 'uuid'; +import { Commands, Tools } from 'wax-prosemirror-core'; +import helpers from '../MultipleChoiceQuestionService/helpers/helpers'; + +@injectable() +class NumericalAnswerQuestion extends Tools { + title = 'Numerical Answer Question'; + icon = ''; + name = 'Numerical Answer'; + + get run() { + return main => {}; + } + + get active() { + return state => { + if ( + Commands.isParentOfType( + state, + state.config.schema.nodes.numerical_answer_container, + ) + ) { + return true; + } + return false; + }; + } + + select = (state, activeViewId, activeView) => {}; +} + +export default NumericalAnswerQuestion; diff --git a/wax-questions-service/src/NumericalAnswerService/NumericalAnswerService.js b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerService.js index 4460c43732381c0183fb2efa254e2ebfdd50ebce..2a55b85b76c01289e3914a4afcf5b838e70a0c78 100644 --- a/wax-questions-service/src/NumericalAnswerService/NumericalAnswerService.js +++ b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerService.js @@ -8,6 +8,10 @@ class NumericalAnswerService extends Service { this.container.bind('').to(); const createNode = this.container.get('CreateNode'); const addPortal = this.container.get('AddPortal'); + + createNode({ + numerical_answer_container: NumericalAnswerContainerNode, + }); } dependencies = []; diff --git a/wax-questions-service/src/NumericalAnswerService/NumericalAnswerToolGroupService/NumericalAnswer.js b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerToolGroupService/NumericalAnswer.js new file mode 100644 index 0000000000000000000000000000000000000000..7c57f06f2b8638bfca34b2cf00db6fb60ef90e44 --- /dev/null +++ b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerToolGroupService/NumericalAnswer.js @@ -0,0 +1,13 @@ +import { injectable, inject } from 'inversify'; +import { ToolGroup } from 'wax-prosemirror-core'; + +@injectable() +class NumericalAnswer extends ToolGroup { + tools = []; + constructor() { + super(); + this.tools = []; + } +} + +export default NumericalAnswer; diff --git a/wax-questions-service/src/NumericalAnswerService/NumericalAnswerToolGroupService/NumericalAnswerToolGroupService.js b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerToolGroupService/NumericalAnswerToolGroupService.js new file mode 100644 index 0000000000000000000000000000000000000000..d18bd11a9159e3e7650898cd73cbb4d9210508a2 --- /dev/null +++ b/wax-questions-service/src/NumericalAnswerService/NumericalAnswerToolGroupService/NumericalAnswerToolGroupService.js @@ -0,0 +1,10 @@ +import { Service } from 'wax-prosemirror-core'; +import NumericalAnswer from './NumericalAnswer'; + +class NumericalAnswerToolGroupService extends Service { + register() { + this.container.bind('NumericalAnswer').to(NumericalAnswer); + } +} + +export default NumericalAnswerToolGroupService; diff --git a/wax-questions-service/src/QuestionsDropDownToolGroupService/DropDownComponent.js b/wax-questions-service/src/QuestionsDropDownToolGroupService/DropDownComponent.js index 1d4ef29d959ce91d5bcbeb6aedfbf2699f99c176..eed85c98d782555c106a763872d95498f848b6cc 100644 --- a/wax-questions-service/src/QuestionsDropDownToolGroupService/DropDownComponent.js +++ b/wax-questions-service/src/QuestionsDropDownToolGroupService/DropDownComponent.js @@ -107,6 +107,11 @@ const DropDownComponent = ({ view, tools }) => { value: '7', item: tools[7], }, + // { + // label: 'Numerical answer', + // value: '8', + // item: tools[8], + // }, ]; const context = useContext(WaxContext);