app/controllers/lightweight_activities_controller.rb
# These are the runtime (student-facing) actions, show and summary
These are the runtime (student-facing) actions, show and summary
These are the runtime ( student - facing ) actions show and summary
def show 
    @run.update_platform_info(params)
    authorize! :read, @activity
    setup_show
    raise_error_if_not_authorized_run(@run)
    if params[:print]
      redirect_to runnable_single_page_activity_path(@activity, request.query_parameters) and return
    end
    if @run.sequence && !(request.url.include? "/sequences/")
      redirect_to sequence_activity_with_run_path(@run.sequence, @activity, @run.key, request.query_parameters) and return
    end
    if @activity.layout == LightweightActivity::LAYOUT_SINGLE_PAGE
      redirect_to runnable_single_page_activity_path(@activity) and return
    end
    @run.increment_run_count!
    if @run.last_page && !@run.last_page.is_hidden && !params[:show_index]
      if @activity != @run.last_page.lightweight_activity
        Rails.logger.error("Page has wrong activity or vice versa")
        Rails.logger.error("Page: #{@run.last_page.id}  wrong activity: #{@activity.id} right activity: #{@run.last_page.lightweight_activity.id}")
        @activity = @run.last_page.lightweight_activity
      end
      redirect_to_page_with_run_path(@run.sequence, @activity.id, @run.last_page.id, @run.key) and return
    end
    if params[:run_key].blank?
      redirect_to runnable_activity_path(@activity) and return
    end
  end
def show @run . update_platform_info ( params ) authorize! :read , @activity setup_show raise_error_if_not_authorized_run ( @run ) if params [ :print ] redirect_to runnable_single_page_activity_path ( @activity , request . query_parameters ) and return end if @run . sequence && ! ( request . url . include? "/sequences/" ) redirect_to sequence_activity_with_run_path ( @run . sequence , @activity , @run . key , request . query_parameters ) and return end if @activity . layout == LightweightActivity :: LAYOUT_SINGLE_PAGE redirect_to runnable_single_page_activity_path ( @activity ) and return end @run . increment_run_count! if @run . last_page && ! @run . last_page . is_hidden && ! params [ :show_index ] if @activity != @run . last_page . lightweight_activity Rails . logger . error ( "Page has wrong activity or vice versa" ) Rails . logger . error ( "Page: #{@run.last_page.id}  wrong activity: #{@activity.id} right activity: #{@run.last_page.lightweight_activity.id}" ) @activity = @run . last_page . lightweight_activity end redirect_to_page_with_run_path ( @run . sequence , @activity . id , @run . last_page . id , @run . key ) and return end if params [ :run_key ] . blank? redirect_to runnable_activity_path ( @activity ) and return end end
These are the runtime (student-facing) actions, show and summary
These are the runtime ( student - facing ) actions show and summary
# show index # If there are launch parameters, set class info on run, # See /app/models/with_class_info.rb #update_platform_info # we pass all query_parameters through so the print param is passed too # however, it might be better to just pass the print param explictly # redirect if this run has a sequence and sequences is not part of the path # this run count seems to be pretty useless it might be incremented mutliple times # depending on redirects. It will also be incremented whenever the user returns to # this show page. I suspect it was added to try to track how many times the activity # has been access by a user. If we really wanted to get a more accurate count this # probably needs to be moved into the client code. The client can store a # sessionStorage variable which will be unique to the browser tab. On each page load # the client can async send this to the server and the server can track the unique # values. Perhaps there is a more simple way to do this. # TODO: If the Page isn't in this activity... Then we need to log that as an error, # and do the best we can to get back to the right page... # if we haven't done any other redirects and we don't have a run_key parameter, # redirect back here with a run_key, this way the user sees a consistant URL. # And if the user stays on this page and gets signed out we will know which run # they were originally accessing