updates progress bar accuracy

The progress bar now accounts for live coders that have opted for
"finish later"

Address part of issue #63
This commit is contained in:
Mark Moser 2016-08-12 12:44:19 -05:00
parent 2c26d4bfb5
commit 30971357af
4 changed files with 22 additions and 5 deletions

View File

@ -18,6 +18,7 @@ class Candidate < ApplicationRecord
def answered_questions def answered_questions
answers.where.not(answer: nil) answers.where.not(answer: nil)
.where("answers.answer not like '%later:%'")
end end
def fetch_question qid def fetch_question qid
@ -25,12 +26,15 @@ class Candidate < ApplicationRecord
end end
def my_quiz def my_quiz
CandidateQuiz.new(id).build_my_quiz @candidate_quiz ||= CandidateQuiz.new(id).build_my_quiz
end
def my_status
@candidate_status ||= QuizStatus.new(self)
end end
def status def status
# TODO: quiz status: not started, started, completed "#{my_status.progress}%"
"--"
end end
def complete! def complete!

View File

@ -11,7 +11,9 @@
<th>Test ID</th> <th>Test ID</th>
<th>Email</th> <th>Email</th>
<th>Experience</th> <th>Experience</th>
<th>Status</th> <th>Progress</th>
<th>Completed</th>
<th>Reminded</th>
</tr> </tr>
<% @candidates.each do |candidate| %> <% @candidates.each do |candidate| %>
@ -21,6 +23,8 @@
<td><%= mail_to(candidate.email) %></td> <td><%= mail_to(candidate.email) %></td>
<td><%= candidate.experience %> years</td> <td><%= candidate.experience %> years</td>
<td><%= candidate.status %></td> <td><%= candidate.status %></td>
<td><%= candidate.completed ? "Submitted" : "" %></td>
<td><%= candidate.reminded ? "Yes" : "" %></td>
</tr> </tr>
<% end %> <% end %>
</table> </table>

View File

@ -373,8 +373,9 @@ juan9:
juan10: juan10:
candidate: juan candidate: juan
question: fed10 question: fed10
answer: answer: 'wibbly wobbly, timey wimey'
saved: 1 saved: 1
submitted: true submitted: true
created_at: <%= DateTime.now() - 38.hours - 40.minutes %> created_at: <%= DateTime.now() - 38.hours - 40.minutes %>
updated_at: <%= DateTime.now() - 38.hours - 20.minutes %> updated_at: <%= DateTime.now() - 38.hours - 20.minutes %>

View File

@ -31,4 +31,12 @@ class QuestionFlowTest < ActionDispatch::IntegrationTest
# TODO: add in capybara and test form post # TODO: add in capybara and test form post
# assert_redirected summary_path # assert_redirected summary_path
end end
test 'juan should be on summary with 80% complete' do
setup_auth candidates(:juan)
get summary_path
assert_response :success
assert_select '.progress span', '80%'
end
end end