Skip to content
Snippets Groups Projects
Commit 6f95403f authored by chris's avatar chris
Browse files

add new tool

parent acf344ae
No related branches found
No related tags found
1 merge request!349Multiple single
...@@ -6,6 +6,7 @@ import QuestionComponent from './components/QuestionComponent'; ...@@ -6,6 +6,7 @@ import QuestionComponent from './components/QuestionComponent';
import MultipleChoiceNodeView from './MultipleChoiceNodeView'; import MultipleChoiceNodeView from './MultipleChoiceNodeView';
import MultipleChoiceSingleCorrectQuestionService from './MultipleChoiceSingleCorrectQuestionService/MultipleChoiceSingleCorrectQuestionService'; import MultipleChoiceSingleCorrectQuestionService from './MultipleChoiceSingleCorrectQuestionService/MultipleChoiceSingleCorrectQuestionService';
import TrueFalseQuestionService from './TrueFalseQuestionService/TrueFalseQuestionService'; import TrueFalseQuestionService from './TrueFalseQuestionService/TrueFalseQuestionService';
import TrueFalseSingleCorrectQuestionService from './TrueFalseSingleCorrectQuestionService/TrueFalseSingleCorrectQuestionService';
class MultipleChoiceQuestionService extends Service { class MultipleChoiceQuestionService extends Service {
register() { register() {
...@@ -31,6 +32,7 @@ class MultipleChoiceQuestionService extends Service { ...@@ -31,6 +32,7 @@ class MultipleChoiceQuestionService extends Service {
dependencies = [ dependencies = [
new MultipleChoiceSingleCorrectQuestionService(), new MultipleChoiceSingleCorrectQuestionService(),
new TrueFalseQuestionService(), new TrueFalseQuestionService(),
new TrueFalseSingleCorrectQuestionService(),
]; ];
} }
......
...@@ -11,7 +11,7 @@ import helpers from '../helpers/helpers'; ...@@ -11,7 +11,7 @@ import helpers from '../helpers/helpers';
import Tools from '../../lib/Tools'; import Tools from '../../lib/Tools';
@injectable() @injectable()
class MultipleChoiceQuestion extends Tools { class TrueFalseQuestion extends Tools {
title = 'Add True False Question'; title = 'Add True False Question';
icon = 'multipleChoice'; icon = 'multipleChoice';
name = 'TrueFalse'; name = 'TrueFalse';
...@@ -66,4 +66,4 @@ class MultipleChoiceQuestion extends Tools { ...@@ -66,4 +66,4 @@ class MultipleChoiceQuestion extends Tools {
} }
} }
export default MultipleChoiceQuestion; export default TrueFalseQuestion;
...@@ -23,7 +23,6 @@ export default class TrueFalseSingleCorrectNodeView extends AbstractNodeView { ...@@ -23,7 +23,6 @@ export default class TrueFalseSingleCorrectNodeView extends AbstractNodeView {
} }
update(node) { update(node) {
// if (!node.sameMarkup(this.node)) return false;
this.node = node; this.node = node;
if (this.context.view[node.attrs.id]) { if (this.context.view[node.attrs.id]) {
const { state } = this.context.view[node.attrs.id]; const { state } = this.context.view[node.attrs.id];
......
import Service from '../../Service';
import TrueFalseSingleCorrectQuestion from './TrueFalseSingleCorrectQuestion';
import trueFalseSingleCorrectNode from './schema/trueFalseSingleCorrectNode';
import trueFalseSingleCorrectContainerNode from './schema/trueFalseSingleCorrectContainerNode';
import QuestionComponent from './components/QuestionComponent';
import TrueFalseSingleCorrectNodeView from './TrueFalseSingleCorrectNodeView';
class TrueFalseSingleCorrectQuestionService extends Service {
register() {
this.container
.bind('TrueFalseSingleCorrectQuestion')
.to(TrueFalseSingleCorrectQuestion);
const createNode = this.container.get('CreateNode');
const addPortal = this.container.get('AddPortal');
createNode({
true_false_single_correct: trueFalseSingleCorrectNode,
});
createNode({
true_false_single_correct_container: trueFalseSingleCorrectContainerNode,
});
addPortal({
nodeView: TrueFalseSingleCorrectNodeView,
component: QuestionComponent,
context: this.app,
});
}
}
export default TrueFalseSingleCorrectQuestionService;
...@@ -16,12 +16,14 @@ class MultipleDropDown extends ToolGroup { ...@@ -16,12 +16,14 @@ class MultipleDropDown extends ToolGroup {
@inject('MultipleChoiceSingleCorrectQuestion') @inject('MultipleChoiceSingleCorrectQuestion')
multipleChoiceSingleCorrectQuestion, multipleChoiceSingleCorrectQuestion,
@inject('TrueFalseQuestion') trueFalseQuestion, @inject('TrueFalseQuestion') trueFalseQuestion,
@inject('TrueFalseSingleCorrectQuestion') trueFalseSingleCorrectQuestion,
) { ) {
super(); super();
this.tools = [ this.tools = [
multipleChoiceQuestion, multipleChoiceQuestion,
multipleChoiceSingleCorrectQuestion, multipleChoiceSingleCorrectQuestion,
trueFalseQuestion, trueFalseQuestion,
trueFalseSingleCorrectQuestion,
]; ];
} }
...@@ -67,7 +69,7 @@ class MultipleDropDown extends ToolGroup { ...@@ -67,7 +69,7 @@ class MultipleDropDown extends ToolGroup {
view: { main }, view: { main },
} = context; } = context;
const { state } = view; const { state } = view;
console.log(this._tools);
const dropDownOptions = [ const dropDownOptions = [
{ {
label: 'Multiple Choice', label: 'Multiple Choice',
...@@ -84,11 +86,11 @@ class MultipleDropDown extends ToolGroup { ...@@ -84,11 +86,11 @@ class MultipleDropDown extends ToolGroup {
value: '2', value: '2',
item: this._tools[2], item: this._tools[2],
}, },
// { {
// label: 'True/False (single correct)', label: 'True/False (single correct)',
// value: '3', value: '3',
// item: this._tools[0], item: this._tools[3],
// }, },
]; ];
const isDisabled = this._tools[0].select(state, activeView); const isDisabled = this._tools[0].select(state, activeView);
......
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