class Student

Schema Information

Table name: users

id                              :integer          not null, primary key
name                            :string(255)
email                           :string(255)      not null
crypted_password                :string(255)
salt                            :string(255)
activation_state                :string(255)
activation_token                :string(255)
activation_token_expires_at     :datetime
reset_password_token            :string(255)
reset_password_token_expires_at :datetime
reset_password_email_sent_at    :datetime
remember_me_token               :string(255)
remember_me_token_expires_at    :datetime
created_at                      :datetime
updated_at                      :datetime
type                            :string(255)
admin                           :boolean          default(FALSE)
uuid                            :string(255)      default("")
availability_defaults           :text
response_time                   :text
searchable                      :boolean          default(FALSE)
last_name                       :string(255)
phone                           :string(255)
credits                         :integer          default(0)
balanced_student_uri           :string(255)
credits_booked                  :integer          default(0)
points                          :integer          default(0)
streak                          :integer          default(0)
level                           :integer          default(1)
exp_title                       :string(255)
minimum_level                   :integer          default(1)
balanced_api_id                 :text
is_featured                     :boolean          default(FALSE)
is_registration_completed       :boolean          default(FALSE)
is_manually_deactivated         :boolean          default(FALSE)
billing_address_1               :string(255)
billing_address_2               :string(255)
billing_city                    :string(255)
billing_state                   :string(255)
billing_zipcode                 :string(255)
shipping_address_1              :string(255)
shipping_address_2              :string(255)
shipping_city                   :string(255)
shipping_state                  :string(255)
shipping_zipcode                :string(255)
location                        :string(255)
experience                      :string(255)
summary                         :text
awards                          :string(255)
skills                          :string(255)
industry                        :string(255)
profile_step                    :integer
headline                        :string(255)
onboard_step                    :integer
pending_chat_with               :integer
cached_notification_count       :integer          default(0)
cached_message_count            :integer          default(0)
auth_token                      :string(255)
university_id                      :integer
level_changed                   :boolean
skills_count                    :integer          default(0)
courses_count                 :integer          default(0)
rate_in_cents                   :integer          default(2000)

Public Instance Methods

added_courses?() click to toggle source

To check if any subrade is exists for the student.

# File app/models/student.rb, line 126
def added_courses?
  courses.exists?
end
confirmed_sessions() click to toggle source

Find confirmed session

# File app/models/student.rb, line 86
def confirmed_sessions
  TutoringSession.where("user_id = ? and end_time <= ? and status = 'c'", self.id , Time.now.in_time_zone)
end
has_credits?() click to toggle source

To check if student has credit

# File app/models/student.rb, line 111
def has_credits?
  remaining_credits > 0
end
has_tutoring_sessions?() click to toggle source

To find if student has a tutoring session

# File app/models/student.rb, line 101
def has_tutoring_sessions?
  tutoring_sessions.exists?
end
has_groups?() click to toggle source

to find if student is part of any groups

# File app/models/student.rb, line 96
def has_groups?
  groups.exists?
end
profile_completed?() click to toggle source

To check whether student profile is completed

# File app/models/student.rb, line 121
def profile_completed?
  !student_incomplete?
end
remaining_credits() click to toggle source

To find remaining credits

# File app/models/student.rb, line 116
def remaining_credits
  (credits - credits_booked) > 0 ? (credits - credits_booked) : 0
end
sent_invites?() click to toggle source

To find if Student has sent invitations

# File app/models/student.rb, line 106
def sent_invites?
  invites.exists?
end
upcoming_tutoring_sessions() click to toggle source

To find upcoming tutoring sessions

# File app/models/student.rb, line 91
def upcoming_tutoring_sessions
  TutoringSession.where("user_id = ? and end_time > ? and (status is null or status != 'r')", self.id , Time.now.in_time_zone)
end