Merge branch 'master' into disable_rfcs

# Conflicts:
#	app/assets/stylesheets/editor.css.scss
This commit is contained in:
Ralf Teusner
2018-03-07 17:30:14 +01:00
26 changed files with 138 additions and 78 deletions

View File

@@ -42,17 +42,14 @@ button i.fa-spin {
background-color: #008CBA;
margin-top: 0;
width: 100%;
display: flex;
button {
font-size: 80%;
}
.button-two-only, .btn-group-two-only {
width: 50%;
}
button, .btn-group {
width: 50%;
flex-grow: 1;
}
.btn-group {
@@ -195,4 +192,4 @@ button i.fa-spin {
.enforce-bottom-margin {
margin-bottom: 5px !important;
}
}

View File

@@ -3,7 +3,8 @@
}
.chosen-container {
width: 250px !important;
min-width: 250px !important;
width: 100% !important;
}
.code-field {

View File

@@ -14,46 +14,40 @@ class RequestForCommentsController < ApplicationController
def index
@search = RequestForComment
.last_per_user(2)
.joins('join "submissions" s on s.id = request_for_comments.submission_id
left outer join "files" f on f.context_id = s.id
left outer join "comments" on comments.file_id = f.id')
.group('request_for_comments.id, request_for_comments.user_id, request_for_comments.exercise_id,
request_for_comments.file_id, request_for_comments.question, request_for_comments.created_at,
request_for_comments.updated_at, request_for_comments.user_type, request_for_comments.solved,
request_for_comments.full_score_reached, request_for_comments.submission_id, request_for_comments.row_number') # ugly, but rails wants it this way
.select('request_for_comments.*, max(comments.updated_at) as last_comment')
.with_last_activity
.search(params[:q])
@request_for_comments = @search.result.order('created_at DESC').paginate(page: params[:page], total_entries: @search.result.length)
@request_for_comments = @search.result
.order('created_at DESC')
.paginate(page: params[:page], total_entries: @search.result.length)
authorize!
end
# GET /my_request_for_comments
def get_my_comment_requests
@search = RequestForComment
.with_last_activity
.where(user_id: current_user.id)
.joins('join "submissions" s on s.id = request_for_comments.submission_id
left outer join "files" f on f.context_id = s.id
left outer join "comments" on comments.file_id = f.id')
.group('request_for_comments.id')
.select('request_for_comments.*, max(comments.updated_at) as last_comment')
.search(params[:q])
@request_for_comments = @search.result.order('created_at DESC').paginate(page: params[:page])
@request_for_comments = @search.result
.order('created_at DESC')
.paginate(page: params[:page])
render 'index'
end
# GET /my_rfc_activity
def get_rfcs_with_my_comments
@search = RequestForComment
.with_last_activity
.joins(:comments) # we don't need to outer join here, because we know the user has commented on these
.where(comments: {user_id: current_user.id})
.joins('join "submissions" s on s.id = request_for_comments.submission_id
left outer join "files" f on f.context_id = s.id
left outer join "comments" as c on c.file_id = f.id')
.group('request_for_comments.id')
.select('request_for_comments.*, max(c.updated_at) as last_comment')
.search(params[:q])
@request_for_comments = @search.result.order('last_comment DESC').paginate(page: params[:page])
@request_for_comments = @search.result
.order('last_comment DESC')
.paginate(page: params[:page])
render 'index'
end
# GET /request_for_comments/1/mark_as_solved
def mark_as_solved
authorize!
@request_for_comment.solved = true
@@ -66,6 +60,7 @@ class RequestForCommentsController < ApplicationController
end
end
# POST /request_for_comments/1/set_thank_you_note
def set_thank_you_note
authorize!
@request_for_comment.thank_you_note = params[:note]
@@ -82,10 +77,6 @@ class RequestForCommentsController < ApplicationController
end
end
def submit
end
# GET /request_for_comments/1
# GET /request_for_comments/1.json
def show
@@ -146,10 +137,6 @@ class RequestForCommentsController < ApplicationController
authorize!
end
def comment_params
params.permit(:exercise_id, :feedback_text).merge(user_id: current_user.id, user_type: current_user.class.name)
end
private
# Use callbacks to share common setup or constraints between actions.
def set_request_for_comment
@@ -162,4 +149,8 @@ class RequestForCommentsController < ApplicationController
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
def comment_params
params.permit(:exercise_id, :feedback_text).merge(user_id: current_user.id, user_type: current_user.class.name)
end
end

View File

@@ -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

View File

@@ -47,7 +47,7 @@ class ExecutionEnvironment < ActiveRecord::Base
private :validate_docker_image?
def working_docker_image?
DockerClient.pull(docker_image) unless DockerClient.image_tags.include?(docker_image)
DockerClient.pull(docker_image) unless DockerClient.find_image_by_tag(docker_image).blank?
output = DockerClient.new(execution_environment: self).execute_arbitrary_command(VALIDATION_COMMAND)
errors.add(:docker_image, "error: #{output[:stderr]}") if output[:stderr].present?
rescue DockerClient::Error => error

View File

@@ -11,7 +11,13 @@ class RequestForComment < ActiveRecord::Base
scope :not_stale, -> { where("user_id%10 <2 OR user_id%10 >= 4").where(exercise.exercise_collections.none{|ec| ec.id = 3} } ########### todo
def self.last_per_user(n = 5)
from("(#{row_number_user_sql}) as request_for_comments").where("row_number <= ?", n)
from("(#{row_number_user_sql}) as request_for_comments")
.where("row_number <= ?", n)
.group('request_for_comments.id, request_for_comments.user_id, request_for_comments.exercise_id,
request_for_comments.file_id, request_for_comments.question, request_for_comments.created_at,
request_for_comments.updated_at, request_for_comments.user_type, request_for_comments.solved,
request_for_comments.full_score_reached, request_for_comments.submission_id, request_for_comments.row_number')
# ugly, but necessary
end
# not used right now, finds the last submission for the respective user and exercise.
@@ -47,6 +53,14 @@ class RequestForComment < ActiveRecord::Base
commenters.uniq {|user| user.id}
end
def self.with_last_activity
self.joins('join "submissions" s on s.id = request_for_comments.submission_id
left outer join "files" f on f.context_id = s.id
left outer join "comments" c on c.file_id = f.id')
.group('request_for_comments.id')
.select('request_for_comments.*, max(c.updated_at) as last_comment')
end
def to_s
"RFC-" + self.id.to_s
end

View File

@@ -1,5 +1,6 @@
#flash.fixed_error_messages data-message-failure=t('shared.message_failure')
- %w[alert danger info notice success warning].each do |severity|
div.alert.flash class="alert-#{{'alert' => 'warning', 'notice' => 'success'}.fetch(severity, severity)}"
p id="flash-#{severity}" = flash[severity]
span.fa.fa-times
#flash-container
#flash.container.fixed_error_messages data-message-failure=t('shared.message_failure')
- %w[alert danger info notice success warning].each do |severity|
div.alert.flash class="alert-#{{'alert' => 'warning', 'notice' => 'success'}.fetch(severity, severity)}"
p id="flash-#{severity}" = flash[severity]
span.fa.fa-times

View File

@@ -32,8 +32,8 @@ html lang='en'
li = link_to(t('shared.help.link'), '#modal-help', data: {toggle: 'modal'})
= render('session')
.container data-controller=controller_name
= render('breadcrumbs')
= render('flash')
= render('breadcrumbs')
- if (controller_name == "exercises" && action_name == "implement")
.container-fluid
= yield

View File

@@ -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)