Skip to content
Browse files

Style display of points in solutions

  • Loading branch information...
1 parent a9e4796 commit fc52c3d918b22094717d17cba3617262119552ff @skanev committed Nov 1, 2011
View
BIN app/assets/images/icons/bullet_go.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
22 app/assets/javascripts/tasks.js
@@ -1,12 +1,26 @@
$(function() {
$('td:has([data-points])').each(function() {
- var td = $(this);
- var points = parseInt($('[data-points]', td).text(), 10);
+ var td = $(this),
+ points = parseInt($('[data-points]', td).text(), 10),
+ adjustment = parseInt($('[data-adjustment]', td).text(), 10);
td.html('');
- for(var i = 0; i < points; i++) {
- $('<span class="point"></span>').appendTo(td);
+
+ if (adjustment >= 0) {
+ for(var i = 0; i < points - adjustment; i++) {
+ $('<span class="point"></span>').appendTo(td);
+ }
+ for(var i = 0; i < adjustment; i++) {
+ $('<span class="bonus-point"></span>').appendTo(td);
+ }
+ } else if (adjustment < 0) {
+ for(var i = 0; i < points; i++) {
+ $('<span class="point"></span>').appendTo(td);
+ }
+ for(var i = 0; i < -adjustment; i++) {
+ $('<span class="penalty-point"></span>').appendTo(td);
+ }
}
});
View
7 app/assets/stylesheets/_tasks.scss
@@ -7,7 +7,7 @@
}
table.solutions {
- .points { width: 130px; }
+ .points { width: 150px; }
.results { width: 180px; }
.results span { display: inline-block; margin-left: 10px; }
@@ -19,6 +19,8 @@ table.solutions {
.comments { @include replace-with-image('icons/comments.png', 16px, 16px); }
.point { @include replace-with-image('icons/emoticon_grin.png', 16px, 16px); display: inline-block; }
+ .bonus-point { @include replace-with-image('icons/star.png', 16px, 16px); display: inline-block; }
+ .penalty-point { @include replace-with-image('icons/stop.png', 16px, 16px); display: inline-block; }
}
#tasks { @include content; }
@@ -27,9 +29,10 @@ table.solutions {
@include content;
.results ul li { background: { position: 0 0; repeat: no-repeat; } list-style: none; padding-left: 25px; }
- .results ul li.points { background-image: image-url('icons/emoticon_grin.png'); }
+ .results ul li.test-points { background-image: image-url('icons/emoticon_grin.png'); }
.results ul li.bonus { background-image: image-url('icons/star.png'); }
.results ul li.penalty { background-image: image-url('icons/stop.png'); }
+ .results ul li.total-points { background-image: image-url('icons/bullet_go.png'); }
.results ul li.passed-tests { background-image: image-url('icons/flag_green.png'); }
.results ul li.failed-tests { background-image: image-url('icons/flag_red.png'); }
View
2 app/views/solutions/index.html.haml
@@ -14,5 +14,5 @@
- @solutions.each do |solution|
%tr
%td.name= link_to solution.user_name, [@task, solution]
- %td.points Точки: <span data-points>#{solution.points}</span>
+ %td.points Точки: <span data-points>#{solution.points}</span> (<span data-adjustment>#{solution.adjustment}</span> добавка)
%td.results <span class="passed">Успешни тестове:</span> #{solution.passed_tests}<span class="failed">, Неуспешни тестове:</span> #{solution.failed_tests}<span class="lines">, Редове:</span> #{solution.rows}<span class="comments">, Коментари:</span> #{solution.comments.count}
View
4 app/views/solutions/show.html.haml
@@ -8,12 +8,12 @@
%h2 Резултати
%ul
- %li.points= pluralize @solution.points, 'точка', 'точки'
-
+ %li.test-points= pluralize @solution.points_for_tests, 'точка от тестове', 'точки от тестове'
- if @solution.adjustment >= 0
%li.bonus= pluralize @solution.adjustment, 'бонус точка', 'бонус точки'
- else
%li.penalty= pluralize @solution.adjustment.abs, 'отнета точка', 'отнети точки'
+ %li.total-points= pluralize @solution.points, 'точка общо', 'точки общо'
%ul
%li.passed-tests #{@solution.passed_tests} успешни тест(а)

0 comments on commit fc52c3d

Please sign in to comment.
Something went wrong with that request. Please try again.