Replace manual activerecord translations with helpers

This commit is contained in:
Sebastian Serth
2024-04-14 14:00:51 +02:00
committed by Sebastian Serth
parent e551c8a699
commit f8330b39fb
72 changed files with 265 additions and 264 deletions

View File

@@ -2,7 +2,7 @@
form#exercise-selection
.mb-3
span.badge = t('activerecord.attributes.exercise_collections.exercises')
span.badge = ExerciseCollection.human_attribute_name('exercises')
.mb-2
= collection_select({}, :exercise_ids, exercises, :id, :title, {}, {id: 'add-exercise-list', class: 'form-control', multiple: true})

View File

@@ -1,14 +1,14 @@
= form_for(@exercise_collection, multipart: true) do |f|
= render('shared/form_errors', object: @exercise_collection)
.mb-3
= f.label(t('activerecord.attributes.exercise_collections.name'), class: 'form-label')
= f.label(:name, class: 'form-label')
= f.text_field(:name, class: 'form-control', required: true)
.form-check.mb-3
label.form-check-label
= f.check_box(:use_anomaly_detection, class: 'form-check-input')
= t('activerecord.attributes.exercise_collections.use_anomaly_detection')
= f.label(:use_anomaly_detection, class: 'form-label mb-0')
.mb-3
= f.label(t('activerecord.attributes.exercise_collections.user'), class: 'form-label')
= f.label(:user, class: 'form-label')
= f.collection_select(:user_id, InternalUser.order(:name), :id, :name, {}, {class: 'form-control'})
.table-responsive#exercise-list
@@ -16,7 +16,7 @@
thead
tr
th
th = t('activerecord.attributes.exercise_collection_item.exercise')
th = ExerciseCollectionItem.human_attribute_name('exercise')
th colspan=2 = t('shared.actions')
tbody#sortable
- @exercise_collection.items.order(:position).each do |item|

View File

@@ -1,13 +1,13 @@
h1 = ExerciseCollection.model_name.human(count: 2)
h1 = ExerciseCollection.model_name.human(count: :other)
.table-responsive
table.table
thead
tr
th = t('activerecord.attributes.exercise_collections.id')
th = t('activerecord.attributes.exercise_collections.name')
th = t('activerecord.attributes.exercise_collections.updated_at')
th = t('activerecord.attributes.exercise_collections.exercises')
th = ExerciseCollection.human_attribute_name('id')
th = ExerciseCollection.human_attribute_name('name')
th = ExerciseCollection.human_attribute_name('updated_at')
th = ExerciseCollection.human_attribute_name('exercises')
th colspan=4 = t('shared.actions')
tbody
- @exercise_collections.each do |collection|

View File

@@ -2,20 +2,20 @@ h1
= @exercise_collection
= render('shared/edit_button', object: @exercise_collection)
= row(label: 'exercise_collections.name', value: @exercise_collection.name)
= row(label: 'exercise_collections.user', value: link_to_if(policy(@exercise_collection.user).show?, @exercise_collection.user.displayname, @exercise_collection.user)) unless @exercise_collection.user.nil?
= row(label: 'exercise_collections.use_anomaly_detection', value: @exercise_collection.use_anomaly_detection)
= row(label: 'exercise_collections.updated_at', value: @exercise_collection.updated_at)
= row(label: 'exercise_collection.name', value: @exercise_collection.name)
= row(label: 'exercise_collection.user', value: link_to_if(policy(@exercise_collection.user).show?, @exercise_collection.user.displayname, @exercise_collection.user)) unless @exercise_collection.user.nil?
= row(label: 'exercise_collection.use_anomaly_detection', value: @exercise_collection.use_anomaly_detection)
= row(label: 'exercise_collection.updated_at', value: @exercise_collection.updated_at)
h4.mt-4 = t('activerecord.attributes.exercise_collections.exercises')
h4.mt-4 = ExerciseCollection.human_attribute_name('exercises')
.table-responsive#exercise-list
table.table
thead
tr
th = '#'
th = t('activerecord.attributes.exercise.title')
th = t('activerecord.attributes.exercise.execution_environment')
th = t('activerecord.attributes.exercise.user')
th = Exercise.human_attribute_name('title')
th = Exercise.human_attribute_name('execution_environment')
th = Exercise.human_attribute_name('user')
th = t('shared.actions')
tbody
- @exercise_collection.items.sort_by(&:position).each do |exercise_collection_item|

View File

@@ -1,11 +1,11 @@
h1 = @exercise_collection
= row(label: 'exercise_collections.name', value: @exercise_collection.name)
= row(label: 'exercise_collections.updated_at', value: @exercise_collection.updated_at)
= row(label: 'exercise_collections.exercises', value: @exercise_collection.exercises.count)
= row(label: 'exercise_collections.users_and_programming_groups', value: Submission.from(@exercise_collection.exercises.joins(:submissions).group(:contributor_id, :contributor_type).select(:contributor_id, :contributor_type)).count)
= row(label: 'exercise_collections.solutions', value: Submission.from(@exercise_collection.exercises.joins(:submissions).group(:contributor_id, :contributor_type, :id).select(:contributor_id, :contributor_type)).count)
= row(label: 'exercise_collections.submissions', value: @exercise_collection.exercises.joins(:submissions).count)
= row(label: 'exercise_collection.name', value: @exercise_collection.name)
= row(label: 'exercise_collection.updated_at', value: @exercise_collection.updated_at)
= row(label: 'exercise_collection.exercises', value: @exercise_collection.exercises.count)
= row(label: 'exercise_collection.users_and_programming_groups', value: Submission.from(@exercise_collection.exercises.joins(:submissions).group(:contributor_id, :contributor_type).select(:contributor_id, :contributor_type)).count)
= row(label: 'exercise_collection.solutions', value: Submission.from(@exercise_collection.exercises.joins(:submissions).group(:contributor_id, :contributor_type, :id).select(:contributor_id, :contributor_type)).count)
= row(label: 'exercise_collection.submissions', value: @exercise_collection.exercises.joins(:submissions).count)
/ further metrics:
/ number of contributors that attempted at least one exercise @exercise_collection.exercises.joins(:submissions).group("submissions.contributor_id", "submissions.contributor_type").count.count
/ number of solutions: @exercise_collection.exercises.joins(:submissions).group("submissions.contributor_id", "submissions.contributor_type").group("id").count.count
@@ -26,17 +26,17 @@ h1 = @exercise_collection
div(class="box #{klass}")
.box-label = label
h4.mt-4 = t('activerecord.attributes.exercise_collections.exercises')
h4.mt-4 = ExerciseCollection.human_attribute_name('exercises')
.table-responsive#exercise-list
table.table class=(@exercise_collection.items.present? ? 'sortable' : '')
thead
tr
th = '#'
th = t('activerecord.attributes.exercise.title')
th = t('activerecord.attributes.exercise.number_of_users_and_programming_groups')
th = t('activerecord.attributes.exercise.distinct_final_submissions')
th = t('activerecord.attributes.exercise.finishing_rate')
th = t('activerecord.attributes.exercise.average_score_percentage')
th = Exercise.human_attribute_name('title')
th = Exercise.human_attribute_name('number_of_users_and_programming_groups')
th = Exercise.human_attribute_name('distinct_final_submissions')
th = Exercise.human_attribute_name('finishing_rate')
th = Exercise.human_attribute_name('average_score_percentage')
th = t('shared.actions')
tbody
- @exercise_collection.items.sort_by(&:position).each do |exercise_collection_item|