Skip to content

Commit

Permalink
Merge branch 'release/6.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Feb 24, 2023
2 parents 75369c9 + beccbe4 commit fbc6f8a
Show file tree
Hide file tree
Showing 36 changed files with 223 additions and 474 deletions.
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gem 'rails', '~> 7.0.4'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.5.5'
# Use Puma as the app server
gem 'puma', '~> 6.0.2'
gem 'puma', '~> 6.1.0'

# Use dart-sass for stylesheets
gem 'cssbundling-rails', '~> 1.1.2'
Expand Down Expand Up @@ -51,7 +51,7 @@ gem 'will_paginate', '~>3.3.1'
# markdown rendering and syntax highlighting
gem 'kramdown', '~>2.4.0'
gem 'kramdown-parser-gfm', '~>1.1.0'
gem 'rouge', '4.0.1'
gem 'rouge', '4.1.0'

# feedback table builder
gem 'builder', '~>3.2.4'
Expand All @@ -66,7 +66,7 @@ gem 'ace-rails-ap', '~>4.5'
gem 'autoprefixer-rails', '~>10.4.7'

# saml authentication
gem 'devise', '~>4.8.1'
gem 'devise', '~>4.9.0'
gem 'ruby-saml', '~> 1.15.0'

# omniauth
Expand Down Expand Up @@ -114,7 +114,7 @@ gem 'httparty', '~> 0.21.0'
gem 'slack-notifier', '~> 2.4.0'

# css styles for emails
gem 'nokogiri', '~> 1.14.1'
gem 'nokogiri', '~> 1.14.2'
gem 'premailer-rails', '~> 1.12.0'

# filtering
Expand All @@ -124,7 +124,7 @@ gem 'has_scope', '~> 0.8.1'
gem 'rubyzip', '~> 2.3.2'

# memcache
gem 'dalli', '~> 3.2.3'
gem 'dalli', '~> 3.2.4'

# Generate 'random' values like usernames, emails, ...
gem 'faker', '~> 3.1.1'
Expand Down Expand Up @@ -157,15 +157,15 @@ group :development, :test do

# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 3.38.0'
gem 'selenium-webdriver', '~> 4.8.0'
gem 'selenium-webdriver', '~> 4.8.1'
end

group :test do
# For measuring coverage
gem 'codecov', '~> 0.6.0', require: false
gem 'minitest-ci', '~> 3.4.0'
gem 'simplecov', '~> 0.21.2', require: false
gem 'test-prof', '~> 1.1.0'
gem 'test-prof', '~> 1.2.0'

# Mocking HTTP requests to third parties.
gem 'webmock'
Expand Down
36 changes: 18 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ GEM
cssbundling-rails (1.1.2)
railties (>= 6.0.0)
daemons (1.4.1)
dalli (3.2.3)
dalli (3.2.4)
date (3.3.3)
ddtrace (1.9.0)
debase-ruby_core_source (>= 0.10.16, <= 3.2.0)
Expand All @@ -151,7 +151,7 @@ GEM
delayed_job (> 2.0.3)
rack-protection (>= 1.5.5)
sinatra (>= 1.4.4)
devise (4.8.1)
devise (4.9.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
Expand Down Expand Up @@ -282,7 +282,7 @@ GEM
net-protocol
net-ssh (7.0.1)
nio4r (2.5.8)
nokogiri (1.14.1-x86_64-linux)
nokogiri (1.14.2-x86_64-linux)
racc (~> 1.4)
oauth2 (2.0.8)
faraday (>= 0.17.3, < 3.0)
Expand Down Expand Up @@ -335,7 +335,7 @@ GEM
pretender (0.4.0)
actionpack (>= 5.2)
public_suffix (5.0.1)
puma (6.0.2)
puma (6.1.0)
nio4r (~> 2.0)
pundit (2.3.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -393,11 +393,11 @@ GEM
ffi (~> 1.0)
rb-readline (0.5.5)
regexp_parser (2.6.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.5)
rouge (4.0.1)
rouge (4.1.0)
rubocop (1.41.1)
json (~> 2.3)
parallel (~> 1.10)
Expand All @@ -422,7 +422,7 @@ GEM
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-webdriver (4.8.0)
selenium-webdriver (4.8.1)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -458,7 +458,7 @@ GEM
httpclient (>= 2.4)
terser (1.1.13)
execjs (>= 0.3.0, < 3)
test-prof (1.1.0)
test-prof (1.2.0)
thor (1.2.1)
tilt (2.0.11)
timeout (0.3.1)
Expand Down Expand Up @@ -493,7 +493,7 @@ GEM
will_paginate (3.3.1)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.6)
zeitwerk (2.6.7)

PLATFORMS
x86_64-linux
Expand All @@ -516,11 +516,11 @@ DEPENDENCIES
codecov (~> 0.6.0)
counter_culture (~> 3.2)
cssbundling-rails (~> 1.1.2)
dalli (~> 3.2.3)
dalli (~> 3.2.4)
ddtrace (~> 1.9.0)
delayed_job_active_record (~> 4.1.7)
delayed_job_web (~> 1.4.4)
devise (~> 4.8.1)
devise (~> 4.9.0)
diff-lcs (~> 1.5)
docker-api (~> 2.2.0)
ed25519
Expand Down Expand Up @@ -549,31 +549,31 @@ DEPENDENCIES
minitest-utils (~> 0.4.8)
mocha (~> 2.0.2)
mysql2 (~> 0.5.5)
nokogiri (~> 1.14.1)
nokogiri (~> 1.14.2)
omniauth-google-oauth2 (~> 1.1.1)
omniauth-oauth2 (~> 1.8.0)
omniauth-rails_csrf_protection (~> 1.0.1)
omniauth_openid_connect (~> 0.6.0)
premailer-rails (~> 1.12.0)
pretender (~> 0.4.0)
puma (~> 6.0.2)
puma (~> 6.1.0)
pundit (~> 2.3.0)
rack-mini-profiler (~> 3.0.0)
rails (~> 7.0.4)
rails-controller-testing (~> 1.0.5)
rails-i18n (~> 7.0.6)
rb-readline (~> 0.5.5)
rouge (= 4.0.1)
rouge (= 4.1.0)
rubocop-rails (~> 2.17.4)
ruby-saml (~> 1.15.0)
rubyzip (~> 2.3.2)
selenium-webdriver (~> 4.8.0)
selenium-webdriver (~> 4.8.1)
simplecov (~> 0.21.2)
slack-notifier (~> 2.4.0)
sprockets-rails (~> 3.4.2)
stackprof (~> 0.2.23)
terser (>= 1.1.1)
test-prof (~> 1.1.0)
test-prof (~> 1.2.0)
tzinfo-data
web-console (~> 4.2.0)
webmock
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/datalist_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class DatalistInput extends watchMixin(ShadowlessLitElement) {

set filter(value: string) {
this._filter = value;
this.value = this.options.find(o => this.filter === o.label)?.value || "";
this.value = this.options?.find(o => this.filter === o.label)?.value || "";
this.fireEvent();
}

Expand All @@ -58,7 +58,7 @@ export class DatalistInput extends watchMixin(ShadowlessLitElement) {
// If we can find a result amongst the filtered options
// dispatch an event
if (!this.value) {
this.value = this.options.find(o => this.filter === o.label)?.value || "";
this.value = this.options?.find(o => this.filter === o.label)?.value || "";
if (this.value) {
this.fireEvent();
}
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/models/questions.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
width: 100px;
}

col.question {
min-width: 150px;
}

col.age {
width: 240px;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def hook
do_reprocess = true
user_hash[:user] = @repository.admins.first
end
@repository.delay(queue: 'git').process_activities_email_errors(**user_hash) if do_reprocess
@repository.process_activities_email_errors_delayed(**user_hash) if do_reprocess

render plain: msg, status: :ok
end
Expand Down
24 changes: 1 addition & 23 deletions app/controllers/series_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class SeriesController < ApplicationController
include ExportHelper
include SetLtiMessage

before_action :set_series, except: %i[index new create indianio_download]
before_action :set_series, except: %i[index new create]
before_action :check_token, only: %i[show overview]
before_action :set_lti_message, only: %i[show]
before_action :set_lti_provider, only: %i[show]
Expand Down Expand Up @@ -148,9 +148,6 @@ def reset_token
type = params[:type].to_sym
value =
case type
when :indianio_token
@series.generate_indianio_token
@series.indianio_token
when :access_token
@series.generate_access_token
series_url(@series, token: @series.access_token)
Expand All @@ -170,25 +167,6 @@ def reset_token
}
end

def indianio_download
token = params[:token]
email = params[:email]
@series = Series.find_by(indianio_token: token)
if token.blank? || @series.nil?
render json: { errors: ['Wrong token'] }, status: :unauthorized
elsif email.blank?
render json: { errors: ['No email given'] }, status: :unprocessable_entity
else
user = User.find_by(email: email)
if user
options = { deadline: true, only_last_submission: true, with_info: true, all_students: true, indianio: true }
send_zip Zipper.new(item: @series, list: @series.exercises, users: [user], options: options, for_user: user).bundle
else
render json: { errors: ['Unknown email'] }, status: :not_found
end
end
end

def add_activity
@activity = Activity.find(params[:activity_id])
unless @activity.usable_by? @series.course
Expand Down
12 changes: 12 additions & 0 deletions app/helpers/courses_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,16 @@ def registration_action_for(**args)
tag.p t('courses.registration.already_a_member')
end
end

def visibility_icons_for(course)
icons = []
if course.closed? || course.moderated
title = []
title.push t("courses.show.registration-#{course.registration}-info", institution: course.institution&.name) if course.hidden?
title.push t('courses.show.moderated-info') if course.moderated
icons.push tag.i class: 'mdi mdi-account-remove-outline', title: title.join("\n")
end
icons.push tag.i class: 'mdi mdi-eye-off-outline', title: t("courses.show.visibility-#{course.visibility}-info", institution: course.institution&.name) if course.hidden?
icons.join(' ').html_safe
end
end
37 changes: 10 additions & 27 deletions app/helpers/export_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Zipper

attr_reader :users, :item, :errors

CONVERT_TO_BOOL = %w[indianio deadline all_students only_last_submission with_info all with_labels].freeze
SUPPORTED_OPTIONS = %w[indianio deadline all_students group_by only_last_submission with_info all with_labels].freeze
CONVERT_TO_BOOL = %w[deadline all_students only_last_submission with_info all with_labels].freeze
SUPPORTED_OPTIONS = %w[deadline all_students group_by only_last_submission with_info all with_labels].freeze

# Keywords used:
# :item : A User, Course or Series for which submissions will be exported
Expand Down Expand Up @@ -62,11 +62,6 @@ def labels?
@options[:with_labels].present?
end

# Exporting a zip for Indianio: make sure to return specific output for this request
def indianio?
@options[:indianio].present?
end

# Whether to include all submissions or just the last one per exercise
def only_last_submission?
@options[:only_last_submission].present?
Expand All @@ -93,8 +88,6 @@ def all?
end

def zip_filename
return "#{@item.name.parameterize}-#{@users.first.full_name.parameterize}.zip" if indianio?

@item.is_a?(User) ? "#{@item.full_name.parameterize}.zip" : "#{@item.name.parameterize}.zip"
end

Expand Down Expand Up @@ -150,8 +143,6 @@ def course_fn(c)
# If a course is being exported, the names of the series will be present in the filenames
# If the submissions of a user are being exported, the course name will also be present if it exists for the submission
def get_filename(user, exercise, submission = nil)
return exercise.file_name if indianio?

ex_and_series_fn = ex_fn(exercise)
unless @item.is_a?(Series)
series = @series_per_exercise[exercise.id]
Expand Down Expand Up @@ -181,14 +172,10 @@ def generate_zip_data(users, exercises, submissions)
exercises_per_user = Hash.new { |hash, user| hash[user] = Set.new }
stringio = Zip::OutputStream.write_buffer do |zio|
info = CSV.generate(force_quotes: true) do |csv|
csv << if indianio?
%w[filename status submission_id name_en name_nl exercise_id]
else
headers = %w[filename id username last_name first_name full_name email]
headers << 'labels' if labels?
headers += %w[status submission_id name_en name_nl exercise_id created_at]
headers
end
headers = %w[filename id username last_name first_name full_name email]
headers << 'labels' if labels?
headers += %w[status submission_id name_en name_nl exercise_id created_at]
csv << headers
submissions.each do |submission|
exercises_per_user[submission.user.id].add(submission.exercise.id)
filename = get_filename submission.user, submission.exercise, submission
Expand Down Expand Up @@ -224,14 +211,10 @@ def write_submission(zio, submission, filename)
end

def csv_submission(csv, user, exercise, submission, filename)
csv << if indianio?
[filename, submission&.status, submission&.id, exercise.name_en, exercise.name_nl, exercise.id]
else
row = [filename, user.id, user.username, user.last_name, user.first_name, user.full_name, user.email]
row << @users_labels[user].map(&:name).join(';') if labels?
row += [submission&.status, submission&.id, exercise.name_en, exercise.name_nl, exercise.id, submission&.created_at]
row
end
row = [filename, user.id, user.username, user.last_name, user.first_name, user.full_name, user.email]
row << @users_labels[user].map(&:name).join(';') if labels?
row += [submission&.status, submission&.id, exercise.name_en, exercise.name_nl, exercise.id, submission&.created_at]
csv << row
end

def bundle
Expand Down
6 changes: 6 additions & 0 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Repository < ApplicationRecord
before_create :create_full_path
after_create :clone_repo_delayed

after_save :process_activities_email_errors_delayed, if: :saved_change_to_judge_id?

belongs_to :judge
has_many :activities, dependent: :restrict_with_error
has_many :labels,
Expand Down Expand Up @@ -110,6 +112,10 @@ def clone_repo
process_activities_email_errors if clone_complete?
end

def process_activities_email_errors_delayed(kwargs = {})
delay(queue: 'git').process_activities_email_errors(kwargs)
end

def process_activities_email_errors(kwargs = {})
kwargs[:user] = admins.first if kwargs.empty? && admins.any?
kwargs[:email] = Rails.application.config.dodona_email if kwargs.empty?
Expand Down
Loading

0 comments on commit fbc6f8a

Please sign in to comment.