fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix answer alignment in exercise replace
[fnpeditor.git]
/
src
/
editor
/
plugins
/
core
/
edumed
/
order
/
view.js
diff --git
a/src/editor/plugins/core/edumed/order/view.js
b/src/editor/plugins/core/edumed/order/view.js
index
3dc9a81
..
4b470e6
100644
(file)
--- a/
src/editor/plugins/core/edumed/order/view.js
+++ b/
src/editor/plugins/core/edumed/order/view.js
@@
-15,6
+15,7
@@
var OrderExerciseView = function(element) {
this.modePills = this.dom.find('.modePills');
this.list = this.dom.find('ol');
this.description = this.dom.find('.description');
this.modePills = this.dom.find('.modePills');
this.list = this.dom.find('ol');
this.description = this.dom.find('.description');
+ this.shuffleButton = this.dom.find('.shuffle');
this.itemViews = [];
this.modePills.find('a').on('click', function(e) {
this.itemViews = [];
this.modePills.find('a').on('click', function(e) {
@@
-23,6
+24,12
@@
var OrderExerciseView = function(element) {
this.setMode($(e.target).parent().attr('mode'));
}.bind(this));
this.setMode($(e.target).parent().attr('mode'));
}.bind(this));
+ this.shuffleButton.on('click', function(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ this.trigger('shuffleItems');
+ }.bind(this));
+
this.mode = 'initial';
var dropTargets = this.dom.find('.placeholder-top');
this.mode = 'initial';
var dropTargets = this.dom.find('.placeholder-top');
@@
-34,13
+41,7
@@
var OrderExerciseView = function(element) {
dropTargets.on('dragenter', function() {
var first = this.itemViews[0];
if(this.mode === 'correct') {
dropTargets.on('dragenter', function() {
var first = this.itemViews[0];
if(this.mode === 'correct') {
- first = this.itemViews.slice(0)
- .sort(function(view1, view2) {
- if(view1.item.getAnswer() > view2.item.getAnswer()) {
- return 1;
- }
- return -1;
- })[0];
+ first = this.sortedItemViews()[0];
}
if(!this.allowDropAt(first, true)) {
return;
}
if(!this.allowDropAt(first, true)) {
return;
@@
-63,13
+64,7
@@
var OrderExerciseView = function(element) {
var first = this.itemViews[0];
if(this.mode === 'correct') {
var first = this.itemViews[0];
if(this.mode === 'correct') {
- first = this.itemViews.slice(0)
- .sort(function(view1, view2) {
- if(view1.item.getAnswer() > view2.item.getAnswer()) {
- return 1;
- }
- return -1;
- })[0];
+ first = this.sortedItemViews()[0];
}
this.trigger(this.mode === 'initial' ? 'moveItem' : 'moveAnswer', droppedItem.item, first.item, 'before');
}
this.trigger(this.mode === 'initial' ? 'moveItem' : 'moveAnswer', droppedItem.item, first.item, 'before');
@@
-110,19
+105,24
@@
_.extend(OrderExerciseView.prototype, Backbone.Events, {
this.itemViews.forEach(function(itemView) {
this.list.append(itemView.dom);
}.bind(this));
this.itemViews.forEach(function(itemView) {
this.list.append(itemView.dom);
}.bind(this));
+ this.shuffleButton.show();
} else {
} else {
- this.itemViews.slice(0)
- .sort(function(view1, view2) {
- if(view1.item.getAnswer() > view2.item.getAnswer()) {
- return 1;
- }
- return -1;
- })
+ this.sortedItemViews()
.forEach(function(itemView) {
this.list.append(itemView.dom);
}.bind(this));
.forEach(function(itemView) {
this.list.append(itemView.dom);
}.bind(this));
+ this.shuffleButton.hide();
}
},
}
},
+ sortedItemViews: function () {
+ return this.itemViews.slice(0)
+ .sort(function(view1, view2) {
+ if(view1.item.getAnswer() > view2.item.getAnswer()) {
+ return 1;
+ }
+ return -1;
+ });
+ },
allowDropAt: function(view, up) {
var arr = [this.draggedView.dom[0]];
if(!up) {
allowDropAt: function(view, up) {
var arr = [this.draggedView.dom[0]];
if(!up) {