candidate quiz progression work
This commit is contained in:
@ -24,7 +24,7 @@ class CandidateQuiz
|
||||
inner join questions q on q.quiz_id = c.quiz_id
|
||||
left join answers a on a.candidate_id = c.id AND a.question_id = q.id
|
||||
where q.active = true and c.id = #{candidate_id} #{question}
|
||||
order by c.id, q.sort;"
|
||||
order by q.sort;"
|
||||
ActiveRecord::Base.connection.exec_query(sql)
|
||||
end
|
||||
end
|
||||
|
@ -27,4 +27,16 @@ class QuizStatus
|
||||
|
||||
(answs / total * 100).round.to_i
|
||||
end
|
||||
|
||||
def current_question_id
|
||||
sql = "select q.id question_id
|
||||
from candidates c
|
||||
inner join questions q on q.quiz_id = c.quiz_id
|
||||
left join answers a on a.candidate_id = c.id AND a.question_id = q.id
|
||||
where q.active = true and c.id = #{candidate.to_i}
|
||||
and (a.id is null OR a.submitted is false)
|
||||
order by q.sort limit 1;"
|
||||
result = ActiveRecord::Base.connection.exec_query(sql).to_hash.first
|
||||
result['question_id'] unless result.nil?
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user