Some comments and cleanup of exercise.rb percentage calculation

This commit is contained in:
Ralf Teusner
2016-03-01 11:14:53 +01:00
parent 491bcc9bde
commit 94c31e35a4
5 changed files with 138 additions and 125 deletions

View File

@ -35,6 +35,7 @@ gem 'uglifier', '>= 1.3.0'
gem 'will_paginate', '~> 3.0' gem 'will_paginate', '~> 3.0'
gem 'tubesock' gem 'tubesock'
gem 'faye-websocket' gem 'faye-websocket'
gem 'websocket-client-simple'
group :development do group :development do
gem 'better_errors', platform: :ruby gem 'better_errors', platform: :ruby

View File

@ -2,41 +2,40 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
ZenTest (4.11.0) ZenTest (4.11.0)
actionmailer (4.1.14) actionmailer (4.1.14.1)
actionpack (= 4.1.14) actionpack (= 4.1.14.1)
actionview (= 4.1.14) actionview (= 4.1.14.1)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
actionpack (4.1.14) actionpack (4.1.14.1)
actionview (= 4.1.14) actionview (= 4.1.14.1)
activesupport (= 4.1.14) activesupport (= 4.1.14.1)
rack (~> 1.5.2) rack (~> 1.5.2)
rack-test (~> 0.6.2) rack-test (~> 0.6.2)
actionview (4.1.14) actionview (4.1.14.1)
activesupport (= 4.1.14) activesupport (= 4.1.14.1)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubis (~> 2.7.0)
activemodel (4.1.14) activemodel (4.1.14.1)
activesupport (= 4.1.14) activesupport (= 4.1.14.1)
builder (~> 3.1) builder (~> 3.1)
activerecord (4.1.14) activerecord (4.1.14.1)
activemodel (= 4.1.14) activemodel (= 4.1.14.1)
activesupport (= 4.1.14) activesupport (= 4.1.14.1)
arel (~> 5.0.0) arel (~> 5.0.0)
activerecord-jdbc-adapter (1.3.15) activerecord-jdbc-adapter (1.3.19)
activerecord (>= 2.2) activerecord (>= 2.2)
activerecord-jdbcpostgresql-adapter (1.3.15) activerecord-jdbcpostgresql-adapter (1.3.19)
activerecord-jdbc-adapter (~> 1.3.15) activerecord-jdbc-adapter (~> 1.3.19)
jdbc-postgres (>= 9.1) jdbc-postgres (>= 9.1)
activesupport (4.1.14) activesupport (4.1.14.1)
i18n (~> 0.6, >= 0.6.9) i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.1) thread_safe (~> 0.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.4.0)
arel (5.0.1.20140414130214) arel (5.0.1.20140414130214)
ast (2.0.0) ast (2.2.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
autotest-rails (4.2.1) autotest-rails (4.2.1)
ZenTest (~> 4.5) ZenTest (~> 4.5)
bcrypt (3.1.10) bcrypt (3.1.10)
@ -50,7 +49,7 @@ GEM
bootstrap-will_paginate (0.0.10) bootstrap-will_paginate (0.0.10)
will_paginate will_paginate
builder (3.2.2) builder (3.2.2)
byebug (6.0.2) byebug (8.2.2)
capistrano (3.3.5) capistrano (3.3.5)
capistrano-stats (~> 1.1.0) capistrano-stats (~> 1.1.0)
i18n i18n
@ -59,19 +58,20 @@ GEM
capistrano-bundler (1.1.4) capistrano-bundler (1.1.4)
capistrano (~> 3.1) capistrano (~> 3.1)
sshkit (~> 1.2) sshkit (~> 1.2)
capistrano-rails (1.1.2) capistrano-rails (1.1.6)
capistrano (~> 3.1) capistrano (~> 3.1)
capistrano-bundler (~> 1.1) capistrano-bundler (~> 1.1)
capistrano-rvm (0.1.2) capistrano-rvm (0.1.2)
capistrano (~> 3.0) capistrano (~> 3.0)
sshkit (~> 1.2) sshkit (~> 1.2)
capistrano-stats (1.1.1) capistrano-stats (1.1.1)
capistrano-upload-config (0.6.0) capistrano-upload-config (0.7.0)
capistrano (>= 3.0) capistrano (>= 3.0)
capistrano3-puma (0.9.0) capistrano3-puma (1.2.1)
capistrano (~> 3.0) capistrano (~> 3.0)
puma (>= 2.6) puma (>= 2.6)
capybara (2.4.4) capybara (2.6.2)
addressable
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)
@ -82,9 +82,9 @@ GEM
activesupport (>= 3.2.0) activesupport (>= 3.2.0)
json (>= 1.7) json (>= 1.7)
mime-types (>= 1.16) mime-types (>= 1.16)
childprocess (0.5.6) childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
codeclimate-test-reporter (0.4.7) codeclimate-test-reporter (0.4.8)
simplecov (>= 0.7.1, < 1.0.0) simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.0) coderay (1.1.0)
coffee-rails (4.0.1) coffee-rails (4.0.1)
@ -93,13 +93,12 @@ GEM
coffee-script (2.4.1) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.9.1) coffee-script-source (1.10.0)
colorize (0.7.7)
concurrent-ruby (1.0.0) concurrent-ruby (1.0.0)
concurrent-ruby (1.0.0-java) concurrent-ruby (1.0.0-java)
concurrent-ruby-ext (1.0.0) concurrent-ruby-ext (1.0.0)
concurrent-ruby (~> 1.0.0) concurrent-ruby (~> 1.0.0)
database_cleaner (1.4.1) database_cleaner (1.5.1)
debug_inspector (0.0.2) debug_inspector (0.0.2)
diff-lcs (1.2.5) diff-lcs (1.2.5)
docile (1.1.5) docile (1.1.5)
@ -107,34 +106,35 @@ GEM
excon (>= 0.38.0) excon (>= 0.38.0)
json json
erubis (2.7.0) erubis (2.7.0)
eventmachine (1.0.8) event_emitter (0.2.5)
eventmachine (1.0.8-java) eventmachine (1.0.9.1)
eventmachine (1.0.9.1-java)
excon (0.45.4) excon (0.45.4)
execjs (2.5.2) execjs (2.6.0)
factory_girl (4.5.0) factory_girl (4.5.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
factory_girl_rails (4.5.0) factory_girl_rails (4.6.0)
factory_girl (~> 4.5.0) factory_girl (~> 4.5.0)
railties (>= 3.0.0) railties (>= 3.0.0)
faraday (0.9.1) faraday (0.9.2)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
faye-websocket (0.10.0) faye-websocket (0.10.2)
eventmachine (>= 0.12.0) eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1) websocket-driver (>= 0.5.1)
ffi (1.9.8) ffi (1.9.10)
ffi (1.9.8-java) ffi (1.9.10-java)
forgery (0.6.0) forgery (0.6.0)
highline (1.7.1) highline (1.7.8)
hike (1.2.3) hike (1.2.3)
i18n (0.7.0) i18n (0.7.0)
ims-lti (1.1.8) ims-lti (1.1.10)
builder builder
oauth (~> 0.4.5) oauth (~> 0.4.5)
jbuilder (2.2.13) jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5) activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2) multi_json (~> 1.2)
jdbc-postgres (9.4.1200) jdbc-postgres (9.4.1206)
jquery-rails (3.1.2) jquery-rails (3.1.4)
railties (>= 3.0, < 5.0) railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
jquery-turbolinks (2.1.0) jquery-turbolinks (2.1.0)
@ -142,115 +142,117 @@ GEM
turbolinks turbolinks
json (1.8.3) json (1.8.3)
json (1.8.3-java) json (1.8.3-java)
jwt (1.4.1) jwt (1.5.1)
kramdown (1.6.0) kramdown (1.9.0)
mail (2.6.3) mail (2.6.3)
mime-types (>= 1.16, < 3) mime-types (>= 1.16, < 3)
method_source (0.8.2) method_source (0.8.2)
mime-types (2.99) mime-types (2.99)
mini_portile (0.6.2) mini_portile2 (2.0.0)
minitest (5.8.3) minitest (5.8.4)
multi_json (1.11.2) multi_json (1.11.2)
multi_xml (0.5.5) multi_xml (0.5.5)
multipart-post (2.0.0) multipart-post (2.0.0)
net-scp (1.2.1) net-scp (1.2.1)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.9.2) net-ssh (3.0.2)
newrelic_rpm (3.11.2.286) newrelic_rpm (3.14.3.313)
nokogiri (1.6.6.2) nokogiri (1.6.7.2)
mini_portile (~> 0.6.0) mini_portile2 (~> 2.0.0.rc2)
nokogiri (1.6.6.2-java) nokogiri (1.6.7.2-java)
nyan-cat-formatter (0.11) nyan-cat-formatter (0.11)
rspec (>= 2.99, >= 2.14.2, < 4) rspec (>= 2.99, >= 2.14.2, < 4)
oauth (0.4.7) oauth (0.4.7)
oauth2 (1.0.0) oauth2 (1.1.0)
faraday (>= 0.8, < 0.10) faraday (>= 0.8, < 0.10)
jwt (~> 1.0) jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3) multi_json (~> 1.3)
multi_xml (~> 0.5) multi_xml (~> 0.5)
rack (~> 1.2) rack (>= 1.2, < 3)
parser (2.2.0.3) parser (2.3.0.6)
ast (>= 1.1, < 3.0) ast (~> 2.2)
pg (0.18.1) pg (0.18.4)
polyamorous (1.2.0) polyamorous (1.3.0)
activerecord (>= 3.0) activerecord (>= 3.0)
powerpack (0.1.0) powerpack (0.1.1)
pry (0.10.1) pry (0.10.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
pry (0.10.1-java) pry (0.10.3-java)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
spoon (~> 0.0) spoon (~> 0.0)
puma (2.15.3) puma (2.15.3)
puma (2.15.3-java) puma (2.15.3-java)
pundit (0.3.0) pundit (1.1.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
rack (1.5.5) rack (1.5.5)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (4.1.14) rails (4.1.14.1)
actionmailer (= 4.1.14) actionmailer (= 4.1.14.1)
actionpack (= 4.1.14) actionpack (= 4.1.14.1)
actionview (= 4.1.14) actionview (= 4.1.14.1)
activemodel (= 4.1.14) activemodel (= 4.1.14.1)
activerecord (= 4.1.14) activerecord (= 4.1.14.1)
activesupport (= 4.1.14) activesupport (= 4.1.14.1)
bundler (>= 1.3.0, < 2.0) bundler (>= 1.3.0, < 2.0)
railties (= 4.1.14) railties (= 4.1.14.1)
sprockets-rails (~> 2.0) sprockets-rails (~> 2.0)
rails-i18n (4.0.4) rails-i18n (4.0.8)
i18n (~> 0.6) i18n (~> 0.7)
railties (~> 4.0) railties (~> 4.0)
railties (4.1.14) railties (4.1.14.1)
actionpack (= 4.1.14) actionpack (= 4.1.14.1)
activesupport (= 4.1.14) activesupport (= 4.1.14.1)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (2.0.0) rainbow (2.1.0)
rake (10.4.2) rake (10.5.0)
ransack (1.6.6) ransack (1.7.0)
actionpack (>= 3.0) actionpack (>= 3.0)
activerecord (>= 3.0) activerecord (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
i18n i18n
polyamorous (~> 1.2) polyamorous (~> 1.2)
rdoc (4.2.0) rdoc (4.2.2)
rspec (3.1.0) json (~> 1.4)
rspec-core (~> 3.1.0) rspec (3.4.0)
rspec-expectations (~> 3.1.0) rspec-core (~> 3.4.0)
rspec-mocks (~> 3.1.0) rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-autotest (1.0.0) rspec-autotest (1.0.0)
rspec-core (>= 2.99.0.beta1, < 4.0.0) rspec-core (>= 2.99.0.beta1, < 4.0.0)
rspec-core (3.1.7) rspec-core (3.4.2)
rspec-support (~> 3.1.0) rspec-support (~> 3.4.0)
rspec-expectations (3.1.2) rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0) rspec-support (~> 3.4.0)
rspec-mocks (3.1.3) rspec-mocks (3.4.1)
rspec-support (~> 3.1.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-rails (3.1.0) rspec-support (~> 3.4.0)
actionpack (>= 3.0) rspec-rails (3.4.2)
activesupport (>= 3.0) actionpack (>= 3.0, < 4.3)
railties (>= 3.0) activesupport (>= 3.0, < 4.3)
rspec-core (~> 3.1.0) railties (>= 3.0, < 4.3)
rspec-expectations (~> 3.1.0) rspec-core (~> 3.4.0)
rspec-mocks (~> 3.1.0) rspec-expectations (~> 3.4.0)
rspec-support (~> 3.1.0) rspec-mocks (~> 3.4.0)
rspec-support (3.1.2) rspec-support (~> 3.4.0)
rubocop (0.30.0) rspec-support (3.4.1)
astrolabe (~> 1.3) rubocop (0.37.2)
parser (>= 2.2.0.1, < 3.0) parser (>= 2.3.0.4, < 3.0)
powerpack (~> 0.1) powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0) rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4) ruby-progressbar (~> 1.7)
rubocop-rspec (1.2.2) unicode-display_width (~> 0.3)
rubocop-rspec (1.4.0)
ruby-progressbar (1.7.5) ruby-progressbar (1.7.5)
rubytree (0.9.4) rubytree (0.9.7)
json (~> 1.8) json (~> 1.8)
structured_warnings (~> 0.1) structured_warnings (~> 0.2)
rubyzip (1.1.7) rubyzip (1.1.7)
sass (3.2.19) sass (3.2.19)
sass-rails (4.0.5) sass-rails (4.0.5)
@ -261,17 +263,17 @@ GEM
sdoc (0.4.1) sdoc (0.4.1)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0) rdoc (~> 4.0)
selenium-webdriver (2.45.0) selenium-webdriver (2.52.0)
childprocess (~> 0.5) childprocess (~> 0.5)
multi_json (~> 1.0) multi_json (~> 1.0)
rubyzip (~> 1.0) rubyzip (~> 1.0)
websocket (~> 1.0) websocket (~> 1.0)
simplecov (0.9.2) simplecov (0.11.2)
docile (~> 1.1.0) docile (~> 1.1.0)
multi_json (~> 1.0) json (~> 1.8)
simplecov-html (~> 0.9.0) simplecov-html (~> 0.10.0)
simplecov-html (0.9.0) simplecov-html (0.10.0)
slim (3.0.3) slim (3.0.6)
temple (~> 0.7.3) temple (~> 0.7.3)
tilt (>= 1.3.3, < 2.1) tilt (>= 1.3.3, < 2.1)
slop (3.6.0) slop (3.6.0)
@ -281,7 +283,7 @@ GEM
oauth2 (>= 0.8.0) oauth2 (>= 0.8.0)
spoon (0.0.4) spoon (0.0.4)
ffi ffi
spring (1.3.4) spring (1.6.3)
sprockets (2.12.4) sprockets (2.12.4)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -291,12 +293,11 @@ GEM
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sshkit (1.7.1) sshkit (1.8.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2) net-scp (>= 1.1.2)
net-ssh (>= 2.8.0) net-ssh (>= 2.8.0)
structured_warnings (0.2.0) structured_warnings (0.2.0)
temple (0.7.5) temple (0.7.6)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
thread_safe (0.3.5-java) thread_safe (0.3.5-java)
@ -308,21 +309,25 @@ GEM
coffee-rails coffee-rails
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (2.7.1) uglifier (2.7.2)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
web-console (2.1.2) unicode-display_width (0.3.1)
web-console (2.3.0)
activemodel (>= 4.0) activemodel (>= 4.0)
binding_of_caller (>= 0.7.2) binding_of_caller (>= 0.7.2)
railties (>= 4.0) railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
websocket (1.2.1) websocket (1.2.2)
websocket-driver (0.6.2) websocket-client-simple (0.2.4)
event_emitter
websocket
websocket-driver (0.6.3)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-driver (0.6.2-java) websocket-driver (0.6.3-java)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2) websocket-extensions (0.1.2)
will_paginate (3.0.7) will_paginate (3.1.0)
xpath (2.0.0) xpath (2.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
@ -387,4 +392,5 @@ DEPENDENCIES
turbolinks turbolinks
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (~> 2.0) web-console (~> 2.0)
websocket-client-simple
will_paginate (~> 3.0) will_paginate (~> 3.0)

View File

@ -29,7 +29,11 @@ class Exercise < ActiveRecord::Base
def average_percentage def average_percentage
(average_score / maximum_score * 100).round if average_score and maximum_score != 0.0 else 0 if average_score and maximum_score != 0.0
(average_score / maximum_score * 100).round
else
0
end
end end
def average_score def average_score

View File

@ -96,8 +96,9 @@ class DockerClient
#Rails.logger.info "docker_client: self.create_container with creation options:" #Rails.logger.info "docker_client: self.create_container with creation options:"
#Rails.logger.info(container_creation_options(execution_environment)) #Rails.logger.info(container_creation_options(execution_environment))
container = Docker::Container.create(container_creation_options(execution_environment)) container = Docker::Container.create(container_creation_options(execution_environment))
# container.start sometimes creates the passed local_workspace_path on disk (depending on the setup).
# this is however not guaranteed and caused issues on the server already. Therefore create the necessary folders manually!
local_workspace_path = generate_local_workspace_path local_workspace_path = generate_local_workspace_path
# container.start always creates the passed local_workspace_path on disk. Seems like we have to live with that, therefore we can also just create the empty folder ourselves.
FileUtils.mkdir(local_workspace_path) FileUtils.mkdir(local_workspace_path)
container.start(container_start_options(execution_environment, local_workspace_path)) container.start(container_start_options(execution_environment, local_workspace_path))
container.start_time = Time.now container.start_time = Time.now

View File

@ -48,6 +48,7 @@ class DockerContainerPool
end end
def self.create_container(execution_environment) def self.create_container(execution_environment)
Rails.logger.info('trying to create container for execution environment: ' + execution_environment.to_s)
container = DockerClient.create_container(execution_environment) container = DockerClient.create_container(execution_environment)
container.status = 'available' container.status = 'available'
#Rails.logger.debug('created container ' + container.to_s + ' for execution environment ' + execution_environment.to_s) #Rails.logger.debug('created container ' + container.to_s + ' for execution environment ' + execution_environment.to_s)