anchor.diff:        <pre>
           require 'oauth/request_proxy/action_controller_request'
           @provider = IMS::LTI::ToolProvider.new(
  -          params[:oauth_consumer_key],
  -          Rails.configuration.lti_settings[params[:oauth_consumer_key]],
  -          params
  +        params[:oauth_consumer_key],
  +        Rails.configuration.lti_settings[params[:oauth_consumer_key]],
  +        params
           )
   
           if not @provider.valid_request?(request)
  -          # the request wasn't validated
  -          render :launch_error, status: 401
  -          return
  +        # the request wasn't validated
  +        render :launch_error, status: 401
  +        return
           end</pre>
       </p><br>
   
       <p>
         <strong>Step 7:</strong>
  -      At this point, you have a valid and authentic LTI request. Now, our quiz application requires a user to be logged in order to take a quiz but this application is launched through Canvas and the whole purpose of LTI is to provide seamless experience to user. Therefore, we will have to create a user account and log him in automatically. To do so, add the following code.
  +      At this point, you have a valid and authentic LTI request.
  +      Now, our quiz application requires a user to be logged in order
  +      to take a quiz.
  +      But this application will be launched through Canvas, and a key
  +      goal of LTI is to provide a seamless experience to the user.
  +      Therefore, we will have to create a user account and log
  +      her in automatically.
  +      To do so, add the following code.
         <pre>
           @@launch_params=params;
           email = params[:lis_person_contact_email_primary]
           @user = User.where(email: email).first
           if @user.blank?
  -          @user = User.new(:username => email,
  -                           :email => email,
  -                           :password => email,
  -                           :password_confirmation => email)
  -          if !@user.save
  -            puts @user.errors.full_messages.first
  -          end
  +        @user = User.new(:username => email,
  +        :email => email,
  +        :password => email,
  +        :password_confirmation => email)
  +        if !@user.save
  +        puts @user.errors.full_messages.first
  +        end
           end
   
           #Login the user and create his session.
  
positive.code:       controller named <i><strong>lti</i></strong> with
        a <i><strong>launch</i></strong> endpoint (so the url can say
        '..../lti/launch' for readability). This launch endpoint will
        receive the post request from the tool consumer and we will
        validate and authenticate the LTI requests within this
        endpoint.
      </p><br>
  
      <p>
        <strong>Step 4:</strong>
        The first thing we need is to keep a check if our application is launched as an LTI application or not. If the application is launched as an LTI application then we will have to make few changes to normal behavior of our app such as we will have to hide header and footer because the application will load in an iframe and therefore, it should look like a part of a Tool Consumer. Also, we will have to send scores back to Tool Consumer rather than redirecting user to results page. For example: If you are using our Quiz application, then it will look like this if you do not remove header from in case of an LTI launch:
        <div class="text-center">
          <%= image_tag "quiz_no_iframe.png", style:'width:40%' %>
        </div><br><br>
  
        To fix this, add the following line at the beginning of <em>launch</em> endpoint.
        <pre>
          session[:isLTI]=true</pre>
        To hide the header, add the following in <em>views/layout/application.html.erb</em> after moving header code in <em>_header</em> partial.<br><br>
        <pre>
          render "layouts/header" unless session[:isLTI]</pre>
          Now, when your application will be launched inside a Canvas, it will look like this:
          <div class="text-center">
            <%= image_tag "quiz_iframe.png", style:'width:40%' %>
          </div><br><br>
      </p><br>
  
      <p>
  
negative.code:         <%= image_tag "quiz_launch_error.png", style:'width:40%' %>
        </div>
  
        Your <strong>routes.rb</strong> file at the end should somewhat
        look like this for our Quiz application:
        <br><br>
        <pre>
          Rails.application.routes.draw do
          get 'quiz/index'
          resources :questions
          post 'questions/submitQuestion'=>'questions#submitQuestion', as: :submit_question
          root 'sessions#login'
          get "signup", :to => "users#new"
          get "login", :to => "sessions#login"
          get "logout", :to => "sessions#logout"
          get "home", :to => "sessions#home"
          get "profile", :to => "sessions#profile"
          get "setting", :to => "sessions#setting"
          post "signup", :to => "users#new"
          post "login", :to => "sessions#login"
          post "logout", :to => "sessions#logout"
          post "login_attempt", :to => "sessions#login_attempt"
          get "login_attempt", :to => "sessions#login_attempt"
          post "user_create", :to => "users#create"
          get "all", :to => "questions#index"
          get "result", :to => "questions#result"
          get 'lti/launch'
          post 'lti/launch'
          get 'lti/submitscore'
          post 'lti/submitscore'
          end
        </pre>
      </p><br>
  
      <p>
        At this point you should have a working LTI-enabled quiz
        application.
        It will work as-is for non LTI launches (on your own domain),
        and will also work as an LTI tool when launched from within a
        tool consumer.
        If it is launched from within a tool consumer,
        then once a user submits an assessment, his scores can be
        recorded in the tool consumer's gradebook.
        On Canvas it will look like this:
  
        <div class="text-center">
          <%= image_tag "quiz_result.png", style:'width:50%' %>
        </div><br><br>
        Here you can download the
        <a href="https://github.com/CSSPLICE/LTI/tree/master/Quiz-LTI">complete source code</a>
        for a version of the quiz application with LTI support.
      </p>
    </span>
  </div>
  