X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6d7963d9e1a726e9e8d2173b7df165c63421f546..bd9d614e2b189f2f086e2223d262d57525f485a9:/src/wlxml/extensions/edumed/edumed.js?ds=sidebyside diff --git a/src/wlxml/extensions/edumed/edumed.js b/src/wlxml/extensions/edumed/edumed.js index fb0885a..8c7472c 100644 --- a/src/wlxml/extensions/edumed/edumed.js +++ b/src/wlxml/extensions/edumed/edumed.js @@ -3,7 +3,15 @@ define(function(require) { 'use strict'; var _ = require('libs/underscore'), - orderExerciseTemplate = require('libs/text!./order.xml'); + templates = { + order: require('libs/text!./order.xml'), + choice: require('libs/text!./choice.xml'), + 'choice.single': require('libs/text!./choiceSingle.xml'), + 'choice.true-or-false': require('libs/text!./choiceTrueOrFalse.xml'), + gap: require('libs/text!./gaps.xml'), + replace: require('libs/text!./replace.xml'), + match: require('libs/text!./match.xml') + }; var Item = function(node, exerciseNode) { Object.defineProperty(this, 'text', { @@ -150,6 +158,9 @@ var extension = {wlxmlClass: {'exercise.order': { }}}; var choiceMethods = { + isContextRoot: function(node) { + return this.object.isChoiceList(node.parent()) || this.sameNode(node); + }, getChoiceList: function() { return this.contents() .filter(function(n) { return this.object.isChoiceList(n); }.bind(this))[0]; @@ -202,11 +213,19 @@ extension.wlxmlClass['exercise.choice.true-or-false'] = { methods: choiceMethods }; +extension.wlxmlClass['exercise.gap'] = extension.wlxmlClass['exercise.replace'] = extension.wlxmlClass['exercise.match'] = { + methods: { + isContextRoot: function(node) { + return this.sameNode(node); + } + } +}; + extension.document = { methods: { edumedCreateExerciseNode: function(klass) { void(klass); - return this.createDocumentNode(orderExerciseTemplate); + return this.createDocumentNode(templates[klass]); } } };