-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactorise la facon de calculer le temps passé dans les exports d…
…e litteratie et numeratie
- Loading branch information
1 parent
15af084
commit fff18d6
Showing
9 changed files
with
127 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/models/restitution/metriques/temps_passe_par_question.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Restitution | ||
module Metriques | ||
class TempsPasseParQuestion | ||
include ApplicationHelper | ||
|
||
def initialize(evenements) | ||
@evenements = evenements | ||
end | ||
|
||
def calculer | ||
return if @evenements.empty? | ||
|
||
evenements_groupes = @evenements.groupees_par_questions | ||
evenements_groupes.each_with_object({}) do |(question, evenements), result| | ||
temps_total = calcul_temps_total(evenements) | ||
result[question] = formate_duree(temps_total) | ||
end | ||
end | ||
|
||
private | ||
|
||
def calcul_temps_total(evenements) | ||
return unless evenements.size >= 2 | ||
|
||
Restitution::MetriquesHelper.temps_entre_couples(evenements)&.first || 0 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters