From b40627b637f18b86afd9720fe588f3114d571178 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Fri, 12 Jun 2020 13:57:55 +0200 Subject: [PATCH] Disable custom Mnemosyne trace --- .../concerns/submission_scoring.rb | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/app/controllers/concerns/submission_scoring.rb b/app/controllers/concerns/submission_scoring.rb index 9cbb2c0f..131680cb 100644 --- a/app/controllers/concerns/submission_scoring.rb +++ b/app/controllers/concerns/submission_scoring.rb @@ -2,45 +2,47 @@ require 'concurrent/future' module SubmissionScoring def collect_test_results(submission) - Mnemosyne.trace 'custom.codeocean.collect_test_results', meta: { submission: submission.id } do - submission.collect_files.select(&:teacher_defined_test?).map do |file| - future = Concurrent::Future.execute do - Mnemosyne.trace 'custom.codeocean.collect_test_results_block', meta: { file: file.id, submission: submission.id } do - assessor = Assessor.new(execution_environment: submission.execution_environment) - output = execute_test_file(file, submission) - assessment = assessor.assess(output) - passed = ((assessment[:passed] == assessment[:count]) and (assessment[:score] > 0)) - testrun_output = passed ? nil : 'message: ' + output[:message].to_s + "\n stdout: " + output[:stdout].to_s + "\n stderr: " + output[:stderr].to_s - unless testrun_output.blank? - 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, submission) - end - end + # Mnemosyne.trace 'custom.codeocean.collect_test_results', meta: { submission: submission.id } do + submission.collect_files.select(&:teacher_defined_test?).map do |file| + future = Concurrent::Future.execute do + # Mnemosyne.trace 'custom.codeocean.collect_test_results_block', meta: { file: file.id, submission: submission.id } do + assessor = Assessor.new(execution_environment: submission.execution_environment) + output = execute_test_file(file, submission) + assessment = assessor.assess(output) + passed = ((assessment[:passed] == assessment[:count]) and (assessment[:score] > 0)) + testrun_output = passed ? nil : 'message: ' + output[:message].to_s + "\n stdout: " + output[:stdout].to_s + "\n stderr: " + output[:stderr].to_s + unless testrun_output.blank? + 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, submission) end - Testrun.new( - submission: submission, - cause: 'assess', - file: file, - passed: passed, - output: testrun_output, - container_execution_time: output[:container_execution_time], - waiting_for_container_time: output[:waiting_for_container_time] - ).save - output.merge!(assessment) - output.merge!(filename: file.name_with_extension, message: feedback_message(file, output[:score]), weight: file.weight) end end - future.value + Testrun.new( + submission: submission, + cause: 'assess', + file: file, + passed: passed, + output: testrun_output, + container_execution_time: output[:container_execution_time], + waiting_for_container_time: output[:waiting_for_container_time] + ).save + output.merge!(assessment) + output.merge!(filename: file.name_with_extension, message: feedback_message(file, output[:score]), weight: file.weight) + # end end + future.value end + # end end + private :collect_test_results def execute_test_file(file, submission) DockerClient.new(execution_environment: file.context.execution_environment).execute_test_command(submission, file.name_with_extension) end + private :execute_test_file def feedback_message(file, score) @@ -65,7 +67,7 @@ module SubmissionScoring submission.update(score: score) if submission.normalized_score == 1.0 Thread.new do - RequestForComment.where(exercise_id: submission.exercise_id, user_id: submission.user_id, user_type: submission.user_type).each{ |rfc| + RequestForComment.where(exercise_id: submission.exercise_id, user_id: submission.user_id, user_type: submission.user_type).each { |rfc| rfc.full_score_reached = true rfc.save }