-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get authentication, class membership, and roles via LTI (#40)
- Loading branch information
Showing
31 changed files
with
381 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,6 @@ node_modules/ | |
app/assets/javascripts/react | ||
/public/packs | ||
/node_modules | ||
|
||
localhost.crt | ||
localhost.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
web: bin/rails s -p3000 -b0.0.0.0 | ||
web: [ -z "$LOCALHOST_SSL" ] && bin/rails s -p3000 -b0.0.0.0 || bundle exec puma -b 'ssl://0.0.0.0:3000?key=/vagrant/localhost.key&cert=/vagrant/localhost.crt' | ||
webpack: bin/webpack-dev-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/controllers/authentication_strategies/config_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AuthenticationStrategies::ConfigController < ApplicationController | ||
|
||
def lti | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// @flow | ||
|
||
import React from 'react' | ||
import { chooseContentItem } from 'shared/lti' | ||
|
||
type ContentItem = {| | ||
kicker: string, | ||
title: string, | ||
dek: string, | ||
coverUrl: string, | ||
url: string, | ||
|} | ||
|
||
type ContentItemsProps = {| | ||
items: ContentItem[], | ||
returnUrl: string, | ||
returnData: string, | ||
|} | ||
|
||
const ContentItems = ({ items, returnUrl, returnData }: ContentItemsProps) => { | ||
const handleChooseContentItem = chooseContentItem.bind( | ||
undefined, | ||
returnUrl, | ||
returnData | ||
) | ||
return ( | ||
<div className="catalog-cases"> | ||
<div className="catalog-cases-index"> | ||
{items.map((item: ContentItem, i: number) => ( | ||
<ContentItemLink | ||
key={i} | ||
{...item} | ||
handleChooseContentItem={handleChooseContentItem} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ContentItems | ||
|
||
type ContentItemProps = ContentItem & {| | ||
handleChooseContentItem: (string) => void, | ||
|} | ||
const ContentItemLink = ( | ||
{ | ||
kicker, | ||
title, | ||
dek, | ||
coverUrl, | ||
url, | ||
handleChooseContentItem, | ||
}: ContentItemProps | ||
) => { | ||
const handleClick = handleChooseContentItem.bind(undefined, url) | ||
return ( | ||
<a | ||
tabIndex="0" | ||
className="BillboardTitle catalog-case catalog-content-item" | ||
style={{ | ||
backgroundImage: ` | ||
linear-gradient(rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.5)), | ||
url(${coverUrl})`, | ||
}} | ||
onClick={handleClick} | ||
> | ||
<div className="catalog-case-credits"> | ||
<h2> | ||
<span className="c-kicker">{kicker}</span> | ||
{title} | ||
</h2> | ||
<p style={{ display: 'none' }}> | ||
{dek} | ||
</p> | ||
</div> | ||
</a> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// @flow | ||
|
||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
|
||
import ContentItems from 'content_items' | ||
|
||
function render (Component: React$Component) { | ||
const container = document.getElementById('content-items-app') | ||
|
||
if (container == null) return | ||
|
||
ReactDOM.render( | ||
<Component | ||
items={JSON.parse(container.getAttribute('data-items'))} | ||
returnUrl={container.getAttribute('data-return-url')} | ||
returnData={container.getAttribute('data-return-data')} | ||
/>, | ||
container | ||
) | ||
} | ||
|
||
render(ContentItems) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// @flow | ||
|
||
export function chooseContentItem ( | ||
returnUrl: string, | ||
returnData: string, | ||
itemUrl: string | ||
): void { | ||
submitForm(returnUrl, contentItemSelectionMessageData(returnData, itemUrl)) | ||
} | ||
|
||
function contentItemSelectionMessageData ( | ||
returnData: string, | ||
itemUrl: string | ||
): { [string]: string } { | ||
return { | ||
lti_message_type: 'ContentItemSelection', | ||
lti_version: 'LTI-1p0', | ||
data: returnData, | ||
content_items: JSON.stringify({ | ||
'@context': 'http://purl.imsglobal.org/ctx/lti/v1/ContentItem', | ||
'@graph': [ | ||
{ | ||
'@type': 'LtiLinkItem', | ||
url: itemUrl, | ||
mediaType: 'application/vnd.ims.lti.v1.ltilink', | ||
placementAdvice: { | ||
presentationDocumentTarget: 'window', | ||
}, | ||
}, | ||
], | ||
}), | ||
} | ||
} | ||
|
||
// Form Submission | ||
|
||
function submitForm (action: string, data: { [string]: string }): void { | ||
const form = document.createElement('form') | ||
form.action = action | ||
form.method = 'POST' | ||
|
||
for (const field in data) { | ||
form.appendChild(buildFormInput(field, data[field])) | ||
} | ||
|
||
document.body && document.body.appendChild(form) | ||
|
||
form.submit() | ||
} | ||
|
||
function buildFormInput (name: string, value: string): HTMLInputElement { | ||
const el = document.createElement('input') | ||
el.type = 'hidden' | ||
el.name = name | ||
el.value = value | ||
return el | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<cartridge_basiclti_link xmlns="http://www.imsglobal.org/xsd/imslticc_v1p0" | ||
xmlns:blti = "http://www.imsglobal.org/xsd/imsbasiclti_v1p0" | ||
xmlns:lticm ="http://www.imsglobal.org/xsd/imslticm_v1p0" | ||
xmlns:lticp ="http://www.imsglobal.org/xsd/imslticp_v1p0" | ||
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation = "http://www.imsglobal.org/xsd/imslticc_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticc_v1p0.xsd | ||
http://www.imsglobal.org/xsd/imsbasiclti_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imsbasiclti_v1p0.xsd | ||
http://www.imsglobal.org/xsd/imslticm_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticm_v1p0.xsd | ||
http://www.imsglobal.org/xsd/imslticp_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticp_v1p0.xsd" | ||
> | ||
<blti:title>Michigan Sustainability Cases</blti:title> | ||
<blti:description>Description of MSC</blti:description> | ||
<blti:launch_url><%= authentication_strategy_lti_omniauth_callback_url %></blti:launch_url> | ||
<blti:extensions platform="canvas.instructure.com"> | ||
<lticm:property name="oauth_compliant">true</lticm:property> | ||
<lticm:property name="privacy_level">public</lticm:property> | ||
<lticm:property name="domain">www.learnmsc.org</lticm:property> | ||
<lticm:options name="course_navigation"> | ||
<lticm:property name="enabled">true</lticm:property> | ||
</lticm:options> | ||
<lticm:options name="assignment_selection"> | ||
<lticm:property name="message_type">ContentItemSelectionRequest</lticm:property> | ||
<lticm:property name="url"><%= catalog_content_items_url %></lticm:property> | ||
</lticm:options> | ||
</blti:extensions> | ||
</cartridge_basiclti_link> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#content-items-app{data: {return_data: @data, | ||
return_url: @return_url, | ||
items: render(template: 'catalog/content_items', formats: [:json])}} | ||
|
||
= javascript_pack_tag 'content_items' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
json.key_format! camelize: :lower | ||
json.array! @items do |kase| | ||
json.extract! kase, *%i(kicker title dek) | ||
json.cover_url ix_cover_image(kase, :small) | ||
json.url authentication_strategy_lti_omniauth_callback_url case_slug: kase.slug | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
<%= yield %> | ||
</div> | ||
|
||
<% parent_layout 'application' %> | ||
<% parent_layout 'with_header' %> |
Oops, something went wrong.