add cause to testruns
trigger run and assess on request_for_comment
This commit is contained in:

committed by
Maximilian Grundke

parent
6dc34d3ebe
commit
194984a620
@ -59,8 +59,6 @@ CodeOceanEditorCodePilot = {
|
||||
}
|
||||
};
|
||||
|
||||
//Request for comments does currently not work on staging platform (no relative root_url used here).
|
||||
//To fix this rely on ruby routes
|
||||
CodeOceanEditorRequestForComments = {
|
||||
requestComments: function () {
|
||||
var user_id = $('#editor').data('user-id');
|
||||
@ -83,6 +81,8 @@ CodeOceanEditorRequestForComments = {
|
||||
}).done(function () {
|
||||
this.hideSpinner();
|
||||
$.flash.success({text: $('#askForCommentsButton').data('message-success')});
|
||||
// trigger a run
|
||||
this.runSubmission.call(this, submission);
|
||||
}.bind(this)).error(this.ajaxError.bind(this));
|
||||
};
|
||||
|
||||
|
@ -144,17 +144,19 @@ CodeOceanEditorSubmissions = {
|
||||
runCode: function(event) {
|
||||
event.preventDefault();
|
||||
if ($('#run').is(':visible')) {
|
||||
this.createSubmission('#run', null, function(response) {
|
||||
this.createSubmission('#run', null, this.runSubmission.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
runSubmission: function (submission) {
|
||||
//Run part starts here
|
||||
$('#stop').data('url', response.stop_url);
|
||||
$('#stop').data('url', submission.stop_url);
|
||||
this.running = true;
|
||||
this.showSpinner($('#run'));
|
||||
$('#score_div').addClass('hidden');
|
||||
this.toggleButtonStates();
|
||||
var url = response.run_url.replace(this.FILENAME_URL_PLACEHOLDER, this.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor
|
||||
var url = submission.run_url.replace(this.FILENAME_URL_PLACEHOLDER, this.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor
|
||||
this.initializeSocketForRunning(url);
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
saveCode: function(event) {
|
||||
|
@ -42,6 +42,14 @@ div.positive-result {
|
||||
box-shadow: 0px 0px 11px 1px rgba(44,222,0,1);
|
||||
}
|
||||
|
||||
div.unknown-result {
|
||||
border-radius: 50%;
|
||||
background-color: #ffca00;
|
||||
-webkit-box-shadow: 0px 0px 11px 1px rgb(255, 202, 0);
|
||||
-moz-box-shadow: 0px 0px 11px 1px rgb(255, 202, 0);
|
||||
box-shadow: 0px 0px 11px 1px rgb(255, 202, 0);
|
||||
}
|
||||
|
||||
div.negative-result {
|
||||
border-radius: 50%;
|
||||
background-color: #ff2600;
|
||||
|
@ -9,7 +9,7 @@ module SubmissionScoring
|
||||
assessment = assessor.assess(output)
|
||||
passed = ((assessment[:passed] == assessment[:count]) and (assessment[:score] > 0))
|
||||
testrun_output = passed ? nil : output[:stderr]
|
||||
Testrun.new(submission: submission, file: file, passed: passed, output: testrun_output).save
|
||||
Testrun.new(submission: submission, cause: 'assess', file: file, passed: passed, output: testrun_output).save
|
||||
output.merge!(assessment)
|
||||
output.merge!(filename: file.name_with_extension, message: feedback_message(file, output[:score]), weight: file.weight)
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
class RequestForCommentsController < ApplicationController
|
||||
include SubmissionScoring
|
||||
before_action :set_request_for_comment, only: [:show, :edit, :update, :destroy, :mark_as_solved, :set_thank_you_note]
|
||||
|
||||
skip_after_action :verify_authorized
|
||||
@ -107,6 +108,10 @@ class RequestForCommentsController < ApplicationController
|
||||
@request_for_comment = RequestForComment.new(request_for_comment_params)
|
||||
respond_to do |format|
|
||||
if @request_for_comment.save
|
||||
# create thread here and execute tests. A run is triggered from the frontend and does not need to be handled here.
|
||||
Thread.new do
|
||||
score_submission(@request_for_comment.submission)
|
||||
end
|
||||
format.json { render :show, status: :created, location: @request_for_comment }
|
||||
else
|
||||
format.html { render :new }
|
||||
|
@ -262,7 +262,7 @@ class SubmissionsController < ApplicationController
|
||||
def save_run_output
|
||||
if !@message_buffer.blank?
|
||||
@message_buffer = @message_buffer[(0..max_message_buffer_size-1)] # trim the string to max_message_buffer_size chars
|
||||
Testrun.create(file: @file, submission: @submission, output: @message_buffer)
|
||||
Testrun.create(file: @file, cause: 'run', submission: @submission, output: @message_buffer)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -54,8 +54,10 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
||||
-submission_or_intervention.testruns.each do |run|
|
||||
- if run.passed
|
||||
.unit-test-result.positive-result title=run.output
|
||||
- else
|
||||
- elsif run.failed
|
||||
.unit-test-result.negative-result title=run.output
|
||||
- else
|
||||
.unit-test-result.unknown-result title=run.output
|
||||
td = Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0
|
||||
-working_times_until.push((Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0))
|
||||
- elsif submission_or_intervention.is_a? UserExerciseIntervention
|
||||
|
18
db/migrate/20170830083601_add_cause_to_testruns.rb
Normal file
18
db/migrate/20170830083601_add_cause_to_testruns.rb
Normal file
@ -0,0 +1,18 @@
|
||||
class AddCauseToTestruns < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :testruns, :cause, :string
|
||||
Testrun.reset_column_information
|
||||
Testrun.all.each{ |testrun|
|
||||
if(testrun.submission.nil?)
|
||||
say_with_time "#{testrun.id} has no submission" do end
|
||||
else
|
||||
testrun.cause = testrun.submission.cause
|
||||
testrun.save
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :testruns, :cause
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user