Merge pull request #277 from openHPI/enhance-exercise_collection-statistics
enhance exercise_collection_statistics
This commit is contained in:
@ -44,7 +44,15 @@ class Exercise < ApplicationRecord
|
|||||||
|
|
||||||
def average_percentage
|
def average_percentage
|
||||||
if average_score and maximum_score != 0.0 and submissions.exists?(cause: 'submit')
|
if average_score and maximum_score != 0.0 and submissions.exists?(cause: 'submit')
|
||||||
(average_score / maximum_score * 100).round
|
(average_score / maximum_score * 100).round(2)
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishers_percentage
|
||||||
|
if users.distinct.count != 0
|
||||||
|
(100.0 / users.distinct.count * finishers.count).round(2)
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
@ -15,3 +15,27 @@ h1 = @exercise_collection
|
|||||||
.legend-entry
|
.legend-entry
|
||||||
div(class="box #{klass}")
|
div(class="box #{klass}")
|
||||||
.box-label = label
|
.box-label = label
|
||||||
|
|
||||||
|
h4.mt-4 = t('activerecord.attributes.exercise_collections.exercises')
|
||||||
|
.table-responsive#exercise-list
|
||||||
|
table.table.sortable
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th = '#'
|
||||||
|
th = t('activerecord.attributes.exercise.title')
|
||||||
|
th = t('activerecord.attributes.exercise.number_of_users')
|
||||||
|
th = t('activerecord.attributes.exercise.distinct_final_submissions')
|
||||||
|
th = t('activerecord.attributes.exercise.finishing_rate')
|
||||||
|
th = t('activerecord.attributes.exercise.average_score_percentage')
|
||||||
|
th = t('shared.actions')
|
||||||
|
tbody
|
||||||
|
- @exercise_collection.items.sort_by{|item| item.position}.each do |exercise_collection_item|
|
||||||
|
- exercise = exercise_collection_item.exercise
|
||||||
|
tr
|
||||||
|
td = exercise_collection_item.position
|
||||||
|
td = link_to_if(policy(exercise).show?, exercise.title, exercise)
|
||||||
|
td = exercise.users.distinct.count
|
||||||
|
td = exercise.submissions.send(:final).distinct.count(:user_id)
|
||||||
|
td = exercise.finishers_percentage
|
||||||
|
td = exercise.average_percentage
|
||||||
|
td = link_to(t('shared.statistics'), statistics_exercise_path(exercise), 'data-turbolinks' => "false") if policy(exercise).statistics?
|
||||||
|
@ -23,8 +23,11 @@ de:
|
|||||||
testing_framework: Testing-Framework
|
testing_framework: Testing-Framework
|
||||||
user: Autor
|
user: Autor
|
||||||
exercise:
|
exercise:
|
||||||
|
average_score_percentage: "Durchschnittliche Bewertung in Prozent"
|
||||||
description: Beschreibung
|
description: Beschreibung
|
||||||
|
distinct_final_submissions: "Endgültige Abgaben"
|
||||||
embedding_parameters: Parameter für LTI-Einbettung
|
embedding_parameters: Parameter für LTI-Einbettung
|
||||||
|
finishing_rate: "Abschlussquote"
|
||||||
tags: Tags
|
tags: Tags
|
||||||
execution_environment: Ausführungsumgebung
|
execution_environment: Ausführungsumgebung
|
||||||
execution_environment_id: Ausführungsumgebung
|
execution_environment_id: Ausführungsumgebung
|
||||||
@ -32,6 +35,7 @@ de:
|
|||||||
hide_file_tree: Dateibaum verstecken
|
hide_file_tree: Dateibaum verstecken
|
||||||
instructions: Anweisungen
|
instructions: Anweisungen
|
||||||
maximum_score: Erreichbare Punktzahl
|
maximum_score: Erreichbare Punktzahl
|
||||||
|
number_of_users: "# Nutzer"
|
||||||
public: Öffentlich
|
public: Öffentlich
|
||||||
selection: Ausgewählt
|
selection: Ausgewählt
|
||||||
title: Titel
|
title: Titel
|
||||||
|
@ -23,8 +23,11 @@ en:
|
|||||||
testing_framework: Testing Framework
|
testing_framework: Testing Framework
|
||||||
user: Author
|
user: Author
|
||||||
exercise:
|
exercise:
|
||||||
|
average_score_percentage: "Average Score Percentage"
|
||||||
description: Description
|
description: Description
|
||||||
|
distinct_final_submissions: "Distinct Final Submissions"
|
||||||
embedding_parameters: LTI Embedding Parameters
|
embedding_parameters: LTI Embedding Parameters
|
||||||
|
finishing_rate: "Finishing Rate"
|
||||||
tags: Tags
|
tags: Tags
|
||||||
execution_environment: Execution Environment
|
execution_environment: Execution Environment
|
||||||
execution_environment_id: Execution Environment
|
execution_environment_id: Execution Environment
|
||||||
@ -32,6 +35,7 @@ en:
|
|||||||
hide_file_tree: Hide File Tree
|
hide_file_tree: Hide File Tree
|
||||||
instructions: Instructions
|
instructions: Instructions
|
||||||
maximum_score: Maximum Score
|
maximum_score: Maximum Score
|
||||||
|
number_of_users: "# Users"
|
||||||
public: Public
|
public: Public
|
||||||
selection: Selected
|
selection: Selected
|
||||||
title: Title
|
title: Title
|
||||||
|
@ -59,7 +59,7 @@ describe Exercise do
|
|||||||
|
|
||||||
it 'returns the average score expressed as a percentage' do
|
it 'returns the average score expressed as a percentage' do
|
||||||
maximum_percentages = exercise.submissions.group_by(&:user_id).values.map { |submission| submission.sort_by(&:score).last.score / exercise.maximum_score * 100 }
|
maximum_percentages = exercise.submissions.group_by(&:user_id).values.map { |submission| submission.sort_by(&:score).last.score / exercise.maximum_score * 100 }
|
||||||
expect(exercise.average_percentage).to eq(maximum_percentages.average.round)
|
expect(exercise.average_percentage).to eq(maximum_percentages.average.round(2))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user