shows exact time limit on quiz summaries and reports

fixes #7327

test plan
  - create a new quiz
  - give it a time limit over 45 min and publish it (try for less than
    45 also)
  - /courses/<course.id>/quizzes
  - should be a summary of all of the quizzes in the course
  - time limit for each course should say the exact number of minutes
    and not something like "about 1 hour"
  - take the quiz
  - click on the quiz to view the summary once you're done taking it
  - above the quiz and on the right bar it should say the exact amount
    of time (in minutes) the user spent taking the quiz instead of something like
    "about 1 hour"

Change-Id: I5f7614e82a5f944b046d0a8fd0dd5106602b00be
Reviewed-on: https://gerrit.instructure.com/13068
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
Sam Olds 2012-08-21 14:21:10 -06:00
parent 0d5eb292bf
commit 295581a65d
4 changed files with 16 additions and 3 deletions

View File

@ -173,4 +173,17 @@ module QuizzesHelper
match.sub(%r{(<option.*?value=['"]#{ERB::Util.h(a)}['"])}, '\\1 selected') match.sub(%r{(<option.*?value=['"]#{ERB::Util.h(a)}['"])}, '\\1 selected')
end end
end end
def duration_in_minutes(duration_seconds)
if duration_seconds < 60
duration_minutes = 0
else
duration_minutes = (duration_seconds / 60).round
end
t("#quizzes.helpers.duration_in_minutes",
{ :zero => "less than 1 minute",
:one => "1 minute",
:other => "%{count} minutes" },
:count => duration_minutes)
end
end end

View File

@ -27,7 +27,7 @@
<tbody> <tbody>
<tr> <tr>
<th><%= before_label(:time, "Time") %></th> <th><%= before_label(:time, "Time") %></th>
<td><%= time_ago_in_words(Time.now - ((@submission.finished_at || @submission.end_at || @submission.started_at) - @submission.started_at)) %></td> <td><%= duration_in_minutes((@submission.finished_at || @submission.end_at || @submission.started_at) - @submission.started_at) %></td>
</tr> </tr>
<% unless @quiz.assignment.present? && @quiz.assignment.muted? %> <% unless @quiz.assignment.present? && @quiz.assignment.muted? %>
<tr style="<%= hidden if @quiz.quiz_type == 'survey' %>"> <tr style="<%= hidden if @quiz.quiz_type == 'survey' %>">

View File

@ -93,7 +93,7 @@
</div> </div>
<% end %> <% end %>
<div class="quiz_duration" style="<%= hidden if @quiz.ungraded? %>"> <div class="quiz_duration" style="<%= hidden if @quiz.ungraded? %>">
<%= t(:attempt_duration, "This attempt took %{duration}.", :duration => time_ago_in_words(Time.now + @submission.duration)) %> <%= t(:attempt_duration, "This attempt took %{duration}.", :duration => duration_in_minutes(@submission.duration)) %>
</div> </div>
<% if @quiz.require_lockdown_browser && @quiz.require_lockdown_browser_for_results && !@lockdown_browser_authorized_to_view && !can_do(@quiz, @current_user, :grade) %> <% if @quiz.require_lockdown_browser && @quiz.require_lockdown_browser_for_results && !@lockdown_browser_authorized_to_view && !can_do(@quiz, @current_user, :grade) %>
<p> <p>

View File

@ -61,7 +61,7 @@
<%= before_label(:quiz_due, "Due") %> <%= datetime_string(q.due_at) %><br/> <%= before_label(:quiz_due, "Due") %> <%= datetime_string(q.due_at) %><br/>
<% end %> <% end %>
<% if q.time_limit %> <% if q.time_limit %>
<%= before_label(:quiz_time_limit, "Time Limit") %> <%= time_ago_in_words(Time.now - q.time_limit.minutes) %><br/> <%= before_label(:quiz_time_limit, "Time Limit") %> <%= duration_in_minutes(q.time_limit.minutes) %><br/>
<% end %> <% end %>
<% if q.allowed_attempts && q.allowed_attempts != 1 %> <% if q.allowed_attempts && q.allowed_attempts != 1 %>
<% if q.allowed_attempts > 0 %> <% if q.allowed_attempts > 0 %>