diff --git a/Gemfile b/Gemfile index 7a4ec659..6a6486a6 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ gem 'carrierwave' gem 'coffee-rails' gem 'concurrent-ruby' gem 'concurrent-ruby-ext', platform: :ruby +gem 'activerecord-deprecated_finders', require: 'active_record/deprecated_finders' gem 'docker-api', require: 'docker' gem 'factory_bot_rails' gem 'forgery' diff --git a/Gemfile.lock b/Gemfile.lock index bf68e982..14913288 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,6 +31,7 @@ GEM activemodel (= 4.2.10) activesupport (= 4.2.10) arel (~> 6.0) + activerecord-deprecated_finders (1.0.4) activerecord-jdbc-adapter (1.3.19) activerecord (>= 2.2) activerecord-jdbcpostgresql-adapter (1.3.19) @@ -385,6 +386,7 @@ PLATFORMS ruby DEPENDENCIES + activerecord-deprecated_finders activerecord-jdbcpostgresql-adapter autotest-rails bcrypt diff --git a/app/assets/stylesheets/editor.css.scss b/app/assets/stylesheets/editor.css.scss index 755e3409..a38157b4 100644 --- a/app/assets/stylesheets/editor.css.scss +++ b/app/assets/stylesheets/editor.css.scss @@ -42,13 +42,14 @@ button i.fa-spin { background-color: #008CBA; margin-top: 0; width: 100%; + display: flex; button { font-size: 80%; } button, .btn-group { - width: 33.33333%; + flex-grow: 1; } .btn-group { @@ -191,4 +192,4 @@ button i.fa-spin { .enforce-bottom-margin { margin-bottom: 5px !important; -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/forms.css.scss b/app/assets/stylesheets/forms.css.scss index 201b5841..69c1722c 100644 --- a/app/assets/stylesheets/forms.css.scss +++ b/app/assets/stylesheets/forms.css.scss @@ -3,7 +3,8 @@ } .chosen-container { - width: 250px !important; + min-width: 250px !important; + width: 100% !important; } .code-field { diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 3e24af1c..410c30cd 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -75,6 +75,11 @@ class SubmissionsController < ApplicationController zio.write(file.content) end + # zip exercise description + zio.put_next_entry(t('activerecord.models.exercise.one') + '.txt') + zio.write(@submission.exercise.title + "\r\n======================\r\n") + zio.write(@submission.exercise.description) + # zip .co file zio.put_next_entry(".co") zio.write(File.read id_file) @@ -167,7 +172,7 @@ class SubmissionsController < ApplicationController # if the command is 'client_kill', send it to docker otherwise. begin parsed = JSON.parse(data) - if parsed['cmd'] == 'client_kill' + if parsed.class == Hash && parsed['cmd'] == 'client_kill' Rails.logger.debug("Client exited container.") @docker_client.kill_container(result[:container]) else diff --git a/app/views/sessions/destroy_through_lti.html.slim b/app/views/sessions/destroy_through_lti.html.slim index 3e55e0fc..d33ced8d 100644 --- a/app/views/sessions/destroy_through_lti.html.slim +++ b/app/views/sessions/destroy_through_lti.html.slim @@ -10,7 +10,7 @@ h2 = t('shared.statistics') = row(label: '.score') do p == t('shared.out_of', maximum_value: @submission.exercise.maximum_score, value: @submission.score) p = progress_bar(@submission.percentage) -= row(label: '.final_submissions', value: @submission.exercise.submissions.final.distinct.count(:user_id, :user_type) - 1) +/= row(label: '.final_submissions', value: @submission.exercise.submissions.final.distinct.count(:user_id, :user_type) - 1) /= row(label: '.average_score') do / p == t('shared.out_of', maximum_value: @submission.exercise.maximum_score, value: @submission.exercise.average_score.round(2)) / p = progress_bar(@submission.exercise.average_percentage) diff --git a/db/migrate/20160630154310_add_submission_to_request_for_comments.rb b/db/migrate/20160630154310_add_submission_to_request_for_comments.rb index d7d13e67..a532bcf9 100644 --- a/db/migrate/20160630154310_add_submission_to_request_for_comments.rb +++ b/db/migrate/20160630154310_add_submission_to_request_for_comments.rb @@ -3,3 +3,31 @@ class AddSubmissionToRequestForComments < ActiveRecord::Migration add_reference :request_for_comments, :submission end end + +=begin +We issued the following on the database to add the submission_ids for existing entries + +UPDATE request_for_comments +SET submission_id = sub.submission_id_external +FROM +(SELECT s.id AS submission_id_external, + rfc.id AS rfc_id, + s.created_at AS submission_created_at, + rfc.created_at AS rfc_created_at +FROM submissions s, + request_for_comments rfc +WHERE s.user_id = rfc.user_id +AND s.exercise_id = rfc.exercise_id +AND rfc.created_at + interval '2 hours' > s.created_at +AND s.created_at = + (SELECT MAX(created_at) + FROM submissions + WHERE exercise_id = s.exercise_id + AND user_id = s.user_id + AND rfc.created_at + interval '2 hours' > created_at + GROUP BY s.exercise_id, + s.user_id)) as sub +WHERE id = sub.rfc_id +AND submission_id IS NULL; + +=end