Add execution environment statistics
This commit is contained in:
@ -392,6 +392,3 @@ DEPENDENCIES
|
|||||||
uglifier (>= 1.3.0)
|
uglifier (>= 1.3.0)
|
||||||
web-console (~> 2.0)
|
web-console (~> 2.0)
|
||||||
will_paginate (~> 3.0)
|
will_paginate (~> 3.0)
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.10.6
|
|
||||||
|
@ -2,7 +2,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
|||||||
include CommonBehavior
|
include CommonBehavior
|
||||||
|
|
||||||
before_action :set_docker_images, only: [:create, :edit, :new, :update]
|
before_action :set_docker_images, only: [:create, :edit, :new, :update]
|
||||||
before_action :set_execution_environment, only: MEMBER_ACTIONS + [:execute_command, :shell]
|
before_action :set_execution_environment, only: MEMBER_ACTIONS + [:execute_command, :shell, :statistics]
|
||||||
before_action :set_testing_framework_adapters, only: [:create, :edit, :new, :update]
|
before_action :set_testing_framework_adapters, only: [:create, :edit, :new, :update]
|
||||||
|
|
||||||
def authorize!
|
def authorize!
|
||||||
@ -28,6 +28,9 @@ class ExecutionEnvironmentsController < ApplicationController
|
|||||||
render(json: @docker_client.execute_arbitrary_command(params[:command]))
|
render(json: @docker_client.execute_arbitrary_command(params[:command]))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def statistics
|
||||||
|
end
|
||||||
|
|
||||||
def execution_environment_params
|
def execution_environment_params
|
||||||
params[:execution_environment].permit(:docker_image, :exposed_ports, :editor_mode, :file_extension, :file_type_id, :help, :indent_size, :memory_limit, :name, :network_enabled, :permitted_execution_time, :pool_size, :run_command, :test_command, :testing_framework).merge(user_id: current_user.id, user_type: current_user.class.name)
|
params[:execution_environment].permit(:docker_image, :exposed_ports, :editor_mode, :file_extension, :file_type_id, :help, :indent_size, :memory_limit, :name, :network_enabled, :permitted_execution_time, :pool_size, :run_command, :test_command, :testing_framework).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ class ExecutionEnvironmentPolicy < AdminOrAuthorPolicy
|
|||||||
end
|
end
|
||||||
private :author?
|
private :author?
|
||||||
|
|
||||||
[:execute_command?, :shell?].each do |action|
|
[:execute_command?, :shell?, :statistics?].each do |action|
|
||||||
define_method(action) { admin? || author? }
|
define_method(action) { admin? || author? }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ h1 = ExecutionEnvironment.model_name.human(count: 2)
|
|||||||
th = t('activerecord.attributes.execution_environment.memory_limit')
|
th = t('activerecord.attributes.execution_environment.memory_limit')
|
||||||
th = t('activerecord.attributes.execution_environment.network_enabled')
|
th = t('activerecord.attributes.execution_environment.network_enabled')
|
||||||
th = t('activerecord.attributes.execution_environment.permitted_execution_time')
|
th = t('activerecord.attributes.execution_environment.permitted_execution_time')
|
||||||
th colspan=4 = t('shared.actions')
|
th colspan=5 = t('shared.actions')
|
||||||
th colspan=2 = t('shared.resources')
|
th colspan=2 = t('shared.resources')
|
||||||
tbody
|
tbody
|
||||||
- @execution_environments.each do |execution_environment|
|
- @execution_environments.each do |execution_environment|
|
||||||
@ -23,6 +23,7 @@ h1 = ExecutionEnvironment.model_name.human(count: 2)
|
|||||||
td = link_to(t('shared.edit'), edit_execution_environment_path(execution_environment))
|
td = link_to(t('shared.edit'), edit_execution_environment_path(execution_environment))
|
||||||
td = link_to(t('shared.destroy'), execution_environment, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
|
td = link_to(t('shared.destroy'), execution_environment, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
|
||||||
td = link_to(t('.shell'), shell_execution_environment_path(execution_environment))
|
td = link_to(t('.shell'), shell_execution_environment_path(execution_environment))
|
||||||
|
td = link_to(t('shared.statistics'), statistics_execution_environment_path(execution_environment))
|
||||||
td = link_to(t('activerecord.models.error.other'), execution_environment_errors_path(execution_environment.id))
|
td = link_to(t('activerecord.models.error.other'), execution_environment_errors_path(execution_environment.id))
|
||||||
td = link_to(t('activerecord.models.hint.other'), execution_environment_hints_path(execution_environment.id))
|
td = link_to(t('activerecord.models.hint.other'), execution_environment_hints_path(execution_environment.id))
|
||||||
|
|
||||||
|
23
app/views/execution_environments/statistics.html.slim
Normal file
23
app/views/execution_environments/statistics.html.slim
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
h1 = @execution_environment
|
||||||
|
|
||||||
|
.table-responsive
|
||||||
|
table.table
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
- ['.exercise', '.score', '.runs', '.worktime'].each do |title|
|
||||||
|
th.header = t(title)
|
||||||
|
tbody
|
||||||
|
- @execution_environment.exercises.each do |exercise|
|
||||||
|
tr
|
||||||
|
- submissions = exercise.submissions
|
||||||
|
td = exercise.title
|
||||||
|
td = submissions.average(:score)
|
||||||
|
td = submissions.count()
|
||||||
|
- minima = submissions.group(:user_id).minimum(:created_at)
|
||||||
|
- maxima = submissions.group(:user_id).maximum(:created_at)
|
||||||
|
- result = 0
|
||||||
|
- results = {}
|
||||||
|
- maxima.each {|key, value| results[key] = value - minima[key]}
|
||||||
|
- results.values.map {|value| result += value}
|
||||||
|
- result /= results.size if results.size > 0
|
||||||
|
td = distance_of_time_in_words(result)
|
@ -167,6 +167,11 @@ de:
|
|||||||
shell:
|
shell:
|
||||||
command: Befehl
|
command: Befehl
|
||||||
headline: Shell
|
headline: Shell
|
||||||
|
statistics:
|
||||||
|
exercise: Übung
|
||||||
|
score: Durchschnittliche Punktzahl
|
||||||
|
runs: Durchschnittliche Anzahl von Versuchen
|
||||||
|
worktime: Durchschnittliche Arbeitszeit
|
||||||
exercises:
|
exercises:
|
||||||
editor:
|
editor:
|
||||||
confirm_start_over: Wollen Sie wirklich von vorne anfangen?
|
confirm_start_over: Wollen Sie wirklich von vorne anfangen?
|
||||||
|
@ -167,6 +167,11 @@ en:
|
|||||||
shell:
|
shell:
|
||||||
command: Command
|
command: Command
|
||||||
headline: Shell
|
headline: Shell
|
||||||
|
statistics:
|
||||||
|
exercise: Exercise
|
||||||
|
score: Average Score
|
||||||
|
runs: Average Number of Runs
|
||||||
|
worktime: Average Worktime
|
||||||
exercises:
|
exercises:
|
||||||
editor:
|
editor:
|
||||||
confirm_start_over: Do you really want to start over?
|
confirm_start_over: Do you really want to start over?
|
||||||
@ -239,10 +244,10 @@ en:
|
|||||||
intermediate_submissions: Intermediate Submissions
|
intermediate_submissions: Intermediate Submissions
|
||||||
participants: Participating Users
|
participants: Participating Users
|
||||||
users: '%{count} distinct users'
|
users: '%{count} distinct users'
|
||||||
user: 'User'
|
user: User
|
||||||
score: 'Score'
|
score: Score
|
||||||
runs: 'Runs'
|
runs: Runs
|
||||||
worktime: 'Worktime'
|
worktime: Worktime
|
||||||
submit:
|
submit:
|
||||||
failure: An error occured while transmitting your score. Please try again later.
|
failure: An error occured while transmitting your score. Please try again later.
|
||||||
files:
|
files:
|
||||||
|
@ -26,6 +26,7 @@ Rails.application.routes.draw do
|
|||||||
member do
|
member do
|
||||||
get :shell
|
get :shell
|
||||||
post 'shell', as: :execute_command, to: :execute_command
|
post 'shell', as: :execute_command, to: :execute_command
|
||||||
|
get :statistics
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :errors, only: [:create, :index, :show]
|
resources :errors, only: [:create, :index, :show]
|
||||||
|
@ -130,6 +130,14 @@ describe ExecutionEnvironmentsController do
|
|||||||
expect_template(:shell)
|
expect_template(:shell)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET #statistics' do
|
||||||
|
before(:each) { get :statistics, id: execution_environment.id }
|
||||||
|
|
||||||
|
expect_assigns(execution_environment: :execution_environment)
|
||||||
|
expect_status(200)
|
||||||
|
expect_template(:statistics)
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
before(:each) { get :show, id: execution_environment.id }
|
before(:each) { get :show, id: execution_environment.id }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user