Class: User
Class Method Summary
collapse
Instance Method Summary
collapse
#navigable_name, #navigation_end?
#build_reminder, #cycles_since, #remider_due?, #remind!, #send_reminder!, #should_send_reminder?
aggregate_of, all_except, defaults, name_model_as, numbered, #save, #save_and_notify!, #save_and_notify_changes!, #update_and_notify!, update_or_create!
Class Method Details
.import_from_json!(json) ⇒ Object
89
90
91
92
|
# File 'app/models/user.rb', line 89
def self.import_from_json!(json)
json = Mumukit::Platform::User::Helpers.slice_platform_json json
User.where(uid: json[:uid]).update_or_create!(json)
end
|
.unsubscription_verifier ⇒ Object
98
99
100
|
# File 'app/models/user.rb', line 98
def self.unsubscription_verifier
Rails.application.message_verifier(:unsubscribe)
end
|
Instance Method Details
#clear_progress! ⇒ Object
70
71
72
73
74
75
|
# File 'app/models/user.rb', line 70
def clear_progress!
transaction do
update! last_submission_date: nil, last_exercise: nil
assignments.destroy_all
end
end
|
#last_lesson ⇒ Object
30
31
32
|
# File 'app/models/user.rb', line 30
def last_lesson
last_guide.try(:lesson)
end
|
#never_submitted? ⇒ Boolean
66
67
68
|
# File 'app/models/user.rb', line 66
def never_submitted?
last_submission_date.nil?
end
|
#passed_submissions_count ⇒ Object
38
39
40
|
# File 'app/models/user.rb', line 38
def passed_submissions_count
passed_assignments.count
end
|
#solved_exercises_count ⇒ Object
46
47
48
|
# File 'app/models/user.rb', line 46
def solved_exercises_count
solved_exercises.count
end
|
#submissions_count ⇒ Object
34
35
36
|
# File 'app/models/user.rb', line 34
def submissions_count
assignments.pluck(:submissions_count).sum
end
|
#submitted_exercises_count ⇒ Object
42
43
44
|
# File 'app/models/user.rb', line 42
def submitted_exercises_count
submitted_exercises.count
end
|
62
63
64
|
# File 'app/models/user.rb', line 62
def to_s
"#{id}:#{name}:#{uid}"
end
|
#transfer_progress_to!(another) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
|
# File 'app/models/user.rb', line 77
def transfer_progress_to!(another)
transaction do
assignments.update_all(submitter_id: another.id)
if another.never_submitted? || last_submission_date.try { |it| it > another.last_submission_date }
another.update! last_submission_date: last_submission_date,
last_exercise: last_exercise,
last_organization: last_organization
end
end
reload
end
|
#unread_messages ⇒ Object
54
55
56
|
# File 'app/models/user.rb', line 54
def unread_messages
messages.where read: false
end
|
#unsubscribe_from_reminders! ⇒ Object
94
95
96
|
# File 'app/models/user.rb', line 94
def unsubscribe_from_reminders!
update! accepts_reminders: false
end
|
#visit!(organization) ⇒ Object
58
59
60
|
# File 'app/models/user.rb', line 58
def visit!(organization)
update!(last_organization: organization) if organization != last_organization
end
|