From 98d249c285d0aade0dec23287070b8eaf77bb8b4 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 12 Feb 2013 13:00:35 +0100 Subject: [PATCH] Exercises: retry implied on move; add handlers to sortable --- catalogue/static/catalogue/css/exercise.css | 23 ++++++++++++++++++- catalogue/static/catalogue/css/exercise.scss | 21 +++++++++++++++++ catalogue/static/catalogue/js/edumed.js | 21 ++++++++++++----- edumed/static/img/ornaments/draggable.png | Bin 0 -> 550 bytes 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 edumed/static/img/ornaments/draggable.png diff --git a/catalogue/static/catalogue/css/exercise.css b/catalogue/static/catalogue/css/exercise.css index 2be22bc..decaef5 100644 --- a/catalogue/static/catalogue/css/exercise.css +++ b/catalogue/static/catalogue/css/exercise.css @@ -101,7 +101,28 @@ .uporzadkuj .lista { list-style: none; margin: 0; - padding: 0; } + padding: 0; + counter-reset: answer; } + .uporzadkuj .lista li { + counter-increment: answer; + padding-right: 3em; + background-image: url(/static/img/ornaments/draggable.png); + background-repeat: no-repeat; + background-position: 100% 50%; } + .uporzadkuj .lista li:before { + border-radius: 0.688em; + padding: 0.5em 0.688em; + background-color: #d4d6d8; + color: #363a3e; + cursor: pointer; + z-index: 2; + content: counter(answer); + float: left; + margin: -0.5em 0 0 -3em; } + .uporzadkuj .lista li.ui-sortable-placeholder { + counter-increment: answer 0; } + .uporzadkuj .lista li.ui-sortable-helper:before { + content: none; } .przyporzadkuj .question-piece { background-color: #d4d6d8; diff --git a/catalogue/static/catalogue/css/exercise.scss b/catalogue/static/catalogue/css/exercise.scss index e16d7d7..035aa2a 100755 --- a/catalogue/static/catalogue/css/exercise.scss +++ b/catalogue/static/catalogue/css/exercise.scss @@ -154,6 +154,27 @@ $px: 0.0625em; } .lista { @include list-plain; + counter-reset: answer; + li { + counter-increment: answer; + padding-right: 3em; + background-image: url(/static/img/ornaments/draggable.png); + background-repeat: no-repeat; + background-position: 100% 50%; + } + li:before { + @include bubble; + @include bubble-drag; + content: counter(answer); + float: left; + margin: -.5em 0 0 -3em; + } + li.ui-sortable-placeholder { + counter-increment: answer 0; + } + li.ui-sortable-helper:before { + content: none; + } } } diff --git a/catalogue/static/catalogue/js/edumed.js b/catalogue/static/catalogue/js/edumed.js index 33b7c58..817dd95 100644 --- a/catalogue/static/catalogue/js/edumed.js +++ b/catalogue/static/catalogue/js/edumed.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.4.0 +// Generated by CoffeeScript 1.3.3 (function() { var $, Binding, EduModule, Exercise, Luki, PrawdaFalsz, Przyporzadkuj, Uporzadkuj, Wybor, Zastap, exercise, __hasProp = {}.hasOwnProperty, @@ -44,9 +44,7 @@ return $(ev.target).hide(); }); $(".retry", this.element).click(function(ev) { - $(".correct, .incorrect", _this.element).removeClass("correct incorrect"); - $(ev.target).prev(".check").show(); - return $(ev.target).hide(); + return _this.retry(); }); $('.solutions', this.element).click(function() { _this.show_solutions(); @@ -57,6 +55,12 @@ }); } + Exercise.prototype.retry = function() { + $(".correct, .incorrect", this.element).removeClass("correct incorrect"); + $(".check", this.element).show(); + return $(".retry", this.element).hide(); + }; + Exercise.prototype.reset = function() { $(this.element).html($(this.element).data('exercise-html')); return exercise(this.element); @@ -174,7 +178,8 @@ var draggable_opts, self; draggable_opts = { revert: 'invalid', - helper: 'clone' + helper: 'clone', + start: _this.retry }; $(".draggable", question).draggable(draggable_opts); self = _this; @@ -220,6 +225,7 @@ function Wybor(element) { Wybor.__super__.constructor.call(this, element); + $(".question-piece input", element).change(this.retry); } Wybor.prototype.check_question = function(question) { @@ -284,7 +290,8 @@ function Uporzadkuj(element) { Uporzadkuj.__super__.constructor.call(this, element); $('ol, ul', this.element).sortable({ - items: "> li" + items: "> li", + start: this.retry }); } @@ -573,11 +580,13 @@ qp = _ref[_i]; $(".true", qp).click(function(ev) { ev.preventDefault(); + this.retry(); $(this).closest(".question-piece").data("value", "true"); return $(this).addClass('chosen').siblings('a').removeClass('chosen'); }); $(".false", qp).click(function(ev) { ev.preventDefault(); + this.retry(); $(this).closest(".question-piece").data("value", "false"); return $(this).addClass('chosen').siblings('a').removeClass('chosen'); }); diff --git a/edumed/static/img/ornaments/draggable.png b/edumed/static/img/ornaments/draggable.png new file mode 100644 index 0000000000000000000000000000000000000000..75af63ed9004f7c19a290f23e7a2885f2b2166c4 GIT binary patch literal 550 zcmeAS@N?(olHy`uVBq!ia0vp^sz98=!3HE5XZ<_{q}Y|gW!U_%O?XxI14-? ziy0WWg+Z8+Vb&Z8pdfpRr>`sfT_zrG5r%@9g|sS7*tPgv`GamHGE z_NmV;!&Zxmb-Nlwh%lwBZ8cPr(BWc~>ObyrS>%|6&UEj5p!gIOPPS&oOD3(?Zb^$> zWxe~pTx02lmnAX&nyi{j&2?6BYwhn|RPgul#}^8A8`f)0&)+WXwpftiL5bDF0*gI+ z%w_m4W^H9)I40qtIony)^U*n{j_oTf`m~*YoDsO15-RmY=XAo_(%avoOXi$UXK>hk z*KPalTs~HY*=LU(ymz&1cj&-#0qEn^>1~k2Laeg|p zs!i0j@%7hNRnt$iMrG>bP0l+XkK DMZ?+- literal 0 HcmV?d00001 -- 2.20.1