Send hints when scoring

This commit is contained in:
Maximilian Grundke
2018-03-13 14:52:40 +01:00
parent ccdcc43431
commit 841a885711
3 changed files with 14 additions and 4 deletions

View File

@ -30,6 +30,7 @@ CodeOceanEditorWebsocket = {
initializeSocketForScoring: function(url) {
this.initializeSocket(url);
this.websocket.on('default',this.handleScoringResponse.bind(this));
this.websocket.on('hint', this.showHint.bind(this));
this.websocket.on('exit', this.handleExitCommand.bind(this));
},

View File

@ -13,7 +13,7 @@ module SubmissionScoring
submission.exercise.execution_environment.error_templates.each do |template|
pattern = Regexp.new(template.signature).freeze
if pattern.match(testrun_output)
StructuredError.create_from_template(template, testrun_output)
StructuredError.create_from_template(template, testrun_output, submission)
end
end
end

View File

@ -197,9 +197,8 @@ class SubmissionsController < ApplicationController
def kill_socket(tubesock)
# search for errors and save them as StructuredError (for scoring runs see submission_scoring.rb)
extract_errors.each do | error |
tubesock.send_data JSON.dump({cmd: 'hint', hint: error.hint, description: error.error_template.description})
end
errors = extract_errors
send_hints(tubesock, errors)
# save the output of this "run" as a "testrun" (scoring runs are saved in submission_scoring.rb)
save_run_output
@ -307,11 +306,21 @@ class SubmissionsController < ApplicationController
# to ensure responsiveness, we therefore open a thread here.
Thread.new {
tubesock.send_data JSON.dump(score_submission(@submission))
send_hints(tubesock, StructuredError.where(submission: @submission))
tubesock.send_data JSON.dump({'cmd' => 'exit'})
}
end
end
def send_hints(tubesock, errors)
errors = errors.to_a.uniq { |e| e.hint}
errors.each do | error |
tubesock.send_data JSON.dump({cmd: 'hint', hint: error.hint, description: error.error_template.description})
end
end
def set_docker_client
@docker_client = DockerClient.new(execution_environment: @submission.execution_environment)
end