Merge pull request #300 from openHPI/fix/working_time

Fix working time calculation
This commit is contained in:
rteusner
2019-05-09 15:37:59 +02:00
committed by GitHub
5 changed files with 52 additions and 46 deletions

View File

@ -5,7 +5,7 @@ services:
language: ruby
rvm:
- 2.6.1
- 2.6.2
cache:
bundler: true
yarn: true

View File

@ -66,15 +66,15 @@ GEM
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
bindex (0.5.0)
bindex (0.7.0)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bootsnap (1.4.2)
bootsnap (1.4.4)
msgpack (~> 1.0)
bootstrap-will_paginate (1.0.0)
will_paginate
builder (3.2.3)
bunny (2.14.1)
bunny (2.14.2)
amq-protocol (~> 2.3, >= 2.3.0)
byebug (11.0.1)
capistrano (3.11.0)
@ -96,7 +96,7 @@ GEM
capistrano (~> 3.7)
capistrano-bundler
puma (~> 3.4)
capybara (3.16.0)
capybara (3.18.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
@ -108,8 +108,8 @@ GEM
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
childprocess (1.0.1)
rake (< 13.0)
chronic (0.10.2)
coderay (1.1.2)
concurrent-ruby (1.1.5)
@ -125,12 +125,12 @@ GEM
unf (>= 0.0.5, < 1.0.0)
erubi (1.8.0)
eventmachine (1.0.9.1)
excon (0.62.0)
excon (0.64.0)
execjs (2.7.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.1)
factory_bot (~> 5.0.0)
factory_bot_rails (5.0.2)
factory_bot (~> 5.0.2)
railties (>= 4.2.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
@ -142,7 +142,7 @@ GEM
globalid (0.4.2)
activesupport (>= 4.2.0)
headless (2.3.1)
highline (2.0.1)
highline (2.0.2)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.6.0)
@ -177,7 +177,7 @@ GEM
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mime-types-data (3.2019.0331)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
@ -185,17 +185,17 @@ GEM
mnemosyne-ruby (1.5.1)
activesupport (>= 4)
bunny
msgpack (1.2.9)
msgpack (1.2.10)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
multipart-post (2.1.0)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
net-ssh (5.2.0)
netrc (0.11.0)
newrelic_rpm (6.2.0.354)
newrelic_rpm (6.3.0.355)
nio4r (2.3.1)
nokogiri (1.10.2)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
nyan-cat-formatter (0.12.0)
rspec (>= 2.99, >= 2.14.2, < 4)
@ -208,8 +208,8 @@ GEM
rack (>= 1.2, < 3)
pagedown-bootstrap-rails (2.1.4)
railties (> 3.1)
parallel (1.16.2)
parser (2.6.2.0)
parallel (1.17.0)
parser (2.6.3.0)
ast (~> 2.4.0)
pg (1.1.4)
pry (0.12.2)
@ -218,12 +218,11 @@ GEM
pry-byebug (3.7.0)
byebug (~> 11.0)
pry (~> 0.10)
psych (3.1.0)
public_suffix (3.0.3)
puma (3.12.1)
pundit (2.0.1)
activesupport (>= 3.0.0)
rack (2.0.6)
rack (2.0.7)
rack-mini-profiler (1.0.2)
rack (>= 1.2.0)
rack-proxy (0.6.5)
@ -274,7 +273,7 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
regexp_parser (1.3.0)
regexp_parser (1.4.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
@ -287,7 +286,7 @@ GEM
rspec-core (>= 2.99.0.beta1, < 4.0.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
rspec-expectations (3.8.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
@ -302,11 +301,10 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.66.0)
rubocop (0.68.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
psych (>= 3.1.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.6)
@ -314,11 +312,11 @@ GEM
rubocop (>= 0.60.0)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
rubytree (1.0.1)
rubytree (1.0.0)
json (~> 2.1)
structured_warnings (~> 0.3)
rubyzip (1.2.2)
sass (3.7.3)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
@ -329,8 +327,8 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
selenium-webdriver (3.142.1)
childprocess (>= 0.5, < 2.0)
rubyzip (~> 1.2, >= 1.2.2)
simplecov (0.16.1)
docile (~> 1.1)
@ -374,7 +372,7 @@ GEM
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unf_ext (0.0.7.6)
unicode-display_width (1.5.0)
web-console (3.7.0)
actionview (>= 5.0)
@ -389,7 +387,7 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
whenever (0.10.0)
whenever (0.11.0)
chronic (>= 0.6.3)
will_paginate (3.1.7)
xpath (3.2.0)

View File

@ -1,15 +1,17 @@
module ActionCableHelper
def trigger_rfc_action_cable
def trigger_rfc_action_cable
Thread.new do
# Context: RfC
if submission.study_group_id.present?
ActionCable.server.broadcast(
"la_exercises_#{exercise_id}_channel_study_group_#{submission.study_group_id}",
type: :rfc,
id: id,
html: (ApplicationController.render(partial: 'request_for_comments/list_entry',
locals: {request_for_comment: self})))
"la_exercises_#{exercise_id}_channel_study_group_#{submission.study_group_id}",
type: :rfc,
id: id,
html: (ApplicationController.render(partial: 'request_for_comments/list_entry',
locals: {request_for_comment: self})))
end
end
end
def trigger_rfc_action_cable_from_comment
# Context: Comment
@ -17,12 +19,14 @@ module ActionCableHelper
end
def trigger_working_times_action_cable
# Context: Submission
if study_group_id.present?
ActionCable.server.broadcast(
"la_exercises_#{exercise_id}_channel_study_group_#{study_group_id}",
type: :working_times,
working_time_data: exercise.get_working_times_for_study_group(study_group_id, user))
Thread.new do
# Context: Submission
if study_group_id.present?
ActionCable.server.broadcast(
"la_exercises_#{exercise_id}_channel_study_group_#{study_group_id}",
type: :working_times,
working_time_data: exercise.get_working_times_for_study_group(study_group_id, user))
end
end
end
end

View File

@ -198,7 +198,7 @@ class Exercise < ApplicationRecord
def get_working_times_for_study_group(study_group_id, user = nil)
user_progress = []
additional_user_data = []
max_bucket = 4
max_bucket = 100
maximum_score = self.maximum_score
if user.blank?
@ -208,8 +208,8 @@ class Exercise < ApplicationRecord
end
results = self.class.connection.execute(study_group_working_time_query(id, study_group_id, additional_filter)).each do |tuple|
if tuple['score'] <= maximum_score
bucket = tuple['score'] / maximum_score * max_bucket
if maximum_score > 0.0 && tuple['score'] <= maximum_score
bucket = (tuple['score'] / maximum_score * max_bucket).round
else
bucket = max_bucket # maximum_score / maximum_score will always be 1
end

View File

@ -5,7 +5,7 @@
######## VERSION INFORMATION ########
postgres_version=10
ruby_version=2.6.1
ruby_version=2.6.2
rails_version=5.2.3
geckodriver_version=0.24.0
@ -33,6 +33,8 @@ sudo apt-get -qq -y install postgresql-client postgresql-$postgres_version postg
# Docker
if [ ! -f /etc/default/docker ]
then
# If Docker doesn't start, check this article
# https://medium.com/@dirk.avery/docker-error-response-from-daemon-1d46235ff61d
curl -sSL https://get.docker.com/ | sudo sh
fi
if ! grep code_ocean /etc/default/docker
@ -56,6 +58,8 @@ sudo docker pull openhpi/co_execenv_python
sudo docker pull openhpi/co_execenv_node
sudo docker pull openhpi/co_execenv_java
sudo docker pull openhpi/co_execenv_java_antlr
sudo docker pull openhpi/co_execenv_ruby
sudo docker pull openhpi/co_execenv_ruby:2.5
# rvm
sudo apt-get -qq -y install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev libgdbm-dev libncurses5-dev automake libtool bison libffi-dev