-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from schulcloud/168-improve-lti-concept
168 improve lti concept
- Loading branch information
Showing
15 changed files
with
304 additions
and
67 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
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,65 @@ | ||
const OAuth = require('oauth-1.0a'); | ||
const crypto = require('crypto'); | ||
|
||
const ltiRoles = { | ||
user: 'Learner', | ||
student: 'Learner', | ||
teacher: 'Instructor', | ||
administrator: 'Administrator', | ||
superhero: 'Administrator' | ||
}; | ||
|
||
class LTICustomer { | ||
constructor() {} | ||
|
||
createConsumer(key, secret) { | ||
return OAuth({ | ||
consumer: { | ||
key: key, | ||
secret: secret | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
} | ||
|
||
mapSchulcloudRoleToLTIRole(role) { | ||
return ltiRoles[role]; | ||
} | ||
|
||
sendRequest(request_data, consumer) { | ||
var name, | ||
form = document.createElement("form"), | ||
node = document.createElement("input"); | ||
|
||
|
||
form.action = request_data.url; | ||
form.method = request_data.method; | ||
form.target = "_blank"; | ||
|
||
var formData = consumer.authorize(request_data); | ||
|
||
for (name in formData) { | ||
node.name = name; | ||
node.value = formData[name].toString(); | ||
form.appendChild(node.cloneNode()); | ||
} | ||
|
||
// To be sent, the form needs to be attached to the main document. | ||
form.style.display = "none"; | ||
document.body.appendChild(form); | ||
|
||
form.submit(); | ||
|
||
// But once the form is sent, it's useless to keep it. | ||
document.body.removeChild(form); | ||
} | ||
|
||
customFieldToString(custom) { | ||
return `custom_${custom.key}`; | ||
} | ||
} | ||
|
||
export default new LTICustomer(); |
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,21 @@ | ||
import React from 'react'; | ||
import {browserHistory} from 'react-router'; | ||
import { Server } from '../../core/helpers'; | ||
|
||
const toolsConnectService = Server.service('/ltiTools/connect'); | ||
const toolService = Server.service('/ltiTools'); | ||
|
||
export default { | ||
createNew: (tool) => { | ||
toolService.create(tool) | ||
.then(result => { | ||
// Todo: remove when subsmanager is implemented | ||
window.location.href = '/tools/' | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
}); | ||
} | ||
}; | ||
|
||
|
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,33 @@ | ||
import LayoutBackend from '../../backend/containers/layout'; | ||
import SectionTitle from '../../backend/components/title'; /* only for backend */ | ||
import {browserHistory} from 'react-router'; | ||
import TemplateToolCard from './templateToolCard'; | ||
|
||
require('../styles/tools.scss'); | ||
|
||
class NewTool extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
let idCount = 0; | ||
return ( | ||
<LayoutBackend className="tools"> | ||
<SectionTitle title="Tool Vorlagen"/> | ||
<div className="tools-section"> | ||
{ | ||
this.props.tools.map((tool) => { | ||
idCount++; | ||
return <TemplateToolCard {...this.props} key={idCount} modalId={idCount} tool={tool} />; | ||
}) | ||
} | ||
</div> | ||
</LayoutBackend> | ||
); | ||
} | ||
|
||
} | ||
|
||
export default NewTool; |
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,48 @@ | ||
import {Link} from 'react-router'; | ||
import NewToolForm from './newToolForm'; | ||
require('../styles/toolCard.scss'); | ||
require('../../../static/images/cloud.png'); | ||
|
||
class ToolCard extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {}; | ||
} | ||
|
||
render() { | ||
var tool = this.props.tool; | ||
return ( | ||
<div> | ||
<Link className="col-sm-4 tool-card" data-toggle="modal" data-target={"#newToolModal" + this.props.modalId}> | ||
<div className="card"> | ||
{ tool.logo_url | ||
? <img className="card-img-top" src={tool.logo_url} alt="Card image cap"/> | ||
: <img className="card-img-top" src="/images/cloud.png" alt="Card image cap"/> | ||
} | ||
<div className="card-block"> | ||
<h4 className="card-title">{tool.name}</h4> | ||
</div> | ||
</div> | ||
</Link> | ||
|
||
<div className="modal fade" id={"newToolModal" + this.props.modalId} role="dialog" aria-labelledby="myModalLabel"> | ||
<div className="modal-dialog" role="document"> | ||
<div className="modal-content"> | ||
<div className="modal-header"> | ||
<button type="button" className="close" data-dismiss="modal" aria-label="Close"><span | ||
aria-hidden="true">×</span></button> | ||
<h4 className="modal-title" id="myModalLabel">Neues LTI-Tool erstellen</h4> | ||
</div> | ||
<div className="modal-body"> | ||
<NewToolForm toolTemplate={tool} modal="#"{...this.props} /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default ToolCard; |
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
Oops, something went wrong.