Skip to content

Instantly share code, notes, and snippets.

@andyfmiller
andyfmiller / gist:4013359
Created Nov 4, 2012
BuildLtiRequestViewBag
View gist:4013359
private void BuildLtiRequestViewBag(Assignment assignment)
{
// Start with the basic and required parameters
var parameters = BuildBaseLtiRequestData(assignment);
// Add recommended and optional parameters
AddOptionalParameters(assignment, parameters);
// Add version specific parameters
if (assignment.LtiVersionId == LtiVersion.Version10)
View gist:4013308
/// <summary>
/// Add optional parameters that are specific to an LTI 1.1 request.
/// </summary>
/// <param name="assignment">The Assignment to be launched.</param>
/// <param name="parameters">The partially filled OAuthParameters object
/// that is being used to collect the data.</param>
private void AddLti11Parameters(Assignment assignment, OAuthParameters parameters)
{
// LTI 1.1 does support custom parameter substitution
if (!string.IsNullOrWhiteSpace(assignment.CustomParameters))
View gist:4013303
/// <summary>
/// Add optional parameters that are specific to an LTI 1.0 request.
/// </summary>
/// <param name="assignment">The Assignment to be launched.</param>
/// <param name="parameters">The partially filled OAuthParameters object
/// that is being used to collect the data.</param>
private void AddLti10Parameters(Assignment assignment, OAuthParameters parameters)
{
// LTI 1.0 does not include custom parameter substitution, so the custom parameter
// values are added as-is.
@andyfmiller
andyfmiller / gist:4013299
Created Nov 4, 2012
AddOptionalParameters
View gist:4013299
/// <summary>
/// Add the optional parameters for an LTI 1.x request.
/// </summary>
/// <param name="assignment">The Assignment to be launched.</param>
/// <param name="parameters">The partially filled OAuthParameters object
/// that is being used to collect the data.</param>
private void AddOptionalParameters(Assignment assignment, OAuthParameters parameters)
{
var user = db.Users.Find(WebSecurity.CurrentUserId);
@andyfmiller
andyfmiller / gist:4013274
Created Nov 4, 2012
BuildBaseLtiRequestData
View gist:4013274
/// <summary>
/// Calculate the data for a basic LTI 1.x request.
/// </summary>
/// <param name="assignment">The Assignment to be launched.</param>
/// <returns>An OAuthParameters object which includes the required paremters
/// for an LTI 1.x request.</returns>
private OAuthParameters BuildBaseLtiRequestData(Assignment assignment)
{
const string lti_version = "LTI-1p0";
const string lti_message_type = "basic-lti-launch-request";