Merge pull request #235 from openHPI/remove_old_hints
Completely remove old hints connected to the execution environment
This commit is contained in:
@ -436,7 +436,6 @@ configureEditors: function () {
|
||||
url: $('#editor').data('errors-url')
|
||||
});
|
||||
jqxhr.always(this.hideSpinner);
|
||||
jqxhr.done(this.renderHint);
|
||||
},
|
||||
|
||||
toggleButtonStates: function () {
|
||||
@ -482,7 +481,6 @@ configureEditors: function () {
|
||||
|
||||
resetOutputTab: function () {
|
||||
this.clearOutput();
|
||||
$('#hint').fadeOut();
|
||||
$('#flowrHint').fadeOut();
|
||||
this.clearHints();
|
||||
this.showOutputBar();
|
||||
|
@ -57,14 +57,6 @@ CodeOceanEditorEvaluation = {
|
||||
}
|
||||
},
|
||||
|
||||
renderHint: function (object) {
|
||||
var hint = object.data || object.hint;
|
||||
if (hint) {
|
||||
$('#hint .card-body').text(hint);
|
||||
$('#hint').fadeIn();
|
||||
}
|
||||
},
|
||||
|
||||
renderScore: function () {
|
||||
var score = parseFloat($('#score').data('score'));
|
||||
var maximum_score = parseFloat($('#score').data('maximum-score'));
|
||||
|
@ -64,10 +64,6 @@ button i.fa-spin {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#hint {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#outputInformation {
|
||||
#output {
|
||||
max-height: 500px;
|
||||
|
@ -1,45 +0,0 @@
|
||||
module CodeOcean
|
||||
class ErrorsController < ApplicationController
|
||||
before_action :set_execution_environment
|
||||
|
||||
def authorize!
|
||||
authorize(@error || @errors)
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
def create
|
||||
@error = CodeOcean::Error.new(error_params)
|
||||
authorize!
|
||||
hint = Whistleblower.new(execution_environment: @error.execution_environment).generate_hint(@error.message)
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
if hint
|
||||
render(json: {hint: hint})
|
||||
else
|
||||
head (@error.save ? :created : :unprocessable_entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def error_params
|
||||
params[:error].permit(:message, :submission_id).merge(execution_environment_id: @execution_environment.id) if params[:error].present?
|
||||
end
|
||||
private :error_params
|
||||
|
||||
def index
|
||||
@errors = CodeOcean::Error.for_execution_environment(@execution_environment).grouped_by_message.paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
def set_execution_environment
|
||||
@execution_environment = ExecutionEnvironment.find(params[:execution_environment_id])
|
||||
end
|
||||
private :set_execution_environment
|
||||
|
||||
def show
|
||||
@error = CodeOcean::Error.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
end
|
||||
end
|
@ -1,57 +0,0 @@
|
||||
class HintsController < ApplicationController
|
||||
include CommonBehavior
|
||||
|
||||
before_action :set_execution_environment
|
||||
before_action :set_hint, only: MEMBER_ACTIONS
|
||||
|
||||
def authorize!
|
||||
authorize(@hint || @hints)
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
def create
|
||||
@hint = Hint.new(hint_params)
|
||||
authorize!
|
||||
create_and_respond(object: @hint, path: proc { execution_environment_hint_path(@execution_environment, @hint) })
|
||||
end
|
||||
|
||||
def destroy
|
||||
destroy_and_respond(object: @hint, path: execution_environment_hints_path(@execution_environment))
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def hint_params
|
||||
params[:hint].permit(:locale, :message, :name, :regular_expression).merge(execution_environment_id: @execution_environment.id) if params[:hint].present?
|
||||
end
|
||||
private :hint_params
|
||||
|
||||
def index
|
||||
@hints = @execution_environment.hints.order(:name).paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
def new
|
||||
@hint = Hint.new
|
||||
authorize!
|
||||
end
|
||||
|
||||
def set_execution_environment
|
||||
@execution_environment = ExecutionEnvironment.find(params[:execution_environment_id])
|
||||
end
|
||||
private :set_execution_environment
|
||||
|
||||
def set_hint
|
||||
@hint = Hint.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_hint
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
update_and_respond(object: @hint, params: hint_params, path: execution_environment_hint_path(@execution_environment, @hint))
|
||||
end
|
||||
end
|
@ -126,14 +126,6 @@ class SubmissionsController < ApplicationController
|
||||
|
||||
# server_sent_event.write({stdout: output[:stdout]}, event: 'output') if output[:stdout]
|
||||
# server_sent_event.write({stderr: output[:stderr]}, event: 'output') if output[:stderr]
|
||||
|
||||
# unless output[:stderr].nil?
|
||||
# if hint = Whistleblower.new(execution_environment: @submission.execution_environment).generate_hint(output[:stderr])
|
||||
# server_sent_event.write(hint, event: 'hint')
|
||||
# else
|
||||
# store_error(output[:stderr])
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
hijack do |tubesock|
|
||||
@ -365,11 +357,6 @@ class SubmissionsController < ApplicationController
|
||||
head :ok
|
||||
end
|
||||
|
||||
def store_error(stderr)
|
||||
CodeOcean::Error.create(submission_id: @submission.id, execution_environment_id: @submission.execution_environment.id, message: stderr)
|
||||
end
|
||||
private :store_error
|
||||
|
||||
def test
|
||||
hijack do |tubesock|
|
||||
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
||||
|
@ -1,19 +0,0 @@
|
||||
module CodeOcean
|
||||
class Error < ApplicationRecord
|
||||
belongs_to :execution_environment
|
||||
|
||||
scope :for_execution_environment, ->(execution_environment) { where(execution_environment_id: execution_environment.id) }
|
||||
scope :grouped_by_message, -> { select('MAX(created_at) AS created_at, MAX(id) AS id, message, COUNT(id) AS count').group(:message).order('count DESC') }
|
||||
|
||||
validates :execution_environment_id, presence: true
|
||||
validates :message, presence: true
|
||||
|
||||
def self.nested_resource?
|
||||
true
|
||||
end
|
||||
|
||||
def to_s
|
||||
id.to_s
|
||||
end
|
||||
end
|
||||
end
|
@ -10,7 +10,6 @@ class ExecutionEnvironment < ApplicationRecord
|
||||
|
||||
has_many :exercises
|
||||
belongs_to :file_type
|
||||
has_many :hints
|
||||
has_many :error_templates
|
||||
|
||||
scope :with_exercises, -> { where('id IN (SELECT execution_environment_id FROM exercises)') }
|
||||
|
@ -1,17 +0,0 @@
|
||||
class Hint < ApplicationRecord
|
||||
belongs_to :execution_environment
|
||||
|
||||
validates :execution_environment_id, presence: true
|
||||
validates :locale, presence: true
|
||||
validates :message, presence: true
|
||||
validates :name, presence: true
|
||||
validates :regular_expression, presence: true
|
||||
|
||||
def self.nested_resource?
|
||||
true
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
module CodeOcean
|
||||
class ErrorPolicy < AdminOrAuthorPolicy
|
||||
def author?
|
||||
@user == @record.execution_environment.author
|
||||
end
|
||||
end
|
||||
end
|
@ -1,5 +0,0 @@
|
||||
class HintPolicy < AdminOrAuthorPolicy
|
||||
def author?
|
||||
@user == @record.execution_environment.author
|
||||
end
|
||||
end
|
@ -1,19 +0,0 @@
|
||||
h1 = CodeOcean::Error.model_name.human(count: 2)
|
||||
|
||||
.table-responsive
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th = t('errors.index.count')
|
||||
th = t('activerecord.attributes.error.message')
|
||||
th = t('shared.created_at')
|
||||
th = t('shared.actions')
|
||||
tbody
|
||||
- @errors.each do |error|
|
||||
tr
|
||||
td = error.count
|
||||
td = error.message
|
||||
td = l(error.created_at, format: :short)
|
||||
td = link_to(t('shared.show'), execution_environment_error_path(params[:execution_environment_id], error))
|
||||
|
||||
p = render('shared/pagination', collection: @errors)
|
@ -1,4 +0,0 @@
|
||||
h1 = CodeOcean::Error.model_name.human
|
||||
|
||||
= row(label: 'error.message', value: @error.message)
|
||||
= row(label: 'shared.created_at', value: l(@error.created_at, format: :short))
|
@ -11,7 +11,6 @@ h1 = ExecutionEnvironment.model_name.human(count: 2)
|
||||
th = t('activerecord.attributes.execution_environment.network_enabled')
|
||||
th = t('activerecord.attributes.execution_environment.permitted_execution_time')
|
||||
th colspan=5 = t('shared.actions')
|
||||
th colspan=2 = t('shared.resources')
|
||||
tbody
|
||||
- @execution_environments.each do |execution_environment|
|
||||
tr
|
||||
@ -26,8 +25,6 @@ h1 = ExecutionEnvironment.model_name.human(count: 2)
|
||||
td = link_to(t('shared.destroy'), execution_environment, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
|
||||
td = link_to(t('.shell'), shell_execution_environment_path(execution_environment))
|
||||
td = link_to(t('shared.statistics'), statistics_execution_environment_path(execution_environment))
|
||||
td = link_to(t('activerecord.models.error.other'), execution_environment_errors_path(execution_environment.id))
|
||||
td = link_to(t('activerecord.models.hint.other'), execution_environment_hints_path(execution_environment.id))
|
||||
|
||||
= render('shared/pagination', collection: @execution_environments)
|
||||
p = render('shared/new_button', model: ExecutionEnvironment)
|
||||
|
@ -4,7 +4,7 @@
|
||||
- show_break_interventions = @show_break_interventions || "false"
|
||||
- show_rfc_interventions = @show_rfc_interventions || "false"
|
||||
- hide_rfc_button = @hide_rfc_button || false
|
||||
#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-errors-url=execution_environment_errors_path(exercise.execution_environment) data-submissions-url=submissions_path data-user-id=@current_user.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-course_token=@course_token data-search-save-url=search_exercise_path(@exercise)
|
||||
#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-submissions-url=submissions_path data-user-id=@current_user.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-course_token=@course_token data-search-save-url=search_exercise_path(@exercise)
|
||||
div id="sidebar" class=(@exercise.hide_file_tree ? 'sidebar-col-collapsed' : 'sidebar-col') = render('editor_file_tree', exercise: @exercise, files: @files)
|
||||
div.editor-col.col.p-0 id='frames'
|
||||
#editor-buttons.btn-group.enforce-bottom-margin
|
||||
|
@ -37,11 +37,6 @@ div.h-100 id='output_sidebar_uncollapsed' class='d-none col-sm-12 enforce-bottom
|
||||
div.enforce-big-top-margin
|
||||
#turtlediv
|
||||
canvas#turtlecanvas.d-none width=400 height=400
|
||||
div.enforce-big-top-margin
|
||||
#hint
|
||||
.card.bg-warning.text-white
|
||||
.card-header = t('exercises.implement.hint')
|
||||
.card-body
|
||||
div.enforce-big-top-margin
|
||||
#prompt.input-group.d-none
|
||||
div.input-group-prepend
|
||||
|
@ -1,17 +0,0 @@
|
||||
= form_for(@hint, url: execution_environment_hints_path(params[:execution_environment_id])) do |f|
|
||||
= render('shared/form_errors', object: @hint)
|
||||
.form-group
|
||||
= f.label(:name)
|
||||
= f.text_field(:name, class: 'form-control', required: true)
|
||||
.form-group
|
||||
= f.label(:locale)
|
||||
= f.select(:locale, I18n.available_locales.map { |locale| [t("locales.#{locale}"), locale] }, {}, class: 'form-control')
|
||||
.form-group
|
||||
= f.label(:message)
|
||||
= f.text_field(:message, class: 'form-control', placeholder: "'$2' has no method '$1'.", required: true)
|
||||
.help-block.form-text = t('.hints.message')
|
||||
.form-group
|
||||
= f.label(:regular_expression)
|
||||
= f.text_field(:regular_expression, class: 'form-control', placeholder: 'undefined method (\w+) for (\w+)', required: true)
|
||||
.help-block.form-text = t('.hints.regular_expression')
|
||||
.actions = render('shared/submit_button', f: f, object: @hint)
|
@ -1,3 +0,0 @@
|
||||
h1 = @hint
|
||||
|
||||
= render('form')
|
@ -1,20 +0,0 @@
|
||||
h1 = Hint.model_name.human(count: 2)
|
||||
|
||||
.table-responsive
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th = t('activerecord.attributes.hint.name')
|
||||
th = t('activerecord.attributes.hint.locale')
|
||||
th colspan=3 = t('shared.actions')
|
||||
tbody
|
||||
- @hints.each do |hint|
|
||||
tr
|
||||
td = hint.name
|
||||
td = t("locales.#{hint.locale}")
|
||||
td = link_to(t('shared.show'), execution_environment_hint_path(params[:execution_environment_id], hint.id))
|
||||
td = link_to(t('shared.edit'), edit_execution_environment_hint_path(params[:execution_environment_id], hint.id))
|
||||
td = link_to(t('shared.destroy'), execution_environment_hint_path(params[:execution_environment_id], hint.id), data: {confirm: t('shared.confirm_destroy')}, method: :delete)
|
||||
|
||||
= render('shared/pagination', collection: @hints)
|
||||
p = render('shared/new_button', model: Hint, path: new_execution_environment_hint_path(params[:execution_environment_id]))
|
@ -1,3 +0,0 @@
|
||||
h1 = t('shared.new_model', model: Hint.model_name.human)
|
||||
|
||||
= render('form')
|
@ -1,8 +0,0 @@
|
||||
h1
|
||||
= @hint
|
||||
= render('shared/edit_button', object: @hint, path: edit_execution_environment_hint_path(params[:execution_environment_id], @hint.id))
|
||||
|
||||
= row(label: 'hint.name', value: @hint.name)
|
||||
= row(label: 'hint.locale', value: t("locales.#{@hint.locale}"))
|
||||
= row(label: 'hint.message', value: @hint.message)
|
||||
= row(label: 'hint.regular_expression', value: code_tag(@hint.regular_expression))
|
@ -5,8 +5,7 @@ h1 = Tag.model_name.human(count: 2)
|
||||
thead
|
||||
tr
|
||||
th = t('activerecord.attributes.hint.name')
|
||||
/th = t('activerecord.attributes.hint.locale')
|
||||
/th colspan=3 = t('shared.actions')
|
||||
th colspan=3 = t('shared.actions')
|
||||
tbody
|
||||
- @tags.each do |tag|
|
||||
tr
|
||||
|
Reference in New Issue
Block a user