Skip to content

Commit

Permalink
Merge pull request #1345 from concord-consortium/187899059-fix-last-r…
Browse files Browse the repository at this point in the history
…un-update

fix: Do not update last_run date of every learner when class is updated [PT-187899059]
  • Loading branch information
dougmartin authored Jul 10, 2024
2 parents 90a0ff1 + f045acb commit 97a4bf3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
72 changes: 36 additions & 36 deletions rails/app/controllers/portal/offerings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def setup_portal_student
if portal_student = current_visitor.portal_student
# create a learner for the user if one doesnt' exist
learner = @offering.find_or_create_learner(portal_student)
learner.update_last_run()
end
learner
end
Expand All @@ -36,42 +37,41 @@ def show
}

format.run_resource_html {
if learner = setup_portal_student
learner.update_last_run
cookies[:save_path] = @offering.runnable.save_path
cookies[:learner_id] = learner.id
cookies[:student_name] = "#{current_visitor.first_name} #{current_visitor.last_name}"
cookies[:activity_name] = @offering.runnable.name
cookies[:class_id] = learner.offering.clazz.id
cookies[:student_id] = learner.student.id
cookies[:runnable_id] = @offering.runnable.id
else
# session[:put_path] = nil
end
external_activity = @offering.runnable
if external_activity.lara_activity_or_sequence?
uri = URI.parse(external_activity.url)
uri.query = {
:externalId => learner.id,
:returnUrl => learner.remote_endpoint_url,
:logging => @offering.clazz.logging || @offering.runnable.logging,
:domain => root_url,
:domain_uid => current_visitor.id,
:class_info_url => @offering.clazz.class_info_url(request.protocol, request.host_with_port),
:context_id => @offering.clazz.class_hash,
# platform_id and platform_user_id are similiar to domain and domain_uid.
# However, LARA uses domain and domain_uid to authenticate the user,
# while the platform params are moving towards LTI compatible launching
# More specifically LARA removes domain and domain_uid from URL,
# so it is harder to use the domain params to setup the run in LARA.
:platform_id => APP_CONFIG[:site_url],
:platform_user_id => current_visitor.id,
:resource_link_id => @offering.id
}.to_query
redirect_to(uri.to_s)
else
redirect_to(@offering.runnable.url(learner, root_url))
end
if learner = setup_portal_student
cookies[:save_path] = @offering.runnable.save_path
cookies[:learner_id] = learner.id
cookies[:student_name] = "#{current_visitor.first_name} #{current_visitor.last_name}"
cookies[:activity_name] = @offering.runnable.name
cookies[:class_id] = learner.offering.clazz.id
cookies[:student_id] = learner.student.id
cookies[:runnable_id] = @offering.runnable.id
else
# session[:put_path] = nil
end
external_activity = @offering.runnable
if external_activity.lara_activity_or_sequence?
uri = URI.parse(external_activity.url)
uri.query = {
:externalId => learner.id,
:returnUrl => learner.remote_endpoint_url,
:logging => @offering.clazz.logging || @offering.runnable.logging,
:domain => root_url,
:domain_uid => current_visitor.id,
:class_info_url => @offering.clazz.class_info_url(request.protocol, request.host_with_port),
:context_id => @offering.clazz.class_hash,
# platform_id and platform_user_id are similiar to domain and domain_uid.
# However, LARA uses domain and domain_uid to authenticate the user,
# while the platform params are moving towards LTI compatible launching
# More specifically LARA removes domain and domain_uid from URL,
# so it is harder to use the domain params to setup the run in LARA.
:platform_id => APP_CONFIG[:site_url],
:platform_user_id => current_visitor.id,
:resource_link_id => @offering.id
}.to_query
redirect_to(uri.to_s)
else
redirect_to(@offering.runnable.url(learner, root_url))
end
}
end
end
Expand Down
1 change: 1 addition & 0 deletions rails/app/models/portal/learner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def report_learner
# see offering_controller#show run_resource_html block
def update_last_run
self.report_learner.update_attribute('last_run', Time.now)
self.update_report_model_cache()
end

# 2021-06-21 NP: method deligation because maybe report_learner will go away
Expand Down
1 change: 0 additions & 1 deletion rails/app/models/report/learner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def update_fields
update_permission_forms

self.complete_percent = 100
self.last_run = Time.now

Rails.logger.debug("Updated Report Learner: #{self.student_name}")
self.save
Expand Down
4 changes: 2 additions & 2 deletions rails/spec/models/report/learner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
end

describe "with a learner" do
it "the last_run time should not be nil" do
it "the last_run time should be nil" do
report = Report::Learner.create(:learner => @learner)
expect(report.last_run).not_to be_nil
expect(report.last_run).to be_nil
end
end

Expand Down

0 comments on commit 97a4bf3

Please sign in to comment.