diff --git a/app/assets/javascripts/editor/participantsupport.js.erb b/app/assets/javascripts/editor/participantsupport.js.erb index 91e9f0d1..63787f4a 100644 --- a/app/assets/javascripts/editor/participantsupport.js.erb +++ b/app/assets/javascripts/editor/participantsupport.js.erb @@ -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)); }; diff --git a/app/assets/javascripts/editor/submissions.js.erb b/app/assets/javascripts/editor/submissions.js.erb index 20d8cd10..21250f7e 100644 --- a/app/assets/javascripts/editor/submissions.js.erb +++ b/app/assets/javascripts/editor/submissions.js.erb @@ -142,19 +142,21 @@ CodeOceanEditorSubmissions = { * Execution-Logic */ runCode: function(event) { - event.preventDefault(); - if ($('#run').is(':visible')) { - this.createSubmission('#run', null, function(response) { - //Run part starts here - $('#stop').data('url', response.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 - this.initializeSocketForRunning(url); - }.bind(this)); - } + event.preventDefault(); + if ($('#run').is(':visible')) { + this.createSubmission('#run', null, this.runSubmission.bind(this)); + } + }, + + runSubmission: function (submission) { + //Run part starts here + $('#stop').data('url', submission.stop_url); + this.running = true; + this.showSpinner($('#run')); + $('#score_div').addClass('hidden'); + this.toggleButtonStates(); + 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); }, saveCode: function(event) { diff --git a/app/assets/stylesheets/statistics.css.scss b/app/assets/stylesheets/statistics.css.scss index f656cd9a..a5ea4430 100644 --- a/app/assets/stylesheets/statistics.css.scss +++ b/app/assets/stylesheets/statistics.css.scss @@ -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; diff --git a/app/controllers/concerns/submission_scoring.rb b/app/controllers/concerns/submission_scoring.rb index 16f1f061..41f9ff26 100644 --- a/app/controllers/concerns/submission_scoring.rb +++ b/app/controllers/concerns/submission_scoring.rb @@ -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 diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb index 8ef8f866..4fd19a92 100644 --- a/app/controllers/request_for_comments_controller.rb +++ b/app/controllers/request_for_comments_controller.rb @@ -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 } diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 9b37fde0..52baefe1 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -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 diff --git a/app/views/exercises/external_users/statistics.html.slim b/app/views/exercises/external_users/statistics.html.slim index 313a19b0..8b5c3b30 100644 --- a/app/views/exercises/external_users/statistics.html.slim +++ b/app/views/exercises/external_users/statistics.html.slim @@ -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 diff --git a/db/migrate/20170830083601_add_cause_to_testruns.rb b/db/migrate/20170830083601_add_cause_to_testruns.rb new file mode 100644 index 00000000..f9a859c4 --- /dev/null +++ b/db/migrate/20170830083601_add_cause_to_testruns.rb @@ -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