From 9c7a4e8e7f76dd17724be436a74647a9ccc83458 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 19 Feb 2014 17:01:51 +0100 Subject: [PATCH] Fix for Uporzadkuj. --- redakcja/static/edumed/js/edumed.coffee | 14 +++----------- redakcja/static/edumed/js/edumed.js | 23 +++++++---------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/redakcja/static/edumed/js/edumed.coffee b/redakcja/static/edumed/js/edumed.coffee index fb8ea872..cb515475 100644 --- a/redakcja/static/edumed/js/edumed.coffee +++ b/redakcja/static/edumed/js/edumed.coffee @@ -252,7 +252,7 @@ class Uporzadkuj extends Exercise check_question: (question) -> positions = @get_value_list(question, 'original', true) - sorted = positions.sort() + sorted = positions.sort (a, b) -> a - b pkts = $('.question-piece', question) correct = 0 @@ -270,19 +270,11 @@ class Uporzadkuj extends Exercise return [correct, bad, all] solve_question: (question) -> - positions = @get_value_list(question, 'original', true) - sorted = positions.sort() pkts = $('.question-piece', question) - pkts.sort (a, b) -> - q = $(a).data('pos') - w = $(b).data('pos') - return 1 if q < w - return -1 if q > w - return 0 - + pkts.sort (a, b) -> return $(a).data('pos') - $(b).data('pos') parent = pkts.eq(0).parent() for p in pkts - parent.prepend(p) + parent.append(p) # XXX propozycje="1/0" diff --git a/redakcja/static/edumed/js/edumed.js b/redakcja/static/edumed/js/edumed.js index 3262cac0..68a558bc 100644 --- a/redakcja/static/edumed/js/edumed.js +++ b/redakcja/static/edumed/js/edumed.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.4.0 (function() { var $, Binding, EduModule, Exercise, Luki, PrawdaFalsz, Przyporzadkuj, Uporzadkuj, Wybor, Zastap, exercise, __hasProp = {}.hasOwnProperty, @@ -309,7 +309,9 @@ Uporzadkuj.prototype.check_question = function(question) { var all, bad, correct, pkt, pkts, positions, sorted, _i, _ref; positions = this.get_value_list(question, 'original', true); - sorted = positions.sort(); + sorted = positions.sort(function(a, b) { + return a - b; + }); pkts = $('.question-piece', question); correct = 0; bad = 0; @@ -328,27 +330,16 @@ }; Uporzadkuj.prototype.solve_question = function(question) { - var p, parent, pkts, positions, sorted, _i, _len, _results; - positions = this.get_value_list(question, 'original', true); - sorted = positions.sort(); + var p, parent, pkts, _i, _len, _results; pkts = $('.question-piece', question); pkts.sort(function(a, b) { - var q, w; - q = $(a).data('pos'); - w = $(b).data('pos'); - if (q < w) { - return 1; - } - if (q > w) { - return -1; - } - return 0; + return $(a).data('pos') - $(b).data('pos'); }); parent = pkts.eq(0).parent(); _results = []; for (_i = 0, _len = pkts.length; _i < _len; _i++) { p = pkts[_i]; - _results.push(parent.prepend(p)); + _results.push(parent.append(p)); } return _results; }; -- 2.20.1