From c88a57c4105d89c20e747b5bc9f945d2817aeed5 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Fri, 7 Oct 2016 16:38:22 +0200 Subject: [PATCH 1/3] some comments and update of gem conccurrent-ruby --- Gemfile.lock | 4 ++-- codeocean-dockerconfig.md | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 codeocean-dockerconfig.md diff --git a/Gemfile.lock b/Gemfile.lock index 527a91fe..18067c27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,8 +96,8 @@ GEM coffee-script-source execjs coffee-script-source (1.10.0) - concurrent-ruby (1.0.0) - concurrent-ruby (1.0.0-java) + concurrent-ruby (1.0.2) + concurrent-ruby (1.0.2-java) concurrent-ruby-ext (1.0.0) concurrent-ruby (~> 1.0.0) d3-rails (3.5.11) diff --git a/codeocean-dockerconfig.md b/codeocean-dockerconfig.md new file mode 100644 index 00000000..84331a8a --- /dev/null +++ b/codeocean-dockerconfig.md @@ -0,0 +1,11 @@ +In order to make containers accessible for codeocean, they need to be reachable via tcp. +For this, the docker daemon has to be started with the following options: + +DOCKER_OPTS='-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock --iptables=false' + +This binds the daemon to the specified socket (for access via the command line on the machine) as well as the specified tcp url. +Either pass these options to the starting call, or specify them in the docker config file. + +In Ubuntu, this file is located under: /ect/default/docker + +In Debian, please refer to the RHEL and CentOS part under that link: https://docs.docker.com/engine/admin/#/configuring-docker-1 From e8f93cb870e3dbec7dea3cc4d27a5cf2c990e543 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 9 Nov 2016 17:56:56 +0100 Subject: [PATCH 2/3] Removed bin folder from linked_dirs in deploy, otherwise no rails console can be started on the servers, because the directory will be empty (as stated on several stackoverflow questions, for example: http://stackoverflow.com/questions/29039927/rails-4-doesnt-detect-application-after-capistrano-deployment ) --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index a1567cb7..173f2b56 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -3,7 +3,7 @@ set :config_example_suffix, '.example' set :default_env, 'PATH' => '/usr/java/jdk1.8.0_40/bin:$PATH' set :deploy_to, '/var/www/app' set :keep_releases, 3 -set :linked_dirs, %w(bin log public/uploads tmp/cache tmp/files tmp/pids tmp/sockets) +set :linked_dirs, %w(log public/uploads tmp/cache tmp/files tmp/pids tmp/sockets) set :linked_files, %w(config/action_mailer.yml config/code_ocean.yml config/database.yml config/newrelic.yml config/secrets.yml config/sendmail.yml config/smtp.yml) set :log_level, :info set :puma_threads, [0, 16] From ff7446fde6972acd28e4612246350efc77965597 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 9 Nov 2016 17:58:10 +0100 Subject: [PATCH 3/3] redirect to RFCs on max score: redirect users to their own RFCs if they are open, fixed wrong usage of user_id (external_id is not used in RFCs, normal id has to be used!). --- app/controllers/exercises_controller.rb | 35 ++++++++++++------- .../request_for_comments_controller.rb | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 75451eb3..cb6e9c9d 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -247,23 +247,34 @@ class ExercisesController < ApplicationController end def redirect_after_submit - Rails.logger.debug('Score ' + @submission.normalized_score.to_s) + Rails.logger.debug('Redirecting user with score:s ' + @submission.normalized_score.to_s) if @submission.normalized_score == 1.0 - # if user has an own rfc, redirect to it and message him to clean up and accept the answer. + # if user is external and has an own rfc, redirect to it and message him to clean up and accept the answer. (we need to check that the user is external, + # otherwise an internal user could be shown a false rfc here, since current_user.id is polymorphic, but only makes sense for external users when used with rfcs.) + if current_user.respond_to? :external_id + if rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise, user_id: current_user.id).first + # set a message that informs the user that his own RFC should be closed. + flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_own_rfc') + flash.keep(:notice) - # else: show open rfc for same exercise - if rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise).order("RANDOM()").first + respond_to do |format| + format.html { redirect_to(rfc) } + format.json { render(json: {redirect: url_for(rfc)}) } + end + return - # set a message that informs the user that his score was perfect and help in RFC is greatly appreciated. - flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc') - flash.keep(:notice) + # else: show open rfc for same exercise if available + elsif rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise).order("RANDOM()").first + # set a message that informs the user that his score was perfect and help in RFC is greatly appreciated. + flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc') + flash.keep(:notice) - respond_to do |format| - format.html { redirect_to(rfc) } - format.json { render(json: {redirect: url_for(rfc)}) } + respond_to do |format| + format.html { redirect_to(rfc) } + format.json { render(json: {redirect: url_for(rfc)}) } + end + return end - - return end end redirect_to_lti_return_path diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb index 37d8bef9..f9e7137e 100644 --- a/app/controllers/request_for_comments_controller.rb +++ b/app/controllers/request_for_comments_controller.rb @@ -82,6 +82,7 @@ class RequestForCommentsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def request_for_comment_params + # we are using the current_user.id here, since internal users are not able to create comments. The external_user.id is a primary key and does not require the consumer_id to be unique. params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at, :solved, :submission_id).merge(user_id: current_user.id, user_type: current_user.class.name) end end diff --git a/config/locales/de.yml b/config/locales/de.yml index a57b2c04..b34d6a7a 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -274,6 +274,7 @@ de: submit: failure: Beim Übermitteln Ihrer Punktzahl ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut. full_score_redirect_to_rfc: Herzlichen Glückwunsch! Sie haben die maximale Punktzahl für diese Aufgabe an den Kurs übertragen. Ein anderer Teilnehmer hat eine Frage zu der von Ihnen gelösten Aufgabe. Er würde sich sicherlich sehr über ihre Hilfe und Kommentare freuen. + full_score_redirect_to_own_rfc: Herzlichen Glückwunsch! Sie haben die maximale Punktzahl für diese Aufgabe an den Kurs übertragen. Ihre Frage ist damit wahrscheinlich gelöst? Falls ja, fügen Sie doch den entscheidenden Kniff als Antwort hinzu und markieren die Frage als gelöst, bevor sie das Fenster schließen. external_users: statistics: no_data_available: Keine Daten verfügbar. diff --git a/config/locales/en.yml b/config/locales/en.yml index 691dfe72..e1663e5d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -274,6 +274,7 @@ en: submit: failure: An error occured while transmitting your score. Please try again later. full_score_redirect_to_rfc: Congratulations! You achieved and submitted the highest possible score for this exercise. Another participant has a question concerning the exercise you just solved. Your help and comments will be greatly appreciated! + full_score_redirect_to_own_rfc: Congratulations! You achieved and submitted the highest possible score for this exercise. Your question concerning the exercise is solved? If so, please share the essential insight with your fellows and mark the question as solved, before you close this window! external_users: statistics: no_data_available: No data available.