Created
March 27, 2018 03:34
-
-
Save dkumar431/cbdef494bc89f12d4485a6887671470f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def get_user_progress | |
if @course.present? && @resource.present? | |
course_tracking = Tracking.where(user_id: current_user.id, key: @course.key).first | |
return if course_tracking.nil? | |
if course_tracking.is_completed | |
@progress = 100 | |
@quizFinished = true | |
else | |
@progress = course_tracking.get_course_progress(@course) | |
@quizFinished = course_tracking.quizzies_completed?(@course) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a pages_controller.rb containing show method which will render the whole page.
I have a before_action filter to track the page view.
If in my application you are logged in as manager, you will have access to 2 variables current_user and current_manager. To login as a manager you have to first login as doctor(current_user) and then manager(current_manager).
**If you are logged in manager , i do not want pages to be tracked.**
I can do
before_action :save_user_progress, only: [:show], if: ->{ current_manager.nil? }
save_user_progress method contains something similar to Tracking.create (…….)
There are some other places also where Tracking.create can be called in future.
So my question which is the right place for this checking controller or model?
If model, i do not have access to current_manager from model.