-
-
Notifications
You must be signed in to change notification settings - Fork 941
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-50682 LTI Add support for 1EdTech PNP URL to launch data
- Loading branch information
Showing
5 changed files
with
126 additions
and
0 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
42 changes: 42 additions & 0 deletions
42
lti/tsugi-util/src/java/org/tsugi/lti13/objects/PNPService.java
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,42 @@ | ||
package org.tsugi.lti13.objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
import java.util.List; | ||
import java.util.ArrayList; | ||
|
||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) | ||
|
||
/* Spec in Draft - This is from Paul G | ||
$pnpHost = 'https://pnp.amp-up.io'; | ||
$pnpBase = '/ims/afapnp/v1p0'; | ||
$requestparams['launch_pnp_settings_service_url'] = $pnpHost . $pnpBase . '/users/' . $USER->id . '/afapnprecords'; | ||
$pnp_launch_settings = array( | ||
'pnp_settings_service_url' => $parms['launch_pnp_settings_service_url'], | ||
'scope' => array('https://purl.imsglobal.org/spec/lti-pnp/scope/pnpsettings.readonly'), | ||
'pnp_supported_versions' => array('http://purl.imsglobal.org/spec/afapnp/v1p0/schema/openapi/afapnpv1p0service_openapi3_v1p0') | ||
); | ||
$payload['https://purl.imsglobal.org/spec/lti-pnp/claim/pnpservice'] = $pnp_launch_settings; | ||
*/ | ||
|
||
public class PNPService extends org.tsugi.jackson.objects.JacksonBase { | ||
public static String SCOPE_PNP_READONLY = "https://purl.imsglobal.org/spec/lti-pnp/scope/pnpsettings.readonly"; | ||
public static String VERSION_1_0 = "http://purl.imsglobal.org/spec/afapnp/v1p0/schema/openapi/afapnpv1p0service_openapi3_v1p0"; | ||
|
||
@JsonProperty("scope") | ||
public List<String> scope = new ArrayList<String>(); | ||
@JsonProperty("pnp_settings_service_url") | ||
public String pnp_settings_service_url; | ||
@JsonProperty("pnp_supported_versions") | ||
public List<String> pnp_supported_versions = new ArrayList<String>(); | ||
|
||
public PNPService() { | ||
this.scope.add(SCOPE_PNP_READONLY); | ||
this.pnp_supported_versions.add(VERSION_1_0); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
lti/tsugi-util/src/test/org/tsugi/lti13/PNPServiceTest.java
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,50 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.tsugi.lti13; | ||
|
||
import static org.junit.Assert.*; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
import org.tsugi.lti13.objects.PNPService; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
|
||
/** | ||
* | ||
* @author csev | ||
*/ | ||
public class PNPServiceTest { | ||
|
||
@Test | ||
public void testConstructor() throws com.fasterxml.jackson.core.JsonProcessingException { | ||
|
||
PNPService ps = new PNPService(); | ||
assertNotNull(ps); | ||
assertEquals(ps.pnp_supported_versions.size(),1); | ||
assertEquals(ps.pnp_supported_versions.get(0), ps.VERSION_1_0); | ||
|
||
assertEquals(ps.scope.size(),1); | ||
assertEquals(ps.scope.get(0), ps.SCOPE_PNP_READONLY); | ||
ps.pnp_settings_service_url = "https://www.myuniv.example.com/2344/groups"; | ||
|
||
ObjectMapper mapper = new ObjectMapper(); | ||
String jsonString = mapper.writeValueAsString(ps); | ||
String jsonTest = "{\"scope\":[\"https://purl.imsglobal.org/spec/lti-pnp/scope/pnpsettings.readonly\"],\"pnp_settings_service_url\":\"https://www.myuniv.example.com/2344/groups\",\"pnp_supported_versions\":[\"http://purl.imsglobal.org/spec/afapnp/v1p0/schema/openapi/afapnpv1p0service_openapi3_v1p0\"]}"; | ||
assertEquals(jsonString, jsonTest); | ||
} | ||
|
||
@Test | ||
public void testAddServiceVersion() { | ||
PNPService groupService = new PNPService(); | ||
groupService.pnp_supported_versions.add("1.1"); | ||
assertTrue(groupService.pnp_supported_versions.contains("1.1")); | ||
} | ||
|
||
} |