Send hints when scoring
This commit is contained in:
@ -30,6 +30,7 @@ CodeOceanEditorWebsocket = {
|
|||||||
initializeSocketForScoring: function(url) {
|
initializeSocketForScoring: function(url) {
|
||||||
this.initializeSocket(url);
|
this.initializeSocket(url);
|
||||||
this.websocket.on('default',this.handleScoringResponse.bind(this));
|
this.websocket.on('default',this.handleScoringResponse.bind(this));
|
||||||
|
this.websocket.on('hint', this.showHint.bind(this));
|
||||||
this.websocket.on('exit', this.handleExitCommand.bind(this));
|
this.websocket.on('exit', this.handleExitCommand.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ module SubmissionScoring
|
|||||||
submission.exercise.execution_environment.error_templates.each do |template|
|
submission.exercise.execution_environment.error_templates.each do |template|
|
||||||
pattern = Regexp.new(template.signature).freeze
|
pattern = Regexp.new(template.signature).freeze
|
||||||
if pattern.match(testrun_output)
|
if pattern.match(testrun_output)
|
||||||
StructuredError.create_from_template(template, testrun_output)
|
StructuredError.create_from_template(template, testrun_output, submission)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -197,9 +197,8 @@ class SubmissionsController < ApplicationController
|
|||||||
|
|
||||||
def kill_socket(tubesock)
|
def kill_socket(tubesock)
|
||||||
# search for errors and save them as StructuredError (for scoring runs see submission_scoring.rb)
|
# search for errors and save them as StructuredError (for scoring runs see submission_scoring.rb)
|
||||||
extract_errors.each do | error |
|
errors = extract_errors
|
||||||
tubesock.send_data JSON.dump({cmd: 'hint', hint: error.hint, description: error.error_template.description})
|
send_hints(tubesock, errors)
|
||||||
end
|
|
||||||
|
|
||||||
# save the output of this "run" as a "testrun" (scoring runs are saved in submission_scoring.rb)
|
# save the output of this "run" as a "testrun" (scoring runs are saved in submission_scoring.rb)
|
||||||
save_run_output
|
save_run_output
|
||||||
@ -307,11 +306,21 @@ class SubmissionsController < ApplicationController
|
|||||||
# to ensure responsiveness, we therefore open a thread here.
|
# to ensure responsiveness, we therefore open a thread here.
|
||||||
Thread.new {
|
Thread.new {
|
||||||
tubesock.send_data JSON.dump(score_submission(@submission))
|
tubesock.send_data JSON.dump(score_submission(@submission))
|
||||||
|
|
||||||
|
send_hints(tubesock, StructuredError.where(submission: @submission))
|
||||||
|
|
||||||
tubesock.send_data JSON.dump({'cmd' => 'exit'})
|
tubesock.send_data JSON.dump({'cmd' => 'exit'})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
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
|
def set_docker_client
|
||||||
@docker_client = DockerClient.new(execution_environment: @submission.execution_environment)
|
@docker_client = DockerClient.new(execution_environment: @submission.execution_environment)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user