Skip to content

Commit

Permalink
Version 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
spvickers committed Mar 13, 2019
1 parent c1a78e6 commit 5558efc
Show file tree
Hide file tree
Showing 71 changed files with 16,409 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This set of PHP classes encapsulates the code required by an LTI compliant tool provider to communicate with an LTI tool consumer.
It includes support for LTI 1.1 and the unofficial extensions to Basic LTI, as well as the registration process and services of LTI 1.2/2.0.
These classes are designed as an update to the LTI Tool Provider class library (http://www.spvsoftwareproducts.com/php/lti_tool_provider/) and
a replacement for the library at https://github.com/IMSGlobal/LTI-Tool-Provider-Library-PHP which is no longer supported.

Whilst supporting LTI is relatively simple, the benefits to using a class library like this one are:
* the abstraction layer provided by the classes keeps the LTI communications separate from the application code;
* the code can be re-used between multiple tool providers;
* LTI data is transformed into useful objects and missing data automatically replaced with sensible defaults;
* the outcomes service function uses LTI 1.1 or the unofficial outcomes extension according to whichever is supported by the tool consumer;
* the unofficial extensions for memberships and setting services are supported;
* additional functionality is included to:
* enable/disable a consumer key;
* set start and end times for enabling access for each consumer key;
* set up arrangements such that users from different resource links can all collaborate together within a single tool provider link;
* LTI applications can take advantage of LTI updates with minimal impact on their code.

The GitHub repository provides access to the [source files](https://github.com/celtic-project/LTI-PHP) and [documentation](https://github.com/celtic-project/LTI-PHP/wiki).
The example [Rating LTI application](https://github.com/celtic-project/Rating-PHP) is based on this library to further illustrate how it can be used.
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "celtic/lti",
"description": "PHP class library for building LTI integrations",
"keywords": ["LTI"],
"homepage": "https://github.com/celtic-project/LTI-PHP",
"type": "library",
"license": "LGPL-3.0-or-later",
"authors": [
{
"name": "Stephen P Vickers",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.6.0"
},
"autoload": {
"psr-4": {
"ceLTIc\\LTI\\": "src/"
}
}
}
125 changes: 125 additions & 0 deletions sql/lti3-tables-mssql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
CREATE TABLE lti2_consumer (
consumer_pk int IDENTITY NOT NULL,
name varchar(50) NOT NULL,
consumer_key256 varchar(256) NOT NULL,
consumer_key text DEFAULT NULL,
secret varchar(1024) NOT NULL,
lti_version varchar(10) DEFAULT NULL,
signature_method varchar(15) NOT NULL DEFAULT 'HMAC-SHA1',
consumer_name varchar(255) DEFAULT NULL,
consumer_version varchar(255) DEFAULT NULL,
consumer_guid varchar(1024) DEFAULT NULL,
profile text DEFAULT NULL,
tool_proxy text DEFAULT NULL,
settings text DEFAULT NULL,
protected bit NOT NULL,
enabled bit NOT NULL,
enable_from datetime2 DEFAULT NULL,
enable_until datetime2 DEFAULT NULL,
last_access date DEFAULT NULL,
created datetime2 NOT NULL,
updated datetime2 NOT NULL,
PRIMARY KEY (consumer_pk),
CONSTRAINT UC_lti2_consumer_consumer_key UNIQUE (consumer_key256)
);

CREATE TABLE lti2_nonce (
consumer_pk int IDENTITY NOT NULL,
value varchar(50) NOT NULL,
expires datetime2 NOT NULL,
PRIMARY KEY (consumer_pk, value)
);

ALTER TABLE lti2_nonce
ADD CONSTRAINT lti2_nonce_lti2_consumer_FK1
FOREIGN KEY (consumer_pk)
REFERENCES lti2_consumer (consumer_pk);

CREATE TABLE lti2_context (
context_pk int NOT NULL IDENTITY,
consumer_pk int NOT NULL,
title varchar(255) DEFAULT NULL,
lti_context_id varchar(255) NOT NULL,
type varchar(50) DEFAULT NULL,
settings text DEFAULT NULL,
created datetime2 NOT NULL,
updated datetime2 NOT NULL,
PRIMARY KEY (context_pk)
);

ALTER TABLE lti2_context
ADD CONSTRAINT lti2_context_lti2_consumer_FK1
FOREIGN KEY (consumer_pk)
REFERENCES lti2_consumer (consumer_pk);

CREATE INDEX lti2_context_consumer_id_IDX
ON lti2_context (consumer_pk);

CREATE TABLE lti2_resource_link (
resource_link_pk int IDENTITY,
context_pk int DEFAULT NULL,
consumer_pk int DEFAULT NULL,
title varchar(255) DEFAULT NULL,
lti_resource_link_id varchar(255) NOT NULL,
settings text,
primary_resource_link_pk int DEFAULT NULL,
share_approved bit DEFAULT NULL,
created datetime2 NOT NULL,
updated datetime2 NOT NULL,
PRIMARY KEY (resource_link_pk)
);

ALTER TABLE lti2_resource_link
ADD CONSTRAINT lti2_resource_link_lti2_consumer_FK1
FOREIGN KEY (consumer_pk)
REFERENCES lti2_consumer (consumer_pk);

ALTER TABLE lti2_resource_link
ADD CONSTRAINT lti2_resource_link_lti2_context_FK1
FOREIGN KEY (context_pk)
REFERENCES lti2_context (context_pk);

ALTER TABLE lti2_resource_link
ADD CONSTRAINT lti2_resource_link_lti2_resource_link_FK1
FOREIGN KEY (primary_resource_link_pk)
REFERENCES lti2_resource_link (resource_link_pk);

CREATE INDEX lti2_resource_link_consumer_pk_IDX
ON lti2_resource_link (consumer_pk);

CREATE INDEX lti2_resource_link_context_pk_IDX
ON lti2_resource_link (context_pk);

CREATE TABLE lti2_user_result (
user_result_pk int IDENTITY,
resource_link_pk int NOT NULL,
lti_user_id varchar(255) NOT NULL,
lti_result_sourcedid varchar(1024) NOT NULL,
created datetime2 NOT NULL,
updated datetime2 NOT NULL,
PRIMARY KEY (user_result_pk)
);

ALTER TABLE lti2_user_result
ADD CONSTRAINT lti2_user_result_lti2_resource_link_FK1
FOREIGN KEY (resource_link_pk)
REFERENCES lti2_resource_link (resource_link_pk);

CREATE INDEX lti2_user_result_resource_link_pk_IDX
ON lti2_user_result (resource_link_pk);

CREATE TABLE lti2_share_key (
share_key_id varchar(32) NOT NULL,
resource_link_pk int NOT NULL,
auto_approve bit NOT NULL,
expires datetime2 NOT NULL,
PRIMARY KEY (share_key_id)
);

ALTER TABLE lti2_share_key
ADD CONSTRAINT lti2_share_key_lti2_resource_link_FK1
FOREIGN KEY (resource_link_pk)
REFERENCES lti2_resource_link (resource_link_pk);

CREATE INDEX lti2_share_key_resource_link_pk_IDX
ON lti2_share_key (resource_link_pk);
143 changes: 143 additions & 0 deletions sql/lti3-tables-mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
CREATE TABLE lti2_consumer (
consumer_pk int(11) NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
consumer_key256 varchar(256) NOT NULL,
consumer_key text DEFAULT NULL,
secret varchar(1024) NOT NULL,
lti_version varchar(10) DEFAULT NULL,
signature_method varchar(15) NOT NULL DEFAULT 'HMAC-SHA1',
consumer_name varchar(255) DEFAULT NULL,
consumer_version varchar(255) DEFAULT NULL,
consumer_guid varchar(1024) DEFAULT NULL,
profile text DEFAULT NULL,
tool_proxy text DEFAULT NULL,
settings text DEFAULT NULL,
protected tinyint(1) NOT NULL,
enabled tinyint(1) NOT NULL,
enable_from datetime DEFAULT NULL,
enable_until datetime DEFAULT NULL,
last_access date DEFAULT NULL,
created datetime NOT NULL,
updated datetime NOT NULL,
PRIMARY KEY (consumer_pk)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE lti2_consumer
ADD UNIQUE INDEX lti2_consumer_consumer_key_UNIQUE (consumer_key256 ASC);

CREATE TABLE lti2_nonce (
consumer_pk int(11) NOT NULL,
value varchar(50) NOT NULL,
expires datetime NOT NULL,
PRIMARY KEY (consumer_pk, value)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE lti2_nonce
ADD CONSTRAINT lti2_nonce_lti2_consumer_FK1 FOREIGN KEY (consumer_pk)
REFERENCES lti2_consumer (consumer_pk);

CREATE TABLE lti2_context (
context_pk int(11) NOT NULL AUTO_INCREMENT,
consumer_pk int(11) NOT NULL,
title varchar(255) DEFAULT NULL,
lti_context_id varchar(255) NOT NULL,
type varchar(50) DEFAULT NULL,
settings text DEFAULT NULL,
created datetime NOT NULL,
updated datetime NOT NULL,
PRIMARY KEY (context_pk)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE lti2_context
ADD CONSTRAINT lti2_context_lti2_consumer_FK1 FOREIGN KEY (consumer_pk)
REFERENCES lti2_consumer (consumer_pk);

ALTER TABLE lti2_context
ADD INDEX lti2_context_consumer_id_IDX (consumer_pk ASC);

CREATE TABLE lti2_resource_link (
resource_link_pk int(11) AUTO_INCREMENT,
context_pk int(11) DEFAULT NULL,
consumer_pk int(11) DEFAULT NULL,
title varchar(255) DEFAULT NULL,
lti_resource_link_id varchar(255) NOT NULL,
settings text,
primary_resource_link_pk int(11) DEFAULT NULL,
share_approved tinyint(1) DEFAULT NULL,
created datetime NOT NULL,
updated datetime NOT NULL,
PRIMARY KEY (resource_link_pk)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE lti2_resource_link
ADD CONSTRAINT lti2_resource_link_lti2_consumer_FK1 FOREIGN KEY (consumer_pk)
REFERENCES lti2_consumer (consumer_pk);

ALTER TABLE lti2_resource_link
ADD CONSTRAINT lti2_resource_link_lti2_context_FK1 FOREIGN KEY (context_pk)
REFERENCES lti2_context (context_pk);

ALTER TABLE lti2_resource_link
ADD CONSTRAINT lti2_resource_link_lti2_resource_link_FK1 FOREIGN KEY (primary_resource_link_pk)
REFERENCES lti2_resource_link (resource_link_pk);

ALTER TABLE lti2_resource_link
ADD INDEX lti2_resource_link_consumer_pk_IDX (consumer_pk ASC);

ALTER TABLE lti2_resource_link
ADD INDEX lti2_resource_link_context_pk_IDX (context_pk ASC);

CREATE TABLE lti2_user (
user_pk int(11) AUTO_INCREMENT,
consumer_pk int(11) NOT NULL,
lti_user_id varchar(255) NOT NULL,
created datetime NOT NULL,
updated datetime NOT NULL,
PRIMARY KEY (user_pk)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE lti2_user
ADD CONSTRAINT lti2_user_lti2_consumer_FK1 FOREIGN KEY (consumer_pk)
REFERENCES lti2_consumer (consumer_pk);

ALTER TABLE lti2_user
ADD UNIQUE INDEX lti2_user_lti_user_id_IDX (consumer_pk, lti_user_id ASC);

CREATE TABLE lti2_user_result (
user_result_pk int(11) AUTO_INCREMENT,
user_pk int(11) NOT NULL,
resource_link_pk int(11) NOT NULL,
lti_result_sourcedid varchar(1024) NOT NULL,
created datetime NOT NULL,
updated datetime NOT NULL,
PRIMARY KEY (user_result_pk)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE lti2_user_result
ADD CONSTRAINT lti2_user_result_lti2_user_FK1 FOREIGN KEY (user_pk)
REFERENCES lti2_user (user_pk);

ALTER TABLE lti2_user_result
ADD CONSTRAINT lti2_user_result_lti2_resource_link_FK1 FOREIGN KEY (resource_link_pk)
REFERENCES lti2_resource_link (resource_link_pk);

ALTER TABLE lti2_user_result
ADD INDEX lti2_user_result_user_pk_IDX (user_pk ASC);

ALTER TABLE lti2_user_result
ADD INDEX lti2_user_result_resource_link_pk_IDX (resource_link_pk ASC);

CREATE TABLE lti2_share_key (
share_key_id varchar(32) NOT NULL,
resource_link_pk int(11) NOT NULL,
auto_approve tinyint(1) NOT NULL,
expires datetime NOT NULL,
PRIMARY KEY (share_key_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE lti2_share_key
ADD CONSTRAINT lti2_share_key_lti2_resource_link_FK1 FOREIGN KEY (resource_link_pk)
REFERENCES lti2_resource_link (resource_link_pk);

ALTER TABLE lti2_share_key
ADD INDEX lti2_share_key_resource_link_pk_IDX (resource_link_pk ASC);
Loading

0 comments on commit 5558efc

Please sign in to comment.